Subversion Repositories FuelGauge

Rev

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
/* Includes ------------------------------------------------------------------*/
21
#include "main.h"
22
 
23
/* Private includes ----------------------------------------------------------*/
24
/* USER CODE BEGIN Includes */
4 mjames 25
#include "sendLeds.h"
5 mjames 26
#include "libLog/log.h"
2 mjames 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;
5 mjames 107
        unsigned const slow = 20;
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
 
5 mjames 173
 
174
uint16_t getADC(){
175
        uint16_t mean = 0;
176
        for (int i =0; i< NUM_SAMPLES; i++)
177
        {
178
                mean+=ADC_Samples[i];
179
        }
180
        return mean/NUM_SAMPLES;
181
}
182
 
183
 
184
 
2 mjames 185
/* USER CODE END 0 */
186
 
187
/**
188
  * @brief  The application entry point.
189
  * @retval int
190
  */
191
int main(void)
192
{
193
  /* USER CODE BEGIN 1 */
194
//  half degree step  315 degree movement
195
#define GAUGE_MAX 315*2
196
#define GAUGE_MIN 0
197
 
198
  /* USER CODE END 1 */
199
 
200
  /* MCU Configuration--------------------------------------------------------*/
201
 
202
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
203
  HAL_Init();
204
 
205
  /* USER CODE BEGIN Init */
206
 
207
  /* USER CODE END Init */
208
 
209
  /* Configure the system clock */
210
  SystemClock_Config();
211
 
212
  /* USER CODE BEGIN SysInit */
213
 
214
  /* USER CODE END SysInit */
215
 
216
  /* Initialize all configured peripherals */
217
  MX_GPIO_Init();
218
  MX_DMA_Init();
219
  MX_ADC_Init();
220
  MX_TIM1_Init();
221
  MX_USART1_UART_Init();
222
  MX_TIM3_Init();
3 mjames 223
  MX_SPI1_Init();
2 mjames 224
  /* USER CODE BEGIN 2 */
225
 
3 mjames 226
        int i;
227
        for (i = 0; i < NUM_SAMPLES; i++)
228
                ADC_Samples[i] = 0;
2 mjames 229
 
3 mjames 230
        HAL_ADC_MspInit(&hadc);
2 mjames 231
 
3 mjames 232
        HAL_ADC_Start_DMA(&hadc, ADC_Samples, NUM_SAMPLES);
2 mjames 233
 
3 mjames 234
        HAL_ADC_Start_IT(&hadc);
2 mjames 235
 
3 mjames 236
        // timer 3 triggers the ADC
237
        HAL_TIM_Base_MspInit(&htim3);
238
        HAL_TIM_Base_Start_IT(&htim3);
2 mjames 239
 
3 mjames 240
        resetGauge();
2 mjames 241
 
3 mjames 242
  /* USER CODE END 2 */
2 mjames 243
 
3 mjames 244
  /* Infinite loop */
245
  /* USER CODE BEGIN WHILE */
246
        while (1) {
4 mjames 247
                sendLeds();
3 mjames 248
                HAL_Delay(10);
2 mjames 249
 
5 mjames 250
 
251
        uint16_t val = log2fix ( getADC(), 8);
252
 
253
        moveGauge(val * 4);
254
 
255
 
2 mjames 256
    /* USER CODE END WHILE */
257
 
258
    /* USER CODE BEGIN 3 */
3 mjames 259
        }
2 mjames 260
  /* USER CODE END 3 */
261
}
262
 
263
/**
264
  * @brief System Clock Configuration
265
  * @retval None
266
  */
267
void SystemClock_Config(void)
268
{
269
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
270
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
271
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
272
 
4 mjames 273
  /** Initializes the RCC Oscillators according to the specified parameters
274
  * in the RCC_OscInitTypeDef structure.
2 mjames 275
  */
276
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14;
277
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
278
  RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
279
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
280
  RCC_OscInitStruct.HSI14CalibrationValue = 16;
281
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
282
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
4 mjames 283
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
2 mjames 284
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
285
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
286
  {
287
    Error_Handler();
288
  }
4 mjames 289
  /** Initializes the CPU, AHB and APB buses clocks
2 mjames 290
  */
291
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
292
                              |RCC_CLOCKTYPE_PCLK1;
293
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
294
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
295
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
296
 
297
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
298
  {
299
    Error_Handler();
300
  }
301
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
302
  PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
303
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
304
  {
305
    Error_Handler();
306
  }
307
}
308
 
309
/**
310
  * @brief ADC Initialization Function
311
  * @param None
312
  * @retval None
313
  */
314
static void MX_ADC_Init(void)
315
{
316
 
317
  /* USER CODE BEGIN ADC_Init 0 */
318
 
319
  /* USER CODE END ADC_Init 0 */
320
 
321
  ADC_ChannelConfTypeDef sConfig = {0};
322
 
323
  /* USER CODE BEGIN ADC_Init 1 */
324
 
325
  /* USER CODE END ADC_Init 1 */
3 mjames 326
  /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
2 mjames 327
  */
328
  hadc.Instance = ADC1;
329
  hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
330
  hadc.Init.Resolution = ADC_RESOLUTION_12B;
331
  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
332
  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
333
  hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
334
  hadc.Init.LowPowerAutoWait = DISABLE;
335
  hadc.Init.LowPowerAutoPowerOff = DISABLE;
336
  hadc.Init.ContinuousConvMode = DISABLE;
337
  hadc.Init.DiscontinuousConvMode = DISABLE;
338
  hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
339
  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
340
  hadc.Init.DMAContinuousRequests = ENABLE;
341
  hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
342
  if (HAL_ADC_Init(&hadc) != HAL_OK)
343
  {
344
    Error_Handler();
345
  }
3 mjames 346
  /** Configure for the selected ADC regular channel to be converted.
2 mjames 347
  */
348
  sConfig.Channel = ADC_CHANNEL_0;
349
  sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
350
  sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES_5;
351
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
352
  {
353
    Error_Handler();
354
  }
355
  /* USER CODE BEGIN ADC_Init 2 */
356
 
357
  /* USER CODE END ADC_Init 2 */
358
 
359
}
360
 
361
/**
3 mjames 362
  * @brief SPI1 Initialization Function
363
  * @param None
364
  * @retval None
365
  */
366
static void MX_SPI1_Init(void)
367
{
368
 
369
  /* USER CODE BEGIN SPI1_Init 0 */
370
 
371
  /* USER CODE END SPI1_Init 0 */
372
 
373
  /* USER CODE BEGIN SPI1_Init 1 */
374
 
375
  /* USER CODE END SPI1_Init 1 */
376
  /* SPI1 parameter configuration*/
377
  hspi1.Instance = SPI1;
378
  hspi1.Init.Mode = SPI_MODE_MASTER;
379
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
380
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
381
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
382
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
383
  hspi1.Init.NSS = SPI_NSS_SOFT;
4 mjames 384
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
385
  hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB;
3 mjames 386
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
387
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
388
  hspi1.Init.CRCPolynomial = 7;
389
  hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
4 mjames 390
  hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
3 mjames 391
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
392
  {
393
    Error_Handler();
394
  }
395
  /* USER CODE BEGIN SPI1_Init 2 */
396
 
397
  /* USER CODE END SPI1_Init 2 */
398
 
399
}
400
 
401
/**
2 mjames 402
  * @brief TIM1 Initialization Function
403
  * @param None
404
  * @retval None
405
  */
406
static void MX_TIM1_Init(void)
407
{
408
 
409
  /* USER CODE BEGIN TIM1_Init 0 */
410
 
411
  /* USER CODE END TIM1_Init 0 */
412
 
413
  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
414
  TIM_MasterConfigTypeDef sMasterConfig = {0};
415
 
416
  /* USER CODE BEGIN TIM1_Init 1 */
417
 
418
  /* USER CODE END TIM1_Init 1 */
419
  htim1.Instance = TIM1;
420
  htim1.Init.Prescaler = 0;
421
  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
4 mjames 422
  htim1.Init.Period = 65535;
2 mjames 423
  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
424
  htim1.Init.RepetitionCounter = 0;
425
  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
426
  if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
427
  {
428
    Error_Handler();
429
  }
430
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
431
  if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
432
  {
433
    Error_Handler();
434
  }
435
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
436
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
437
  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
438
  {
439
    Error_Handler();
440
  }
441
  /* USER CODE BEGIN TIM1_Init 2 */
442
 
443
  /* USER CODE END TIM1_Init 2 */
444
 
445
}
446
 
447
/**
448
  * @brief TIM3 Initialization Function
449
  * @param None
450
  * @retval None
451
  */
452
static void MX_TIM3_Init(void)
453
{
454
 
455
  /* USER CODE BEGIN TIM3_Init 0 */
456
 
457
  /* USER CODE END TIM3_Init 0 */
458
 
459
  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
460
  TIM_MasterConfigTypeDef sMasterConfig = {0};
461
 
462
  /* USER CODE BEGIN TIM3_Init 1 */
463
 
464
  /* USER CODE END TIM3_Init 1 */
465
  htim3.Instance = TIM3;
466
  htim3.Init.Prescaler = 32;
467
  htim3.Init.CounterMode = TIM_COUNTERMODE_DOWN;
468
  htim3.Init.Period = 10000;
469
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
470
  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
471
  if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
472
  {
473
    Error_Handler();
474
  }
475
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
476
  if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
477
  {
478
    Error_Handler();
479
  }
480
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
481
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
482
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
483
  {
484
    Error_Handler();
485
  }
486
  /* USER CODE BEGIN TIM3_Init 2 */
487
 
488
  /* USER CODE END TIM3_Init 2 */
489
 
490
}
491
 
492
/**
493
  * @brief USART1 Initialization Function
494
  * @param None
495
  * @retval None
496
  */
497
static void MX_USART1_UART_Init(void)
498
{
499
 
500
  /* USER CODE BEGIN USART1_Init 0 */
501
 
502
  /* USER CODE END USART1_Init 0 */
503
 
504
  /* USER CODE BEGIN USART1_Init 1 */
505
 
506
  /* USER CODE END USART1_Init 1 */
507
  huart1.Instance = USART1;
508
  huart1.Init.BaudRate = 38400;
509
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
510
  huart1.Init.StopBits = UART_STOPBITS_1;
511
  huart1.Init.Parity = UART_PARITY_NONE;
512
  huart1.Init.Mode = UART_MODE_TX_RX;
513
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
514
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
515
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
516
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
517
  if (HAL_UART_Init(&huart1) != HAL_OK)
518
  {
519
    Error_Handler();
520
  }
521
  /* USER CODE BEGIN USART1_Init 2 */
522
 
523
  /* USER CODE END USART1_Init 2 */
524
 
525
}
526
 
3 mjames 527
/**
2 mjames 528
  * Enable DMA controller clock
529
  */
3 mjames 530
static void MX_DMA_Init(void)
2 mjames 531
{
532
 
533
  /* DMA controller clock enable */
534
  __HAL_RCC_DMA1_CLK_ENABLE();
535
 
536
  /* DMA interrupt init */
537
  /* DMA1_Channel1_IRQn interrupt configuration */
538
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
539
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
3 mjames 540
  /* DMA1_Channel2_3_IRQn interrupt configuration */
541
  HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0);
542
  HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
2 mjames 543
 
544
}
545
 
546
/**
547
  * @brief GPIO Initialization Function
548
  * @param None
549
  * @retval None
550
  */
551
static void MX_GPIO_Init(void)
552
{
553
  GPIO_InitTypeDef GPIO_InitStruct = {0};
554
 
555
  /* GPIO Ports Clock Enable */
556
  __HAL_RCC_GPIOA_CLK_ENABLE();
557
  __HAL_RCC_GPIOB_CLK_ENABLE();
558
 
559
  /*Configure GPIO pin Output Level */
3 mjames 560
  HAL_GPIO_WritePin(GPIOA, enableCurrent_Pin|step2N_Pin|step1N_Pin|step1P_Pin, GPIO_PIN_RESET);
2 mjames 561
 
562
  /*Configure GPIO pin Output Level */
3 mjames 563
  HAL_GPIO_WritePin(step2P_GPIO_Port, step2P_Pin, GPIO_PIN_RESET);
2 mjames 564
 
3 mjames 565
  /*Configure GPIO pins : enableCurrent_Pin step2N_Pin step1N_Pin step1P_Pin */
566
  GPIO_InitStruct.Pin = enableCurrent_Pin|step2N_Pin|step1N_Pin|step1P_Pin;
2 mjames 567
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
568
  GPIO_InitStruct.Pull = GPIO_NOPULL;
569
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
570
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
571
 
3 mjames 572
  /*Configure GPIO pin : step2P_Pin */
573
  GPIO_InitStruct.Pin = step2P_Pin;
2 mjames 574
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
575
  GPIO_InitStruct.Pull = GPIO_NOPULL;
576
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
3 mjames 577
  HAL_GPIO_Init(step2P_GPIO_Port, &GPIO_InitStruct);
2 mjames 578
 
579
}
580
 
581
/* USER CODE BEGIN 4 */
582
 
583
/* USER CODE END 4 */
584
 
585
/**
586
  * @brief  This function is executed in case of error occurrence.
587
  * @retval None
588
  */
589
void Error_Handler(void)
590
{
591
  /* USER CODE BEGIN Error_Handler_Debug */
3 mjames 592
        /* User can add his own implementation to report the HAL error return state */
2 mjames 593
 
594
  /* USER CODE END Error_Handler_Debug */
595
}
596
 
597
#ifdef  USE_FULL_ASSERT
598
/**
599
  * @brief  Reports the name of the source file and the source line number
600
  *         where the assert_param error has occurred.
601
  * @param  file: pointer to the source file name
602
  * @param  line: assert_param error line source number
603
  * @retval None
604
  */
4 mjames 605
void assert_failed(uint8_t *file, uint32_t line)
3 mjames 606
{
2 mjames 607
  /* USER CODE BEGIN 6 */
608
  /* User can add his own implementation to report the file name and line number,
609
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
610
  /* USER CODE END 6 */
611
}
612
#endif /* USE_FULL_ASSERT */
613
 
614
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/