K
kevin.watters
Probably way off base, but instead of returning SPORT, for example,
shouldn't it return st_sci?
Sorry if wrong
Kevin
shouldn't it return st_sci?
Sorry if wrong
Kevin
typedef volatile struct st_sci * SPORT;
SPORT temp;
switch(PORTNAME)
{
case 0: temp = 0xFFFF78; break;
COMPILE ERROR:- "temp" TYPE NOT COMPATABLE
typedef volatile struct st_sci * SPORT;
SPORT getPort(char port);
SPORT sci = getPort(PORTNAME);
char data = sci.RDR;
silentlights said:HI,
How could I handle groups of registers in a single function by passing the
address of the registers to the functions as parameters..?
I am trying something like..
typedef volatile struct st_sci * SPORT;
SPORT getPort(char port);
SPORT getPort(char PORTNAME)
{
SPORT temp;
switch(PORTNAME)
{
case 0: temp = 0xFFFF78; break;
case 1: temp = 0xFFFF80; break;
case 2: temp = 0xFFFF88; break;
case 3: temp = 0xFFFDD0; break;
}
return temp;
}
char getChar(char PORTNAME)
{
SPORT sci = getPort(PORTNAME);
char data = sci.RDR;
return data;
}
COMPILE ERROR:- "temp" TYPE NOT COMPATABLE
..........................................
Any suggestions..!!
Thanks
silentlights said:typedef volatile struct st_sci * SPORT;
SPORT getPort(char port);
SPORT getPort(char PORTNAME)
{
SPORT temp;
switch(PORTNAME)
{
case 0: temp = 0xFFFF78; break;
#define TX_REG_OFFSET 0
#define RX_REG_OFFSET 4
#define STATUS_REG_OFFSET 8
#define CTRL_REG_OFFSET 12
unsigned char Read_Serial_Port(unsigned char * base_ptr)
{
unsigned char byte = 0;
if (*((unsigned int *)(base_ptr + CTRL_REG_OFFSET))
& RX_RDY)
The offsets are calculated by subtracting the address of a givensilentlights said:Hi Thomas,
That was a brilliant idea. Could you please explain me a little bit more..
I want to understand in detail so I can implement this idea in all other
get() and put() functions.
How do I calculate the offset ?
RX_RDY happens to be a bit in the status register thatWhat is RX_RDY ?, If I want to check for a flag in register how can I do
that..?
Thanks in advance
Densil
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.