Move cpuFrequencyDivider to config::stepTimerFrequencyDivider

pull/47/head
Yuri D'Elia 2021-07-11 21:17:08 +02:00
parent 0c47d8f0d1
commit 066aab7adc
4 changed files with 6 additions and 4 deletions

View File

@ -44,6 +44,9 @@ static constexpr uint16_t minStepRate = 120;
/// Size for the motion planner block buffer size /// Size for the motion planner block buffer size
static constexpr uint8_t blockBufferSize = 2; static constexpr uint8_t blockBufferSize = 2;
/// Step timer frequency divider (F = F_CPU / divider)
static constexpr uint8_t stepTimerFrequencyDivider = 8;
/// Idler configuration /// Idler configuration
static constexpr AxisConfig idler = { static constexpr AxisConfig idler = {
.dirOn = true, .dirOn = true,

View File

@ -104,7 +104,7 @@ bool PulseGen::PlanMoveTo(pos_t target, steps_t feed_rate) {
// Acceleration of the segment, in steps/sec^2 // Acceleration of the segment, in steps/sec^2
block->acceleration = acceleration; block->acceleration = acceleration;
block->acceleration_rate = block->acceleration * (rate_t)((float)F_CPU / (F_CPU / speed_table::cpuFrequencyDivider)); block->acceleration_rate = block->acceleration * (rate_t)((float)F_CPU / (F_CPU / config::stepTimerFrequencyDivider));
// Perform the trapezoid calculations // Perform the trapezoid calculations
CalculateTrapezoid(block, max_jerk, max_jerk); CalculateTrapezoid(block, max_jerk, max_jerk);

View File

@ -12,8 +12,7 @@ namespace speed_table {
typedef uint16_t st_timer_t; typedef uint16_t st_timer_t;
/// CPU timer frequency divider required for the speed tables /// CPU timer frequency divider required for the speed tables
static constexpr uint8_t cpuFrequencyDivider = 8; static_assert(F_CPU / config::stepTimerFrequencyDivider == 2000000,
static_assert(F_CPU / cpuFrequencyDivider == 2000000,
"speed tables not compatible for the requested frequency"); "speed tables not compatible for the requested frequency");
/// Lookup table for rates equal or higher than 8*256 /// Lookup table for rates equal or higher than 8*256

View File

@ -6,7 +6,7 @@ using Catch::Matchers::Equals;
using namespace modules::speed_table; using namespace modules::speed_table;
// The following reference values are calculated for 2MHz timer // The following reference values are calculated for 2MHz timer
static_assert(F_CPU / cpuFrequencyDivider == 2000000, static_assert(F_CPU / config::stepTimerFrequencyDivider == 2000000,
"speed tables not compatible for the requested frequency"); "speed tables not compatible for the requested frequency");
static const st_timer_t reference[][3] = { static const st_timer_t reference[][3] = {