Implementation
RCX has its registers mapped on memory.
To access them we have to access the memory address
corresponding to the register. Our code is below:
#define
S_RDR *((volatile unsigned char *) 0xffdd) /* Receive
Data Register */
#define S_TDR *((volatile unsigned char *) 0xffdb) /*
Transmit Data Register */
#define S_SMR *((volatile unsigned char *) 0xffd8) /*
Serial Mode Register */
#define S_SCR *((volatile unsigned char *) 0xffda) /*
Serial Control Register */
#define S_SSR *((volatile unsigned char *) 0xffdc) /*
Serial Status Register */
#define S_BRR *((volatile unsigned char *) 0xffd9) /*
Bit Rate Register */
Using the volatile keyword we make
sure that everytime we make a reference to it, it will
get the value directly on the memory (will not cache
it).
We can control many
features by changing bit values. We enable and disable
interruptions, specify baud rate, asynchronous or
synchronous communication, etc.
|