pellepl / spiflash_driver

Hardware agnostic generic spi flash driver
MIT License
73 stars 27 forks source link

tx_internal_buffer alignment #3

Open enrico1036 opened 5 years ago

enrico1036 commented 5 years ago

I had and issue using this driver in a STM32F030xxx. Whenever I call HAL_SPI_Transmit(...) inside the _spiflash_spi_txrx callback, the system goes in HardFault. I started to investigate and I discovered that the problem was in a cast to uint16_t *, made inside the HAL_SPI function, of tx_data passed as argument by the callback, because the address was not aligned to a 16 bit address. The fix I propose is to align the tx_internal_buffer of the spiflash_t struct. I already tried uint8_t tx_internal_buf[16] __attribute__ ((aligned(16))); at line 275 and it works. Maybe due to the wide targets of this driver would be even better to align to a 32 bit address.