xiaoxiaocheng_plc/users/usart.c

46 lines
2.0 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/****************************************************************************
通讯格式详解D8120
----------------------------------------------------------------------
位号 | 含 义 | 描述
-----------+-------------+--------------------------------------------
b0 | 数据长度 | 0 7位 1 8位
-----------+-------------+--------------------------------------------
b2b1 | 校验方式 | 00不用 01奇校验 11偶校验
-----------+-------------+--------------------------------------------
b3 | 停止位 | 0 1位 1 2位
-----------+-------------+--------------------------------------------
| | 0001300 01114800
b7b6b5b4 | 波特率 | 0100600 10009600
| | 01011200 100119200
| | 01102400
-----------+-------------+--------------------------------------------
b8 | | 0不用 注:无协议通讯专用
-----------+-------------+--------------------------------------------
b9 | | 0不用 同上
-----------+-------------+--------------------------------------------
b12b11b10 | 通讯接口 | 000RS485RS422接口
| | 010 RS232C接口
-----------+-------------+--------------------------------------------
b13 | 求和检查 | 0不加求和码 1自动加上求和码
-----------+-------------+-------------------------------------------
b14 | 协议 | 0无协议通讯 1专用通讯协议
-----------+-------------+--------------------------------------------
b15 | 协议格式 | 0格式1 1格式4
----------------------------------------------------------------------
举例D8120 = 0X4096 通讯波特率是19200
*********************************************************************************/
#include <main.h>
#include "usart.h"
#include "PLC_IO.h"
#include "stm32f10x_dma.h"
extern char tx_data[143]; //发送缓存
extern u16 all_data[16600];