Mercurial > public > ostc4
annotate Small_CPU/Src/gpio.c @ 1036:5865f0aeb438 Puls_Integration
Radio data integration:
Added functionality for displaying radio data as debug message. The USART3 has been configurated for receiption and a function for the visualization of the data has been added to the demo unit (draft implementation). For activation the radio as well as the logger functionality needs to be activated via compile switch. Note that at the moment bluetooth and radio DMA may not be operated in parallel.
| author | Ideenmodellierer |
|---|---|
| date | Sun, 10 Aug 2025 15:28:59 +0200 |
| parents | c386ae6635e4 |
| children | 9fabad6436a2 |
| rev | line source |
|---|---|
| 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" | |
| 951 | 26 #include "data_exchange.h" |
| 27 #include "scheduler.h" | |
|
994
bad5561c0c59
Fix a compilation error occurring on non-Windows platforms, caused by incorrect case in '#include' file names.
heinrichsweikamp
parents:
988
diff
changeset
|
28 #include "uart_Internal.h" |
| 988 | 29 #include "GNSS.h" |
| 935 | 30 |
| 31 /* Exported variables --------------------------------------------------------*/ | |
| 32 /* Private variables ---------------------------------------------------------*/ | |
| 988 | 33 static uint8_t GPIO_Version = 0; |
| 935 | 34 /* Private types -------------------------------------------------------------*/ |
| 35 | |
| 36 /* Private function prototypes -----------------------------------------------*/ | |
| 37 | |
| 38 /* Exported functions --------------------------------------------------------*/ | |
| 39 void GPIO_LEDs_VIBRATION_Init(void) { | |
| 40 GPIO_InitTypeDef GPIO_InitStructure; | |
| 41 | |
| 42 __GPIOA_CLK_ENABLE(); | |
| 43 GPIO_InitStructure.Pin = LED_CONTROL_PIN_RED; | |
| 44 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 45 GPIO_InitStructure.Pull = GPIO_PULLUP; | |
| 46 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 47 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); | |
| 48 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET); | |
| 49 | |
| 50 GPIO_InitStructure.Pin = LED_CONTROL_PIN_GREEN; | |
| 51 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 52 GPIO_InitStructure.Pull = GPIO_PULLUP; | |
| 53 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 54 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); | |
| 55 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET); | |
| 56 | |
| 57 GPIO_InitStructure.Pin = VIBRATION_CONTROL_PIN; | |
| 58 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 59 GPIO_InitStructure.Pull = GPIO_PULLDOWN; | |
| 60 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 61 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); | |
| 62 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET); | |
| 938 | 63 } |
| 64 | |
| 65 void GPIO_GNSS_Init() | |
| 66 { | |
| 67 GPIO_InitTypeDef GPIO_InitStructure; | |
| 935 | 68 |
| 69 __GPIOB_CLK_ENABLE(); | |
| 70 GPIO_InitStructure.Pin = GPS_POWER_CONTROL_PIN; | |
| 71 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 72 GPIO_InitStructure.Pull = GPIO_PULLUP; | |
| 73 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 74 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure); | |
| 75 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET); | |
| 76 | |
| 77 GPIO_InitStructure.Pin = GPS_BCKP_CONTROL_PIN; | |
| 78 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 79 GPIO_InitStructure.Pull = GPIO_PULLDOWN; | |
| 80 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 81 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure); | |
| 947 | 82 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET); |
| 935 | 83 } |
| 84 | |
| 85 void GPIO_Power_MainCPU_Init(void) { | |
| 86 GPIO_InitTypeDef GPIO_InitStructure; | |
| 87 __GPIOC_CLK_ENABLE(); | |
| 88 GPIO_InitStructure.Pin = MAINCPU_CONTROL_PIN; | |
| 89 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; | |
| 90 GPIO_InitStructure.Pull = GPIO_PULLUP; | |
| 91 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 92 HAL_GPIO_Init( GPIOC, &GPIO_InitStructure); | |
| 93 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); | |
| 94 } | |
| 95 | |
| 951 | 96 void GPIO_HandleBuzzer() |
| 97 { | |
| 98 static uint32_t buzzerOnTick = 0; | |
| 99 static uint8_t buzzerWasOn = 0; | |
| 100 | |
| 101 if(((global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_BUZZER_ON) != 0)) | |
| 102 { | |
| 103 if(!buzzerWasOn) | |
| 104 { | |
| 105 buzzerOnTick = HAL_GetTick(); | |
| 106 GPIO_VIBRATION_ON(); | |
| 107 /* GPIO_LED_RED_ON(); */ | |
| 108 | |
| 109 if(time_elapsed_ms(buzzerOnTick,HAL_GetTick()) > EXT_INTERFACE_BUZZER_ON_TIME_MS) | |
| 110 { | |
| 111 GPIO_VIBRATION_OFF(); | |
| 112 /* GPIO_LED_RED_OFF(); */ | |
| 113 } | |
| 114 } | |
| 115 buzzerWasOn = 1; | |
| 116 } | |
| 117 else | |
| 118 { | |
| 119 if(buzzerWasOn) | |
| 120 { | |
| 121 buzzerOnTick = 0; | |
| 122 GPIO_VIBRATION_OFF(); | |
| 123 /* GPIO_LED_RED_OFF(); */ | |
| 124 } | |
| 125 buzzerWasOn = 0; | |
| 126 } | |
| 127 } | |
| 988 | 128 |
| 935 | 129 void GPIO_Power_MainCPU_ON(void) { |
| 130 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); | |
| 131 } | |
| 132 | |
| 133 void GPIO_Power_MainCPU_OFF(void) { | |
| 134 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET); | |
| 135 } | |
| 136 | |
| 137 void GPIO_LED_GREEN_ON(void) { | |
| 138 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET); | |
| 139 } | |
| 140 | |
| 141 void GPIO_LED_GREEN_OFF(void) { | |
| 142 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET); | |
| 143 } | |
| 144 | |
| 145 void GPIO_LED_RED_ON(void) { | |
| 146 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_RESET); | |
| 147 } | |
| 148 | |
| 149 void GPIO_LED_RED_OFF(void) { | |
| 150 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET); | |
| 151 } | |
| 152 | |
| 153 void GPIO_VIBRATION_ON(void) { | |
| 154 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_SET); | |
| 155 } | |
| 156 | |
| 157 void GPIO_VIBRATION_OFF(void) { | |
| 158 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET); | |
| 159 } | |
| 160 | |
| 161 void GPIO_GPS_ON(void) { | |
| 162 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_RESET); | |
| 163 } | |
| 164 | |
| 165 void GPIO_GPS_OFF(void) { | |
| 166 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET); | |
| 167 } | |
| 168 | |
| 169 void GPIO_GPS_BCKP_ON(void) { | |
| 170 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET); | |
| 171 } | |
| 172 | |
| 173 void GPIO_GPS_BCKP_OFF(void) { | |
| 174 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET); | |
| 175 } | |
| 988 | 176 |
| 177 uint8_t GPIO_GetVersion() | |
| 178 { | |
| 179 return GPIO_Version; | |
| 180 } | |
| 181 | |
| 182 void GPIO_Activate_V2(void) | |
| 183 { | |
| 1000 | 184 if(GPIO_Version == 0) |
| 185 { | |
| 988 | 186 GPIO_Version = 1; |
| 187 GPIO_LEDs_VIBRATION_Init(); | |
| 188 | |
| 189 #ifdef ENABLE_GNSS_INTERN | |
| 190 GNSS_IO_init(); | |
| 191 GPIO_GPS_ON(); | |
| 192 GPIO_GPS_BCKP_ON(); | |
| 193 MX_USART6_UART_Init(); | |
| 194 GNSS_Init(&GNSS_Handle, &huart6); | |
| 935 | 195 #endif |
| 1000 | 196 } |
| 988 | 197 } |
| 935 | 198 /* Private functions ---------------------------------------------------------*/ |
| 199 | |
| 200 | |
| 201 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |
