Subversion Repositories DashDisplay

Rev

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

Rev Author Line No. Line
2 mjames 1
/**
5 mjames 2
  ******************************************************************************
3
  * File Name          : main.c
4
  * Description        : Main program body
5
  ******************************************************************************
6
  *
7
  * COPYRIGHT(c) 2016 STMicroelectronics
8
  *
9
  * Redistribution and use in source and binary forms, with or without modification,
10
  * are permitted provided that the following conditions are met:
11
  *   1. Redistributions of source code must retain the above copyright notice,
12
  *      this list of conditions and the following disclaimer.
13
  *   2. Redistributions in binary form must reproduce the above copyright notice,
14
  *      this list of conditions and the following disclaimer in the documentation
15
  *      and/or other materials provided with the distribution.
16
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
17
  *      may be used to endorse or promote products derived from this software
18
  *      without specific prior written permission.
19
  *
20
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
  *
31
  ******************************************************************************
32
  */
2 mjames 33
/* Includes ------------------------------------------------------------------*/
34
#include "stm32f1xx_hal.h"
35
 
36
/* USER CODE BEGIN Includes */
37
#include "ap_math.h"
38
#include "serial.h"
39
#include "SSD1306.h"
40
#include "dials.h"
4 mjames 41
#include "switches.h"
2 mjames 42
#include <math.h>
4 mjames 43
#include "plx.h"
2 mjames 44
 
45
/* USER CODE END Includes */
46
 
47
/* Private variables ---------------------------------------------------------*/
48
ADC_HandleTypeDef hadc1;
49
 
50
SPI_HandleTypeDef hspi1;
51
 
3 mjames 52
UART_HandleTypeDef huart1;
2 mjames 53
UART_HandleTypeDef huart2;
54
 
55
/* USER CODE BEGIN PV */
56
/* Private variables ---------------------------------------------------------*/
57
 
58
/* USER CODE END PV */
59
 
60
/* Private function prototypes -----------------------------------------------*/
61
void SystemClock_Config(void);
5 mjames 62
void Error_Handler(void);
2 mjames 63
static void MX_GPIO_Init(void);
64
static void MX_ADC1_Init(void);
65
static void MX_SPI1_Init(void);
66
static void MX_USART2_UART_Init(void);
3 mjames 67
static void MX_USART1_UART_Init(void);
2 mjames 68
 
69
/* USER CODE BEGIN PFP */
70
/* Private function prototypes -----------------------------------------------*/
71
 
72
/* USER CODE END PFP */
73
 
74
/* USER CODE BEGIN 0 */
75
/* dummy function */
76
void _init(void) {
77
 
78
}
79
 
80
/* USER CODE END 0 */
81
 
5 mjames 82
int main(void)
83
{
2 mjames 84
 
5 mjames 85
  /* USER CODE BEGIN 1 */
2 mjames 86
 
87
        GPIO_InitTypeDef GPIO_InitStruct;
88
 
89
        __HAL_RCC_SPI1_CLK_ENABLE()
90
        ;
4 mjames 91
        __HAL_RCC_USART1_CLK_ENABLE()
92
        ; // PLX main port
93
        __HAL_RCC_USART2_CLK_ENABLE()
94
        ; // debug port
5 mjames 95
  /* USER CODE END 1 */
2 mjames 96
 
5 mjames 97
  /* MCU Configuration----------------------------------------------------------*/
2 mjames 98
 
5 mjames 99
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
100
  HAL_Init();
2 mjames 101
 
5 mjames 102
  /* Configure the system clock */
103
  SystemClock_Config();
2 mjames 104
 
5 mjames 105
  /* Initialize all configured peripherals */
106
  MX_GPIO_Init();
107
 // MX_ADC1_Init();
108
  MX_SPI1_Init();
109
  MX_USART2_UART_Init();
110
  MX_USART1_UART_Init();
2 mjames 111
 
5 mjames 112
  /* USER CODE BEGIN 2 */
2 mjames 113
        /* Need to set AF mode for output pins DURR. */
114
        /* SPI bus AF pin selects */
115
        GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
116
 
117
        GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7;
118
        GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
119
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
120
 
121
        /* USART2 AF pin selects */
122
        GPIO_InitStruct.Pin = GPIO_PIN_2;
123
        GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
124
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
125
 
3 mjames 126
        /* USART1 AF pin selects */
127
        GPIO_InitStruct.Pin = GPIO_PIN_9;
128
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
2 mjames 129
 
130
        /* Turn on USART2 IRQ  */
131
        HAL_NVIC_SetPriority(USART2_IRQn, 4, 0);
132
        HAL_NVIC_EnableIRQ(USART2_IRQn);
133
 
3 mjames 134
        /* Turn on USART1 IRQ */
135
        HAL_NVIC_SetPriority(USART1_IRQn, 2, 0);
136
        HAL_NVIC_EnableIRQ(USART1_IRQn);
2 mjames 137
 
138
        /* setup the USART control blocks */
3 mjames 139
        init_usart_ctl(&uc1, huart1.Instance);
4 mjames 140
        init_usart_ctl(&uc2, huart2.Instance);
2 mjames 141
 
3 mjames 142
        EnableSerialRxInterrupt(&uc1);
2 mjames 143
        EnableSerialRxInterrupt(&uc2);
144
 
145
        ap_init(); // set up the approximate math library
146
 
5 mjames 147
        int disp;
148
        static const int xp = 128 - 42;
149
    for(disp=0; disp< 2; disp++)
150
    {
151
        select_display(disp);
152
           ssd1306_begin(1, 0);
153
           clearDisplay();
154
           dim(0);
2 mjames 155
        //font_puts(
156
        //              "Hello world !!\rThis text is a test of the text rendering library in a 5*7 font");
157
 
5 mjames 158
           dial_origin(xp, 40);
159
           dial_size(40);
160
           dial_draw_scale(10, 20, 16, 2);
2 mjames 161
 
5 mjames 162
        display();
2 mjames 163
 
5 mjames 164
    }
4 mjames 165
        InitSwitches();
2 mjames 166
 
5 mjames 167
        select_display(0);
168
  /* USER CODE END 2 */
4 mjames 169
 
5 mjames 170
  /* Infinite loop */
171
  /* USER CODE BEGIN WHILE */
4 mjames 172
        uint32_t Ticks = HAL_GetTick() + 100;
2 mjames 173
        int16_t dial0 = 0;
174
        int16_t dial1 = -1;
175
 
176
        int c = 0;
177
        int i;
178
        char buff[10];
179
 
4 mjames 180
        // PLX decoder protocol
181
#define MAXRDG 10
182
        char PLXPacket = 0;
183
        union {
184
                PLX_SensorInfo Sensor[MAXRDG];
185
                char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
2 mjames 186
 
4 mjames 187
        } Data;
188
        int Max[MAXRDG];
189
        int Min[MAXRDG];
190
        for (i = 0; i < MAXRDG; i++) {
191
                Max[i] = 0;
192
                Min[i] = 0xFFF; // 12 bit max value
193
        }
194
 
195
        int PLXPtr;
196
        int PLXItems;
197
 
198
        int OldObservation = -1; // illegal initial value
199
        int OldObservationIndex = -1; // if more than one sensor this will be printed
2 mjames 200
        while (1) {
4 mjames 201
// poll switches
202
                HandleSwitches();
203
                int ItemIndex  = dial_pos[0];
2 mjames 204
 
4 mjames 205
                uint16_t cc = SerialCharsReceived(&uc1);
206
                for (i = 0; i < cc; i++) {
207
                        char c = GetCharSerial(&uc1);
208
                        if (c == PLX_Start) // at any time if the start byte appears, reset the pointers
209
                                        {
210
                                PLXPtr = 0;    // reset the pointer
211
                                PLXPacket = 1;
212
                                continue;
213
                        }
214
 
215
                        if (c == PLX_Stop) {
216
                                // we can now decode the selected parameter
217
                                PLXPacket = 0;
218
                                PLXItems = PLXPtr / sizeof(PLX_SensorInfo);
219
                                // saturate the rotary switch position
220
                if(ItemIndex > PLXItems)
221
                {
222
                        dial_pos[0]= PLXItems;
223
                        ItemIndex = PLXItems;
224
                }
225
 
226
                                int DataVal;
227
                                // process min/max
228
                                for (i = 0; i < PLXItems; i++) {
229
                                        DataVal = ConvPLX(Data.Sensor[i].ObsH, Data.Sensor[i].ObsL);
230
                                        if (DataVal > Max[i]) {
231
                                                Max[i] = DataVal;
232
                                        }
233
                                        if (DataVal < Min[i]) {
234
                                                Min[i] = DataVal;
235
                                        }
236
                                }
237
 
238
                                DataVal = ConvPLX(Data.Sensor[ItemIndex].ObsH,
239
                                                Data.Sensor[ItemIndex].ObsL);
240
                                int Observation = ConvPLX(Data.Sensor[ItemIndex].ObsH,
241
                                                Data.Sensor[ItemIndex].ObsL);
5 mjames 242
                                int ObservationIndex = ConvPLX(0, Data.Sensor[ItemIndex].ObsIndex);
4 mjames 243
                                // now to convert the readings and format strings
244
                                // find out limits
245
                                if (Observation != OldObservation
246
                                                || ObservationIndex != OldObservationIndex) {
247
 
248
                                        dial_draw_scale(
249
                                                        DisplayInfo[Observation].Low
250
                                                                        / DisplayInfo[Observation].TickScale,
251
                                                        DisplayInfo[Observation].High
252
                                                                        / DisplayInfo[Observation].TickScale, 16,
253
                                                        1);
254
                                        int len;
255
                                        if (ObservationIndex > 0) {
256
                                                len=4;
257
                                                buff[5] = ObservationIndex + '1';
258
                                        } else {
259
                                                len=5;
260
                                        }
261
                                        for(i=0;i<len;i++)
262
                                        {
263
                                                buff[i] = DisplayInfo[Observation].name;
264
                                        }
265
                                        print_large_string(buff, 0, 0, 5); // this prints spaces for \0 at end of string
266
 
267
                                        OldObservation = Observation;
268
                                        OldObservationIndex = ObservationIndex;
269
                                }
270
                                //
271
 
272
                                double  max_rdg;
273
                                double  min_rdg;
274
                                double  cur_rdg;
275
 
276
                                max_rdg = ConveriMFDRaw2Data(Observation, DisplayInfo[Observation].Units, Max[ItemIndex]);
277
                                min_rdg = ConveriMFDRaw2Data(Observation, DisplayInfo[Observation].Units, Min[ItemIndex]);
278
                                cur_rdg = ConveriMFDRaw2Data(Observation, DisplayInfo[Observation].Units, DataVal);
279
 
280
 
281
 
282
 
283
 
284
                        }
285
                        if (c > PLX_Stop) // illegal char, restart reading
286
                                        {
287
                                PLXPacket = 0;
288
                        }
289
                        if (PLXPtr < sizeof(Data.Bytes)) {
290
                                Data.Bytes[PLXPtr++] = c;
291
                        }
292
                }
293
 
2 mjames 294
                HAL_Delay(1);
295
 
4 mjames 296
 
297
                /* now scale and decode the dial position etc .
298
                 *
299
                 */
2 mjames 300
                uint32_t CurrTicks = HAL_GetTick();
301
                if (CurrTicks > Ticks) {
4 mjames 302
                    /* Lookup the dial etc . */
303
 
304
 
305
                        Ticks = CurrTicks + 100;
2 mjames 306
                        /* old needle un-draw */
307
                        if (dial1 >= 0) {
308
                                dial_draw_needle(dial1);
309
                        }
310
                        // print value overlaid by needle
4 mjames 311
                        // this is actual reading
312
                        print_digits(xp - 16, 48, 4, 3, c);
2 mjames 313
 
314
                        dial_draw_needle(dial0);
315
                        dial1 = dial0;
316
 
317
                        c++;
318
                        //font_gotoxy(0, 2);
319
                        //font_puts("baud\r\n");
320
                        //char buff[10];
321
                        //itoa(hirda3.Init.BaudRate, buff, 10);
322
                        //char l = 6 - strlen(buff);
323
                        /* pad with leading spaces */
324
                        //while (l > 0) {
325
                        //      font_putchar(' ');
326
                        //      l--;
327
                        //}
328
                        //font_puts(itoa(hirda3.Init.BaudRate, buff, 10));
329
                        display();
330
                }
5 mjames 331
  /* USER CODE END WHILE */
2 mjames 332
 
5 mjames 333
  /* USER CODE BEGIN 3 */
2 mjames 334
 
335
        }
5 mjames 336
  /* USER CODE END 3 */
2 mjames 337
 
338
}
339
 
340
/** System Clock Configuration
5 mjames 341
*/
342
void SystemClock_Config(void)
343
{
2 mjames 344
 
5 mjames 345
  RCC_OscInitTypeDef RCC_OscInitStruct;
346
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
347
  RCC_PeriphCLKInitTypeDef PeriphClkInit;
2 mjames 348
 
5 mjames 349
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
350
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
351
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
352
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
353
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
354
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
355
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
356
  {
357
    Error_Handler();
358
  }
2 mjames 359
 
5 mjames 360
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
361
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
362
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
363
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
364
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
365
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
366
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
367
  {
368
    Error_Handler();
369
  }
2 mjames 370
 
5 mjames 371
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
372
  PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
373
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
374
  {
375
    Error_Handler();
376
  }
2 mjames 377
 
5 mjames 378
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
2 mjames 379
 
5 mjames 380
  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
2 mjames 381
 
5 mjames 382
  /* SysTick_IRQn interrupt configuration */
383
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
2 mjames 384
}
385
 
386
/* ADC1 init function */
5 mjames 387
static void MX_ADC1_Init(void)
388
{
2 mjames 389
 
5 mjames 390
  ADC_ChannelConfTypeDef sConfig;
2 mjames 391
 
5 mjames 392
    /**Common config
393
    */
394
  hadc1.Instance = ADC1;
395
  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
396
  hadc1.Init.ContinuousConvMode = DISABLE;
397
  hadc1.Init.DiscontinuousConvMode = DISABLE;
398
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
399
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
400
  hadc1.Init.NbrOfConversion = 1;
401
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
402
  {
403
    Error_Handler();
404
  }
2 mjames 405
 
5 mjames 406
    /**Configure Regular Channel
407
    */
408
  sConfig.Channel = ADC_CHANNEL_0;
409
  sConfig.Rank = 1;
410
  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
411
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
412
  {
413
    Error_Handler();
414
  }
2 mjames 415
 
416
}
417
 
418
/* SPI1 init function */
5 mjames 419
static void MX_SPI1_Init(void)
420
{
2 mjames 421
 
5 mjames 422
  hspi1.Instance = SPI1;
423
  hspi1.Init.Mode = SPI_MODE_MASTER;
424
  hspi1.Init.Direction = SPI_DIRECTION_1LINE;
425
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
426
  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
427
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
428
  hspi1.Init.NSS = SPI_NSS_SOFT;
429
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
430
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
431
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
432
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
433
  hspi1.Init.CRCPolynomial = 10;
434
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
435
  {
436
    Error_Handler();
437
  }
2 mjames 438
 
439
}
440
 
3 mjames 441
/* USART1 init function */
5 mjames 442
static void MX_USART1_UART_Init(void)
443
{
3 mjames 444
 
5 mjames 445
  huart1.Instance = USART1;
446
  huart1.Init.BaudRate = 115200;
447
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
448
  huart1.Init.StopBits = UART_STOPBITS_1;
449
  huart1.Init.Parity = UART_PARITY_NONE;
450
  huart1.Init.Mode = UART_MODE_TX_RX;
451
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
452
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
453
  if (HAL_UART_Init(&huart1) != HAL_OK)
454
  {
455
    Error_Handler();
456
  }
3 mjames 457
 
458
}
459
 
2 mjames 460
/* USART2 init function */
5 mjames 461
static void MX_USART2_UART_Init(void)
462
{
2 mjames 463
 
5 mjames 464
  huart2.Instance = USART2;
465
  huart2.Init.BaudRate = 115200;
466
  huart2.Init.WordLength = UART_WORDLENGTH_8B;
467
  huart2.Init.StopBits = UART_STOPBITS_1;
468
  huart2.Init.Parity = UART_PARITY_NONE;
469
  huart2.Init.Mode = UART_MODE_TX_RX;
470
  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
471
  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
472
  if (HAL_UART_Init(&huart2) != HAL_OK)
473
  {
474
    Error_Handler();
475
  }
2 mjames 476
 
477
}
478
 
479
/** Configure pins as
5 mjames 480
        * Analog
481
        * Input
482
        * Output
483
        * EVENT_OUT
484
        * EXTI
485
*/
486
static void MX_GPIO_Init(void)
487
{
2 mjames 488
 
5 mjames 489
  GPIO_InitTypeDef GPIO_InitStruct;
2 mjames 490
 
5 mjames 491
  /* GPIO Ports Clock Enable */
492
  __HAL_RCC_GPIOD_CLK_ENABLE();
493
  __HAL_RCC_GPIOA_CLK_ENABLE();
494
  __HAL_RCC_GPIOC_CLK_ENABLE();
495
  __HAL_RCC_GPIOB_CLK_ENABLE();
2 mjames 496
 
5 mjames 497
  /*Configure GPIO pin Output Level */
498
  HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET);
2 mjames 499
 
5 mjames 500
  /*Configure GPIO pin Output Level */
501
  HAL_GPIO_WritePin(SPI1CD_GPIO_Port, SPI1CD_Pin, GPIO_PIN_RESET);
2 mjames 502
 
5 mjames 503
  /*Configure GPIO pin Output Level */
504
  HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|USART3_INVERT_Pin|USB_PWR_Pin, GPIO_PIN_RESET);
2 mjames 505
 
5 mjames 506
  /*Configure GPIO pin Output Level */
507
  HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET);
2 mjames 508
 
5 mjames 509
  /*Configure GPIO pins : SPI_NSS1_Pin SPI1CD_Pin */
510
  GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI1CD_Pin;
511
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
512
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
513
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
2 mjames 514
 
5 mjames 515
  /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin USART3_INVERT_Pin USB_PWR_Pin */
516
  GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|USART3_INVERT_Pin|USB_PWR_Pin;
517
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
518
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
519
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
2 mjames 520
 
5 mjames 521
  /*Configure GPIO pins : SW1_PUSH_Pin SW1_I_Pin SW1_Q_Pin SW2_PUSH_Pin */
522
  GPIO_InitStruct.Pin = SW1_PUSH_Pin|SW1_I_Pin|SW1_Q_Pin|SW2_PUSH_Pin;
523
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
524
  GPIO_InitStruct.Pull = GPIO_PULLUP;
525
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
526
 
527
  /*Configure GPIO pins : SW2_I_Pin SW2_Q_Pin */
528
  GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin;
529
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
530
  GPIO_InitStruct.Pull = GPIO_PULLUP;
531
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
532
 
2 mjames 533
}
534
 
535
/* USER CODE BEGIN 4 */
536
 
537
/* USER CODE END 4 */
538
 
5 mjames 539
/**
540
  * @brief  This function is executed in case of error occurrence.
541
  * @param  None
542
  * @retval None
543
  */
544
void Error_Handler(void)
545
{
546
  /* USER CODE BEGIN Error_Handler */
547
  /* User can add his own implementation to report the HAL error return state */
548
  while(1)
549
  {
550
  }
551
  /* USER CODE END Error_Handler */
552
}
553
 
2 mjames 554
#ifdef USE_FULL_ASSERT
555
 
556
/**
5 mjames 557
   * @brief Reports the name of the source file and the source line number
558
   * where the assert_param error has occurred.
559
   * @param file: pointer to the source file name
560
   * @param line: assert_param error line source number
561
   * @retval None
562
   */
2 mjames 563
void assert_failed(uint8_t* file, uint32_t line)
564
{
5 mjames 565
  /* USER CODE BEGIN 6 */
2 mjames 566
        /* User can add his own implementation to report the file name and line number,
567
         ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
5 mjames 568
  /* USER CODE END 6 */
2 mjames 569
 
570
}
571
 
572
#endif
573
 
574
/**
5 mjames 575
  * @}
576
  */
2 mjames 577
 
578
/**
5 mjames 579
  * @}
580
*/
2 mjames 581
 
582
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/