Subversion Repositories DashDisplay

Rev

Rev 5 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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