diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-06 07:20:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-06 07:20:48 +0100 |
| commit | 90b5c170347e7a46a8f56628a9830ea5a719a326 (patch) | |
| tree | f2a2a9e2a02e6ad1a23a367445d673bf9de8af17 /platforms | |
| parent | da7811f82aad8997495750c9ef70117f9934f340 (diff) | |
Fix SPI bus lock issue in spi_start_extended when using mutual exclusion (#25447)
Diffstat (limited to 'platforms')
| -rw-r--r-- | platforms/chibios/drivers/spi_master.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index f5e48edfda..84d027bf49 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c | |||
| @@ -130,10 +130,16 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||
| 130 | #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | 130 | #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) |
| 131 | 131 | ||
| 132 | if (spiStarted) { | 132 | if (spiStarted) { |
| 133 | #if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 134 | spiReleaseBus(&SPI_DRIVER); | ||
| 135 | #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 133 | return false; | 136 | return false; |
| 134 | } | 137 | } |
| 135 | #if SPI_SELECT_MODE != SPI_SELECT_MODE_NONE | 138 | #if SPI_SELECT_MODE != SPI_SELECT_MODE_NONE |
| 136 | if (start_config->slave_pin == NO_PIN) { | 139 | if (start_config->slave_pin == NO_PIN) { |
| 140 | # if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 141 | spiReleaseBus(&SPI_DRIVER); | ||
| 142 | # endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 137 | return false; | 143 | return false; |
| 138 | } | 144 | } |
| 139 | #endif | 145 | #endif |
| @@ -146,10 +152,16 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||
| 146 | 152 | ||
| 147 | # if defined(AT32F415) | 153 | # if defined(AT32F415) |
| 148 | if (roundedDivisor < 2 || roundedDivisor > 1024) { | 154 | if (roundedDivisor < 2 || roundedDivisor > 1024) { |
| 155 | # if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 156 | spiReleaseBus(&SPI_DRIVER); | ||
| 157 | # endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 149 | return false; | 158 | return false; |
| 150 | } | 159 | } |
| 151 | # else | 160 | # else |
| 152 | if (roundedDivisor < 2 || roundedDivisor > 256) { | 161 | if (roundedDivisor < 2 || roundedDivisor > 256) { |
| 162 | # if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 163 | spiReleaseBus(&SPI_DRIVER); | ||
| 164 | # endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 153 | return false; | 165 | return false; |
| 154 | } | 166 | } |
| 155 | # endif | 167 | # endif |
| @@ -234,6 +246,9 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||
| 234 | } | 246 | } |
| 235 | 247 | ||
| 236 | if (start_config->divisor < 1) { | 248 | if (start_config->divisor < 1) { |
| 249 | # if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 250 | spiReleaseBus(&SPI_DRIVER); | ||
| 251 | # endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||
| 237 | return false; | 252 | return false; |
| 238 | } | 253 | } |
| 239 | 254 | ||
