串口通讯程序(中断方式)

本文分享了一段从《嵌入式系统构件》移植而来的中断方式串口通讯程序,包括串口中断服务程序、数据读写、缓冲区管理和状态检查等关键功能。程序使用循环缓冲区和互斥锁serial_lock保护数据结构,适用于嵌入式系统的串行通信。
摘要由CSDN通过智能技术生成

把我用的串口通讯程序(中断方式)搭个便车让大家看看,并非原创,从<<嵌入式系统构件>>的相关代码移植而来。
#include "../inc/includes.h"

char xdata ser_buffer[SERIAL_BUFF_SIZE];  /* the receive buffer*/

int ser_end = -1;
int ser_start=-1;      /* indexes into receive buffer*/
int ser_ch;
int char_ready=0;           /* current character and ready flag*/

int serial_lock = 0;                /* serial ISR semaphore so the buffer*/
                                 /* isn't altered will it is being written*/
//功能介绍:串口通讯中断服务程序。
//入口参数:无
//出口参数:无
//备注:系统开中断后由中断触发执行。
void  Serial_Isr(void) interrupt 4
{
   
/* this is the ISR (Interrupt Service Routine) for the com port.  It is very*/
/* simple.  When it gets called, it gets the next character out of the receive*/
/* buffer register 0 and places it into the software buffer. Note

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值