write data to the address (PC104)--solved
zhoupeng
zpeng563 at 126.com
Sun Jul 1 08:25:31 UTC 2012
Recently , I want to write data to register of can device. At first I use IO space , so I can't make the device operated. Later, I change to use memory space. I can send data and receive data from the register.
IO space:
/*
---------------------------------------------------
两个最基本的SJA1000寄存器读写函数
*/
/*unsigned char read_sja(unsigned char RegNum)
{
unsigned char bValue;
RegNum &= 0x7F; //最高位清0
inport_byte(BASE_ADDRESS+RegNum,bValue);
return (bValue);
}
void write_sja(unsigned char RegNum, unsigned char bValue)
{
RegNum &= 0x7F; //最高位清0
outport_byte(BASE_ADDRESS+RegNum,bValue);
delay(50000);
}*/
memory space:
unsigned char read_sja(unsigned char RegNum)
{
unsigned char data;
RegNum &= 0x7F;
data = * (volatile unsigned char *)((BASE_ADDRESS)+RegNum);
return (data);
}
void write_sja(unsigned char RegNum, unsigned char data)
{
RegNum &= 0x7F;
* (volatile unsigned char *)((BASE_ADDRESS)+RegNum) = data;
}
By the way , not all the PC-104 have can module. If you PC-104 have can module, you can follow the manual. But you must find out if the operation of register is IO space or memory space.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20120701/f98c0ca0/attachment.html>
More information about the users
mailing list