Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 50 | mjames | 1 | /* USER CODE BEGIN Header */ |
| 2 | mjames | 2 | /** |
| 52 | mjames | 3 | ****************************************************************************** |
| 4 | * @file : main.c |
||
| 5 | * @brief : Main program body |
||
| 6 | ****************************************************************************** |
||
| 7 | * @attention |
||
| 8 | * |
||
| 9 | * <h2><center>© Copyright (c) 2020 STMicroelectronics. |
||
| 10 | * All rights reserved.</center></h2> |
||
| 11 | * |
||
| 12 | * This software component is licensed by ST under BSD 3-Clause license, |
||
| 13 | * the "License"; You may not use this file except in compliance with the |
||
| 14 | * License. You may obtain a copy of the License at: |
||
| 15 | * opensource.org/licenses/BSD-3-Clause |
||
| 16 | * |
||
| 17 | ****************************************************************************** |
||
| 18 | */ |
||
| 50 | mjames | 19 | /* USER CODE END Header */ |
| 2 | mjames | 20 | /* Includes ------------------------------------------------------------------*/ |
| 50 | mjames | 21 | #include "main.h" |
| 2 | mjames | 22 | |
| 50 | mjames | 23 | /* Private includes ----------------------------------------------------------*/ |
| 2 | mjames | 24 | /* USER CODE BEGIN Includes */ |
| 50 | mjames | 25 | |
| 26 | #include "libPLX/plx.h" |
||
| 27 | #include "libSerial/serial.H" |
||
| 28 | #include "libSmallPrintf/small_printf.h" |
||
| 4 | mjames | 29 | #include "switches.h" |
| 2 | mjames | 30 | |
| 31 | /* USER CODE END Includes */ |
||
| 32 | |||
| 50 | mjames | 33 | /* Private typedef -----------------------------------------------------------*/ |
| 34 | /* USER CODE BEGIN PTD */ |
||
| 35 | |||
| 36 | /* USER CODE END PTD */ |
||
| 37 | |||
| 38 | /* Private define ------------------------------------------------------------*/ |
||
| 39 | /* USER CODE BEGIN PD */ |
||
| 40 | /* USER CODE END PD */ |
||
| 41 | |||
| 42 | /* Private macro -------------------------------------------------------------*/ |
||
| 43 | /* USER CODE BEGIN PM */ |
||
| 44 | |||
| 45 | /* USER CODE END PM */ |
||
| 46 | |||
| 2 | mjames | 47 | /* Private variables ---------------------------------------------------------*/ |
| 48 | SPI_HandleTypeDef hspi1; |
||
| 49 | |||
| 50 | mjames | 50 | TIM_HandleTypeDef htim2; |
| 44 | mjames | 51 | TIM_HandleTypeDef htim3; |
| 52 | TIM_HandleTypeDef htim9; |
||
| 53 | |||
| 3 | mjames | 54 | UART_HandleTypeDef huart1; |
| 2 | mjames | 55 | UART_HandleTypeDef huart2; |
| 23 | mjames | 56 | UART_HandleTypeDef huart3; |
| 2 | mjames | 57 | |
| 58 | /* USER CODE BEGIN PV */ |
||
| 59 | /* Private variables ---------------------------------------------------------*/ |
||
| 60 | |||
| 50 | mjames | 61 | context_t contexts[MAX_DISPLAYS]; |
| 62 | |||
| 24 | mjames | 63 | /* timeout when the ignition is switched off */ |
| 64 | #define IGNITION_OFF_TIMEOUT 30000UL |
||
| 65 | |||
| 52 | mjames | 66 | #define LOGGER_INTERVAL 500UL |
| 14 | mjames | 67 | |
| 57 | mjames | 68 | const int DialTimeout = 10000; // about 10 seconds after twiddle, save the dial position. |
| 18 | mjames | 69 | |
| 56 | mjames | 70 | nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data"))); |
| 14 | mjames | 71 | |
| 56 | mjames | 72 | info_t Info[MAXRDG]; |
| 73 | |||
| 74 | /// \brief storage for incoming data |
||
| 50 | mjames | 75 | data_t Data; |
| 56 | mjames | 76 | |
| 7 | mjames | 77 | int PLXItems; |
| 24 | mjames | 78 | |
| 27 | mjames | 79 | uint32_t Latch_Timer = IGNITION_OFF_TIMEOUT; |
| 24 | mjames | 80 | |
| 2 | mjames | 81 | /* USER CODE END PV */ |
| 82 | |||
| 83 | /* Private function prototypes -----------------------------------------------*/ |
||
| 52 | mjames | 84 | void |
| 85 | SystemClock_Config (void); |
||
| 86 | static void |
||
| 87 | MX_GPIO_Init (void); |
||
| 88 | static void |
||
| 89 | MX_SPI1_Init (void); |
||
| 90 | static void |
||
| 91 | MX_USART1_UART_Init (void); |
||
| 92 | static void |
||
| 93 | MX_USART2_UART_Init (void); |
||
| 94 | static void |
||
| 95 | MX_USART3_UART_Init (void); |
||
| 96 | static void |
||
| 97 | MX_TIM3_Init (void); |
||
| 98 | static void |
||
| 99 | MX_TIM9_Init (void); |
||
| 100 | static void |
||
| 101 | MX_TIM2_Init (void); |
||
| 2 | mjames | 102 | /* USER CODE BEGIN PFP */ |
| 103 | |||
| 7 | mjames | 104 | // the dial is the switch number we are using. |
| 105 | // suppress is the ItemIndex we wish to suppress on this display |
||
| 52 | mjames | 106 | int |
| 107 | DisplayCurrent (int dial, int suppress) |
||
| 7 | mjames | 108 | { |
| 57 | mjames | 109 | if (contexts[dial].knobPos < 0) |
| 50 | mjames | 110 | return -1; |
| 57 | mjames | 111 | return cc_display (dial, suppress); |
| 50 | mjames | 112 | } |
| 30 | mjames | 113 | |
| 53 | mjames | 114 | void |
| 115 | setBaud (usart_ctl *ctl, uint32_t baud) |
||
| 116 | { |
||
| 117 | ctl->handle->Init.BaudRate = baud; |
||
| 118 | __disable_irq (); |
||
| 119 | HAL_UART_Init (ctl->handle); |
||
| 120 | __enable_irq (); |
||
| 121 | } |
||
| 122 | |||
| 123 | void |
||
| 124 | sendString (usart_ctl *ctl, char *string, int length) |
||
| 125 | { |
||
| 126 | int i; |
||
| 127 | for (i = 0; i < length; i++) |
||
| 128 | PutCharSerial (ctl, string[i]); |
||
| 129 | |||
| 130 | } |
||
| 131 | |||
| 56 | mjames | 132 | /// \note this code doesnt work so it leaves speed as 9600. |
| 133 | /// \brief Setup Bluetooth module |
||
| 53 | mjames | 134 | void |
| 135 | initModule (usart_ctl *ctl, uint32_t baudRate) |
||
| 136 | { |
||
| 137 | char initBuf[30]; |
||
| 138 | // switch to command mode |
||
| 139 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
||
| 140 | HAL_Delay (500); |
||
| 57 | mjames | 141 | int initLen = small_sprintf (initBuf, "AT+UART=%l,1,2\n", baudRate); |
| 53 | mjames | 142 | setBaud (ctl, 38400); |
| 143 | sendString (ctl, initBuf, initLen); |
||
| 144 | TxWaitEmpty (ctl); |
||
| 145 | // switch back to normal comms at new baud rate |
||
| 146 | |||
| 147 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_SET); |
||
| 148 | setBaud (ctl, baudRate); |
||
| 149 | HAL_Delay (100); |
||
| 150 | |||
| 151 | } |
||
| 152 | |||
| 50 | mjames | 153 | /* USER CODE END PFP */ |
| 14 | mjames | 154 | |
| 50 | mjames | 155 | /* Private user code ---------------------------------------------------------*/ |
| 156 | /* USER CODE BEGIN 0 */ |
||
| 14 | mjames | 157 | |
| 7 | mjames | 158 | /* USER CODE END 0 */ |
| 2 | mjames | 159 | |
| 50 | mjames | 160 | /** |
| 52 | mjames | 161 | * @brief The application entry point. |
| 162 | * @retval int |
||
| 163 | */ |
||
| 164 | int |
||
| 165 | main (void) |
||
| 7 | mjames | 166 | { |
| 16 | mjames | 167 | /* USER CODE BEGIN 1 */ |
| 50 | mjames | 168 | __HAL_RCC_SPI1_CLK_ENABLE() |
| 169 | ; |
||
| 170 | __HAL_RCC_USART1_CLK_ENABLE() |
||
| 171 | ; // PLX main port |
||
| 172 | __HAL_RCC_USART2_CLK_ENABLE() |
||
| 173 | ; // debug port |
||
| 174 | __HAL_RCC_USART3_CLK_ENABLE () |
||
| 175 | ; // Bluetooth port |
||
| 2 | mjames | 176 | |
| 50 | mjames | 177 | __HAL_RCC_TIM3_CLK_ENABLE(); |
| 2 | mjames | 178 | |
| 50 | mjames | 179 | __HAL_RCC_TIM9_CLK_ENABLE(); |
| 23 | mjames | 180 | |
| 16 | mjames | 181 | /* USER CODE END 1 */ |
| 2 | mjames | 182 | |
| 50 | mjames | 183 | /* MCU Configuration--------------------------------------------------------*/ |
| 6 | mjames | 184 | |
| 16 | mjames | 185 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
| 52 | mjames | 186 | HAL_Init (); |
| 2 | mjames | 187 | |
| 50 | mjames | 188 | /* USER CODE BEGIN Init */ |
| 189 | |||
| 190 | /* USER CODE END Init */ |
||
| 191 | |||
| 16 | mjames | 192 | /* Configure the system clock */ |
| 52 | mjames | 193 | SystemClock_Config (); |
| 2 | mjames | 194 | |
| 50 | mjames | 195 | /* USER CODE BEGIN SysInit */ |
| 196 | |||
| 197 | /* USER CODE END SysInit */ |
||
| 198 | |||
| 16 | mjames | 199 | /* Initialize all configured peripherals */ |
| 52 | mjames | 200 | MX_GPIO_Init (); |
| 201 | MX_SPI1_Init (); |
||
| 202 | MX_USART1_UART_Init (); |
||
| 203 | MX_USART2_UART_Init (); |
||
| 204 | MX_USART3_UART_Init (); |
||
| 205 | MX_TIM3_Init (); |
||
| 206 | MX_TIM9_Init (); |
||
| 207 | MX_TIM2_Init (); |
||
| 16 | mjames | 208 | /* USER CODE BEGIN 2 */ |
| 2 | mjames | 209 | |
| 50 | mjames | 210 | /* Turn on USART1 IRQ */ |
| 52 | mjames | 211 | HAL_NVIC_SetPriority (USART1_IRQn, 2, 0); |
| 212 | HAL_NVIC_EnableIRQ (USART1_IRQn); |
||
| 4 | mjames | 213 | |
| 50 | mjames | 214 | /* Turn on USART2 IRQ */ |
| 52 | mjames | 215 | HAL_NVIC_SetPriority (USART2_IRQn, 4, 0); |
| 216 | HAL_NVIC_EnableIRQ (USART2_IRQn); |
||
| 2 | mjames | 217 | |
| 50 | mjames | 218 | /* turn on USART3 IRQ */ |
| 52 | mjames | 219 | HAL_NVIC_SetPriority (USART3_IRQn, 4, 0); |
| 220 | HAL_NVIC_EnableIRQ (USART3_IRQn); |
||
| 4 | mjames | 221 | |
| 50 | mjames | 222 | /* setup the USART control blocks */ |
| 53 | mjames | 223 | init_usart_ctl (&uc1, &huart1); |
| 224 | init_usart_ctl (&uc2, &huart2); |
||
| 225 | init_usart_ctl (&uc3, &huart3); |
||
| 23 | mjames | 226 | |
| 52 | mjames | 227 | EnableSerialRxInterrupt (&uc1); |
| 228 | EnableSerialRxInterrupt (&uc2); |
||
| 229 | EnableSerialRxInterrupt (&uc3); |
||
| 23 | mjames | 230 | |
| 52 | mjames | 231 | HAL_TIM_Encoder_Start (&htim3, TIM_CHANNEL_ALL); |
| 23 | mjames | 232 | |
| 52 | mjames | 233 | HAL_TIM_Encoder_Start (&htim9, TIM_CHANNEL_ALL); |
| 44 | mjames | 234 | |
| 50 | mjames | 235 | // Switch handler called on sysTick interrupt. |
| 52 | mjames | 236 | InitSwitches (); |
| 2 | mjames | 237 | |
| 56 | mjames | 238 | initModule (&uc3, 9600); |
| 53 | mjames | 239 | |
| 52 | mjames | 240 | cc_init (); |
| 23 | mjames | 241 | |
| 50 | mjames | 242 | int i; |
| 243 | for (i = 0; i < 2; i++) |
||
| 52 | mjames | 244 | { |
| 57 | mjames | 245 | dial_pos[i] = 0; // default to items 0 and 1 |
| 246 | contexts[i].knobPos = -1; |
||
| 52 | mjames | 247 | } |
| 7 | mjames | 248 | |
| 50 | mjames | 249 | /* reset the display timeout, latch on power from accessories */ |
| 250 | Latch_Timer = IGNITION_OFF_TIMEOUT; |
||
| 52 | mjames | 251 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET); |
| 16 | mjames | 252 | |
| 253 | /* USER CODE END 2 */ |
||
| 7 | mjames | 254 | |
| 16 | mjames | 255 | /* Infinite loop */ |
| 256 | /* USER CODE BEGIN WHILE */ |
||
| 52 | mjames | 257 | while (1) |
| 258 | { |
||
| 7 | mjames | 259 | |
| 52 | mjames | 260 | /* while ignition is on, keep resetting power latch timer */ |
| 261 | if (HAL_GPIO_ReadPin (IGNITION_GPIO_Port, IGNITION_Pin) == GPIO_PIN_RESET) |
||
| 262 | { |
||
| 263 | Latch_Timer = HAL_GetTick () + IGNITION_OFF_TIMEOUT; |
||
| 264 | } |
||
| 265 | else |
||
| 266 | { |
||
| 267 | /* if the ignition has been off for a while, then turn off power */ |
||
| 268 | if (HAL_GetTick () > Latch_Timer) |
||
| 269 | { |
||
| 270 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, |
||
| 271 | GPIO_PIN_RESET); |
||
| 272 | } |
||
| 273 | } |
||
| 27 | mjames | 274 | |
| 52 | mjames | 275 | uint32_t timeout = 0; // |
| 27 | mjames | 276 | |
| 52 | mjames | 277 | uint32_t nextTick = HAL_GetTick () + LOGGER_INTERVAL; |
| 278 | uint8_t log = 0; |
||
| 279 | // PLX decoder protocols |
||
| 280 | char PLXPacket = 0; |
||
| 281 | for (i = 0; i < MAXRDG; i++) |
||
| 282 | { |
||
| 56 | mjames | 283 | Info[i].Max = 0; |
| 284 | Info[i].Min = 0xFFF; // 12 bit max value |
||
| 52 | mjames | 285 | } |
| 27 | mjames | 286 | |
| 52 | mjames | 287 | int PLXPtr = 0; |
| 24 | mjames | 288 | |
| 52 | mjames | 289 | while (1) |
| 290 | { |
||
| 53 | mjames | 291 | // Handle the bluetooth pairing / reset function by pressing both buttons. |
| 52 | mjames | 292 | if ((push_pos[0] == 1) && (push_pos[1] == 1)) |
| 293 | { |
||
| 294 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
||
| 295 | GPIO_PIN_RESET); |
||
| 296 | } |
||
| 297 | else |
||
| 298 | { |
||
| 299 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
||
| 300 | GPIO_PIN_SET); |
||
| 301 | } |
||
| 7 | mjames | 302 | |
| 52 | mjames | 303 | uint16_t cc = SerialCharsReceived (&uc1); |
| 304 | int chr; |
||
| 305 | if (cc == 0) |
||
| 306 | { |
||
| 307 | timeout++; |
||
| 308 | if (timeout % 1000 == 0) |
||
| 309 | { |
||
| 310 | const char msg[] = "Timeout\r\n"; |
||
| 53 | mjames | 311 | sendString (&uc3, msg, sizeof(msg)); |
| 38 | mjames | 312 | |
| 52 | mjames | 313 | } |
| 38 | mjames | 314 | |
| 52 | mjames | 315 | if (timeout > 60000) |
| 316 | { |
||
| 7 | mjames | 317 | |
| 52 | mjames | 318 | // do turn off screen |
| 319 | } |
||
| 27 | mjames | 320 | |
| 52 | mjames | 321 | } |
| 322 | for (chr = 0; chr < cc; chr++) |
||
| 323 | { |
||
| 324 | char c = GetCharSerial (&uc1); |
||
| 7 | mjames | 325 | |
| 52 | mjames | 326 | if (c == PLX_Start) // at any time if the start byte appears, reset the pointers |
| 327 | { |
||
| 328 | PLXPtr = 0; // reset the pointer |
||
| 329 | PLXPacket = 1; |
||
| 330 | timeout = 0; // Reset the timer |
||
| 331 | if (HAL_GetTick () > nextTick) |
||
| 332 | { |
||
| 333 | nextTick = HAL_GetTick () + LOGGER_INTERVAL; |
||
| 334 | log = 1; |
||
| 335 | } |
||
| 336 | else |
||
| 337 | log = 0; |
||
| 338 | } |
||
| 339 | else if (c == PLX_Stop) |
||
| 340 | { |
||
| 341 | if (PLXPacket) |
||
| 342 | { |
||
| 343 | // we can now decode the selected parameter |
||
| 344 | PLXItems = PLXPtr / sizeof(PLX_SensorInfo); // total |
||
| 345 | // saturate the rotary switch position |
||
| 9 | mjames | 346 | |
| 52 | mjames | 347 | int DataVal; |
| 348 | // process min/max |
||
| 349 | for (i = 0; i < PLXItems; i++) |
||
| 350 | { |
||
| 56 | mjames | 351 | Info[i].observation = ConvPLX (Data.Sensor[i].AddrH, |
| 352 | Data.Sensor[i].AddrL); |
||
| 353 | Info[i].instance = Data.Sensor[i].Instance; |
||
| 354 | Info[i].data = ConvPLX (Data.Sensor[i].ReadingH, |
||
| 355 | Data.Sensor[i].ReadingL); |
||
| 356 | if (Info[i].data > Info[i].Max) |
||
| 357 | { |
||
| 358 | Info[i].Max = Info[i].data; |
||
| 359 | } |
||
| 360 | if (Info[i].data < Info[i].Min) |
||
| 361 | { |
||
| 362 | Info[i].Min = Info[i].data; |
||
| 363 | } |
||
| 23 | mjames | 364 | |
| 56 | mjames | 365 | // Send item to BT |
| 366 | |||
| 52 | mjames | 367 | if (log) |
| 368 | { |
||
| 56 | mjames | 369 | |
| 52 | mjames | 370 | char outbuff[100]; |
| 30 | mjames | 371 | |
| 57 | mjames | 372 | int cnt = small_sprintf (outbuff, |
| 373 | "$PLLOG,%d,%d,%d", |
||
| 56 | mjames | 374 | Info[i].observation, |
| 375 | Info[i].instance, |
||
| 376 | Info[i].data); |
||
| 4 | mjames | 377 | |
| 53 | mjames | 378 | //checksum |
| 52 | mjames | 379 | int ck; |
| 380 | int sum = 0; |
||
| 53 | mjames | 381 | for (ck = 1; ck < cnt; ck++) |
| 52 | mjames | 382 | sum += outbuff[ck]; |
| 53 | mjames | 383 | cnt += small_sprintf (outbuff + cnt, "*%02X\n", |
| 384 | sum & 0xFF); |
||
| 385 | sendString (&uc3, outbuff, cnt); |
||
| 50 | mjames | 386 | |
| 52 | mjames | 387 | } |
| 388 | } |
||
| 50 | mjames | 389 | |
| 52 | mjames | 390 | // now to display the information |
| 391 | int suppress = DisplayCurrent (0, -1); |
||
| 392 | DisplayCurrent (1, suppress); |
||
| 393 | } |
||
| 394 | PLXPtr = 0; |
||
| 395 | PLXPacket = 0; |
||
| 396 | } |
||
| 397 | else if (c > PLX_Stop) // illegal char, restart reading |
||
| 398 | { |
||
| 399 | PLXPacket = 0; |
||
| 400 | PLXPtr = 0; |
||
| 401 | } |
||
| 402 | else if (PLXPacket && PLXPtr < sizeof(Data.Bytes)) |
||
| 403 | { |
||
| 404 | Data.Bytes[PLXPtr++] = c; |
||
| 405 | } |
||
| 406 | |||
| 407 | } |
||
| 408 | |||
| 409 | HAL_Delay (1); |
||
| 56 | mjames | 410 | |
| 57 | mjames | 411 | for (i = 0; i < MAX_DISPLAYS; i++) |
| 412 | { |
||
| 413 | if (dial_pos[i] > 1000) |
||
| 414 | dial_pos[i] = PLXItems - 1; |
||
| 415 | if (dial_pos[i] >= PLXItems) |
||
| 416 | dial_pos[i] = 0; |
||
| 56 | mjames | 417 | |
| 57 | mjames | 418 | int prevPos = contexts[i].knobPos; |
| 419 | if (contexts[i].knobPos >= 0) |
||
| 420 | contexts[i].knobPos = dial_pos[i]; |
||
| 421 | // if the dial position was changed then reset timer |
||
| 422 | if (prevPos != contexts[i].knobPos) |
||
| 423 | contexts[i].dial_timer = DialTimeout; |
||
| 424 | |||
| 425 | cc_check_nvram (i); |
||
| 426 | if (contexts[i].knobPos >= 0) |
||
| 427 | dial_pos[i] = contexts[i].knobPos; |
||
| 428 | } |
||
| 52 | mjames | 429 | } |
| 430 | /* USER CODE END WHILE */ |
||
| 431 | |||
| 432 | /* USER CODE BEGIN 3 */ |
||
| 433 | } |
||
| 16 | mjames | 434 | /* USER CODE END 3 */ |
| 2 | mjames | 435 | } |
| 436 | |||
| 50 | mjames | 437 | /** |
| 52 | mjames | 438 | * @brief System Clock Configuration |
| 439 | * @retval None |
||
| 440 | */ |
||
| 441 | void |
||
| 442 | SystemClock_Config (void) |
||
| 5 | mjames | 443 | { |
| 52 | mjames | 444 | RCC_OscInitTypeDef RCC_OscInitStruct = |
| 445 | { 0 }; |
||
| 446 | RCC_ClkInitTypeDef RCC_ClkInitStruct = |
||
| 447 | { 0 }; |
||
| 2 | mjames | 448 | |
| 50 | mjames | 449 | /** Configure the main internal regulator output voltage |
| 52 | mjames | 450 | */ |
| 29 | mjames | 451 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
| 50 | mjames | 452 | /** Initializes the RCC Oscillators according to the specified parameters |
| 52 | mjames | 453 | * in the RCC_OscInitTypeDef structure. |
| 454 | */ |
||
| 44 | mjames | 455 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
| 456 | RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; |
||
| 16 | mjames | 457 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 44 | mjames | 458 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
| 459 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
||
| 29 | mjames | 460 | RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; |
| 52 | mjames | 461 | if (HAL_RCC_OscConfig (&RCC_OscInitStruct) != HAL_OK) |
| 462 | { |
||
| 463 | Error_Handler (); |
||
| 464 | } |
||
| 50 | mjames | 465 | /** Initializes the CPU, AHB and APB buses clocks |
| 52 | mjames | 466 | */ |
| 467 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
||
| 468 | | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
||
| 16 | mjames | 469 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 470 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
||
| 29 | mjames | 471 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
| 16 | mjames | 472 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
| 50 | mjames | 473 | |
| 52 | mjames | 474 | if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) |
| 475 | { |
||
| 476 | Error_Handler (); |
||
| 477 | } |
||
| 2 | mjames | 478 | } |
| 479 | |||
| 50 | mjames | 480 | /** |
| 52 | mjames | 481 | * @brief SPI1 Initialization Function |
| 482 | * @param None |
||
| 483 | * @retval None |
||
| 484 | */ |
||
| 485 | static void |
||
| 486 | MX_SPI1_Init (void) |
||
| 5 | mjames | 487 | { |
| 2 | mjames | 488 | |
| 50 | mjames | 489 | /* USER CODE BEGIN SPI1_Init 0 */ |
| 490 | |||
| 491 | /* USER CODE END SPI1_Init 0 */ |
||
| 492 | |||
| 493 | /* USER CODE BEGIN SPI1_Init 1 */ |
||
| 494 | |||
| 495 | /* USER CODE END SPI1_Init 1 */ |
||
| 496 | /* SPI1 parameter configuration*/ |
||
| 16 | mjames | 497 | hspi1.Instance = SPI1; |
| 498 | hspi1.Init.Mode = SPI_MODE_MASTER; |
||
| 499 | hspi1.Init.Direction = SPI_DIRECTION_1LINE; |
||
| 500 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
||
| 501 | hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH; |
||
| 502 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
||
| 503 | hspi1.Init.NSS = SPI_NSS_SOFT; |
||
| 50 | mjames | 504 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; |
| 16 | mjames | 505 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; |
| 506 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
||
| 507 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
||
| 508 | hspi1.Init.CRCPolynomial = 10; |
||
| 52 | mjames | 509 | if (HAL_SPI_Init (&hspi1) != HAL_OK) |
| 510 | { |
||
| 511 | Error_Handler (); |
||
| 512 | } |
||
| 50 | mjames | 513 | /* USER CODE BEGIN SPI1_Init 2 */ |
| 2 | mjames | 514 | |
| 50 | mjames | 515 | /* USER CODE END SPI1_Init 2 */ |
| 516 | |||
| 2 | mjames | 517 | } |
| 518 | |||
| 50 | mjames | 519 | /** |
| 52 | mjames | 520 | * @brief TIM2 Initialization Function |
| 521 | * @param None |
||
| 522 | * @retval None |
||
| 523 | */ |
||
| 524 | static void |
||
| 525 | MX_TIM2_Init (void) |
||
| 50 | mjames | 526 | { |
| 527 | |||
| 528 | /* USER CODE BEGIN TIM2_Init 0 */ |
||
| 529 | |||
| 530 | /* USER CODE END TIM2_Init 0 */ |
||
| 531 | |||
| 52 | mjames | 532 | TIM_ClockConfigTypeDef sClockSourceConfig = |
| 533 | { 0 }; |
||
| 534 | TIM_MasterConfigTypeDef sMasterConfig = |
||
| 535 | { 0 }; |
||
| 50 | mjames | 536 | |
| 537 | /* USER CODE BEGIN TIM2_Init 1 */ |
||
| 538 | |||
| 539 | /* USER CODE END TIM2_Init 1 */ |
||
| 540 | htim2.Instance = TIM2; |
||
| 541 | htim2.Init.Prescaler = 0; |
||
| 542 | htim2.Init.CounterMode = TIM_COUNTERMODE_UP; |
||
| 543 | htim2.Init.Period = 65535; |
||
| 544 | htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
||
| 545 | htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
||
| 52 | mjames | 546 | if (HAL_TIM_Base_Init (&htim2) != HAL_OK) |
| 547 | { |
||
| 548 | Error_Handler (); |
||
| 549 | } |
||
| 50 | mjames | 550 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; |
| 52 | mjames | 551 | if (HAL_TIM_ConfigClockSource (&htim2, &sClockSourceConfig) != HAL_OK) |
| 552 | { |
||
| 553 | Error_Handler (); |
||
| 554 | } |
||
| 50 | mjames | 555 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; |
| 556 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
||
| 52 | mjames | 557 | if (HAL_TIMEx_MasterConfigSynchronization (&htim2, &sMasterConfig) != HAL_OK) |
| 558 | { |
||
| 559 | Error_Handler (); |
||
| 560 | } |
||
| 50 | mjames | 561 | /* USER CODE BEGIN TIM2_Init 2 */ |
| 562 | |||
| 563 | /* USER CODE END TIM2_Init 2 */ |
||
| 564 | |||
| 565 | } |
||
| 566 | |||
| 567 | /** |
||
| 52 | mjames | 568 | * @brief TIM3 Initialization Function |
| 569 | * @param None |
||
| 570 | * @retval None |
||
| 571 | */ |
||
| 572 | static void |
||
| 573 | MX_TIM3_Init (void) |
||
| 44 | mjames | 574 | { |
| 575 | |||
| 50 | mjames | 576 | /* USER CODE BEGIN TIM3_Init 0 */ |
| 44 | mjames | 577 | |
| 50 | mjames | 578 | /* USER CODE END TIM3_Init 0 */ |
| 579 | |||
| 52 | mjames | 580 | TIM_Encoder_InitTypeDef sConfig = |
| 581 | { 0 }; |
||
| 582 | TIM_MasterConfigTypeDef sMasterConfig = |
||
| 583 | { 0 }; |
||
| 50 | mjames | 584 | |
| 585 | /* USER CODE BEGIN TIM3_Init 1 */ |
||
| 586 | |||
| 587 | /* USER CODE END TIM3_Init 1 */ |
||
| 44 | mjames | 588 | htim3.Instance = TIM3; |
| 589 | htim3.Init.Prescaler = 0; |
||
| 590 | htim3.Init.CounterMode = TIM_COUNTERMODE_UP; |
||
| 50 | mjames | 591 | htim3.Init.Period = 65535; |
| 592 | htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
||
| 593 | htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
||
| 44 | mjames | 594 | sConfig.EncoderMode = TIM_ENCODERMODE_TI1; |
| 50 | mjames | 595 | sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; |
| 44 | mjames | 596 | sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; |
| 597 | sConfig.IC1Prescaler = TIM_ICPSC_DIV1; |
||
| 598 | sConfig.IC1Filter = 15; |
||
| 50 | mjames | 599 | sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; |
| 44 | mjames | 600 | sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; |
| 601 | sConfig.IC2Prescaler = TIM_ICPSC_DIV1; |
||
| 602 | sConfig.IC2Filter = 15; |
||
| 52 | mjames | 603 | if (HAL_TIM_Encoder_Init (&htim3, &sConfig) != HAL_OK) |
| 604 | { |
||
| 605 | Error_Handler (); |
||
| 606 | } |
||
| 44 | mjames | 607 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; |
| 608 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
||
| 52 | mjames | 609 | if (HAL_TIMEx_MasterConfigSynchronization (&htim3, &sMasterConfig) != HAL_OK) |
| 610 | { |
||
| 611 | Error_Handler (); |
||
| 612 | } |
||
| 50 | mjames | 613 | /* USER CODE BEGIN TIM3_Init 2 */ |
| 44 | mjames | 614 | |
| 50 | mjames | 615 | /* USER CODE END TIM3_Init 2 */ |
| 616 | |||
| 44 | mjames | 617 | } |
| 618 | |||
| 50 | mjames | 619 | /** |
| 52 | mjames | 620 | * @brief TIM9 Initialization Function |
| 621 | * @param None |
||
| 622 | * @retval None |
||
| 623 | */ |
||
| 624 | static void |
||
| 625 | MX_TIM9_Init (void) |
||
| 44 | mjames | 626 | { |
| 627 | |||
| 50 | mjames | 628 | /* USER CODE BEGIN TIM9_Init 0 */ |
| 44 | mjames | 629 | |
| 50 | mjames | 630 | /* USER CODE END TIM9_Init 0 */ |
| 631 | |||
| 52 | mjames | 632 | TIM_Encoder_InitTypeDef sConfig = |
| 633 | { 0 }; |
||
| 634 | TIM_MasterConfigTypeDef sMasterConfig = |
||
| 635 | { 0 }; |
||
| 50 | mjames | 636 | |
| 637 | /* USER CODE BEGIN TIM9_Init 1 */ |
||
| 638 | |||
| 639 | /* USER CODE END TIM9_Init 1 */ |
||
| 44 | mjames | 640 | htim9.Instance = TIM9; |
| 641 | htim9.Init.Prescaler = 0; |
||
| 642 | htim9.Init.CounterMode = TIM_COUNTERMODE_UP; |
||
| 50 | mjames | 643 | htim9.Init.Period = 65535; |
| 644 | htim9.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
||
| 645 | htim9.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
||
| 44 | mjames | 646 | sConfig.EncoderMode = TIM_ENCODERMODE_TI1; |
| 50 | mjames | 647 | sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; |
| 44 | mjames | 648 | sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; |
| 649 | sConfig.IC1Prescaler = TIM_ICPSC_DIV1; |
||
| 650 | sConfig.IC1Filter = 15; |
||
| 50 | mjames | 651 | sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; |
| 44 | mjames | 652 | sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; |
| 653 | sConfig.IC2Prescaler = TIM_ICPSC_DIV1; |
||
| 50 | mjames | 654 | sConfig.IC2Filter = 0; |
| 52 | mjames | 655 | if (HAL_TIM_Encoder_Init (&htim9, &sConfig) != HAL_OK) |
| 656 | { |
||
| 657 | Error_Handler (); |
||
| 658 | } |
||
| 44 | mjames | 659 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; |
| 660 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
||
| 52 | mjames | 661 | if (HAL_TIMEx_MasterConfigSynchronization (&htim9, &sMasterConfig) != HAL_OK) |
| 662 | { |
||
| 663 | Error_Handler (); |
||
| 664 | } |
||
| 50 | mjames | 665 | /* USER CODE BEGIN TIM9_Init 2 */ |
| 44 | mjames | 666 | |
| 50 | mjames | 667 | /* USER CODE END TIM9_Init 2 */ |
| 668 | |||
| 44 | mjames | 669 | } |
| 670 | |||
| 50 | mjames | 671 | /** |
| 52 | mjames | 672 | * @brief USART1 Initialization Function |
| 673 | * @param None |
||
| 674 | * @retval None |
||
| 675 | */ |
||
| 676 | static void |
||
| 677 | MX_USART1_UART_Init (void) |
||
| 5 | mjames | 678 | { |
| 3 | mjames | 679 | |
| 50 | mjames | 680 | /* USER CODE BEGIN USART1_Init 0 */ |
| 681 | |||
| 682 | /* USER CODE END USART1_Init 0 */ |
||
| 683 | |||
| 684 | /* USER CODE BEGIN USART1_Init 1 */ |
||
| 685 | |||
| 686 | /* USER CODE END USART1_Init 1 */ |
||
| 16 | mjames | 687 | huart1.Instance = USART1; |
| 688 | huart1.Init.BaudRate = 19200; |
||
| 689 | huart1.Init.WordLength = UART_WORDLENGTH_8B; |
||
| 44 | mjames | 690 | huart1.Init.StopBits = UART_STOPBITS_1; |
| 16 | mjames | 691 | huart1.Init.Parity = UART_PARITY_NONE; |
| 692 | huart1.Init.Mode = UART_MODE_TX_RX; |
||
| 693 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||
| 694 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; |
||
| 52 | mjames | 695 | if (HAL_UART_Init (&huart1) != HAL_OK) |
| 696 | { |
||
| 697 | Error_Handler (); |
||
| 698 | } |
||
| 50 | mjames | 699 | /* USER CODE BEGIN USART1_Init 2 */ |
| 3 | mjames | 700 | |
| 50 | mjames | 701 | /* USER CODE END USART1_Init 2 */ |
| 702 | |||
| 3 | mjames | 703 | } |
| 704 | |||
| 50 | mjames | 705 | /** |
| 52 | mjames | 706 | * @brief USART2 Initialization Function |
| 707 | * @param None |
||
| 708 | * @retval None |
||
| 709 | */ |
||
| 710 | static void |
||
| 711 | MX_USART2_UART_Init (void) |
||
| 5 | mjames | 712 | { |
| 2 | mjames | 713 | |
| 50 | mjames | 714 | /* USER CODE BEGIN USART2_Init 0 */ |
| 715 | |||
| 716 | /* USER CODE END USART2_Init 0 */ |
||
| 717 | |||
| 718 | /* USER CODE BEGIN USART2_Init 1 */ |
||
| 719 | |||
| 720 | /* USER CODE END USART2_Init 1 */ |
||
| 16 | mjames | 721 | huart2.Instance = USART2; |
| 722 | huart2.Init.BaudRate = 115200; |
||
| 723 | huart2.Init.WordLength = UART_WORDLENGTH_8B; |
||
| 724 | huart2.Init.StopBits = UART_STOPBITS_1; |
||
| 725 | huart2.Init.Parity = UART_PARITY_NONE; |
||
| 726 | huart2.Init.Mode = UART_MODE_TX_RX; |
||
| 727 | huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||
| 728 | huart2.Init.OverSampling = UART_OVERSAMPLING_16; |
||
| 52 | mjames | 729 | if (HAL_UART_Init (&huart2) != HAL_OK) |
| 730 | { |
||
| 731 | Error_Handler (); |
||
| 732 | } |
||
| 50 | mjames | 733 | /* USER CODE BEGIN USART2_Init 2 */ |
| 2 | mjames | 734 | |
| 50 | mjames | 735 | /* USER CODE END USART2_Init 2 */ |
| 736 | |||
| 2 | mjames | 737 | } |
| 738 | |||
| 50 | mjames | 739 | /** |
| 52 | mjames | 740 | * @brief USART3 Initialization Function |
| 741 | * @param None |
||
| 742 | * @retval None |
||
| 743 | */ |
||
| 744 | static void |
||
| 745 | MX_USART3_UART_Init (void) |
||
| 23 | mjames | 746 | { |
| 747 | |||
| 50 | mjames | 748 | /* USER CODE BEGIN USART3_Init 0 */ |
| 749 | |||
| 750 | /* USER CODE END USART3_Init 0 */ |
||
| 751 | |||
| 752 | /* USER CODE BEGIN USART3_Init 1 */ |
||
| 753 | |||
| 754 | /* USER CODE END USART3_Init 1 */ |
||
| 23 | mjames | 755 | huart3.Instance = USART3; |
| 52 | mjames | 756 | huart3.Init.BaudRate = 9600; |
| 23 | mjames | 757 | huart3.Init.WordLength = UART_WORDLENGTH_8B; |
| 50 | mjames | 758 | huart3.Init.StopBits = UART_STOPBITS_1; |
| 44 | mjames | 759 | huart3.Init.Parity = UART_PARITY_NONE; |
| 23 | mjames | 760 | huart3.Init.Mode = UART_MODE_TX_RX; |
| 761 | huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||
| 762 | huart3.Init.OverSampling = UART_OVERSAMPLING_16; |
||
| 52 | mjames | 763 | if (HAL_UART_Init (&huart3) != HAL_OK) |
| 764 | { |
||
| 765 | Error_Handler (); |
||
| 766 | } |
||
| 50 | mjames | 767 | /* USER CODE BEGIN USART3_Init 2 */ |
| 23 | mjames | 768 | |
| 50 | mjames | 769 | /* USER CODE END USART3_Init 2 */ |
| 770 | |||
| 23 | mjames | 771 | } |
| 772 | |||
| 50 | mjames | 773 | /** |
| 52 | mjames | 774 | * @brief GPIO Initialization Function |
| 775 | * @param None |
||
| 776 | * @retval None |
||
| 777 | */ |
||
| 778 | static void |
||
| 779 | MX_GPIO_Init (void) |
||
| 5 | mjames | 780 | { |
| 52 | mjames | 781 | GPIO_InitTypeDef GPIO_InitStruct = |
| 782 | { 0 }; |
||
| 2 | mjames | 783 | |
| 16 | mjames | 784 | /* GPIO Ports Clock Enable */ |
| 29 | mjames | 785 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
| 786 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
||
| 787 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
||
| 788 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
||
| 2 | mjames | 789 | |
| 16 | mjames | 790 | /*Configure GPIO pin Output Level */ |
| 52 | mjames | 791 | HAL_GPIO_WritePin (SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
| 2 | mjames | 792 | |
| 16 | mjames | 793 | /*Configure GPIO pin Output Level */ |
| 52 | mjames | 794 | HAL_GPIO_WritePin (GPIOA, SPI_CD_Pin | BT_BUTTON_Pin, GPIO_PIN_RESET); |
| 2 | mjames | 795 | |
| 50 | mjames | 796 | /*Configure GPIO pin Output Level */ |
| 52 | mjames | 797 | HAL_GPIO_WritePin (GPIOC, SPI_RESET_Pin | POWER_LATCH_Pin | USB_PWR_Pin, |
| 798 | GPIO_PIN_RESET); |
||
| 50 | mjames | 799 | |
| 800 | /*Configure GPIO pin Output Level */ |
||
| 52 | mjames | 801 | HAL_GPIO_WritePin (SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
| 50 | mjames | 802 | |
| 803 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
||
| 52 | mjames | 804 | GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_CD_Pin; |
| 16 | mjames | 805 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 29 | mjames | 806 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 16 | mjames | 807 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| 52 | mjames | 808 | HAL_GPIO_Init (GPIOA, &GPIO_InitStruct); |
| 2 | mjames | 809 | |
| 24 | mjames | 810 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
| 52 | mjames | 811 | GPIO_InitStruct.Pin = SPI_RESET_Pin | SPI_NSS2_Pin | POWER_LATCH_Pin |
| 812 | | USB_PWR_Pin; |
||
| 16 | mjames | 813 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 29 | mjames | 814 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 16 | mjames | 815 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| 52 | mjames | 816 | HAL_GPIO_Init (GPIOC, &GPIO_InitStruct); |
| 2 | mjames | 817 | |
| 44 | mjames | 818 | /*Configure GPIO pins : SW1_PUSH_Pin SW2_PUSH_Pin */ |
| 52 | mjames | 819 | GPIO_InitStruct.Pin = SW1_PUSH_Pin | SW2_PUSH_Pin; |
| 16 | mjames | 820 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
| 32 | mjames | 821 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 52 | mjames | 822 | HAL_GPIO_Init (GPIOB, &GPIO_InitStruct); |
| 5 | mjames | 823 | |
| 32 | mjames | 824 | /*Configure GPIO pin : IGNITION_Pin */ |
| 825 | GPIO_InitStruct.Pin = IGNITION_Pin; |
||
| 826 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
||
| 827 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 52 | mjames | 828 | HAL_GPIO_Init (IGNITION_GPIO_Port, &GPIO_InitStruct); |
| 32 | mjames | 829 | |
| 37 | mjames | 830 | /*Configure GPIO pin : BT_BUTTON_Pin */ |
| 831 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
||
| 832 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
||
| 833 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 834 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 52 | mjames | 835 | HAL_GPIO_Init (BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
| 37 | mjames | 836 | |
| 2 | mjames | 837 | } |
| 838 | |||
| 839 | /* USER CODE BEGIN 4 */ |
||
| 840 | |||
| 841 | /* USER CODE END 4 */ |
||
| 842 | |||
| 5 | mjames | 843 | /** |
| 52 | mjames | 844 | * @brief This function is executed in case of error occurrence. |
| 845 | * @retval None |
||
| 846 | */ |
||
| 847 | void |
||
| 848 | Error_Handler (void) |
||
| 5 | mjames | 849 | { |
| 50 | mjames | 850 | /* USER CODE BEGIN Error_Handler_Debug */ |
| 851 | /* User can add his own implementation to report the HAL error return state */ |
||
| 852 | |||
| 853 | /* USER CODE END Error_Handler_Debug */ |
||
| 30 | mjames | 854 | } |
| 5 | mjames | 855 | |
| 50 | mjames | 856 | #ifdef USE_FULL_ASSERT |
| 2 | mjames | 857 | /** |
| 50 | mjames | 858 | * @brief Reports the name of the source file and the source line number |
| 859 | * where the assert_param error has occurred. |
||
| 860 | * @param file: pointer to the source file name |
||
| 861 | * @param line: assert_param error line source number |
||
| 862 | * @retval None |
||
| 863 | */ |
||
| 864 | void assert_failed(uint8_t *file, uint32_t line) |
||
| 29 | mjames | 865 | { |
| 866 | /* USER CODE BEGIN 6 */ |
||
| 50 | mjames | 867 | /* User can add his own implementation to report the file name and line number, |
| 868 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
||
| 29 | mjames | 869 | /* USER CODE END 6 */ |
| 870 | } |
||
| 50 | mjames | 871 | #endif /* USE_FULL_ASSERT */ |
| 2 | mjames | 872 | |
| 873 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |