tao_z
2022-05-25 1044ba0d2286698d0da28112bffc0f114bef2134
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
/**
 * @file Hal_GPIO.c
 * @author Ethan.Tao (tzj0429@163.com)
 * @brief
 * @version 0.1
 * @date 2022-05-15
 *
 * @copyright Copyright (c) 2022 Äþ²¨ÕýÀÊÆû³µÁ㲿¼þÓÐÏÞ¹«Ë¾
 *
 */
 
#include "xl_gpio.h"
#include "Hal_GPIO.h"
 
#define WAKE_UP_PIN GPIO_PTH2
#define CAN_STB_PIN GPIO_PTH7
 
#define LED_P_PIN GPIO_PTD3
#define LED_R_PIN GPIO_PTF1
#define LED_N_PIN GPIO_PTD4
#define LED_D_PIN GPIO_PTG4
#define LED_M_PIN GPIO_PTF0
 
const uint8_t Hal_LEDMapPin[] = {LED_P_PIN, LED_R_PIN, LED_N_PIN, LED_D_PIN, LED_M_PIN};
/**
 * @brief HAL GPIO Init
 *
 */
extern void Hal_GPIOInit(void)
{
    GPIO_SetPinDir(LED_P_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(LED_R_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(LED_N_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(LED_D_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(LED_M_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(WAKE_UP_PIN, GPIO_Direction_Output);
    GPIO_SetPinDir(CAN_STB_PIN, GPIO_Direction_Output);
 
    GPIO_SetPinOutput(LED_P_PIN, GPIO_Output_Low);
    GPIO_SetPinOutput(LED_R_PIN, GPIO_Output_Low);
    GPIO_SetPinOutput(LED_N_PIN, GPIO_Output_Low);
    GPIO_SetPinOutput(LED_D_PIN, GPIO_Output_Low);
    GPIO_SetPinOutput(LED_M_PIN, GPIO_Output_Low);
    GPIO_SetPinOutput(WAKE_UP_PIN, GPIO_Output_High);
    GPIO_SetPinOutput(CAN_STB_PIN, GPIO_Output_Low);
}
/**
 * @brief Set P LED
 *
 * @param cmd 1:LED ON 0:LED OFF
 */
 
extern void Hal_ToggleLED(LED_t led)
{
    GPIO_TogglePin(Hal_LEDMapPin[led]);
}
 
extern void Hal_SetCanStanbyMode(void)
{
    GPIO_SetPin(CAN_STB_PIN);
}
 
extern void Hal_SetCanNormalMode(void)
{
    GPIO_ClrPin(CAN_STB_PIN);
}
extern void Hal_EnableWakeup(void)
{
    GPIO_ClrPin(WAKE_UP_PIN);
}
 
extern void Hal_DisableWakeup(void)
{
    GPIO_SetPin(WAKE_UP_PIN);
}