Skip to content

Commit

Permalink
Fixed RMT problem
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Oct 5, 2024
1 parent 921f32b commit db2132e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
10 changes: 6 additions & 4 deletions FluidNC/src/Machine/LimitPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ namespace Machine {
void LimitPin::update(bool value) {
if (value) {
if (Homing::approach() || (!state_is(State::Homing) && _pHardLimits)) {
*_pLimited = value;

if (_pLimited != nullptr) {
*_pLimited = value;
}
if (_pExtraLimited != nullptr) {
*_pExtraLimited = value;
}
Expand All @@ -70,8 +71,9 @@ namespace Machine {
set_bits(*_negLimits, _bitmask);
}
} else {
*_pLimited = value;

if (_pLimited != nullptr) {
*_pLimited = value;
}
if (_pExtraLimited != nullptr) {
*_pExtraLimited = value;
}
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/Motors/TrinamicBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace MotorDrivers {
void TrinamicBase::config_motor() {
_has_errors = !test(); // Try communicating with motor. Prints an error if there is a problem.

log_debug("Trinamic base config_motor");
init_step_dir_pins();

if (_has_errors) {
Expand Down
22 changes: 10 additions & 12 deletions FluidNC/src/Stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ namespace Machine {
Stepper::init();
}

rmt_channel_t _rmt_chan_num = RMT_CHANNEL_MAX;

static int init_rmt_channel(rmt_channel_t& rmt_chan_num, int step_gpio, bool invert_step, uint32_t dir_delay_ms, uint32_t pulse_us) {
static int init_rmt_channel(int step_gpio, bool invert_step, uint32_t dir_delay_ms, uint32_t pulse_us) {
static rmt_channel_t next_RMT_chan_num = RMT_CHANNEL_0;
if (rmt_chan_num == RMT_CHANNEL_MAX) {
if (next_RMT_chan_num == RMT_CHANNEL_MAX) {
log_error("Out of RMT channels");
return -1;
}
rmt_chan_num = next_RMT_chan_num;
next_RMT_chan_num = static_cast<rmt_channel_t>(static_cast<int>(next_RMT_chan_num) + 1);
if (next_RMT_chan_num == RMT_CHANNEL_MAX) {
log_error("Out of RMT channels");
return -1;
}
rmt_channel_t rmt_chan_num = next_RMT_chan_num;
next_RMT_chan_num = static_cast<rmt_channel_t>(static_cast<int>(next_RMT_chan_num) + 1);

rmt_config_t rmtConfig = { .rmt_mode = RMT_MODE_TX,
.channel = rmt_chan_num,
Expand Down Expand Up @@ -92,17 +88,19 @@ namespace Machine {
rmtItem[0].level1 = !rmtConfig.tx_config.idle_level;
rmt_config(&rmtConfig);
rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], rmtConfig.mem_block_num, 0);
return rmt_chan_num;
return static_cast<int>(rmt_chan_num);
}

Stepping::motor_t* Stepping::axis_motors[MAX_N_AXIS][MAX_MOTORS_PER_AXIS] = { nullptr };

void Stepping::assignMotor(int axis, int motor, int step_pin, bool step_invert, int dir_pin, bool dir_invert) {
log_debug("assignMotor " << axis << " " << motor << " " << step_pin << " " << dir_pin << " " << dir_invert);
if (axis >= _n_active_axes) {
_n_active_axes = axis + 1;
}
if (_engine == RMT_ENGINE) {
step_pin = init_rmt_channel(_rmt_chan_num, step_pin, step_invert, _directionDelayUsecs, _pulseUsecs);
step_pin = init_rmt_channel(step_pin, step_invert, _directionDelayUsecs, _pulseUsecs);
log_debug("RMT num " << step_pin << " for axis " << axis << " motor " << motor);
}

motor_t* m = new motor_t;
Expand Down

0 comments on commit db2132e

Please sign in to comment.