I recently stumbled upon this book:
http://books.google.com/books?id=i62vDV ... on&f=false
It discusses defining bit-fields of an address with a structure using the ':' operator.
With a header file of structs like these, writing code for peripheral programming becomes quite nice!
We can write:
Code: Select all
while ( !(UART_RIS.RXRIS) );
return UART_DR.DATA;
Code: Select all
typedef struct
{
unsigned int RIRMIS : 1;
unsigned int CTSRMIS : 1;
unsigned int DCDRMIS : 1;
unsigned int DSRRMIS : 1;
unsigned int RXRIS : 1;
unsigned int TXRIS : 1;
unsigned int RTRIS : 1;
unsigned int FERIS : 1;
unsigned int PERIS : 1;
unsigned int BERIS : 1;
unsigned int OERIS : 1;
unsigned int RESERVED : 21;
} uart_ris;
#define UART_RIS (* (uart_ris*) 0x2020103c)
typedef struct
{
unsigned int DATA : 8;
unsigned int FE : 1;
unsigned int PE : 1;
unsigned int BE : 1;
unsigned int OE : 1;
unsigned int RESERVED : 20;
} uart_dr;
#define UART_DR (* (uart_dr*) 0x20201000)
Thanks!