- 论坛徽章:
- 0
|
前几天学习uart,没时间总结,一直拖到今天,废话多了,现在就开始吧。首先需要明白的uart的通信原理,所谓uart就是串口通信,通过一根数据线传输信息单向传输,可以使用一对数据线完成全双工的信息传输,一般的uart信息格式为:
start D0 D1 D2 D3 D4 D5 D6 D7 ...DN parity stop
其中parity为奇偶校验位,stop为停止位。跟其他设备一样,所有的linux系统环境下设备都是通过文件的形式进行操作,处理使用文件操作函数open() close() write() read(),各个设备都有属于自己特殊的操作函数, uart的特殊函数主要有
int tcgetattr(int fd,struct termois *option);
int tcsetattr(int fd,int optact ,struct termois *option);
int cfsetispeed(struct termios *option,speed_t speed);
int cfsetospeed(struct termios *option,speed_t speed);
明天在写了,晚了,要回学校了。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/94039/showart_1887794.html |
|