Fix SPI bus lock issue in spi_start_extended when using mutual exclusion (#25447)
This commit is contained in:
		
							parent
							
								
									da7811f82a
								
							
						
					
					
						commit
						90b5c17034
					
				| @ -130,10 +130,16 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||||||
| #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
| 
 | 
 | ||||||
|     if (spiStarted) { |     if (spiStarted) { | ||||||
|  | #if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||||||
|  |         spiReleaseBus(&SPI_DRIVER); | ||||||
|  | #endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| #if SPI_SELECT_MODE != SPI_SELECT_MODE_NONE | #if SPI_SELECT_MODE != SPI_SELECT_MODE_NONE | ||||||
|     if (start_config->slave_pin == NO_PIN) { |     if (start_config->slave_pin == NO_PIN) { | ||||||
|  | #    if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||||||
|  |         spiReleaseBus(&SPI_DRIVER); | ||||||
|  | #    endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| @ -146,10 +152,16 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||||||
| 
 | 
 | ||||||
| #    if defined(AT32F415) | #    if defined(AT32F415) | ||||||
|     if (roundedDivisor < 2 || roundedDivisor > 1024) { |     if (roundedDivisor < 2 || roundedDivisor > 1024) { | ||||||
|  | #        if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||||||
|  |         spiReleaseBus(&SPI_DRIVER); | ||||||
|  | #        endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| #    else | #    else | ||||||
|     if (roundedDivisor < 2 || roundedDivisor > 256) { |     if (roundedDivisor < 2 || roundedDivisor > 256) { | ||||||
|  | #        if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||||||
|  |         spiReleaseBus(&SPI_DRIVER); | ||||||
|  | #        endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| #    endif | #    endif | ||||||
| @ -234,6 +246,9 @@ bool spi_start_extended(spi_start_config_t *start_config) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (start_config->divisor < 1) { |     if (start_config->divisor < 1) { | ||||||
|  | #    if (SPI_USE_MUTUAL_EXCLUSION == TRUE) | ||||||
|  |         spiReleaseBus(&SPI_DRIVER); | ||||||
|  | #    endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user