-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel_usart.h
168 lines (133 loc) · 2.99 KB
/
panel_usart.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef __PANEL_USART_H
#define __PANEL_USART_H
#include "stm32f4xx.h"
#include <stdio.h>
/**
* @defgroup UART
* @{
*/
/**
* @brief Data Structure
* @{
*/
/**
* @brief 串口信息结构体
*
*/
typedef struct
{
uint8_t MsgBuff[10]; /*!< 串口信息缓存区 */
const uint8_t MsgLenth; /*!< 串口信息的长度 */
const uint8_t MsgFlag; /*!< 串口信息的首部和尾部标志 */
void (*MsgHandler)(void *uartMsg); /*!< 串口信息处理函数 */
} UartMsg;
extern UartMsg statusMsg;
extern UartMsg ctrlMsg;
/**
* @}
*/
/**
* @defgroup AP_UART
* @brief AP与面板进行通讯的串口
* @{
*/
/**
* @defgroup AP_Macro
* @{
*/
#define AP_USART USART1
#define AP_USART_CLK RCC_APB2Periph_USART1
#define AP_USART_BAUDRATE 115200
#define AP_USART_RX_GPIO_PORT GPIOA
#define AP_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOA
#define AP_USART_RX_PIN GPIO_Pin_10
#define AP_USART_RX_AF GPIO_AF_USART1
#define AP_USART_RX_SOURCE GPIO_PinSource10
#define AP_USART_TX_GPIO_PORT GPIOA
#define AP_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOA
#define AP_USART_TX_PIN GPIO_Pin_9
#define AP_USART_TX_AF GPIO_AF_USART1
#define AP_USART_TX_SOURCE GPIO_PinSource9
#define AP_USART_IRQHandler USART1_IRQHandler
#define AP_USART_IRQ USART1_IRQn
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup ST_UART
* @brief ST与面板进行通讯的串口
* @{
*/
/**
* @defgroup ST_Macro
* @{
*/
#define ST_USART USART3
#define ST_USART_CLK RCC_APB1Periph_USART3
#define ST_USART_BAUDRATE 115200
#define ST_USART_RX_GPIO_PORT GPIOC
#define ST_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define ST_USART_RX_PIN GPIO_Pin_11
#define ST_USART_RX_AF GPIO_AF_USART3
#define ST_USART_RX_SOURCE GPIO_PinSource11
#define ST_USART_TX_GPIO_PORT GPIOC
#define ST_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define ST_USART_TX_PIN GPIO_Pin_10
#define ST_USART_TX_AF GPIO_AF_USART3
#define ST_USART_TX_SOURCE GPIO_PinSource10
#define ST_USART_IRQHandler USART3_IRQHandler
#define ST_USART_IRQ USART3_IRQn
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup DEBUG_UART
* @brief 用于输出调试信息的串口
* @{
*/
/**
* @defgroup DEBUG_Macro
* @{
*/
#define DEBUG_USART USART6
#define DEBUG_USART_CLK RCC_APB2Periph_USART6
#define DEBUG_USART_BAUDRATE 115200
#define DEBUG_USART_TX_GPIO_PORT GPIOC
#define DEBUG_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define DEBUG_USART_TX_PIN GPIO_Pin_6
#define DEBUG_USART_TX_AF GPIO_AF_USART6
#define DEBUG_USART_TX_SOURCE GPIO_PinSource6
#define DEBUG_USART_RX_GPIO_PORT GPIOC
#define DEBUG_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define DEBUG_USART_RX_PIN GPIO_Pin_7
#define DEBUG_USART_RX_AF GPIO_AF_USART6
#define DEBUG_USART_RX_SOURCE GPIO_PinSource7
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup Function
* @{
*/
void PANEL_USART_Config(void);
void DEBUG_USART_Config(void);
void AP_USART_Config(void);
void ST_USART_Config(void);
void NVIC_Configuration(void);
void Usart_SendBuff(USART_TypeDef *pUSARTx, uint8_t *buf, uint8_t len);
/**
* @}
*/
/**
* @}
*/
#endif /* __USART1_H */