GPIO in the kernel: an introduction
GPIO in the kernel: an introduction
Posted Jan 21, 2013 11:36 UTC (Mon) by etienne (guest, #25256)In reply to: GPIO in the kernel: an introduction by jimparis
Parent article: GPIO in the kernel: an introduction
> The volatile should ensure that both writes occur in that case.
Last time I tried few days ago it did not work, you have to do:
#define IOWRITE32BITS(addr, val) do { \
volatile unsigned *ptr = (volatile unsigned *)(addr); \
*ptr = (val); \
} while (0)
> You lose control over the access size
Yes, I would also like to have bitfields accessed like they are declared, i.e. "char abit : 2;" accessed as a byte and "unsigned abit :2;" accessed as a 32 bits, because it is usual to have devices which cannot do short word access (lots of system on chip).
> [... using "(struct my_IO_s) {}" extension ...]
My system is more complex than Arduino, I have arrays of structures containing other arrays in these I/O areas, and all those #define blessed by software-quality people drive me mad.
#define FPGA1_FILTER_2_PARAMETER_4_ACTIVE 1
How to do a loop for each filters?
In short, in C or C++, unlike BASIC, the linker is made to manage addresses, the compiler manages offsets into these addresses; the C pre-processor has nothing to do there.
IHMO even GPIO in the kernel shall be identified with an address, not a #define.
