[coldfire-gnu-discuss] Port access with gcc

Alex Parkinson okalex at gmail.com
Thu Feb 1 15:35:49 UTC 2007


On 2/1/07, Nathan Sidwell <nathan at codesourcery.com> wrote:

> The port will be a memory mapped address.  You can access it from C with
> something like
>
> #define my_port (*(volatile int)NNNNN)
>
> where NNNNN is the address of the port.  If the port is not 32 bits wide,
> use
> short or char as appropriate.
>
> int Foo ()
> {
>    myport = 0;
>    myport = 1;
>    return myport;
> }
>

Thanks, Nathan.  At first this was generating a compiler error, but it turns
out that the port definition should actually be
#define my_port (*(volatile int *)NNNNN)

Notice the extra '*'.  Without this, the code was generating the error,
"error: invalid type argument of 'unary *'".  All is working now.

Cheers,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/coldfire-gnu-discuss/attachments/20070201/0259cab6/attachment.html>


More information about the coldfire-gnu-discuss mailing list