Skip to content

Commit

Permalink
Merge pull request #808 from Paciente8159/digipot-hw-spi-option
Browse files Browse the repository at this point in the history
added option to use hw SPI
  • Loading branch information
Paciente8159 authored Jan 20, 2025
2 parents 3fad45e + ea34237 commit 572072a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions uCNC/src/modules/digipot.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@

#ifdef STEPPER_CURR_DIGIPOT

#if defined(STEPPER_CURR_DIGIPOT_HW_SPI_PORT) && defined(MCU_HAS_SPI)
HARDSPI(digipotspi, 1000000UL, 0, mcu_spi_port)
#elif defined(STEPPER_CURR_DIGIPOT_HW_SPI2_PORT) && defined(MCU_HAS_SPI2)
HARDSPI(digipotspi, 1000000UL, 0, mcu_spi2_port)
#else
SOFTSPI(digipotspi, 1000000UL, 0, STEPPER_DIGIPOT_SDO, STEPPER_DIGIPOT_SDI, STEPPER_DIGIPOT_CLK)
#endif

/*custom gcode commands*/
#if defined(ENABLE_PARSER_MODULES)
Expand Down Expand Up @@ -71,6 +77,8 @@ bool m907_exec(void *args)
return STATUS_GCODE_NO_AXIS_WORDS;
}

softspi_start(&digipotspi);

io_clear_output(STEPPER_DIGIPOT_CS);

if (CHECKFLAG(ptr->cmd->words, GCODE_WORD_X))
Expand Down Expand Up @@ -132,6 +140,8 @@ bool m907_exec(void *args)

io_set_output(STEPPER_DIGIPOT_CS);

softspi_stop(&digipotspi);

*(ptr->error) = STATUS_OK;
return EVENT_HANDLED;
}
Expand Down

0 comments on commit 572072a

Please sign in to comment.