There a “!” in the if statement.
NO!! Please take look!!
Your !DMA_BUFFER(src) is going to run non-DMA SPI APIs!!
This if statement is wrong logic!!
if (len == 1 || query_irq() == IRQ_STATE_DISABLED || !DMA_BUFFER(src)) {
// !!!!!!!!!!!!!!!! Read data directly !!!!!!!!!!!!!!!!!
} else {
// Read data with DMA <-- But now the address is not aligned on 4 bytes.
}
Wow… I am sorry, I saw your new version already removed DMA_BUFFER check.
So this bug is not exist anymore.
Thanks~~
Ibrahim, can you check this carefully.
Thanks,
I don’t see the problem…
This is the DMA_BUFFER macro for the F7:
#define DMA_BUFFER(p) ((uint32_t)p & 3)
This is the if statement:
if (len == 1 || query_irq() == IRQ_STATE_DISABLED || !DMA_BUFFER(dest)) {
If the length of the buffer is 1 byte OR the IRQs are disabled OR it’s NOT a DMA buffer (not aligned) then read the data without using the DMA. Otherwise it’s more than 1 byte and IRQs are enabled and it’s aligned.
What is the problem ?
Oh I see the issue now, I actually fixed this bug before for the SDCARD but I forgot to fix it in the SPI code. This is the fixed macros:
#define ALIGNED_BUFFER(p) (((uint32_t)p & 3) == 0)
#if defined(STM32H7)
// NOTE: H7 SD DMA can only access AXI SRAM.
#define DMA_BUFFER(p) ((uint32_t) p >= 0x24000000 && (uint32_t) p < 0x24080000)
#elif defined(STM32F4)
// NOTE: F4 CCM is not accessible by GP-DMA.
#define DMA_BUFFER(p) ((uint32_t) p > 0x10010000)
#else
// Assume it's DMA'able
#define DMA_BUFFER(p) (true)
#endif
^.^ I am happy to know I’m not crazy.