3 #include "../config/config.h"
4 #include "../hal/progmem.h"
5 #include "../hal/cpu.h"
11 namespace speed_table {
13 typedef uint16_t st_timer_t;
17 "speed tables not compatible for the requested frequency");
20 extern const st_timer_t speed_table_fast[256][2]
PROGMEM;
23 extern const st_timer_t speed_table_slow[256][2]
PROGMEM;
26 static inline st_timer_t
calc_timer(st_timer_t step_rate, uint8_t &step_loops) {
29 if (step_rate > 20000) {
30 step_rate = (step_rate >> 2) & 0x3fff;
32 }
else if (step_rate > 10000) {
33 step_rate = (step_rate >> 1) & 0x7fff;
44 if (step_rate < (
F_CPU / 500000))
45 step_rate = (
F_CPU / 500000);
46 step_rate -= (
F_CPU / 500000);
47 if (step_rate >= (8 * 256)) {
48 const uint16_t *table_address = &speed_table_fast[(uint8_t)(step_rate >> 8)][0];
49 uint8_t tmp_step_rate = (step_rate & 0x00ff);
54 const uint16_t *table_address = &speed_table_slow[0][0];
55 table_address += (step_rate >> 2) & 0xfffe;
57 timer -= ((
pm::read_word(table_address + 1) * (uint8_t)(step_rate & 0x0007)) >> 3);
#define F_CPU
Main clock frequency.
Definition: cpu.h:11
static constexpr uint16_t maxStepFrequency
Max step frequency 40KHz.
Definition: config.h:62
static constexpr uint8_t stepTimerFrequencyDivider
Step timer frequency divider (F = F_CPU / divider)
Definition: config.h:71
AVR PROGMEM handling.
Definition: progmem.h:14
static uint16_t read_word(const uint16_t *addr)
read a 16bit word from PROGMEM
Definition: progmem.h:17
static uint16_t mulU8X16toH16(const uint8_t charIn1, const uint16_t intIn2)
(intIn1 * intIn2) >> 8
Definition: math.h:11
static st_timer_t calc_timer(st_timer_t step_rate, uint8_t &step_loops)
Calculate the next timer interval and steps according to current step rate.
Definition: speed_table.h:26
const st_timer_t speed_table_fast[256][2] PROGMEM
CPU timer frequency divider required for the speed tables.
Definition: speed_table.cpp:9
The modules namespace contains models of MMU's components.
Definition: command_base.h:8