In an attempt to make my current project portable across multiple
generations of the development PCB, I've moved all the hardware
configuration into headers for each rev. This includes things like
which port and pin controls a debug LED.
In order to control the LED sanely, I need to set the INVEN bit on each
of them, since it's a common-anode LED. However, with the headers as
currently designed, I can't do that because the PINnCTRL registers can't
be accessed as an offset based on the _bp macros I have in my header.
I've tested and would like to propose adding the following structures
where relevant to the ATxMega headers. Other places this might be
useful are the TC.CCx regs (with the obvious caveat of A=0, B=1...),
event control regs, etc. Basically anywhere there's a bit position or
other number embedded in a sequence of registers.
/* I/O Ports */
typedef struct PORT_struct
{
...
register8_t INTFLAGS; /* Interrupt Flag Register */
register8_t reserved_0x0D;
register8_t reserved_0x0E;
register8_t reserved_0x0F;
union {
struct {
register8_t PIN0CTRL; /* Pin 0 Control Register */
register8_t PIN1CTRL; /* Pin 1 Control Register */
register8_t PIN2CTRL; /* Pin 2 Control Register */
register8_t PIN3CTRL; /* Pin 3 Control Register */
register8_t PIN4CTRL; /* Pin 4 Control Register */
register8_t PIN5CTRL; /* Pin 5 Control Register */
register8_t PIN6CTRL; /* Pin 6 Control Register */
register8_t PIN7CTRL; /* Pin 7 Control Register */
};
register8_t PINnCTRL[8];
};
} PORT_t;
It's used exactly as one might expect:
PORTC.PINnCTRL[4] = PORT_INVEN_bm;
If there's interest in doing this, I can work up a patch for all of the
xmega parts.
_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev