Hi,
I trying to convert a stm32 function code to nRF52. The goal is to use a spi periperal on my custom board.
In this application we need to have 2 bytes transfert. That why I need to have an uint16_t function.
In spi exemple and driver nrf_drv_spi, we have this function nrf_drv_spi_transfer. ANd this function take only uint8_t parameters.
This is stm32 function :
uint16_t SpiInOut( Spi_t *obj, uint16_t outData )
{
uint8_t rxData = 0;
if( ( obj == NULL ) || ( SpiHandle[obj->SpiId].Instance ) == NULL )
{
assert_param( FAIL );
}
__HAL_SPI_ENABLE( &SpiHandle[obj->SpiId] );
CRITICAL_SECTION_BEGIN( );
while( __HAL_SPI_GET_FLAG( &SpiHandle[obj->SpiId], SPI_FLAG_TXE ) == RESET );
SpiHandle[obj->SpiId].Instance->DR = ( uint16_t ) ( outData & 0xFF );
while( __HAL_SPI_GET_FLAG( &SpiHandle[obj->SpiId], SPI_FLAG_RXNE ) == RESET );
rxData = ( uint16_t ) SpiHandle[obj->SpiId].Instance->DR;
CRITICAL_SECTION_END( );
return( rxData );
}
Another advantage of this function, that we can send and receve SPI information !
Do you have some advise/help to help me for this translation?
Sani300