wanes98 said:
Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
I am sure there some code around...
gest regards
wayne
Since you insist:
volatile int * const COM_STATUS_REGISTER =
(volatile int * const) 0x40000;
volatile unsigned char * const COM_RECV_REG =
(volatile unsigned char * const) 0x40004;
volatile unsigned char * const COM_XMIT_REG =
(volatile unsigned char * const) 0x40008;
const unsigned int CHAR_RECEIVED = 0x01;
const unsigned int XMIT_BUFFER_EMPTY = 0x02;
unsigned char Read_Com_Port(void)
{
while (*COM_STATUS_REGISTER & CHAR_RECIEVED == 0)
{
;
}
return *COM_RECV_REG;
}
void Send_Com_Port(unsigned char c)
{
while (*COM_STATUS_REGISTER & XMIT_BUFFER_EMPTY == 0)
{
;
}
*COM_XMIT_REG = c;
return;
}
For other variations, see: For more appropriate help, post to a newsgroup that
deals with your platform or operating system.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book