-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm32f4xx_it.c
285 lines (255 loc) · 7.15 KB
/
stm32f4xx_it.c
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/**
******************************************************************************
* @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.5.0
* @date 06-March-2015
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"
#include "main.h"
#include "string.h"
#include "delay.h"
/** @addtogroup Template_Project
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
TimingDelay_Decrement();
}
void USART1_IRQHandler(void) //串口1中断服务程序
{
if(USART_GetITStatus(USART1,USART_IT_RXNE) != RESET)
{
}
}
const char sof = 0xA5;
const char end = 0xFE;
char RECIVE_start=0;
volatile char rec_buff[30];
volatile int rec_count=0;
char temp_buf[14]={0};
//extern u8 Motor_2310_state;
//extern u8 Servo_state;
u16 Usart6_time_cnt = 0;
//int a=0;
extern tReceTXoneData ReceData;
void USART6_IRQHandler(void)
{
if(USART_GetITStatus(USART6,USART_IT_RXNE) != RESET)
{
// LED_ON;
temp_buf[rec_count] = USART_ReceiveData(USART6);
if(temp_buf[rec_count] == sof)
{
RECIVE_start = 1;
rec_count = 1;
return;
}
if(RECIVE_start)
{
temp_buf[rec_count++] = USART_ReceiveData(USART6);
if(temp_buf[rec_count-1] == end)
{
RECIVE_start = 0;
rec_count = 0;
memcpy(&ReceData,temp_buf,sizeof(tReceTXoneData));
// LED_OFF;
}
}
// delay_ms(2);
}
}
//char temp_buf[30];
//volatile int rec_count=0;
//char RECIVE_start = 0;
//char data_size = 0;
//extern volatile float Gyno;
//u16 rec_sum = 0;
//void USART3_IRQHandler(void) //串口1中断服务程序
//{
// int i;
// if(USART_GetITStatus(USART3,USART_IT_RXNE) != RESET)
// {
//
// // USART1->DR = USART_ReceiveData(USART3);
// temp_buf[rec_count] = USART_ReceiveData(USART3);
// if((temp_buf[rec_count] == compass_eof) && (!RECIVE_start))
// {
// RECIVE_start = 1;
// rec_count = 1;
// return;
// }
// if(RECIVE_start)
// {
// temp_buf[rec_count++] = USART_ReceiveData(USART3);
// data_size = temp_buf[1];
// // printf("data_size is %d\n",data_size);
// if((rec_count-1) == data_size)
// {
// rec_sum = 0;
// for(i = 1;i<data_size;i++)
// {
// rec_sum+=temp_buf[i];
//// while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
//// USART1->DR = temp_buf[i];
// }
//
//
// //USART1->DR = rec_sum&0x00ff;
//
// // USART1->DR = 0xFF;
//
// //USART1->DR = temp_buf[12];
// // printf("sum is %d,temp is %d \n",rec_sum&0xff,temp_buf[data_size]);
//
// if(temp_buf[data_size] == (rec_sum&0x00ff) )
// {
// Gyno = (-1)*(temp_buf[data_size-3]>>4)*((temp_buf[data_size-3]&0x0f)*100 + (temp_buf[data_size-2]>>4)*10 + (temp_buf[data_size-2]&0x0f) + (temp_buf[data_size-1]>>4)*0.1 + (temp_buf[data_size-1]&0x0f)*0.01);
// //printf("Sum ok!\n");
// }
//
// RECIVE_start = 0;
// rec_count = 0;
// data_size = 0;
//
//
// }
//
// }
//
// }
// }
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/