Documentation/coding style suggestion....
Posted: Sat Jan 02, 2016 12:14 pm
On http://chibios.org/dokuwiki/doku.php?id ... _dma_guide I see:
Might I suggest to write such things as:
and have
somewhere else?
Why? First it deals with the compiler issue in one place. Adding a different compiler is easier when this is concentrated somewhere. Second it makes the code shorter and more readable. The code now clearly shows that the buffer needs 32-byte alignment, even if there is no way to indicate this to the compiler.
Code: Select all
#if defined(__GNUC__)
__attribute__((aligned (32)))
#endif
static uint8_t txbuf[SPI_BUFFERS_SIZE];Might I suggest to write such things as:
Code: Select all
ALIGNED32 static uint8_t txbuf[SPI_BUFFERS_SIZE];and have
Code: Select all
#if defined(__GNUC__)
#define ALIGNED32 __attribute__((aligned (32)))
#else
// Auch! Data that needs 32-byte alignment will not be aligned!
#warning "don't know how to align data to 32 bytes!"
#define ALIGNED32
#endifWhy? First it deals with the compiler issue in one place. Adding a different compiler is easier when this is concentrated somewhere. Second it makes the code shorter and more readable. The code now clearly shows that the buffer needs 32-byte alignment, even if there is no way to indicate this to the compiler.