@@ -520,19 +520,16 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
520
520
}
521
521
}
522
522
523
- uint32_t spi_irq_handler_asynch (spi_t * obj )
523
+ inline uint32_t spi_irq_handler_asynch (spi_t * obj )
524
524
{
525
- // use the right instance
526
- struct spi_s * spiobj = SPI_S (obj );
527
- SPI_HandleTypeDef * handle = & spiobj -> handle ;
528
525
int event = 0 ;
529
526
530
527
// call the CubeF4 handler, this will update the handle
531
- HAL_SPI_IRQHandler (handle );
528
+ HAL_SPI_IRQHandler (& obj -> spi . handle );
532
529
533
- if (HAL_SPI_GetState ( handle ) == HAL_SPI_STATE_READY ) {
530
+ if (obj -> spi . handle . State == HAL_SPI_STATE_READY ) {
534
531
// When HAL SPI is back to READY state, check if there was an error
535
- int error = HAL_SPI_GetError ( handle ) ;
532
+ int error = obj -> spi . handle . ErrorCode ;
536
533
if (error != HAL_SPI_ERROR_NONE ) {
537
534
// something went wrong and the transfer has definitely completed
538
535
event = SPI_EVENT_ERROR | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE ;
@@ -546,11 +543,10 @@ uint32_t spi_irq_handler_asynch(spi_t *obj)
546
543
event = SPI_EVENT_COMPLETE | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE ;
547
544
}
548
545
// enable the interrupt
549
- NVIC_DisableIRQ (spiobj -> spiIRQ );
550
- NVIC_ClearPendingIRQ (spiobj -> spiIRQ );
546
+ NVIC_DisableIRQ (obj -> spi . spiIRQ );
547
+ NVIC_ClearPendingIRQ (obj -> spi . spiIRQ );
551
548
}
552
549
553
- if (event ) DEBUG_PRINTF ("SPI: Event: 0x%x\n" , event );
554
550
555
551
return (event & (obj -> spi .event | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE ));
556
552
}
0 commit comments