935
|
1 /**
|
|
2 ******************************************************************************
|
|
3 * @file gpio.c
|
|
4 * @author heinrichs weikamp gmbh
|
|
5 * @version V0.0.1
|
|
6 * @date 08-Dec-2024
|
|
7 * @brief Definitions for GPIO operations (GPIO_V2)
|
|
8 *
|
|
9 @verbatim
|
|
10 ==============================================================================
|
|
11 ##### How to use #####
|
|
12 ==============================================================================
|
|
13 @endverbatim
|
|
14 ******************************************************************************
|
|
15 * @attention
|
|
16 *
|
|
17 * <h2><center>© COPYRIGHT(c) 2024 heinrichs weikamp</center></h2>
|
|
18 *
|
|
19 ******************************************************************************
|
|
20 */
|
|
21
|
|
22 /* Includes ------------------------------------------------------------------*/
|
|
23
|
|
24 #include "stm32f4xx_hal.h"
|
|
25 #include "gpio.h"
|
|
26
|
|
27 /* Exported variables --------------------------------------------------------*/
|
|
28 /* Private variables ---------------------------------------------------------*/
|
|
29
|
|
30 /* Private types -------------------------------------------------------------*/
|
|
31
|
|
32 /* Private function prototypes -----------------------------------------------*/
|
|
33
|
|
34 /* Exported functions --------------------------------------------------------*/
|
|
35 void GPIO_LEDs_VIBRATION_Init(void) {
|
|
36 GPIO_InitTypeDef GPIO_InitStructure;
|
|
37
|
|
38 __GPIOA_CLK_ENABLE();
|
|
39 GPIO_InitStructure.Pin = LED_CONTROL_PIN_RED;
|
|
40 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
41 GPIO_InitStructure.Pull = GPIO_PULLUP;
|
|
42 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
43 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
|
|
44 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET);
|
|
45
|
|
46 GPIO_InitStructure.Pin = LED_CONTROL_PIN_GREEN;
|
|
47 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
48 GPIO_InitStructure.Pull = GPIO_PULLUP;
|
|
49 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
50 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
|
|
51 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET);
|
|
52
|
|
53 GPIO_InitStructure.Pin = VIBRATION_CONTROL_PIN;
|
|
54 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
55 GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
|
56 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
57 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
|
|
58 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET);
|
938
|
59 }
|
|
60
|
|
61 void GPIO_GNSS_Init()
|
|
62 {
|
|
63 GPIO_InitTypeDef GPIO_InitStructure;
|
935
|
64
|
|
65 __GPIOB_CLK_ENABLE();
|
|
66 GPIO_InitStructure.Pin = GPS_POWER_CONTROL_PIN;
|
|
67 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
68 GPIO_InitStructure.Pull = GPIO_PULLUP;
|
|
69 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
70 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
|
|
71 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
|
|
72
|
|
73 GPIO_InitStructure.Pin = GPS_BCKP_CONTROL_PIN;
|
|
74 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
75 GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
|
76 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
77 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
|
947
|
78 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET);
|
935
|
79 }
|
|
80
|
|
81 void GPIO_Power_MainCPU_Init(void) {
|
|
82 GPIO_InitTypeDef GPIO_InitStructure;
|
|
83 __GPIOC_CLK_ENABLE();
|
|
84 GPIO_InitStructure.Pin = MAINCPU_CONTROL_PIN;
|
|
85 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
86 GPIO_InitStructure.Pull = GPIO_PULLUP;
|
|
87 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
88 HAL_GPIO_Init( GPIOC, &GPIO_InitStructure);
|
|
89 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
|
|
90 }
|
|
91
|
|
92 void GPIO_Power_MainCPU_ON(void) {
|
|
93 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
|
|
94 }
|
|
95
|
|
96 void GPIO_Power_MainCPU_OFF(void) {
|
|
97 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET);
|
|
98 }
|
|
99
|
|
100 #ifdef ENABLE_GPIO_V2
|
|
101 void GPIO_LED_GREEN_ON(void) {
|
|
102 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET);
|
|
103 }
|
|
104
|
|
105 void GPIO_LED_GREEN_OFF(void) {
|
|
106 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET);
|
|
107 }
|
|
108
|
|
109 void GPIO_LED_RED_ON(void) {
|
|
110 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_RESET);
|
|
111 }
|
|
112
|
|
113 void GPIO_LED_RED_OFF(void) {
|
|
114 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET);
|
|
115 }
|
|
116
|
|
117 void GPIO_VIBRATION_ON(void) {
|
|
118 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_SET);
|
|
119 }
|
|
120
|
|
121 void GPIO_VIBRATION_OFF(void) {
|
|
122 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET);
|
|
123 }
|
|
124
|
|
125 void GPIO_GPS_ON(void) {
|
|
126 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_RESET);
|
|
127 }
|
|
128
|
|
129 void GPIO_GPS_OFF(void) {
|
|
130 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
|
|
131 }
|
|
132
|
|
133 void GPIO_GPS_BCKP_ON(void) {
|
|
134 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET);
|
|
135 }
|
|
136
|
|
137 void GPIO_GPS_BCKP_OFF(void) {
|
|
138 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET);
|
|
139 }
|
|
140 #endif
|
|
141
|
|
142 /* Private functions ---------------------------------------------------------*/
|
|
143
|
|
144
|
|
145 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
|