> > I was looking for something that would let me do:
> >
> > if(LED1)
> > LED2 = 1;
> >
> > This would require associating LED1 and LED2 with a particular bit in
> > the appropriate IOPIN register. Judging from your response, this is
> > not possible with GCC and ARM?
>
Of course if portability is a concern use bit shifting and masking instead.
Macros make quick work of this.
> If you're ok with bit fields, try this (it works in IAR, should work in
> GCC):
>
> struct PORT {
> unsigned bit0:1;
> unsigned bit1:1;
> unsigned bit2:1;
> unsigned bit3:1;
> unsigned bit4:1;
> unsigned bit5:1;
> unsigned bit6:1;
> unsigned bit7:1;
> unsigned bit8:1;
> unsigned bit9:1;
> unsigned bit10:1;
> unsigned bit11:1;
> unsigned bit12:1;
> unsigned bit13:1;
> unsigned bit14:1;
> unsigned bit15:1;
> unsigned bit16:1;
> unsigned bit17:1;
> unsigned bit18:1;
> unsigned bit19:1;
> unsigned bit20:1;
> unsigned bit21:1;
> unsigned bit22:1;
> unsigned bit23:1;
> unsigned bit24:1;
> unsigned bit25:1;
> unsigned bit26:1;
> unsigned bit27:1;
> unsigned bit28:1;
> unsigned bit29:1;
> unsigned bit30:1;
> unsigned bit31:1;
> };
>
> volatile struct PORT *port0_reg = ((volatile struct PORT *)
FIO_BASE_ADDR);
>
> #define LED1 (port0_reg->bit13)
> #define LED2 (port0_reg->bit12)
>
> if(LED1)
> LED2 = 1;
>
>
> JoelMessage
RE: [lpc2000] Re: Bit set/clear w/ gcc
2006-01-12 by Joel Winarske
Attachments
- No local attachments were found for this message.