凌云物联网实验室ISKBoard(IoT Starter Kits Board)开发板项目源码
guowenxue
2023-04-03 32806da6f5647ac637fa7d48aa9c221b091ab35e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 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.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "adc.h"
#include "can.h"
#include "usart.h"
#include "spi.h"
#include "tim.h"
#include "gpio.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <string.h>
#include "miscdev.h"
#include "ds18b20.h"
#include "sht20.h"
#include "isl1208.h"
#include "ws2812b.h"
#include "w25q32.h"
#include "comport.h"
#include "hal_oled.h"
#include "esp32.h"
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
 
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
 
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
 
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
 
/* USER CODE BEGIN PV */
 
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
 
/* USER CODE END PFP */
 
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
#define POS_X       5
#define POS_Y       1
#define SHOWTIME    800
#define BLOCK_TIME        0XFFFFFFFF
 
static inline void oled_show(char *msg)
{
    OLED_Init();
    OLED_ShowString(POS_X, POS_Y, msg, OLED_FONT16);
    HAL_Delay(SHOWTIME);
}
 
 
int test_beep(void);
int test_relay(void);
int test_led(void);
int test_wifi(void);
int test_adc(void);
int test_spiflash(void);
int test_ds18b20(void);
int test_sht20(void);
int test_rtc(void);
int test_usart3(void);
int test_can(void);
int test_rs485(void);
int test_mikrobus(void);
 
/* USER CODE END 0 */
 
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
    rtc_time_t       tm = { .tm_year=2023, .tm_mon=4, .tm_mday=2, .tm_hour=6, .tm_min=6, .tm_sec=6 };
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_USART3_UART_Init();
  MX_USART1_UART_Init();
  MX_LPUART1_UART_Init();
  MX_ADC1_Init();
  MX_TIM6_Init();
  MX_TIM1_Init();
  MX_SPI1_Init();
  MX_CAN1_Init();
  /* USER CODE BEGIN 2 */
 
  printf("Welcome to ISKBoard v1.0\r\n");
 
  OLED_Init();
  ws2812b_init();
  set_rtc_time(tm);
 
  test_beep();
  test_relay();
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
      test_mikrobus();
 
      test_spiflash();
      test_rtc();
      test_wifi();
 
      test_adc();
      test_ds18b20();
      test_sht20();
 
      test_usart3();
      test_can();
      test_rs485();
 
      test_led();
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
 
/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
  /** Configure the main internal regulator output voltage
  */
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
  {
    Error_Handler();
  }
 
  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 1;
  RCC_OscInitStruct.PLL.PLLN = 20;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
  RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
 
  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  {
    Error_Handler();
  }
}
 
/* USER CODE BEGIN 4 */
 
int test_beep(void)
{
    printf("Buzzer                    [TEST]\r\n");
    oled_show("Beep [TEST]");
    beep_start(2, 300);
 
    printf("\r\n");
    return 0;
}
 
int test_relay(void)
{
    printf("Relay                     [TEST]\r\n");
    oled_show("Relay [TEST]");
 
    turn_relay(ON);
    HAL_Delay(800);
    turn_relay(OFF);
 
    printf("\r\n");
    return 0;
}
 
#define MIKROBUS_PIN_GROUP      5
static gpio_t  mikrobus_pins[MIKROBUS_PIN_GROUP][2] =
{
        { {"AN", mikrobus_an_GPIO_Port, mikrobus_an_Pin}, {"RST", mikrobus_rst_GPIO_Port, mikrobus_rst_Pin} },
        { {"CS", mikrobus_cs_GPIO_Port, mikrobus_cs_Pin}, {"SCK", mikrobus_sck_GPIO_Port, mikrobus_sck_Pin} },
        { {"MISO", mikrobus_miso_GPIO_Port, mikrobus_miso_Pin}, {"MOSI", mikrobus_mosi_GPIO_Port, mikrobus_mosi_Pin} },
        { {"PWM", mikrobus_pwm_GPIO_Port, mikrobus_pwm_Pin}, {"INT", mikrobus_int_GPIO_Port, mikrobus_int_Pin} },
        /* RX3/TX3 initial as comport before, and test as comport but not GPIO mode */
        { {"SCL", mikrobus_scl_GPIO_Port, mikrobus_scl_Pin}, {"SDA", mikrobus_sda_GPIO_Port, mikrobus_sda_Pin} },
};
 
#define PIN_OUTPUT         1
#define PIN_INPUT          0
 
void set_gpio_mode(gpio_t pin, int mode)
{
    GPIO_InitTypeDef    GPIO_InitStruct = {0};
 
    if( PIN_INPUT == mode )
    {
        GPIO_InitStruct.Pin = pin.pin;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_NOPULL;
        HAL_GPIO_Init(pin.group, &GPIO_InitStruct);
    }
    else
    {
        GPIO_InitStruct.Pin = pin.pin;
        GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
        GPIO_InitStruct.Pull = GPIO_NOPULL;
        GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
        HAL_GPIO_Init(pin.group, &GPIO_InitStruct);
    }
 
}
 
int comport_test(UART_HandleTypeDef *huart)
{
    comport_t          *comport = NULL;
    char                buf[32] = { 0 };
    int                 rv = 0;
 
    comport = comport_open(huart);
    if( !comport )
    {
        //printf("%s() comport open failed\r\n", __func__);
        return -2;
    }
 
    comport_flush(comport);
    comport_send(comport, "ISKBoard", strlen("ISKBoard"));
    comport_recv(comport, buf, sizeof(buf), 50);
//    printf("%s() receive: %s\r\n", __func__, buf);
 
    if( strcmp(buf, "ISKBoard") )
    {
        rv = -3;
        goto cleanup;
    }
 
cleanup:
    comport_term(comport);
    return rv;
}
 
int rs485_test(UART_HandleTypeDef *huart)
{
    comport_t          *comport_rs485 = NULL;
    char                buf[32] = { 0 };
    int                 rv = 0;
 
    comport_rs485 = comport_open(huart);
    if( !comport_rs485 )
    {
        //printf("%s() comport open failed\r\n", __func__);
        return -2;
    }
 
    comport_flush(comport_rs485);
    rs485_recv(comport_rs485, buf, sizeof(buf), BLOCK_TIME);
//    printf("%s() receive: %s\r\n", __func__, buf);
 
    if( !strstr(buf, "PC2ISKBoard-RS485") )
    {
        rv = -3;
        goto cleanup;
    }else
    {
        rs485_send(comport_rs485, "ISKBoard2PC-RS485", strlen("ISKBoard2PC-RS485"));
    }
 
cleanup:
    rs485_term(comport_rs485);
    return rv;
}
 
int can_test(can_t *pcan)
{
    char                rx_data_buf[8] = { 0 };
    char                 test_data_buf[8] = {0x01, 0x02, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
    int                 rv = 0;
 
    if( !pcan )
    {
        //printf("%s() CAN open failed\r\n", __func__);
        return -2;
    }
 
    if(can_recv(pcan, rx_data_buf, sizeof(rx_data_buf), BLOCK_TIME) > 0)
    {
#if 0    //echo CAN recv 8bytes data
        printf("CAN RX DATA:");
        for(int i=0; i<sizeof(rx_data_buf); i++)
        {
            printf("0x%x ", rx_data_buf[i]);
        }
        printf("\r\n");
#endif
        if( !memcmp(test_data_buf, rx_data_buf, sizeof(test_data_buf)) )
        {
            can_send(pcan, test_data_buf, sizeof(test_data_buf));
        }else
        {
            rv = -3;
            goto cleanup;
        }
    }else
    {
        rv = -4;
        goto cleanup;
    }
 
cleanup:
    return rv;
}
 
int test_mikrobus(void)
{
    int                 i = 0, rv=0;
    int                 failed = 0;
 
 
    for(i=0; i<MIKROBUS_PIN_GROUP; i++)
    {
        /* Set pin as output/input mode */
        set_gpio_mode(mikrobus_pins[i][0], PIN_OUTPUT);
        set_gpio_mode(mikrobus_pins[i][1], PIN_INPUT);
 
        HAL_GPIO_WritePin(mikrobus_pins[i][0].group, mikrobus_pins[i][0].pin, GPIO_PIN_SET);
        if( GPIO_PIN_SET != HAL_GPIO_ReadPin(mikrobus_pins[i][1].group, mikrobus_pins[i][1].pin) )
        {
            failed = 1;
            break;
        }
 
        HAL_GPIO_WritePin(mikrobus_pins[i][0].group, mikrobus_pins[i][0].pin, GPIO_PIN_RESET);
        if( GPIO_PIN_RESET != HAL_GPIO_ReadPin(mikrobus_pins[i][1].group, mikrobus_pins[i][1].pin) )
        {
            failed = 1;
            break;
        }
 
        /* Set pin as output mode */
        set_gpio_mode(mikrobus_pins[i][1], PIN_OUTPUT);
        set_gpio_mode(mikrobus_pins[i][0], PIN_INPUT);
 
        HAL_GPIO_WritePin(mikrobus_pins[i][1].group, mikrobus_pins[i][1].pin, GPIO_PIN_SET);
        if( GPIO_PIN_SET != HAL_GPIO_ReadPin(mikrobus_pins[i][0].group, mikrobus_pins[i][0].pin) )
        {
            failed = 1;
            break;
        }
 
        HAL_GPIO_WritePin(mikrobus_pins[i][1].group, mikrobus_pins[i][1].pin, GPIO_PIN_RESET);
        if( GPIO_PIN_RESET != HAL_GPIO_ReadPin(mikrobus_pins[i][0].group, mikrobus_pins[i][0].pin) )
        {
            failed = 1;
            break;
        }
        printf("MikroBUS %4s<->%4s test [OKAY]\r\n", mikrobus_pins[i][0].name, mikrobus_pins[i][1].name);
    }
 
    if( failed )
    {
        printf("MikroBUS %4s<->%4s test [FAIL]\r\n", mikrobus_pins[i][0].name, mikrobus_pins[i][1].name);
        rv = -1;
        goto cleanup;
    }
 
    if( comport_test(&huart3) < 0 )
        printf("MikroBUS UART test        [FAIL]\r\n");
    else
        printf("MikroBUS UART test        [OKAY]\r\n");
 
cleanup:
    if( rv )
        oled_show("MikroBUS [FAIL]");
    else
        oled_show("MikroBUS [OK]");
 
    printf("\r\n");
    return 0;
}
 
int test_led(void)
{
    oled_show("LED [TEST]");
    printf("RGB Led                   [TEST]\r\n");
 
    blink_led(LedRed, 200);
    blink_led(LedGreen, 200);
    blink_led(LedBlue, 200);
 
    printf("Strip Lights              [TEST]\r\n");
    ws2812b_blink();
 
    printf("\r\n");
    return 0;
}
 
int test_spiflash(void)
{
    int              rv;
    char             oledstr[32] = {0};
 
    rv = w25q_Init();
    printf("SPI Flash W25Q32     test [%s]\r\n", rv?"FAIL":"OKAY");
    snprintf(oledstr, sizeof(oledstr), "W25Q: %s", rv?"FAIL":"OK");
    oled_show(oledstr);
 
    printf("\r\n");
    return 0;
}
 
 
int test_wifi(void)
{
    static int         init = 0;
    static comport_t  *comport = NULL;
    int                rv;
    char               oledstr[32] = {0};
    char               version[256] = {0};
 
    if( !init )
    {
        comport = comport_open(&huart2);
        if( !comport )
            return -1;
 
        esp32_hwreset(comport);
 
        esp32_set_echo(comport, DISABLE);
 
        rv = esp32_get_firmware(comport, version, sizeof(version));
        if( rv < 0)
        {
            printf("Query ESP32 firmware version failed: %d\r\n", rv);
            return rv;
        }
 
        printf("ESP32 firmware version:\r\n%s\r\n", version);
        init = 1;
    }
 
    rv = send_atcmd_check_ok(comport, "AT", 500);
 
    printf("WiFi module AT test       [%s]\r\n", rv?"FAIL":"OKAY");
    snprintf(oledstr, sizeof(oledstr), "WiFi: %s", rv?"FAIL":"OK");
    oled_show(oledstr);
 
    printf("\r\n");
    return 0;
}
 
int test_adc(void)
{
    char             oledstr[32] = {0};
    uint32_t         lux, noisy;
 
      adc_sample_lux_noisy(&lux, &noisy);
      printf("Lux: %lu Noisy: %lu\r\n", lux, noisy);
 
      printf("ADC(Lux/Noisy) test       [OKAY]\r\n");
      snprintf(oledstr, sizeof(oledstr), "lux:%lu db:%lu", lux, noisy);
      oled_show(oledstr);
 
      printf("\r\n");
      return 0;
}
 
int test_ds18b20(void)
{
    int              rv;
    float            temperature_f = 0.0;
    char             oledstr[32] = {0};
 
    rv = ds18b20_sample(&temperature_f);
    if( rv < 0 )
    {
        printf("DS18B20 test              [FAIL]\r\n");
          oled_show("DS18B20: [FAIL]");
        return -1;
    }
 
    printf("DS18B20 sample temperature: %.3f\'C\r\n", temperature_f);
    printf("DS18B20 test              [OKAY]\r\n");
 
      snprintf(oledstr, sizeof(oledstr), "DS18B20: %.3f", temperature_f);
      oled_show(oledstr);
 
      printf("\r\n");
      return 0;
}
 
int test_sht20(void)
{
    uint32_t         TrH, temperature, humdity;
    char             oledstr[32] = {0};
 
    TrH = sht20_sample_TrH(&temperature, &humdity);
    if( TRH_FAIL_VAL == TrH)
    {
        printf("SHT20 test                [FAIL]\r\n");
          oled_show("SHT20: [FAIL]");
        return -1;
 
    }
 
    printf("SHT20 sample temperature: %lu.%02lu\'C humidity: %lu.%02lu%%\r\n",
            temperature/100, temperature%100, humdity/100, humdity%100);
 
    printf("SHT20 test                [OKAY]\r\n");
 
    snprintf(oledstr, sizeof(oledstr), "SHT20: %lu.%02lu\'C", temperature/100, temperature%100);
      oled_show(oledstr);
 
    snprintf(oledstr, sizeof(oledstr), "SHT20: %lu.%02lu%%", humdity/100, humdity%100);
      oled_show(oledstr);
 
      printf("\r\n");
      return 0;
}
 
int test_rtc(void)
{
    char             oledstr[32] = {0};
    rtc_time_t       tm;
 
    if( get_rtc_time(&tm) < 0 )
        return -1;
 
    printf("RTC: %04d-%02d-%02d %02d:%02d:%02d %s\r\n", tm.tm_year, tm.tm_mon, tm.tm_mday,
        tm.tm_hour, tm.tm_min, tm.tm_sec, weekday[tm.tm_wday]);
 
    printf("RTC ISL1208 test          [OKAY]\r\n");
 
    snprintf(oledstr, sizeof(oledstr), "RTC: %04d-%02d-%02d", tm.tm_year, tm.tm_mon, tm.tm_mday);
      oled_show(oledstr);
 
    snprintf(oledstr, sizeof(oledstr), "RTC: %02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
      oled_show(oledstr);
 
      printf("\r\n");
    return 0;
}
 
int test_usart3(void)
{
    printf("Please switch USART3 to RS232.\r\n");
 
    if( comport_test(&huart3) < 0 )
    {
        printf("USART3 RS232 test         [FAIL]\r\n");
        oled_show("RS232  [FAIL]");
    }
    else
    {
        printf("USART3 RS232 test         [OKAY]\r\n");
        oled_show("RS232  [OK]");
    }
 
      printf("\r\n");
      return 0;
}
 
int test_can(void)
{
    printf("Please send {0x01, 0x02, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F} CAN frame data in PC.\r\n");
    if( can_test(&can) < 0 )
    {
        printf("CAN test                  [FAIL]\r\n");
        oled_show("CAN  [FAIL]");
    }
    else
    {
        printf("CAN test                  [OKAY]\r\n");
        oled_show("CAN  [OK]");
    }
 
      printf("\r\n");
      return 0;
}
 
int test_rs485(void)
{
    printf("Please send {PC2ISKBoard-RS485} rs485 data in PC.\r\n");
    if( rs485_test(&hlpuart1) < 0 )
    {
        printf("RS485 test                [FAIL]\r\n");
        oled_show("RS485  [FAIL]");
    }
    else
    {
        printf("RS485 test                [OKAY]\r\n");
        oled_show("RS485  [OK]");
    }
 
      printf("\r\n");
      return 0;
}
 
 
/* USER CODE END 4 */
 
/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}
 
#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */