bugAVR C Runtime Library - Bugs: bug #37848, Add arrays to some Xmega...

 
 

bug #37848: Add arrays to some Xmega peripheral structures

Submitted by:  Erik Walthinsen <omega>
Submitted on:  Sat 01 Dec 2012 01:37:33 AM UTC  
 
Category: Feature RequestSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: NonePercent Complete: 0%
Assigned to: NoneOpen/Closed: Open
Release: 1.8.0Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 01 Dec 2012 01:37:33 AM UTC, original submission:

In developing my product I have a header file that lets me shuffle around all the various pinouts and peripherals to match the generation of PCB I'm running on, as well as utility libraries that operate on peripherals with multiple parallel subsystems (like the 4 capture channels of the timers).

I ended up changing (via a script that's attached) a decent chunk of all the Xmega headers to include unions inside the structs that give array access to common multiple registers:

From:

typedef struct PORT_struct {
. . .
register8_t reserved_0x0D;
register8_t REMAP; /* I/O Port Pin Remap Register */
register8_t reserved_0x0F;
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 */
} PORT_t;

To:

typedef struct PORT_struct {
. . .
register8_t reserved_0x0D;
register8_t REMAP; /* I/O Port Pin Remap Register */
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;

This one in particular is highly useful, because I can specify a particular subsystem like:

#define DEBUG_USART USARTC0
#define DEBUG_USART_TX_bp 3

and then do:

DEBUG_USART.PINnCTRL[DEBUG_USART_TX_bp] = PIN_INVEN_bm;

The attached script takes the header filename on the commandline and outputs on stdout the altered header. Obviously this would be better implemented in the primary header conversion script, but that script is still quite opaque to me.

Erik Walthinsen <omega>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #27006:  xunion.py added by omega (2kB - text/x-python)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by omega (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 01 Dec 2012 01:37:33 AM UTComegaAttached File-=>Added xunion.py, #27006

    Back to the top


    Powered by Savane 3.1-cleanup