comparison Small_CPU/Src/gpio.c @ 935:f2494a708f52 Evo_2_23

Added unit files for GPIO: The new gpios need to be accessed from severall units. That's why the current, static implementation in the baseCPU did not fit. To enable global usage of the function they have been moved into new source / header file
author Ideenmodellierer
date Sun, 08 Dec 2024 21:59:22 +0100
parents
children df87dbfc9c21
comparison
equal deleted inserted replaced
934:406d498786e7 935:f2494a708f52
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>&copy; 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);
59
60 __GPIOB_CLK_ENABLE();
61 GPIO_InitStructure.Pin = GPS_POWER_CONTROL_PIN;
62 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
63 GPIO_InitStructure.Pull = GPIO_PULLUP;
64 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
65 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
66 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
67
68 GPIO_InitStructure.Pin = GPS_BCKP_CONTROL_PIN;
69 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
70 GPIO_InitStructure.Pull = GPIO_PULLDOWN;
71 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
72 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
73 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET);
74 }
75
76 void GPIO_Power_MainCPU_Init(void) {
77 GPIO_InitTypeDef GPIO_InitStructure;
78 __GPIOC_CLK_ENABLE();
79 GPIO_InitStructure.Pin = MAINCPU_CONTROL_PIN;
80 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
81 GPIO_InitStructure.Pull = GPIO_PULLUP;
82 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
83 HAL_GPIO_Init( GPIOC, &GPIO_InitStructure);
84 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
85 }
86
87 void GPIO_Power_MainCPU_ON(void) {
88 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
89 }
90
91 void GPIO_Power_MainCPU_OFF(void) {
92 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET);
93 }
94
95 #ifdef ENABLE_GPIO_V2
96 void GPIO_LED_GREEN_ON(void) {
97 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET);
98 }
99
100 void GPIO_LED_GREEN_OFF(void) {
101 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET);
102 }
103
104 void GPIO_LED_RED_ON(void) {
105 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_RESET);
106 }
107
108 void GPIO_LED_RED_OFF(void) {
109 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET);
110 }
111
112 void GPIO_VIBRATION_ON(void) {
113 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_SET);
114 }
115
116 void GPIO_VIBRATION_OFF(void) {
117 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET);
118 }
119
120 void GPIO_GPS_ON(void) {
121 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_RESET);
122 }
123
124 void GPIO_GPS_OFF(void) {
125 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
126 }
127
128 void GPIO_GPS_BCKP_ON(void) {
129 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET);
130 }
131
132 void GPIO_GPS_BCKP_OFF(void) {
133 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET);
134 }
135 #endif
136
137 /* Private functions ---------------------------------------------------------*/
138
139
140 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/