init.c
来自「嵌入式系统的小作品」· C语言 代码 · 共 59 行
C
59 行
/****************Portting Start *******************/
#include "string.h"
#include "vxworks.h"
#include "tylib.h"
int consoleFd;
void serial_init( )
{
consoleFd=open("/tyCo/0",O_RDWR,0666);
ioctl(consoleFd,FIOSETOPTIONS,OPT_RAW);
ioctl(consoleFd,FIOFLUSH,0);
}
/* Test if there's chars at serial port */
int sio_ischar()
{
int cnt;
ioctl (consoleFd, FIONREAD, (int) &cnt);
return cnt;
}
void Uart_SendKey(unsigned char trychar)
{
unsigned char keyout;
keyout = trychar;
write(consoleFd, &keyout, 1);
}
int Uart_GetKey(unsigned char * chp)
{
unsigned char ch;
/* last_error = 0; */
while ( !sio_ischar() )
{
taskDelay(4);
return -1;
}
read(consoleFd,&ch,1);
/* last_error = 1; */
*chp=ch;
/* printf("Uart_GetKey: Get the char %c .\n",ch);*/
return (int)ch;
}
/****************Portting End*******************/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?