Skip to content

Commit

Permalink
[stm32] better
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiomargan committed Nov 6, 2024
1 parent 2c39ede commit cb490cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion soes/hal/advr_esc/hal_ec_STM32F4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ inline uint8_t spi_write(uint8_t data) {
#else

inline uint8_t spi_write(uint8_t data) {
// must be enabled in MX_SPIx_Init with __HAL_SPI_ENABLE(&hspix);
static uint8_t spi_enabled;
// must be enabled with __HAL_SPI_ENABLE(&hspix);
if ( ! spi_enabled ) {
__HAL_SPI_ENABLE(&ecat_spi);
spi_enabled = 1;
}
ecat_spi.Instance->DR = data;
while ( ! __HAL_SPI_GET_FLAG(&ecat_spi, SPI_FLAG_RXNE) );
return ecat_spi.Instance->DR;
Expand Down

0 comments on commit cb490cd

Please sign in to comment.