Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions | Variables
main.c File Reference

: Main program body More...

#include "main.h"
#include "../Inc/Files/can1_dbc.h"
#include "../Inc/Systems/Comms/Can/Can.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

void SystemClock_Config (void)
 System Clock Configuration. More...
 
static void MX_GPIO_Init (void)
 GPIO Initialization Function. More...
 
static void MX_DMA_Init (void)
 
static void MX_TIM1_Init (void)
 TIM1 Initialization Function. More...
 
static void MX_ADC1_Init (void)
 ADC1 Initialization Function. More...
 
static void MX_ADC2_Init (void)
 ADC2 Initialization Function. More...
 
static void MX_ADC3_Init (void)
 ADC3 Initialization Function. More...
 
static void MX_CAN1_Init (void)
 CAN1 Initialization Function. More...
 
static void MX_CAN2_Init (void)
 CAN2 Initialization Function. More...
 
static void MX_USART3_UART_Init (void)
 USART3 Initialization Function. More...
 
static void MX_I2C1_Init (void)
 I2C1 Initialization Function. More...
 
static void MX_I2C2_Init (void)
 I2C2 Initialization Function. More...
 
static void MX_I2C4_Init (void)
 I2C4 Initialization Function. More...
 
static void MX_SPI3_Init (void)
 SPI3 Initialization Function. More...
 
static void MX_SPI4_Init (void)
 SPI4 Initialization Function. More...
 
static void MX_SPI5_Init (void)
 SPI5 Initialization Function. More...
 
int main (void)
 The application entry point. More...
 
int _write (int file, char *data, int len)
 
void Error_Handler (void)
 This function is executed in case of error occurrence. More...
 

Variables

ADC_HandleTypeDef hadc1
 
ADC_HandleTypeDef hadc2
 
ADC_HandleTypeDef hadc3
 
DMA_HandleTypeDef hdma_adc1
 
DMA_HandleTypeDef hdma_adc2
 
DMA_HandleTypeDef hdma_adc3
 
CAN_HandleTypeDef hcan1
 
CAN_HandleTypeDef hcan2
 
I2C_HandleTypeDef hi2c1
 
I2C_HandleTypeDef hi2c2
 
I2C_HandleTypeDef hi2c4
 
SPI_HandleTypeDef hspi3
 
SPI_HandleTypeDef hspi4
 
SPI_HandleTypeDef hspi5
 
TIM_HandleTypeDef htim1
 
UART_HandleTypeDef huart3
 

Detailed Description

: Main program body

Attention

Copyright (c) 2024 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file main.c.

Function Documentation

◆ _write()

int _write ( int  file,
char *  data,
int  len 
)

Definition at line 1162 of file main.c.

1163{
1164 // Transmit data using USART3
1165 HAL_UART_Transmit(&huart3, (uint8_t *)data, len, HAL_MAX_DELAY);
1166 return len;
1167
1168#endif // <--- DONT DELETE THIS, IT IS LINKED TO LAST LINE IN MAIN FUNCTION TO ALLOW SIL BUILDS
1169
1170}
UART_HandleTypeDef huart3
Definition: main.c:64

◆ Error_Handler()

void Error_Handler ( void  )

This function is executed in case of error occurrence.

Return values
None

Definition at line 1178 of file main.c.

1179{
1180 /* USER CODE BEGIN Error_Handler_Debug */
1181 /* User can add his own implementation to report the HAL error return state */
1182
1183 #ifndef TEST_MODE
1184 __disable_irq();
1185 #endif
1186
1187 while (1)
1188 {
1189 }
1190 /* USER CODE END Error_Handler_Debug */
1191}
Here is the caller graph for this function:

◆ main()

int main ( void  )

The application entry point.

Return values
int

Definition at line 99 of file main.c.

100{
101
102 /* USER CODE BEGIN 1 */
103
104 #ifndef TEST_MODE
105
106 /* USER CODE END 1 */
107
108 /* MCU Configuration--------------------------------------------------------*/
109
110 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
111 HAL_Init();
112
113 /* USER CODE BEGIN Init */
114
115 /* USER CODE END Init */
116
117 /* Configure the system clock */
119
120 /* USER CODE BEGIN SysInit */
121
122 /* USER CODE END SysInit */
123
124 /* Initialize all configured peripherals */
125 MX_GPIO_Init();
126 MX_DMA_Init();
127 MX_TIM1_Init();
128 MX_ADC1_Init();
129 MX_ADC2_Init();
130 MX_ADC3_Init();
131 MX_CAN1_Init();
132 MX_CAN2_Init();
134 MX_I2C1_Init();
135 MX_I2C2_Init();
136 MX_I2C4_Init();
137 MX_SPI3_Init();
138 MX_SPI4_Init();
139 MX_SPI5_Init();
140 /* USER CODE BEGIN 2 */
141
142 #endif
143
144 // Clear the screen
145 printf("\033[2J\033[1;1H");
146 printf("Welcome to VCU!!!\r\n");
147 if (init_CANBus(CAN_1) != 0) {
148 printf("CAN1 init failed\r\n");
149 }
150
151// printf("Load DBC status: %d\r\n", load_dbc_file(CAN_1, Core_Inc_Files_can1_dbc));
152
153 // Add a message to the CAN message list
154 CAN_Signal_Template signals[8] = {
155 { .name = "Char 1", .start_bit = 0, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
156 { .name = "Char 2", .start_bit = 8, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
157 { .name = "Char 3", .start_bit = 16, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
158 { .name = "Char 4", .start_bit = 24, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
159 { .name = "Char 5", .start_bit = 32, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
160 { .name = "Char 6", .start_bit = 40, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
161 { .name = "Char 7", .start_bit = 48, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" },
162 { .name = "Char 8", .start_bit = 56, .length = 8, .endian = 0, .isSigned = 0, .scale = 1, .offset = 0, .min = 0, .max = 255, .unit = "unit", .reciever = "reciever" }
163 };
164
165 add_message_lop(CAN_1, 0x123, 8, 0, 0, "Message 1", "AD3", 8, signals);
166
167
168 add_message_lop(CAN_1, 0x124, 8, 0, 0, "Message 2", "VCU", 8, signals);
169
170 // Print the CAN message list
172
173 uint8_t txdata[8] = {0, 1, 2, 3, 4, 5, 6, 7};
174
175
176 /* USER CODE END 2 */
177
178 /* Infinite loop */
179 /* USER CODE BEGIN WHILE */
180 while (1)
181 {
182 send_CAN_message(CAN_1, CAN_2A, 124, txdata, 8);
183
184 #ifndef TEST_MODE
185 HAL_Delay(1000);
186 #endif
187
188 /* USER CODE END WHILE */
189
190 /* USER CODE BEGIN 3 */
191 }
192 /* USER CODE END 3 */
193
194 #ifndef TEST_MODE
195}
int init_CANBus(CANBus bus)
Initializes the CANBus struct.
Definition: Can.c:17
@ CAN_1
Definition: Can.h:99
int add_message_lop(CANBus bus, int id, int dlc, int ide, int rtr, const char *name, const char *sender, int signal_count, CAN_Signal_Template *signals)
Adds a message to the CAN message list by passing in the individual message parameters hence "LOP" (L...
Definition: Can.c:55
int send_CAN_message(CANBus bus, CANProtocol protocol, uint32_t id, uint8_t *data, uint8_t len)
Sends a CAN message.
Definition: Can.c:79
@ CAN_2A
Definition: Can.h:105
void print_CAN_Messages_Lists()
Prints the CAN message list.
Definition: Can.c:190
static void MX_USART3_UART_Init(void)
USART3 Initialization Function.
Definition: main.c:961
static void MX_TIM1_Init(void)
TIM1 Initialization Function.
Definition: main.c:914
static void MX_CAN1_Init(void)
CAN1 Initialization Function.
Definition: main.c:530
static void MX_I2C1_Init(void)
I2C1 Initialization Function.
Definition: main.c:650
static void MX_ADC2_Init(void)
ADC2 Initialization Function.
Definition: main.c:367
static void MX_DMA_Init(void)
Definition: main.c:994
void SystemClock_Config(void)
System Clock Configuration.
Definition: main.c:201
static void MX_CAN2_Init(void)
CAN2 Initialization Function.
Definition: main.c:590
static void MX_ADC1_Init(void)
ADC1 Initialization Function.
Definition: main.c:259
static void MX_SPI5_Init(void)
SPI5 Initialization Function.
Definition: main.c:874
static void MX_SPI3_Init(void)
SPI3 Initialization Function.
Definition: main.c:794
static void MX_ADC3_Init(void)
ADC3 Initialization Function.
Definition: main.c:453
static void MX_SPI4_Init(void)
SPI4 Initialization Function.
Definition: main.c:834
static void MX_GPIO_Init(void)
GPIO Initialization Function.
Definition: main.c:1018
static void MX_I2C4_Init(void)
I2C4 Initialization Function.
Definition: main.c:746
static void MX_I2C2_Init(void)
I2C2 Initialization Function.
Definition: main.c:698
char name[MAX_SIGNAL_NAME_LENGTH]
Definition: Can.h:20
Here is the call graph for this function:

◆ MX_ADC1_Init()

static void MX_ADC1_Init ( void  )
static

ADC1 Initialization Function.

Parameters
None
Return values
None

Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)

Configure the ADC multi-mode

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Definition at line 259 of file main.c.

260{
261
262 /* USER CODE BEGIN ADC1_Init 0 */
263
264 /* USER CODE END ADC1_Init 0 */
265
266 ADC_MultiModeTypeDef multimode = {0};
267 ADC_ChannelConfTypeDef sConfig = {0};
268
269 /* USER CODE BEGIN ADC1_Init 1 */
270
271 /* USER CODE END ADC1_Init 1 */
272
275 hadc1.Instance = ADC1;
276 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
277 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
278 hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
279 hadc1.Init.ContinuousConvMode = ENABLE;
280 hadc1.Init.DiscontinuousConvMode = DISABLE;
281 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
282 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
283 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
284 hadc1.Init.NbrOfConversion = 6;
285 hadc1.Init.DMAContinuousRequests = ENABLE;
286 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
287 if (HAL_ADC_Init(&hadc1) != HAL_OK)
288 {
290 }
291
294 multimode.Mode = ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT;
295 multimode.DMAAccessMode = ADC_DMAACCESSMODE_1;
296 multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_5CYCLES;
297 if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
298 {
300 }
301
304 sConfig.Channel = ADC_CHANNEL_0;
305 sConfig.Rank = ADC_REGULAR_RANK_1;
306 sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
307 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
308 {
310 }
311
314 sConfig.Channel = ADC_CHANNEL_1;
315 sConfig.Rank = ADC_REGULAR_RANK_2;
316 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
317 {
319 }
320
323 sConfig.Channel = ADC_CHANNEL_2;
324 sConfig.Rank = ADC_REGULAR_RANK_3;
325 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
326 {
328 }
329
332 sConfig.Channel = ADC_CHANNEL_3;
333 sConfig.Rank = ADC_REGULAR_RANK_4;
334 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
335 {
337 }
338
341 sConfig.Channel = ADC_CHANNEL_4;
342 sConfig.Rank = ADC_REGULAR_RANK_5;
343 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
344 {
346 }
347
350 sConfig.Channel = ADC_CHANNEL_5;
351 sConfig.Rank = ADC_REGULAR_RANK_6;
352 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
353 {
355 }
356 /* USER CODE BEGIN ADC1_Init 2 */
357
358 /* USER CODE END ADC1_Init 2 */
359
360}
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition: main.c:1178
ADC_HandleTypeDef hadc1
Definition: main.c:44
#define ENABLE(item_)
Definition: Updateable.h:10
#define DISABLE(item_)
Definition: Updateable.h:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_ADC2_Init()

static void MX_ADC2_Init ( void  )
static

ADC2 Initialization Function.

Parameters
None
Return values
None

Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Definition at line 367 of file main.c.

368{
369
370 /* USER CODE BEGIN ADC2_Init 0 */
371
372 /* USER CODE END ADC2_Init 0 */
373
374 ADC_ChannelConfTypeDef sConfig = {0};
375
376 /* USER CODE BEGIN ADC2_Init 1 */
377
378 /* USER CODE END ADC2_Init 1 */
379
382 hadc2.Instance = ADC2;
383 hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
384 hadc2.Init.Resolution = ADC_RESOLUTION_12B;
385 hadc2.Init.ScanConvMode = ADC_SCAN_ENABLE;
386 hadc2.Init.ContinuousConvMode = ENABLE;
387 hadc2.Init.DiscontinuousConvMode = DISABLE;
388 hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
389 hadc2.Init.NbrOfConversion = 5;
390 hadc2.Init.DMAContinuousRequests = ENABLE;
391 hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
392 if (HAL_ADC_Init(&hadc2) != HAL_OK)
393 {
395 }
396
399 sConfig.Channel = ADC_CHANNEL_6;
400 sConfig.Rank = ADC_REGULAR_RANK_1;
401 sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
402 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
403 {
405 }
406
409 sConfig.Channel = ADC_CHANNEL_7;
410 sConfig.Rank = ADC_REGULAR_RANK_2;
411 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
412 {
414 }
415
418 sConfig.Channel = ADC_CHANNEL_8;
419 sConfig.Rank = ADC_REGULAR_RANK_3;
420 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
421 {
423 }
424
427 sConfig.Channel = ADC_CHANNEL_14;
428 sConfig.Rank = ADC_REGULAR_RANK_4;
429 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
430 {
432 }
433
436 sConfig.Channel = ADC_CHANNEL_15;
437 sConfig.Rank = ADC_REGULAR_RANK_5;
438 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
439 {
441 }
442 /* USER CODE BEGIN ADC2_Init 2 */
443
444 /* USER CODE END ADC2_Init 2 */
445
446}
ADC_HandleTypeDef hadc2
Definition: main.c:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_ADC3_Init()

static void MX_ADC3_Init ( void  )
static

ADC3 Initialization Function.

Parameters
None
Return values
None

Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

Definition at line 453 of file main.c.

454{
455
456 /* USER CODE BEGIN ADC3_Init 0 */
457
458 /* USER CODE END ADC3_Init 0 */
459
460 ADC_ChannelConfTypeDef sConfig = {0};
461
462 /* USER CODE BEGIN ADC3_Init 1 */
463
464 /* USER CODE END ADC3_Init 1 */
465
468 hadc3.Instance = ADC3;
469 hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
470 hadc3.Init.Resolution = ADC_RESOLUTION_12B;
471 hadc3.Init.ScanConvMode = ADC_SCAN_ENABLE;
472 hadc3.Init.ContinuousConvMode = ENABLE;
473 hadc3.Init.DiscontinuousConvMode = DISABLE;
474 hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
475 hadc3.Init.NbrOfConversion = 4;
476 hadc3.Init.DMAContinuousRequests = ENABLE;
477 hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
478 if (HAL_ADC_Init(&hadc3) != HAL_OK)
479 {
481 }
482
485 sConfig.Channel = ADC_CHANNEL_10;
486 sConfig.Rank = ADC_REGULAR_RANK_1;
487 sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
488 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
489 {
491 }
492
495 sConfig.Channel = ADC_CHANNEL_11;
496 sConfig.Rank = ADC_REGULAR_RANK_2;
497 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
498 {
500 }
501
504 sConfig.Channel = ADC_CHANNEL_12;
505 sConfig.Rank = ADC_REGULAR_RANK_3;
506 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
507 {
509 }
510
513 sConfig.Channel = ADC_CHANNEL_13;
514 sConfig.Rank = ADC_REGULAR_RANK_4;
515 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
516 {
518 }
519 /* USER CODE BEGIN ADC3_Init 2 */
520
521 /* USER CODE END ADC3_Init 2 */
522
523}
ADC_HandleTypeDef hadc3
Definition: main.c:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_CAN1_Init()

static void MX_CAN1_Init ( void  )
static

CAN1 Initialization Function.

Parameters
None
Return values
None

Definition at line 530 of file main.c.

531{
532
533 /* USER CODE BEGIN CAN1_Init 0 */
534
535 /* USER CODE END CAN1_Init 0 */
536
537 /* USER CODE BEGIN CAN1_Init 1 */
538
539 /* USER CODE END CAN1_Init 1 */
540 hcan1.Instance = CAN1;
541 hcan1.Init.Prescaler = 6;
542 hcan1.Init.Mode = CAN_MODE_NORMAL;
543 hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
544 hcan1.Init.TimeSeg1 = CAN_BS1_13TQ;
545 hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
546 hcan1.Init.TimeTriggeredMode = DISABLE;
547 hcan1.Init.AutoBusOff = DISABLE;
548 hcan1.Init.AutoWakeUp = DISABLE;
549 hcan1.Init.AutoRetransmission = DISABLE;
550 hcan1.Init.ReceiveFifoLocked = DISABLE;
551 hcan1.Init.TransmitFifoPriority = DISABLE;
552 if (HAL_CAN_Init(&hcan1) != HAL_OK)
553 {
555 }
556 /* USER CODE BEGIN CAN1_Init 2 */
557 CAN_FilterTypeDef sFilterConfig;
558 sFilterConfig.FilterBank = 0;
559 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
560 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
561 sFilterConfig.FilterIdHigh = 0x0000;
562 sFilterConfig.FilterIdLow = 0x0000;
563 sFilterConfig.FilterMaskIdHigh = 0x0000;
564 sFilterConfig.FilterMaskIdLow = 0x0000;
565 sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
566 sFilterConfig.FilterActivation = ENABLE;
567 sFilterConfig.SlaveStartFilterBank = 14;
568 HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig);
569
570 // Stop CAN
571 HAL_CAN_Stop(&hcan1);
572 // Start CAN
573 if (HAL_CAN_Start(&hcan1) != HAL_OK) {
574 printf("CAN1 Start Error: ErrorCode = 0x%lX\r\n", hcan1.ErrorCode);
575 }
576
577 // Start IRQ for CAN Rx
578 if (HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) {
579 printf("interrupt CAN1 init failed\r\n");
580 }
581 /* USER CODE END CAN1_Init 2 */
582
583}
CAN_HandleTypeDef hcan1
Definition: main.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_CAN2_Init()

static void MX_CAN2_Init ( void  )
static

CAN2 Initialization Function.

Parameters
None
Return values
None

Definition at line 590 of file main.c.

591{
592
593 /* USER CODE BEGIN CAN2_Init 0 */
594
595 /* USER CODE END CAN2_Init 0 */
596
597 /* USER CODE BEGIN CAN2_Init 1 */
598
599 /* USER CODE END CAN2_Init 1 */
600 hcan2.Instance = CAN2;
601 hcan2.Init.Prescaler = 4;
602 hcan2.Init.Mode = CAN_MODE_NORMAL;
603 hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
604 hcan2.Init.TimeSeg1 = CAN_BS1_10TQ;
605 hcan2.Init.TimeSeg2 = CAN_BS2_1TQ;
606 hcan2.Init.TimeTriggeredMode = DISABLE;
607 hcan2.Init.AutoBusOff = DISABLE;
608 hcan2.Init.AutoWakeUp = DISABLE;
609 hcan2.Init.AutoRetransmission = DISABLE;
610 hcan2.Init.ReceiveFifoLocked = DISABLE;
611 hcan2.Init.TransmitFifoPriority = DISABLE;
612 if (HAL_CAN_Init(&hcan2) != HAL_OK)
613 {
615 }
616 /* USER CODE BEGIN CAN2_Init 2 */
617 CAN_FilterTypeDef sFilterConfig;
618 sFilterConfig.FilterBank = 0;
619 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
620 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
621 sFilterConfig.FilterIdHigh = 0x0000;
622 sFilterConfig.FilterIdLow = 0x0000;
623 sFilterConfig.FilterMaskIdHigh = 0x0000;
624 sFilterConfig.FilterMaskIdLow = 0x0000;
625 sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
626 sFilterConfig.FilterActivation = ENABLE;
627 sFilterConfig.SlaveStartFilterBank = 14;
628 HAL_CAN_ConfigFilter(&hcan2, &sFilterConfig);
629
630 // Stop CAN
631 HAL_CAN_Stop(&hcan2);
632 // Start CAN
633 if (HAL_CAN_Start(&hcan2) != HAL_OK) {
634 printf("CAN2 Start Error: ErrorCode = 0x%lX\r\n", hcan2.ErrorCode);
635 }
636
637 // Start IRQ for CAN Rx
638 if (HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) {
639 printf("interrupt CAN2 init failed\r\n");
640 }
641 /* USER CODE END CAN2_Init 2 */
642
643}
CAN_HandleTypeDef hcan2
Definition: main.c:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_DMA_Init()

static void MX_DMA_Init ( void  )
static

Enable DMA controller clock

Definition at line 994 of file main.c.

995{
996
997 /* DMA controller clock enable */
998 __HAL_RCC_DMA2_CLK_ENABLE();
999
1000 /* DMA interrupt init */
1001 /* DMA2_Stream0_IRQn interrupt configuration */
1002 HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
1003 HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
1004 /* DMA2_Stream1_IRQn interrupt configuration */
1005 HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
1006 HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
1007 /* DMA2_Stream2_IRQn interrupt configuration */
1008 HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0);
1009 HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn);
1010
1011}
Here is the caller graph for this function:

◆ MX_GPIO_Init()

static void MX_GPIO_Init ( void  )
static

GPIO Initialization Function.

Parameters
None
Return values
None

Definition at line 1018 of file main.c.

1019{
1020 GPIO_InitTypeDef GPIO_InitStruct = {0};
1021/* USER CODE BEGIN MX_GPIO_Init_1 */
1022/* USER CODE END MX_GPIO_Init_1 */
1023
1024 /* GPIO Ports Clock Enable */
1025 __HAL_RCC_GPIOE_CLK_ENABLE();
1026 __HAL_RCC_GPIOC_CLK_ENABLE();
1027 __HAL_RCC_GPIOF_CLK_ENABLE();
1028 __HAL_RCC_GPIOH_CLK_ENABLE();
1029 __HAL_RCC_GPIOA_CLK_ENABLE();
1030 __HAL_RCC_GPIOB_CLK_ENABLE();
1031 __HAL_RCC_GPIOG_CLK_ENABLE();
1032 __HAL_RCC_GPIOD_CLK_ENABLE();
1033
1034 /*Configure GPIO pin Output Level */
1035 HAL_GPIO_WritePin(GPIOB, LD3_Pin|LD2_Pin, GPIO_PIN_RESET);
1036
1037 /*Configure GPIO pin Output Level */
1038 HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);
1039
1040 /*Configure GPIO pins : PE3 PE4 PE7 PE8
1041 PE9 PE10 PE11 PE12
1042 PE13 */
1043 GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8
1044 |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
1045 |GPIO_PIN_13;
1046 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
1047 GPIO_InitStruct.Pull = GPIO_NOPULL;
1048 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
1049
1050 /*Configure GPIO pin : USER_Btn_Pin */
1051 GPIO_InitStruct.Pin = USER_Btn_Pin;
1052 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
1053 GPIO_InitStruct.Pull = GPIO_NOPULL;
1054 HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct);
1055
1056 /*Configure GPIO pins : PF2 PF3 PF4 PF5
1057 PF6 PF10 PF11 PF12
1058 PF13 */
1059 GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
1060 |GPIO_PIN_6|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
1061 |GPIO_PIN_13;
1062 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
1063 GPIO_InitStruct.Pull = GPIO_NOPULL;
1064 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
1065
1066 /*Configure GPIO pins : PG0 PG1 USB_OverCurrent_Pin */
1067 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|USB_OverCurrent_Pin;
1068 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
1069 GPIO_InitStruct.Pull = GPIO_NOPULL;
1070 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
1071
1072 /*Configure GPIO pins : PE14 PE15 PE0 PE1 */
1073 GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
1074 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1075 GPIO_InitStruct.Pull = GPIO_NOPULL;
1076 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
1077
1078 /*Configure GPIO pins : PB10 PB11 PB12 PB15
1079 PB3 PB4 PB6 */
1080 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15
1081 |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_6;
1082 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1083 GPIO_InitStruct.Pull = GPIO_NOPULL;
1084 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
1085
1086 /*Configure GPIO pins : LD3_Pin LD2_Pin */
1087 GPIO_InitStruct.Pin = LD3_Pin|LD2_Pin;
1088 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
1089 GPIO_InitStruct.Pull = GPIO_NOPULL;
1090 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
1091 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
1092
1093 /*Configure GPIO pins : PD10 PD11 PD12 PD13
1094 PD14 PD15 PD2 PD3
1095 PD4 PD5 PD7 */
1096 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
1097 |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_2|GPIO_PIN_3
1098 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7;
1099 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1100 GPIO_InitStruct.Pull = GPIO_NOPULL;
1101 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
1102
1103 /*Configure GPIO pins : PG2 PG3 PG4 PG5
1104 PG8 PG9 PG10 PG11
1105 PG12 PG13 PG14 PG15 */
1106 GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
1107 |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
1108 |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
1109 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1110 GPIO_InitStruct.Pull = GPIO_NOPULL;
1111 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
1112
1113 /*Configure GPIO pin : USB_PowerSwitchOn_Pin */
1114 GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
1115 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
1116 GPIO_InitStruct.Pull = GPIO_NOPULL;
1117 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
1118 HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
1119
1120 /*Configure GPIO pins : PC6 PC7 PC8 PC9
1121 PC12 */
1122 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
1123 |GPIO_PIN_12;
1124 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1125 GPIO_InitStruct.Pull = GPIO_NOPULL;
1126 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
1127
1128 /*Configure GPIO pins : USB_SOF_Pin USB_DM_Pin USB_DP_Pin */
1129 GPIO_InitStruct.Pin = USB_SOF_Pin|USB_DM_Pin|USB_DP_Pin;
1130 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
1131 GPIO_InitStruct.Pull = GPIO_NOPULL;
1132 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
1133 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
1134 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
1135
1136 /*Configure GPIO pin : USB_VBUS_Pin */
1137 GPIO_InitStruct.Pin = USB_VBUS_Pin;
1138 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
1139 GPIO_InitStruct.Pull = GPIO_NOPULL;
1140 HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
1141
1142 /*Configure GPIO pins : PA10 PA15 */
1143 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_15;
1144 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
1145 GPIO_InitStruct.Pull = GPIO_NOPULL;
1146 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
1147
1148 /*Configure GPIO pin : PD6 */
1149 GPIO_InitStruct.Pin = GPIO_PIN_6;
1150 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
1151 GPIO_InitStruct.Pull = GPIO_NOPULL;
1152 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
1153 GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
1154 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
1155
1156/* USER CODE BEGIN MX_GPIO_Init_2 */
1157/* USER CODE END MX_GPIO_Init_2 */
1158}
#define USB_VBUS_Pin
Definition: main.h:82
#define USB_VBUS_GPIO_Port
Definition: main.h:83
#define USB_DP_Pin
Definition: main.h:86
#define USB_PowerSwitchOn_GPIO_Port
Definition: main.h:77
#define USB_OverCurrent_Pin
Definition: main.h:78
#define LD3_Pin
Definition: main.h:70
#define USB_SOF_Pin
Definition: main.h:80
#define USB_DM_Pin
Definition: main.h:84
#define USER_Btn_Pin
Definition: main.h:66
#define USB_PowerSwitchOn_Pin
Definition: main.h:76
#define USER_Btn_GPIO_Port
Definition: main.h:67
#define LD2_Pin
Definition: main.h:92
Here is the caller graph for this function:

◆ MX_I2C1_Init()

static void MX_I2C1_Init ( void  )
static

I2C1 Initialization Function.

Parameters
None
Return values
None

Configure Analogue filter

Configure Digital filter

Definition at line 650 of file main.c.

651{
652
653 /* USER CODE BEGIN I2C1_Init 0 */
654
655 /* USER CODE END I2C1_Init 0 */
656
657 /* USER CODE BEGIN I2C1_Init 1 */
658
659 /* USER CODE END I2C1_Init 1 */
660 hi2c1.Instance = I2C1;
661 hi2c1.Init.Timing = 0x20303E5D;
662 hi2c1.Init.OwnAddress1 = 0;
663 hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
664 hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
665 hi2c1.Init.OwnAddress2 = 0;
666 hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
667 hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
668 hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
669 if (HAL_I2C_Init(&hi2c1) != HAL_OK)
670 {
672 }
673
676 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
677 {
679 }
680
683 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
684 {
686 }
687 /* USER CODE BEGIN I2C1_Init 2 */
688
689 /* USER CODE END I2C1_Init 2 */
690
691}
I2C_HandleTypeDef hi2c1
Definition: main.c:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_I2C2_Init()

static void MX_I2C2_Init ( void  )
static

I2C2 Initialization Function.

Parameters
None
Return values
None

Configure Analogue filter

Configure Digital filter

Definition at line 698 of file main.c.

699{
700
701 /* USER CODE BEGIN I2C2_Init 0 */
702
703 /* USER CODE END I2C2_Init 0 */
704
705 /* USER CODE BEGIN I2C2_Init 1 */
706
707 /* USER CODE END I2C2_Init 1 */
708 hi2c2.Instance = I2C2;
709 hi2c2.Init.Timing = 0x20303E5D;
710 hi2c2.Init.OwnAddress1 = 0;
711 hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
712 hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
713 hi2c2.Init.OwnAddress2 = 0;
714 hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
715 hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
716 hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
717 if (HAL_I2C_Init(&hi2c2) != HAL_OK)
718 {
720 }
721
724 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
725 {
727 }
728
731 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
732 {
734 }
735 /* USER CODE BEGIN I2C2_Init 2 */
736
737 /* USER CODE END I2C2_Init 2 */
738
739}
I2C_HandleTypeDef hi2c2
Definition: main.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_I2C4_Init()

static void MX_I2C4_Init ( void  )
static

I2C4 Initialization Function.

Parameters
None
Return values
None

Configure Analogue filter

Configure Digital filter

Definition at line 746 of file main.c.

747{
748
749 /* USER CODE BEGIN I2C4_Init 0 */
750
751 /* USER CODE END I2C4_Init 0 */
752
753 /* USER CODE BEGIN I2C4_Init 1 */
754
755 /* USER CODE END I2C4_Init 1 */
756 hi2c4.Instance = I2C4;
757 hi2c4.Init.Timing = 0x20303E5D;
758 hi2c4.Init.OwnAddress1 = 0;
759 hi2c4.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
760 hi2c4.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
761 hi2c4.Init.OwnAddress2 = 0;
762 hi2c4.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
763 hi2c4.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
764 hi2c4.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
765 if (HAL_I2C_Init(&hi2c4) != HAL_OK)
766 {
768 }
769
772 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c4, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
773 {
775 }
776
779 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c4, 0) != HAL_OK)
780 {
782 }
783 /* USER CODE BEGIN I2C4_Init 2 */
784
785 /* USER CODE END I2C4_Init 2 */
786
787}
I2C_HandleTypeDef hi2c4
Definition: main.c:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_SPI3_Init()

static void MX_SPI3_Init ( void  )
static

SPI3 Initialization Function.

Parameters
None
Return values
None

Definition at line 794 of file main.c.

795{
796
797 /* USER CODE BEGIN SPI3_Init 0 */
798
799 /* USER CODE END SPI3_Init 0 */
800
801 /* USER CODE BEGIN SPI3_Init 1 */
802
803 /* USER CODE END SPI3_Init 1 */
804 /* SPI3 parameter configuration*/
805 hspi3.Instance = SPI3;
806 hspi3.Init.Mode = SPI_MODE_MASTER;
807 hspi3.Init.Direction = SPI_DIRECTION_2LINES;
808 hspi3.Init.DataSize = SPI_DATASIZE_4BIT;
809 hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
810 hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
811 hspi3.Init.NSS = SPI_NSS_SOFT;
812 hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
813 hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
814 hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
815 hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
816 hspi3.Init.CRCPolynomial = 7;
817 hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
818 hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
819 if (HAL_SPI_Init(&hspi3) != HAL_OK)
820 {
822 }
823 /* USER CODE BEGIN SPI3_Init 2 */
824
825 /* USER CODE END SPI3_Init 2 */
826
827}
SPI_HandleTypeDef hspi3
Definition: main.c:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_SPI4_Init()

static void MX_SPI4_Init ( void  )
static

SPI4 Initialization Function.

Parameters
None
Return values
None

Definition at line 834 of file main.c.

835{
836
837 /* USER CODE BEGIN SPI4_Init 0 */
838
839 /* USER CODE END SPI4_Init 0 */
840
841 /* USER CODE BEGIN SPI4_Init 1 */
842
843 /* USER CODE END SPI4_Init 1 */
844 /* SPI4 parameter configuration*/
845 hspi4.Instance = SPI4;
846 hspi4.Init.Mode = SPI_MODE_MASTER;
847 hspi4.Init.Direction = SPI_DIRECTION_2LINES;
848 hspi4.Init.DataSize = SPI_DATASIZE_4BIT;
849 hspi4.Init.CLKPolarity = SPI_POLARITY_LOW;
850 hspi4.Init.CLKPhase = SPI_PHASE_1EDGE;
851 hspi4.Init.NSS = SPI_NSS_SOFT;
852 hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
853 hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB;
854 hspi4.Init.TIMode = SPI_TIMODE_DISABLE;
855 hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
856 hspi4.Init.CRCPolynomial = 7;
857 hspi4.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
858 hspi4.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
859 if (HAL_SPI_Init(&hspi4) != HAL_OK)
860 {
862 }
863 /* USER CODE BEGIN SPI4_Init 2 */
864
865 /* USER CODE END SPI4_Init 2 */
866
867}
SPI_HandleTypeDef hspi4
Definition: main.c:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_SPI5_Init()

static void MX_SPI5_Init ( void  )
static

SPI5 Initialization Function.

Parameters
None
Return values
None

Definition at line 874 of file main.c.

875{
876
877 /* USER CODE BEGIN SPI5_Init 0 */
878
879 /* USER CODE END SPI5_Init 0 */
880
881 /* USER CODE BEGIN SPI5_Init 1 */
882
883 /* USER CODE END SPI5_Init 1 */
884 /* SPI5 parameter configuration*/
885 hspi5.Instance = SPI5;
886 hspi5.Init.Mode = SPI_MODE_MASTER;
887 hspi5.Init.Direction = SPI_DIRECTION_2LINES;
888 hspi5.Init.DataSize = SPI_DATASIZE_4BIT;
889 hspi5.Init.CLKPolarity = SPI_POLARITY_LOW;
890 hspi5.Init.CLKPhase = SPI_PHASE_1EDGE;
891 hspi5.Init.NSS = SPI_NSS_SOFT;
892 hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
893 hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB;
894 hspi5.Init.TIMode = SPI_TIMODE_DISABLE;
895 hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
896 hspi5.Init.CRCPolynomial = 7;
897 hspi5.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
898 hspi5.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
899 if (HAL_SPI_Init(&hspi5) != HAL_OK)
900 {
902 }
903 /* USER CODE BEGIN SPI5_Init 2 */
904
905 /* USER CODE END SPI5_Init 2 */
906
907}
SPI_HandleTypeDef hspi5
Definition: main.c:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_TIM1_Init()

static void MX_TIM1_Init ( void  )
static

TIM1 Initialization Function.

Parameters
None
Return values
None

Definition at line 914 of file main.c.

915{
916
917 /* USER CODE BEGIN TIM1_Init 0 */
918
919 /* USER CODE END TIM1_Init 0 */
920
921 TIM_ClockConfigTypeDef sClockSourceConfig = {0};
922 TIM_MasterConfigTypeDef sMasterConfig = {0};
923
924 /* USER CODE BEGIN TIM1_Init 1 */
925
926 /* USER CODE END TIM1_Init 1 */
927 htim1.Instance = TIM1;
928 htim1.Init.Prescaler = 47999;
929 htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
930 htim1.Init.Period = 999;
931 htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
932 htim1.Init.RepetitionCounter = 0;
933 htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
934 if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
935 {
937 }
938 sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
939 if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
940 {
942 }
943 sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
944 sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
945 sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
946 if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
947 {
949 }
950 /* USER CODE BEGIN TIM1_Init 2 */
951
952 /* USER CODE END TIM1_Init 2 */
953
954}
TIM_HandleTypeDef htim1
Definition: main.c:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MX_USART3_UART_Init()

static void MX_USART3_UART_Init ( void  )
static

USART3 Initialization Function.

Parameters
None
Return values
None

Definition at line 961 of file main.c.

962{
963
964 /* USER CODE BEGIN USART3_Init 0 */
965
966 /* USER CODE END USART3_Init 0 */
967
968 /* USER CODE BEGIN USART3_Init 1 */
969
970 /* USER CODE END USART3_Init 1 */
971 huart3.Instance = USART3;
972 huart3.Init.BaudRate = 115200;
973 huart3.Init.WordLength = UART_WORDLENGTH_8B;
974 huart3.Init.StopBits = UART_STOPBITS_1;
975 huart3.Init.Parity = UART_PARITY_NONE;
976 huart3.Init.Mode = UART_MODE_TX_RX;
977 huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
978 huart3.Init.OverSampling = UART_OVERSAMPLING_16;
979 huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
980 huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
981 if (HAL_UART_Init(&huart3) != HAL_OK)
982 {
984 }
985 /* USER CODE BEGIN USART3_Init 2 */
986
987 /* USER CODE END USART3_Init 2 */
988
989}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SystemClock_Config()

void SystemClock_Config ( void  )

System Clock Configuration.

Return values
None

Configure LSE Drive Capability

Configure the main internal regulator output voltage

Initializes the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef structure.

Activate the Over-Drive mode

Initializes the CPU, AHB and APB buses clocks

Definition at line 201 of file main.c.

202{
203 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
204 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
205
208 HAL_PWR_EnableBkUpAccess();
209
212 __HAL_RCC_PWR_CLK_ENABLE();
213 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
214
218 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
219 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
220 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
221 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
222 RCC_OscInitStruct.PLL.PLLM = 4;
223 RCC_OscInitStruct.PLL.PLLN = 96;
224 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
225 RCC_OscInitStruct.PLL.PLLQ = 4;
226 RCC_OscInitStruct.PLL.PLLR = 2;
227 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
228 {
230 }
231
234 if (HAL_PWREx_EnableOverDrive() != HAL_OK)
235 {
237 }
238
241 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
242 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
243 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
244 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
245 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
246 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
247
248 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
249 {
251 }
252}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ hadc1

ADC_HandleTypeDef hadc1

Definition at line 44 of file main.c.

◆ hadc2

ADC_HandleTypeDef hadc2

Definition at line 45 of file main.c.

◆ hadc3

ADC_HandleTypeDef hadc3

Definition at line 46 of file main.c.

◆ hcan1

CAN_HandleTypeDef hcan1

Definition at line 51 of file main.c.

◆ hcan2

CAN_HandleTypeDef hcan2

Definition at line 52 of file main.c.

◆ hdma_adc1

DMA_HandleTypeDef hdma_adc1

Definition at line 47 of file main.c.

◆ hdma_adc2

DMA_HandleTypeDef hdma_adc2

Definition at line 48 of file main.c.

◆ hdma_adc3

DMA_HandleTypeDef hdma_adc3

Definition at line 49 of file main.c.

◆ hi2c1

I2C_HandleTypeDef hi2c1

Definition at line 54 of file main.c.

◆ hi2c2

I2C_HandleTypeDef hi2c2

Definition at line 55 of file main.c.

◆ hi2c4

I2C_HandleTypeDef hi2c4

Definition at line 56 of file main.c.

◆ hspi3

SPI_HandleTypeDef hspi3

Definition at line 58 of file main.c.

◆ hspi4

SPI_HandleTypeDef hspi4

Definition at line 59 of file main.c.

◆ hspi5

SPI_HandleTypeDef hspi5

Definition at line 60 of file main.c.

◆ htim1

TIM_HandleTypeDef htim1

Definition at line 62 of file main.c.

◆ huart3

UART_HandleTypeDef huart3

Definition at line 64 of file main.c.