Re: mmap for I/O access



Robert Scott wrote:

Not necessarily. The I/O defined at 0x56000000 includes some 32-bit and some
16-bit registers, and even some 8-bit ones. And the documentation gives all the
addresses in terms of byte addresses. So if I want to make my code look like it
corresponds exactly with the documentation, then I want address arithmetic to
work on bytes. The variable mptr is never used directly in my application. I
use it in macros, like:

#define gpb_DAT (*(short int*)(mptr+0x14))

In your situation, I like to use a struct with the __packed__ attribute (as supported by GCC and other compilers). This lets you see registers of different sizes directly by accessing members of a struct. But the outcome is much the same.

.



Relevant Pages