avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Question: PDF to C Headers utility


From: Royce & Sharal Pereira
Subject: [avr-gcc-list] Question: PDF to C Headers utility
Date: Mon, 13 Dec 2004 07:08:31 +0530

Hi Ned,
----- Original Message -----
From: "Ned Konz" <address@hidden>
 -------------------------------
> Can this method be used for ports & other SFRs which have predetermined
> addresses?
---------------8<----------------
Yes.
I use this kind of code all the time. Here's the definition of an 8-bit wide
port, ADMUX on an ATTiny26L:

typedef union
{
    unsigned char asByte;
    struct            //<----------------struct..
    {
        unsigned char bMUX0:1;
        unsigned char bMUX1:1;
        unsigned char bMUX2:1;
        unsigned char bMUX3:1;
        unsigned char bMUX4:1;
        unsigned char :1;
        unsigned char bREFS0:1;
        unsigned char bREFS1:1;
    };
    struct
    {
        unsigned char bMUX:5;   // MUX0..4
        unsigned char bADLAR:1;
        unsigned char bREFS:2;  // REFS0, REFS1
    };
} ADCMUX_t;
-------------------8<----------------------------
Ned, in your mail above the union is of a byte and a structure.
However, in your headers supplied as examples with the ruby script,(zipped
in PDFtoCHeaders.zip) I see a union of bits rather than the structure as
above.

typedef union ADMUX_t {
  uint8_t asByte;
  union {           // <------------------union!
    uint8_t bMUX0 :1;
    uint8_t bMUX1 :1;
    uint8_t bMUX2 :1;
    uint8_t bMUX3 :1;
    uint8_t bMUX4 :1;
    uint8_t bADLAR :1;
    uint8_t bREFS0 :1;
    uint8_t bREFS1 :1;
  };
  union {
    uint8_t fMUX :5;
    uint8_t :1; /* ADLAR */
    uint8_t fREFS :2;
  };
} ADMUX_t;

This is the case for all the sfrs..
I have not yet used your utility, and just happened to notice this. Which is
correct? Sorry if my C is a bit rusty!

Regards,
--Royce.





reply via email to

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