This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Direct I/O reads/writes from C programs


>
>As far as memory mapped I/O, there have been some recent posts here on that
>subject, but one possibility is something like this:
>
>unsigned char * addr = (unsigned char *) 0x12345678;
>unsigned char ch;
>
>/* to write 0x10 */
>*addr = 0x10;
>
>/* to read a byte */
>ch = *addr;

It might be a good idea to declare addr as pointing to a volatile to
avoid undesired compiler optimization.

i.e.:
volatile unsigned char * addr = (unsigned char *) 0x12345678;

If addr can't be modified, it can be declared as a const pointer:
volatile unsigned char * const addr = (unsigned char *) 0x12345678;

Art

_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.