@@ -33,7 +33,8 @@ static SPI_Type *const spi_address[] = SPI_BASE_PTRS;
3333/* Array of SPI bus clock frequencies */
3434static clock_name_t const spi_clocks [] = SPI_CLOCK_FREQS ;
3535
36- SPIName spi_get_peripheral_name (PinName mosi , PinName miso , PinName sclk ) {
36+ SPIName spi_get_peripheral_name (PinName mosi , PinName miso , PinName sclk )
37+ {
3738 SPIName spi_mosi = (SPIName )pinmap_peripheral (mosi , PinMap_SPI_MOSI );
3839 SPIName spi_miso = (SPIName )pinmap_peripheral (miso , PinMap_SPI_MISO );
3940 SPIName spi_sclk = (SPIName )pinmap_peripheral (sclk , PinMap_SPI_SCLK );
@@ -122,7 +123,7 @@ void spi_frequency(spi_t *obj, int hz)
122123 DSPI_MasterSetDelayTimes (spi_address [obj -> spi .instance ], kDSPI_Ctar0 , kDSPI_LastSckToPcs , busClock , 500000000 / hz );
123124}
124125
125- static inline int spi_readable (spi_t * obj )
126+ static inline int spi_readable (spi_t * obj )
126127{
127128 return (DSPI_GetStatusFlags (spi_address [obj -> spi .instance ]) & kDSPI_RxFifoDrainRequestFlag );
128129}
@@ -146,17 +147,18 @@ int spi_master_write(spi_t *obj, int value)
146147}
147148
148149int spi_master_block_write (spi_t * obj , const char * tx_buffer , int tx_length ,
149- char * rx_buffer , int rx_length , char write_fill ) {
150+ char * rx_buffer , int rx_length , char write_fill )
151+ {
150152 int total = (tx_length > rx_length ) ? tx_length : rx_length ;
151153
152154 // Default write is done in each and every call, in future can create HAL API instead
153155 DSPI_SetDummyData (spi_address [obj -> spi .instance ], write_fill );
154156
155- DSPI_MasterTransferBlocking (spi_address [obj -> spi .instance ], & (dspi_transfer_t ){
156- .txData = (uint8_t * )tx_buffer ,
157- .rxData = (uint8_t * )rx_buffer ,
158- .dataSize = total ,
159- .configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous ,
157+ DSPI_MasterTransferBlocking (spi_address [obj -> spi .instance ], & (dspi_transfer_t ) {
158+ .txData = (uint8_t * )tx_buffer ,
159+ .rxData = (uint8_t * )rx_buffer ,
160+ .dataSize = total ,
161+ .configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcs0 | kDSPI_MasterPcsContinuous ,
160162 });
161163
162164 DSPI_ClearStatusFlags (spi_address [obj -> spi .instance ], kDSPI_RxFifoDrainRequestFlag | kDSPI_EndOfQueueFlag );
@@ -199,7 +201,7 @@ static int32_t spi_master_transfer_asynch(spi_t *obj)
199201 obj -> spi .status = kDSPI_Busy ;
200202
201203 if (obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_ALLOCATED ||
202- obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED ) {
204+ obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED ) {
203205 status = DSPI_MasterTransferEDMA (spi_address [obj -> spi .instance ], & obj -> spi .spi_dma_master_handle , & masterXfer );
204206 if (status == kStatus_DSPI_OutOfRange ) {
205207 if (obj -> spi .bits > 8 ) {
@@ -331,14 +333,14 @@ static void spi_buffer_set(spi_t *obj, const void *tx, uint32_t tx_length, void
331333
332334void spi_master_transfer (spi_t * obj , const void * tx , size_t tx_length , void * rx , size_t rx_length , uint8_t bit_width , uint32_t handler , uint32_t event , DMAUsage hint )
333335{
334- if (spi_active (obj )) {
336+ if (spi_active (obj )) {
335337 return ;
336338 }
337339
338340 /* check corner case */
339- if (tx_length == 0 ) {
341+ if (tx_length == 0 ) {
340342 tx_length = rx_length ;
341- tx = (void * ) 0 ;
343+ tx = (void * ) 0 ;
342344 }
343345
344346 /* First, set the buffer */
@@ -439,13 +441,13 @@ uint32_t spi_irq_handler_asynch(spi_t *obj)
439441void spi_abort_asynch (spi_t * obj )
440442{
441443 // If we're not currently transferring, then there's nothing to do here
442- if (spi_active (obj ) == 0 ) {
444+ if (spi_active (obj ) == 0 ) {
443445 return ;
444446 }
445447
446448 // Determine whether we're running DMA or interrupt
447449 if (obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_ALLOCATED ||
448- obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED ) {
450+ obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED ) {
449451 DSPI_MasterTransferAbortEDMA (spi_address [obj -> spi .instance ], & obj -> spi .spi_dma_master_handle );
450452 /* Release the dma channels if they were opportunistically allocated */
451453 if (obj -> spi .spiDmaMasterRx .dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED ) {
0 commit comments