avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #37848] Add arrays to some Xmega peripheral structur


From: Erik Walthinsen
Subject: [avr-libc-dev] [bug #37848] Add arrays to some Xmega peripheral structures
Date: Sat, 01 Dec 2012 01:37:34 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0

URL:
  <http://savannah.nongnu.org/bugs/?37848>

                 Summary: Add arrays to some Xmega peripheral structures
                 Project: AVR C Runtime Library
            Submitted by: omega
            Submitted on: Fri 30 Nov 2012 05:37:33 PM PST
                Category: Feature Request
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.8.0
           Fixed Release: None

    _______________________________________________________

Details:

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.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 30 Nov 2012 05:37:33 PM PST  Name: xunion.py  Size: 2kB   By: omega

<http://savannah.nongnu.org/bugs/download.php?file_id=27006>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?37848>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]