cancel
Showing results for 
Search instead for 
Did you mean: 

how to use 'HAL_SPI_TransmitReceive_DMA' for spi

kim_dy
Associate II

I'm using 'CUBEIDE' / 'STM32F107VC'

in deca_spi.c

 

int readfromspi(uint16_t headerLength,
const uint8_t *headerBuffer,
uint32_t readlength,
uint8_t *readBuffer)
{
uint8_t spi_TmpBuffer[BUFFLEN];
assert_param(headerLength+readlength < BUFFLEN );
 
//    decaIrqStatus_t  stat ;
//    stat = decamutexon() ;
 
/* Blocking: Check whether previous transfer has been finished */
while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
 
HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_RESET); /**< Put chip select line low */
 
//HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)headerBuffer, spi_TmpBuffer, (uint16_t)(headerLength+readlength), 10);
HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t *)headerBuffer, spi_TmpBuffer, (uint16_t)(headerLength+readlength));
    //HAL_DMA_STATE_CHANGE(&hspi1); //HAL_SPI_STATE_BUSY_TX -> HAL_SPI_STATE_READY
 
HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_SET); /**< Put chip select line high */
 
memcpy((uint8_t*)readBuffer , (uint8_t*)&spi_TmpBuffer[headerLength], readlength);
 
// decamutexoff(stat);
 
    return 0;
} // end readfromspi()

 

 

I am trying to use the 'HAL_SPI_TransmitReceive_DMA' function, but when I run it, there is a problem with using this function.

If you use the commented 'HAL_SPI_TransmitReceive' above the 'HAL_SPI_TransmitReceive_DMA' function, the devID is 0xdeca0310.
If you use the 'HAL_SPI_TransmitReceive_DMA' function, the devID is 0x0.

please please solve it

DMA setting

kim_dy_0-1688604243276.png

 

 

0 REPLIES 0