You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uint32_t targetSpeed = std::abs((*std::min_element(this->motorList, this->motorList + N, Stepper::cmpVmin))->vMax); // use the lowest max frequency for the move, scale by relSpeed
64
+
uint32_t targetSpeed = abs((*std::min_element(this->motorList, this->motorList + N, Stepper::cmpVmin))->vMax); // use the lowest max frequency for the move, scale by relSpeed
65
65
uint32_t acceleration = (*std::min_element(this->motorList, this->motorList + N, Stepper::cmpAcc))->a; // use the lowest acceleration for the move
constexprvolatile FTM_t* timer = __builtin_constant_p((FTM_t*)timerAddr) ? (FTM_t*)timerAddr : (FTM_t*)timerAddr;// base address for register block of selected timer
146
-
constexprunsigned irq = IRQ_Number[(int)board][selTimer]; // IRQ number of selected timer
147
-
constexprunsigned maxChannel = _nrOfChannels[selTimer]; // Number of channels for selected timer
145
+
volatile FTM_t *const timer = (FTM_t*)timerAddr; // base address for register block of selected timer
146
+
constexprunsigned irq = IRQ_Number[(int)board][selTimer]; // IRQ number of selected timer
147
+
constexprunsigned maxChannel = _nrOfChannels[selTimer]; // Number of channels for selected timer
148
148
149
-
static_assert(timer != nullptr && irq != 0, "Board does not support choosen timer"); //Generate compiler error in case the board does not support the selected timer
149
+
static_assert(timerAddr != 0 && irq != 0, "Board does not support choosen timer"); //Generate compiler error in case the board does not support the selected timer
constexprunsigned _timer_frequency = isFTM ? F_BUS : 16000000; // FTM timers are clocked with F_BUS, the TPM timers are clocked with OSCERCLK (16MHz for all teensies)
155
155
156
156
// Choose prescaler such that one timer cycle corresponds to about 1µs
157
-
constexprunsigned prescale =
157
+
constexprunsigned prescale =
158
158
_timer_frequency > 120000000 ? 0b111 :
159
159
_timer_frequency > 60000000 ? 0b110 :
160
-
_timer_frequency > 30000000 ? 0b101 :
160
+
_timer_frequency > 30000000 ? 0b101 :
161
161
_timer_frequency > 15000000 ? 0b100 :
162
162
_timer_frequency > 8000000 ? 0b011 :
163
163
_timer_frequency > 4000000 ? 0b010 :
164
164
_timer_frequency > 2000000 ? 0b001 : 0b000;
165
165
166
-
// Calculates required reload value to get a delay of mu microseconds.
167
-
// this will be completely evaluated by the compiler as long as mu is known at compile time
166
+
// Calculates required reload value to get a delay of mu microseconds.
167
+
// this will be completely evaluated by the compiler as long as mu is known at compile time
0 commit comments