HAL function to ensure min stepper interrupt interval (#9985)

This commit is contained in:
Chris Pepper
2018-03-07 23:53:25 +00:00
committed by Scott Lahteine
parent be0e100fed
commit a1a88ebabc
10 changed files with 51 additions and 29 deletions

View File

@ -126,6 +126,8 @@ extern "C" {
#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
#define STEPPER_TIMER_PRESCALE 8
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
#define STEP_TIMER_NUM 1
#define TIMER_OCR_1 OCR1A
#define TIMER_COUNTER_1 TCNT1
@ -148,6 +150,8 @@ extern "C" {
#define _CAT(a, ...) a ## __VA_ARGS__
#define HAL_timer_set_compare(timer, compare) (_CAT(TIMER_OCR_, timer) = compare)
#define HAL_timer_restrain(timer, interval_µs) NOLESS(_CAT(TIMER_OCR_, timer), _CAT(TIMER_COUNTER_, timer) + interval_µs * HAL_TICKS_PER_US)
#define HAL_timer_get_compare(timer) _CAT(TIMER_OCR_, timer)
#define HAL_timer_get_count(timer) _CAT(TIMER_COUNTER_, timer)

View File

@ -221,7 +221,7 @@ void spiBegin (void) {
/** Soft SPI receive byte */
uint8_t spiRec() {
uint8_t data = 0;
// no interrupts during byte receive - about 8 us
// no interrupts during byte receive - about 8µs
cli();
// output pin high - like sending 0xFF
WRITE(MOSI_PIN, HIGH);
@ -252,7 +252,7 @@ void spiBegin (void) {
//------------------------------------------------------------------------------
/** Soft SPI send byte */
void spiSend(uint8_t data) {
// no interrupts during byte send - about 8 us
// no interrupts during byte send - about 8µs
cli();
for (uint8_t i = 0; i < 8; i++) {
WRITE(SCK_PIN, LOW);