Subversion Repositories FuelGauge

Rev

Rev 2 | Rev 4 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/* USER CODE BEGIN Header */
2
/**
3 mjames 3
 ******************************************************************************
4
 * @file           : main.c
5
 * @brief          : Main program body
6
 ******************************************************************************
7
 * @attention
8
 *
9
 * <h2><center>&copy; 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
 */
2 mjames 19
/* USER CODE END Header */
20
 
21
/* Includes ------------------------------------------------------------------*/
22
#include "main.h"
23
 
24
/* Private includes ----------------------------------------------------------*/
25
/* USER CODE BEGIN Includes */
26
 
27
/* USER CODE END Includes */
28
 
29
/* Private typedef -----------------------------------------------------------*/
30
/* USER CODE BEGIN PTD */
31
 
32
/* USER CODE END PTD */
33
 
34
/* Private define ------------------------------------------------------------*/
35
/* USER CODE BEGIN PD */
36
/* USER CODE END PD */
37
 
38
/* Private macro -------------------------------------------------------------*/
39
/* USER CODE BEGIN PM */
40
 
41
/* USER CODE END PM */
42
 
43
/* Private variables ---------------------------------------------------------*/
44
ADC_HandleTypeDef hadc;
45
DMA_HandleTypeDef hdma_adc;
46
 
3 mjames 47
SPI_HandleTypeDef hspi1;
48
DMA_HandleTypeDef hdma_spi1_tx;
49
 
2 mjames 50
TIM_HandleTypeDef htim1;
51
TIM_HandleTypeDef htim3;
52
 
53
UART_HandleTypeDef huart1;
54
 
55
/* USER CODE BEGIN PV */
56
#define NUM_SAMPLES 8
3 mjames 57
uint32_t ADC_Samples[NUM_SAMPLES];
2 mjames 58
 
3 mjames 59
#define NUM_SPI_BYTES 20
60
uint8_t SPI_Buffer[NUM_SPI_BYTES];
2 mjames 61
 
62
/* USER CODE END PV */
63
 
64
/* Private function prototypes -----------------------------------------------*/
65
void SystemClock_Config(void);
66
static void MX_GPIO_Init(void);
67
static void MX_DMA_Init(void);
68
static void MX_ADC_Init(void);
69
static void MX_TIM1_Init(void);
70
static void MX_USART1_UART_Init(void);
71
static void MX_TIM3_Init(void);
3 mjames 72
static void MX_SPI1_Init(void);
2 mjames 73
/* USER CODE BEGIN PFP */
74
 
75
/* USER CODE END PFP */
76
 
77
/* Private user code ---------------------------------------------------------*/
78
/* USER CODE BEGIN 0 */
79
 
80
void setDrive1(uint8_t bit) {
81
        if (bit) {
3 mjames 82
                HAL_GPIO_WritePin(step1P_GPIO_Port, step1P_Pin, GPIO_PIN_SET);
83
                HAL_GPIO_WritePin(step1N_GPIO_Port, step1N_Pin, GPIO_PIN_RESET);
2 mjames 84
        } else {
3 mjames 85
                HAL_GPIO_WritePin(step1P_GPIO_Port, step1P_Pin, GPIO_PIN_RESET);
86
                HAL_GPIO_WritePin(step1N_GPIO_Port, step1N_Pin, GPIO_PIN_SET);
2 mjames 87
        }
88
}
89
 
90
void setDrive2(uint8_t bit) {
91
        if (bit) {
3 mjames 92
                HAL_GPIO_WritePin(step2P_GPIO_Port, step2P_Pin, GPIO_PIN_SET);
93
                HAL_GPIO_WritePin(step2N_GPIO_Port, step2N_Pin, GPIO_PIN_RESET);
2 mjames 94
        } else {
3 mjames 95
                HAL_GPIO_WritePin(step2P_GPIO_Port, step2P_Pin, GPIO_PIN_RESET);
96
                HAL_GPIO_WritePin(step2N_GPIO_Port, step2N_Pin, GPIO_PIN_SET);
2 mjames 97
        }
98
}
99
 
100
//
101
int count = 0;
102
int origin = 0;
103
 
3 mjames 104
void moveGauge(int target) {
2 mjames 105
 
3 mjames 106
        unsigned const fast = 10;
107
        unsigned const slow = 30;
2 mjames 108
        unsigned const range = slow - fast;
109
        unsigned del = fast;
110
        int step = 1;
111
        while (count != target) {
112
 
113
                // use bit mask, so it works for negative count values ..
114
                switch (count & 3) {
115
                case 0:
3 mjames 116
                        setDrive1(0);
117
                        setDrive2(1);
2 mjames 118
                        break;
119
                case 1:
120
                        setDrive1(1);
121
                        setDrive2(1);
122
                        break;
123
                case 2:
3 mjames 124
                        setDrive1(1);
125
                        setDrive2(0);
2 mjames 126
                        break;
127
                case 3:
128
                        setDrive1(0);
129
                        setDrive2(0);
130
                        break;
131
                }
132
 
133
                // all this calculates minimum distance from
134
                // target or origin
135
                int d1 = count - origin;
136
                if (d1 < 0)
137
                        d1 = -d1;
138
                int d2 = count - target;
139
                if (d2 < 0)
140
                        d2 = -d2;
141
                // finally, minimum distance
142
                int dist = d1 < d2 ? d1 : d2;
143
 
144
                del = fast;
145
                if (dist < range) // inside lower bound of distance
146
                                {
147
                        del = slow - dist;
148
                }
149
                HAL_Delay(del);
150
 
151
                if (count < target) {
152
                        step = 1;
153
                }
154
                if (count > target) {
155
                        step = -1;
156
                }
157
                if (count == target) {
158
                        step = 0;
159
                }
160
                count = count + step;
161
 
162
        }
163
 
164
}
165
 
166
// move gauge back to zero position
3 mjames 167
void resetGauge() {
2 mjames 168
        moveGauge(-600);
3 mjames 169
        count = 0;
2 mjames 170
        origin = 0;
171
}
172
 
173
/* USER CODE END 0 */
174
 
175
/**
176
  * @brief  The application entry point.
177
  * @retval int
178
  */
179
int main(void)
180
{
181
  /* USER CODE BEGIN 1 */
182
//  half degree step  315 degree movement
183
#define GAUGE_MAX 315*2
184
#define GAUGE_MIN 0
185
 
186
  /* USER CODE END 1 */
187
 
188
  /* MCU Configuration--------------------------------------------------------*/
189
 
190
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
191
  HAL_Init();
192
 
193
  /* USER CODE BEGIN Init */
194
 
195
  /* USER CODE END Init */
196
 
197
  /* Configure the system clock */
198
  SystemClock_Config();
199
 
200
  /* USER CODE BEGIN SysInit */
201
 
202
  /* USER CODE END SysInit */
203
 
204
  /* Initialize all configured peripherals */
205
  MX_GPIO_Init();
206
  MX_DMA_Init();
207
  MX_ADC_Init();
208
  MX_TIM1_Init();
209
  MX_USART1_UART_Init();
210
  MX_TIM3_Init();
3 mjames 211
  MX_SPI1_Init();
2 mjames 212
  /* USER CODE BEGIN 2 */
213
 
3 mjames 214
        int i;
215
        for (i = 0; i < NUM_SAMPLES; i++)
216
                ADC_Samples[i] = 0;
2 mjames 217
 
3 mjames 218
        HAL_ADC_MspInit(&hadc);
2 mjames 219
 
3 mjames 220
        HAL_ADC_Start_DMA(&hadc, ADC_Samples, NUM_SAMPLES);
2 mjames 221
 
3 mjames 222
        HAL_ADC_Start_IT(&hadc);
2 mjames 223
 
3 mjames 224
        // timer 3 triggers the ADC
225
        HAL_TIM_Base_MspInit(&htim3);
226
        HAL_TIM_Base_Start_IT(&htim3);
2 mjames 227
 
3 mjames 228
        resetGauge();
2 mjames 229
 
3 mjames 230
  /* USER CODE END 2 */
2 mjames 231
 
3 mjames 232
  /* Infinite loop */
233
  /* USER CODE BEGIN WHILE */
234
        while (1) {
2 mjames 235
 
3 mjames 236
                HAL_SPI_Transmit_DMA(&hspi1, SPI_Buffer, NUM_SPI_BYTES);
2 mjames 237
 
3 mjames 238
                HAL_Delay(10);
2 mjames 239
 
240
    /* USER CODE END WHILE */
241
 
242
    /* USER CODE BEGIN 3 */
3 mjames 243
        }
2 mjames 244
  /* USER CODE END 3 */
245
}
246
 
247
/**
248
  * @brief System Clock Configuration
249
  * @retval None
250
  */
251
void SystemClock_Config(void)
252
{
253
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
254
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
255
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
256
 
3 mjames 257
  /** Initializes the CPU, AHB and APB busses clocks
2 mjames 258
  */
259
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14;
260
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
261
  RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
262
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
263
  RCC_OscInitStruct.HSI14CalibrationValue = 16;
264
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
265
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
266
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8;
267
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
268
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
269
  {
270
    Error_Handler();
271
  }
3 mjames 272
  /** Initializes the CPU, AHB and APB busses clocks
2 mjames 273
  */
274
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
275
                              |RCC_CLOCKTYPE_PCLK1;
276
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
277
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
278
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
279
 
280
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
281
  {
282
    Error_Handler();
283
  }
284
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
285
  PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
286
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
287
  {
288
    Error_Handler();
289
  }
290
}
291
 
292
/**
293
  * @brief ADC Initialization Function
294
  * @param None
295
  * @retval None
296
  */
297
static void MX_ADC_Init(void)
298
{
299
 
300
  /* USER CODE BEGIN ADC_Init 0 */
301
 
302
  /* USER CODE END ADC_Init 0 */
303
 
304
  ADC_ChannelConfTypeDef sConfig = {0};
305
 
306
  /* USER CODE BEGIN ADC_Init 1 */
307
 
308
  /* USER CODE END ADC_Init 1 */
3 mjames 309
  /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
2 mjames 310
  */
311
  hadc.Instance = ADC1;
312
  hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
313
  hadc.Init.Resolution = ADC_RESOLUTION_12B;
314
  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
315
  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
316
  hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
317
  hadc.Init.LowPowerAutoWait = DISABLE;
318
  hadc.Init.LowPowerAutoPowerOff = DISABLE;
319
  hadc.Init.ContinuousConvMode = DISABLE;
320
  hadc.Init.DiscontinuousConvMode = DISABLE;
321
  hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
322
  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
323
  hadc.Init.DMAContinuousRequests = ENABLE;
324
  hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
325
  if (HAL_ADC_Init(&hadc) != HAL_OK)
326
  {
327
    Error_Handler();
328
  }
3 mjames 329
  /** Configure for the selected ADC regular channel to be converted.
2 mjames 330
  */
331
  sConfig.Channel = ADC_CHANNEL_0;
332
  sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
333
  sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES_5;
334
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
335
  {
336
    Error_Handler();
337
  }
338
  /* USER CODE BEGIN ADC_Init 2 */
339
 
340
  /* USER CODE END ADC_Init 2 */
341
 
342
}
343
 
344
/**
3 mjames 345
  * @brief SPI1 Initialization Function
346
  * @param None
347
  * @retval None
348
  */
349
static void MX_SPI1_Init(void)
350
{
351
 
352
  /* USER CODE BEGIN SPI1_Init 0 */
353
 
354
  /* USER CODE END SPI1_Init 0 */
355
 
356
  /* USER CODE BEGIN SPI1_Init 1 */
357
 
358
  /* USER CODE END SPI1_Init 1 */
359
  /* SPI1 parameter configuration*/
360
  hspi1.Instance = SPI1;
361
  hspi1.Init.Mode = SPI_MODE_MASTER;
362
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
363
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
364
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
365
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
366
  hspi1.Init.NSS = SPI_NSS_SOFT;
367
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
368
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
369
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
370
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
371
  hspi1.Init.CRCPolynomial = 7;
372
  hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
373
  hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
374
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
375
  {
376
    Error_Handler();
377
  }
378
  /* USER CODE BEGIN SPI1_Init 2 */
379
 
380
  /* USER CODE END SPI1_Init 2 */
381
 
382
}
383
 
384
/**
2 mjames 385
  * @brief TIM1 Initialization Function
386
  * @param None
387
  * @retval None
388
  */
389
static void MX_TIM1_Init(void)
390
{
391
 
392
  /* USER CODE BEGIN TIM1_Init 0 */
393
 
394
  /* USER CODE END TIM1_Init 0 */
395
 
396
  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
397
  TIM_MasterConfigTypeDef sMasterConfig = {0};
398
 
399
  /* USER CODE BEGIN TIM1_Init 1 */
400
 
401
  /* USER CODE END TIM1_Init 1 */
402
  htim1.Instance = TIM1;
403
  htim1.Init.Prescaler = 0;
404
  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
405
  htim1.Init.Period = 0;
406
  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
407
  htim1.Init.RepetitionCounter = 0;
408
  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
409
  if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
410
  {
411
    Error_Handler();
412
  }
413
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
414
  if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
415
  {
416
    Error_Handler();
417
  }
418
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
419
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
420
  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
421
  {
422
    Error_Handler();
423
  }
424
  /* USER CODE BEGIN TIM1_Init 2 */
425
 
426
  /* USER CODE END TIM1_Init 2 */
427
 
428
}
429
 
430
/**
431
  * @brief TIM3 Initialization Function
432
  * @param None
433
  * @retval None
434
  */
435
static void MX_TIM3_Init(void)
436
{
437
 
438
  /* USER CODE BEGIN TIM3_Init 0 */
439
 
440
  /* USER CODE END TIM3_Init 0 */
441
 
442
  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
443
  TIM_MasterConfigTypeDef sMasterConfig = {0};
444
 
445
  /* USER CODE BEGIN TIM3_Init 1 */
446
 
447
  /* USER CODE END TIM3_Init 1 */
448
  htim3.Instance = TIM3;
449
  htim3.Init.Prescaler = 32;
450
  htim3.Init.CounterMode = TIM_COUNTERMODE_DOWN;
451
  htim3.Init.Period = 10000;
452
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
453
  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
454
  if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
455
  {
456
    Error_Handler();
457
  }
458
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
459
  if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
460
  {
461
    Error_Handler();
462
  }
463
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
464
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
465
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
466
  {
467
    Error_Handler();
468
  }
469
  /* USER CODE BEGIN TIM3_Init 2 */
470
 
471
  /* USER CODE END TIM3_Init 2 */
472
 
473
}
474
 
475
/**
476
  * @brief USART1 Initialization Function
477
  * @param None
478
  * @retval None
479
  */
480
static void MX_USART1_UART_Init(void)
481
{
482
 
483
  /* USER CODE BEGIN USART1_Init 0 */
484
 
485
  /* USER CODE END USART1_Init 0 */
486
 
487
  /* USER CODE BEGIN USART1_Init 1 */
488
 
489
  /* USER CODE END USART1_Init 1 */
490
  huart1.Instance = USART1;
491
  huart1.Init.BaudRate = 38400;
492
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
493
  huart1.Init.StopBits = UART_STOPBITS_1;
494
  huart1.Init.Parity = UART_PARITY_NONE;
495
  huart1.Init.Mode = UART_MODE_TX_RX;
496
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
497
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
498
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
499
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
500
  if (HAL_UART_Init(&huart1) != HAL_OK)
501
  {
502
    Error_Handler();
503
  }
504
  /* USER CODE BEGIN USART1_Init 2 */
505
 
506
  /* USER CODE END USART1_Init 2 */
507
 
508
}
509
 
3 mjames 510
/**
2 mjames 511
  * Enable DMA controller clock
512
  */
3 mjames 513
static void MX_DMA_Init(void)
2 mjames 514
{
515
 
516
  /* DMA controller clock enable */
517
  __HAL_RCC_DMA1_CLK_ENABLE();
518
 
519
  /* DMA interrupt init */
520
  /* DMA1_Channel1_IRQn interrupt configuration */
521
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
522
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
3 mjames 523
  /* DMA1_Channel2_3_IRQn interrupt configuration */
524
  HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0);
525
  HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
2 mjames 526
 
527
}
528
 
529
/**
530
  * @brief GPIO Initialization Function
531
  * @param None
532
  * @retval None
533
  */
534
static void MX_GPIO_Init(void)
535
{
536
  GPIO_InitTypeDef GPIO_InitStruct = {0};
537
 
538
  /* GPIO Ports Clock Enable */
539
  __HAL_RCC_GPIOF_CLK_ENABLE();
540
  __HAL_RCC_GPIOA_CLK_ENABLE();
541
  __HAL_RCC_GPIOB_CLK_ENABLE();
542
 
543
  /*Configure GPIO pin Output Level */
3 mjames 544
  HAL_GPIO_WritePin(GPIOA, enableCurrent_Pin|step2N_Pin|step1N_Pin|step1P_Pin, GPIO_PIN_RESET);
2 mjames 545
 
546
  /*Configure GPIO pin Output Level */
3 mjames 547
  HAL_GPIO_WritePin(step2P_GPIO_Port, step2P_Pin, GPIO_PIN_RESET);
2 mjames 548
 
3 mjames 549
  /*Configure GPIO pins : enableCurrent_Pin step2N_Pin step1N_Pin step1P_Pin */
550
  GPIO_InitStruct.Pin = enableCurrent_Pin|step2N_Pin|step1N_Pin|step1P_Pin;
2 mjames 551
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
552
  GPIO_InitStruct.Pull = GPIO_NOPULL;
553
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
554
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
555
 
3 mjames 556
  /*Configure GPIO pin : step2P_Pin */
557
  GPIO_InitStruct.Pin = step2P_Pin;
2 mjames 558
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
559
  GPIO_InitStruct.Pull = GPIO_NOPULL;
560
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
3 mjames 561
  HAL_GPIO_Init(step2P_GPIO_Port, &GPIO_InitStruct);
2 mjames 562
 
563
}
564
 
565
/* USER CODE BEGIN 4 */
566
 
567
/* USER CODE END 4 */
568
 
569
/**
570
  * @brief  This function is executed in case of error occurrence.
571
  * @retval None
572
  */
573
void Error_Handler(void)
574
{
575
  /* USER CODE BEGIN Error_Handler_Debug */
3 mjames 576
        /* User can add his own implementation to report the HAL error return state */
2 mjames 577
 
578
  /* USER CODE END Error_Handler_Debug */
579
}
580
 
581
#ifdef  USE_FULL_ASSERT
582
/**
583
  * @brief  Reports the name of the source file and the source line number
584
  *         where the assert_param error has occurred.
585
  * @param  file: pointer to the source file name
586
  * @param  line: assert_param error line source number
587
  * @retval None
588
  */
589
void assert_failed(char *file, uint32_t line)
3 mjames 590
{
2 mjames 591
  /* USER CODE BEGIN 6 */
592
  /* User can add his own implementation to report the file name and line number,
593
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
594
  /* USER CODE END 6 */
595
}
596
#endif /* USE_FULL_ASSERT */
597
 
598
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/