Subversion Repositories FuelGauge

Rev

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