- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
串口收发(Serial transceiver)
串口收发(Serial transceiver)
/ / 头文件包含
# include stm32f10x.h
# include platform _ config.h
_ inittypedef gpio gpio _ initstructure;
typedef enum {failed = 0, by =. teststatus failed};
# define txbuffersize1 (countof (txbuffer1) - 1) / / 定义uart1的发送缓冲器的字节数
# define txbuffersize2 (countof (txbuffer2) - 1) / / 定义uart2的发送缓冲器的字节数
# define rxbuffersize1 txbuffersize2
# define rxbuffersize2 txbuffersize1
# define countof (and) (sizeof (and) / sizeof (* (a))) / / sizeof (a) = 数组字节长度
/ / sizeof (* (a) = 数组变量类型 (char = 1、int = 2)
/ / 数组长度 = sizeof (数组) / sizeof (* 数组)
/ / 数组长度 = sizeof (数组) / sizeof (* 数组) (数组内为纯数字)
/ / 数组长度 = sizeof (数组) - 1 / sizeof (* 数组) (数组内为纯字符或者数字数组混和)
/ / 最后, 那么调用宏定义, 即可得出该数组内的字节数量: # define writebuffersize (countof (parameter _ tab)
/ / writebuffersize就等于该数组内的字节数量.
usart _ inittypedef usart _ initstructure; / / 定义串口初始化结构
uint8 _ t txbuffer1 [] = 串口中断收发示例: 串口1 - 串口2 (中断收发);
uint8 _ t txbuffer2 [] = 串口中断收发示例: 串口2 - 串口1 (中断收发);
uint8 _ t rxbuffer1 [rxbuffersize1];
uint8 _ t rxbuffer2 [rxbuffersize2];
_ _ io uint8 _ t txcounter1 = 0x00;
_ _ io uint8 _ t txcounter2 = 0x00;
_ _ io uint8 _ t rxcounter1 = 0x00;
_ _ io uint8 _ t rxcounter2 = 0x00;
uint8 _ t nbrofdatatotransfer1 = txbuffersize1;
uint8 _ t nbrofdatatotransfer2 = txbuffersize2;
uint8 _ t nbrofdatatoread1 = rxbuffersize1;
uint8 _ t nbrofdatatoread2 = rxbuffersize2;
_ _ io teststatus transferstatus1 = failed;
_ _ io teststatus transferstatus2 = failed;
/ * private function prototypes ----------------------------------------------- * /
void rcc _ configuration (void); / / 时钟配置函数
void _ gpio configuration (void); / / gpio口配置函数
void nvic _ configuration (void); / / 中断配置函数
teststatus buffercmp (uint8 _ t * pbuffer1, uint8 _ t * pbuffer2, uint16 _ t bufferlength);
int main (void)
{
rcc _ configuration ();
nvic _ configuration ();
_ gpio configuration ();
gpio _ setbits (gpio _ ice, ds1 _ pin | ds2 _ pin | ds3 _ pin | ds4 _ pin); / / 关闭所有的led指示灯
usart _ initstructure.usart _ baudrate = 115200; / / 设置波特率为11
您可能关注的文档
- 《英雄连 勇气传说》全任务攻略(Heroes even courage legend full task introduction).doc
- 《蟋蟀的住宅》教学设计(The teaching design of cricket house).doc
- 《西方经济学(二)》作业3(Western Economics (two) assignment 3).doc
- 《西门豹》教学设计(a、b案)(Their instructional design (a, b)).doc
- 《认识圆》教学设计(Teaching design of knowing the circle).doc
- 《课堂教学中师生互动的方式及其有效性研究》实施方案(郝学英)(The implementation of teacher student interaction in classroom teaching and its implementation (Hao Xueying)).doc
- 《素问》四经十二从义考(Four by twelve plain questions from meaning test).doc
- 《赤壁之战》新论_2984(Battle of Red Cliff on _2984).doc
- 《管理经济学(二)》在线作业(Management Economics (two) online homework).doc
- 《过三点的圆》(The circle after three).doc
原创力文档


文档评论(0)