-
Notifications
You must be signed in to change notification settings - Fork 1
/
Functionality.c
89 lines (55 loc) · 1.17 KB
/
Functionality.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
#include "Functionality.h"
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart7;
extern uint8_t rxdata;
extern
char CmdStart ;
uint8_t RxBuffer[100];
void SendUartData(uint8_t UartNo, char str[],int Length)
{
if(Length==0)
Length = strlen(str);
switch(UartNo)
{
case DEBUG:
if( HAL_UART_Transmit(&huart7,(uint8_t*)str,Length,100) != HAL_OK)
{
Error_Handler(ERROR_UART_TX);
}
break;
case GSM :
if( HAL_UART_Transmit(&huart1,(uint8_t*)str,Length,100) != HAL_OK)
{
Error_Handler(ERROR_UART_TX);
}
break;
default:
break;
}
}
void Error_Handler(uint8_t ErrorType)
{
switch(ErrorType)
{
case ERROR_UART:
break;
case ERROR_UART_RX:
break;
case ERROR_UART_TX:
break;
case ERROR_UART_TX_RX:
SendUartData(DEBUG,"E",0);
CmdStart = 0;
StartRecieve(&huart1);
break;
default:
break;
}
}
void StartRecieve(UART_HandleTypeDef *UartHandle)
{
if (HAL_UART_Receive_IT(UartHandle,&rxdata,1) != HAL_OK)
{
Error_Handler(ERROR_UART_RX);
}
}