2017-09-19 07:11 AM
I'm using STM32F103RBT6 and try to make an slave SPI-Transfer over DMA using th latest STM32Cube.
The Master sends me 16-Bit Data Packets, i configured the SPI1 to 16 Bit, the DMA channels for Receive and transmit with half word, both circular.
My first Question: the Function 'HAL_SPI_TransmitReceive_DMA' is generated with 8-bit pointers, i cannot pass a 16-bit Array! Why?
->I also use SPI2 with DMA for an external ADC with 8-Bit transfer.
I wondered, that all DMA Interrupts call the same HAL_SPI_TxRxHalfCpltCallback and HAL_SPI_TxRxCpltCallback.
Thanks for helping me!
#spi-over-dma #dma-spi #spi-dma2017-09-19 08:20 AM
Doesn't the callback provide explicit context? The IRQHandler doesn't.
Perhaps void* would be better the SPI can be configured for various widths, the newer STM32 can be aware of width of access also. Use a cast.
2017-09-19 02:33 PM
yes, that's the Point. I would expect that the STM32Cube-Functions should use generic pointers, but they use explicit uint8_t.
The Callbacks have the spi-handle as an Argument, so i can see which SPI it is. But i would prefer to have different functions. I think the code would be more modular and easier to understand.
2017-09-19 03:57 PM
Problem here is a lack of rigour throughout. Some of the code traps on CM0 parts due to arbitrary casting of 8-bit pointer to 16-bit one, with the potential to cause unaligned access.
The HAL requires you to buy into a certain paradigm. Feel free to overload the functionality and let the linker discard the dead code you replace.