Subversion Repositories EngineBay2

Rev

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

Rev 17 Rev 18
Line 2... Line 2...
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) 2017 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.
Line 82... Line 82...
82
unsigned int RPM_FilteredWidth = 0;
82
unsigned int RPM_FilteredWidth = 0;
83
 
83
 
84
unsigned int Coded_RPM = 0;
84
unsigned int Coded_RPM = 0;
85
unsigned int Coded_CHT = 0;
85
unsigned int Coded_CHT = 0;
86
 
86
 
-
 
87
uint32_t Power_CHT_Timer;
-
 
88
 
87
/* USER CODE END PV */
89
/* USER CODE END PV */
88
 
90
 
89
/* Private function prototypes -----------------------------------------------*/
91
/* Private function prototypes -----------------------------------------------*/
90
void SystemClock_Config(void);
92
void SystemClock_Config(void);
91
void Error_Handler(void);
93
void Error_Handler(void);
Line 124... Line 126...
124
 int i;
126
 int i;
125
 for(i=0;i<6;i++)
127
 for(i=0;i<6;i++)
126
 {
128
 {
127
        FILT_Samples[i] += (ADC_Samples[i] * Scale - FILT_Samples[i]) / 2;
129
        FILT_Samples[i] += (ADC_Samples[i] * Scale - FILT_Samples[i]) / 2;
128
 }
130
 }
129
 
-
 
130
 
-
 
131
 
-
 
132
}
131
}
133
 
132
 
134
 
133
 
135
void ProcessRPM(int instance) {
134
void ProcessRPM(int instance) {
136
// compute the timer values
135
// compute the timer values
Line 173... Line 172...
173
                }
172
                }
174
 
173
 
175
        }
174
        }
176
 
175
 
177
        if (RPM_Pulsecount > 0) {
176
        if (RPM_Pulsecount > 0) {
178
 
-
 
179
 
-
 
180
 
-
 
181
 
-
 
182
                // now have time for N pulses in clocks
177
                // now have time for N pulses in clocks
183
                // need to scale by 19.55: one unit is 19.55 RPM
178
                // need to scale by 19.55: one unit is 19.55 RPM
184
                // 1Hz is 60 RPM
179
                // 1Hz is 60 RPM
185
                float new_RPM = (30.0 / 19.55 * RPM_Pulsecount * RPM_COUNT_RATE)
180
                float new_RPM = (30.0 / 19.55 * RPM_Pulsecount * RPM_COUNT_RATE)
186
                                                / (RPM_FilteredWidth) + 0.5;
181
                                                / (RPM_FilteredWidth) + 0.5;
Line 198... Line 193...
198
        plx_sendword(PLX_RPM);
193
        plx_sendword(PLX_RPM);
199
        PutCharSerial(&uc1, instance);
194
        PutCharSerial(&uc1, instance);
200
        plx_sendword(Coded_RPM/Scale);
195
        plx_sendword(Coded_RPM/Scale);
201
}
196
}
202
 
197
 
203
uint8_t CHT_Timer = 0;
-
 
204
 
198
 
205
// this uses a MAX6675 which is a simple 16 bit read
199
// this uses a MAX6675 which is a simple 16 bit read
206
// SPI is configured for 8 bits so I can use an OLED display if I need it
200
// SPI is configured for 8 bits so I can use an OLED display if I need it
207
// must wait > 0.22 seconds between conversion attempts as this is the measurement time
201
// must wait > 0.22 seconds between conversion attempts as this is the measurement time
208
//
202
//
-
 
203
 
209
void ProcessCHT(int instance)
204
uint8_t CHT_Timer[2] = { 0, 0 }; // two temperature readings
210
{
205
 
-
 
206
void ProcessCHT(int instance) {
211
        uint8_t buffer[2];
207
        uint8_t buffer[2];
-
 
208
        if (instance > 2)
-
 
209
                return;
212
        CHT_Timer++;
210
        CHT_Timer[instance]++;
213
        if(CHT_Timer >= 3) // every 300 milliseconds
211
        if (CHT_Timer[instance] >= 3) // every 300 milliseconds
214
 
212
 
215
        {
213
                        {
216
                CHT_Timer=0;
214
                CHT_Timer[instance] = 0;
217
 
215
 
218
                   HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, SPI_NS_Temp_Pin, GPIO_PIN_RESET);
216
                uint16_t Pin = (instance == 0) ? SPI_NS_Temp_Pin : SPI_NS_Temp2_Pin;
219
 
217
 
220
                   HAL_SPI_Receive(&hspi1, buffer, 2, 2);
218
                HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, Pin, GPIO_PIN_RESET);
221
 
219
 
222
                   HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, SPI_NS_Temp_Pin, GPIO_PIN_SET);
220
                HAL_SPI_Receive(&hspi1, buffer, 2, 2);
223
 
221
 
-
 
222
                HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, Pin, GPIO_PIN_SET);
224
 
223
 
225
                   uint16_t obs = (buffer[0]<<8)| buffer[1];
224
                uint16_t obs = (buffer[0] << 8) | buffer[1];
226
 
225
 
227
                   uint8_t  good = (obs & 4)==0;
226
                uint8_t good = (obs & 4) == 0;
228
                   if(good)
227
                if (good) {
229
                   {
-
 
230
                     Coded_CHT = obs>>5;
228
                        Coded_CHT = obs >> 5;
231
                   }
-
 
232
                   else
229
                } else {
233
                   {
-
 
234
                          Coded_CHT= 1024; // signal fail
230
                        Coded_CHT = 1024; // signal fail
235
                   }
231
                }
236
        }
232
        }
237
 
233
 
238
        plx_sendword(PLX_X_CHT);
234
        plx_sendword(PLX_X_CHT);
239
        PutCharSerial(&uc1, instance);
235
        PutCharSerial(&uc1, instance);
240
        plx_sendword(Coded_CHT);
236
        plx_sendword(Coded_CHT);
241
 
237
 
242
}
238
}
243
 
239
 
244
// 1023 is 20.00 volts.
240
// 1023 is 20.00 volts.
245
void ProcessBatteryVoltage(int instance)
241
void ProcessBatteryVoltage(int instance) {
246
{
-
 
247
    float reading = FILT_Samples[instance] * ADC_Scale ;
242
        float reading = FILT_Samples[instance] * ADC_Scale;
248
    reading = reading * 7.8125; // real voltage
243
        reading = reading * 7.8125; // real voltage
249
    reading = reading * 51.15 ; // 1023/20
244
        reading = reading * 51.15; // 1023/20
250
 
-
 
251
 
245
 
252
        plx_sendword(PLX_Volts);
246
        plx_sendword(PLX_Volts);
253
        PutCharSerial(&uc1, instance);
247
        PutCharSerial(&uc1, instance);
254
        plx_sendword((uint16_t)reading);
248
        plx_sendword((uint16_t) reading);
-
 
249
 
-
 
250
}
255
 
251
 
-
 
252
/****!
-
 
253
 * @brief this reads the reference voltage within the STM32L151
-
 
254
 * Powers up reference voltage and temperature sensor, waits 3mS  and takes reading
-
 
255
 * Requires that the ADC be powered up
-
 
256
 */
256
 
257
 
-
 
258
uint32_t ADC_VREF_MV = 3300;           // 3.300V typical
-
 
259
const uint16_t STM32REF_MV = 1224;           // 1.224V typical
-
 
260
 
-
 
261
void CalibrateADC(void) {
-
 
262
        uint32_t adc_val = FILT_Samples[6];       // as set up in device config
-
 
263
        ADC_VREF_MV = (STM32REF_MV * 4096) / adc_val;
-
 
264
}
-
 
265
 
-
 
266
void ProcessCPUTemperature(int instance) {
-
 
267
        int32_t temp_val;
-
 
268
        uint16_t TS_CAL30 = *(uint16_t *) 0x1FF8007A; /* ADC reading for temperature sensor at 30 degrees C with Vref = 3000mV */
-
 
269
        uint16_t TS_CAL110 = *(uint16_t *) 0x1FF8007E; /* ADC reading for temperature sensor at 110 degrees C with Vref = 3000mV */
-
 
270
        /* get the ADC reading corresponding to ADC channel 16 after turning on the ADC */
-
 
271
 
-
 
272
        temp_val = FILT_Samples[5];
-
 
273
 
-
 
274
        /* renormalise temperature value to account for different ADC Vref  : normalise to that which we would get for a 3000mV reference */
-
 
275
        temp_val = temp_val * ADC_VREF_MV / 3000UL;
-
 
276
 
-
 
277
        int32_t result = 800 * ((int32_t) temp_val - TS_CAL30);
-
 
278
        result = result / (TS_CAL110 - TS_CAL30) + 300;
-
 
279
 
-
 
280
    if(result < 0)
-
 
281
    {
-
 
282
        result = 0;
-
 
283
    }
-
 
284
        plx_sendword(PLX_FluidTemp);
-
 
285
        PutCharSerial(&uc1, instance);
-
 
286
        plx_sendword(result/10);
257
 
287
 
258
}
288
}
259
 
289
 
260
// the MAP sensor is giving us a reading of
290
// the MAP sensor is giving us a reading of
261
// 4.6 volts for 1019mB or 2.27 volts at the ADC input (resistive divider by 2.016)
291
// 4.6 volts for 1019mB or 2.27 volts at the ADC input (resistive divider by 2.016)
Line 263... Line 293...
263
 
293
 
264
void ProcessMAP(int instance)
294
void ProcessMAP(int instance)
265
{
295
{
266
// Using ADC_Samples[3] as the MAP input
296
// Using ADC_Samples[3] as the MAP input
267
    float reading = FILT_Samples[3] * ADC_Scale;
297
    float reading = FILT_Samples[3] * ADC_Scale;
268
    reading = reading * 2.016; // real voltage
298
    reading = reading * 2.016;      // real voltage
269
    reading = (reading-0.5) * 1000/ 4;
299
    reading = (reading) * 1000/ 4.5; // do not assume 0.5 volt offset : reading from 0 to 4.5 instead of 0.5 to 4.5
270
 
-
 
271
        plx_sendword(PLX_MAP);
300
        plx_sendword(PLX_MAP);
272
        PutCharSerial(&uc1, instance);
301
        PutCharSerial(&uc1, instance);
273
        plx_sendword((uint16_t)reading);
302
        plx_sendword((uint16_t)reading);
274
 
303
 
275
 
-
 
276
 
-
 
277
}
304
}
278
 
305
 
279
// the Oil pressi sensor is giving us a reading of
306
// the Oil pressi sensor is giving us a reading of
280
// 4.5 volts for 100 PSI or  2.25 volts at the ADC input (resistive divider by 2.016)
307
// 4.5 volts for 100 PSI or  2.25 volts at the ADC input (resistive divider by 2.016)
281
// I believe the sensor reads  4.5V at 100PSI and 0.5V at  0PSI
308
// I believe the sensor reads  4.5V at 100PSI and 0.5V at  0PSI
Line 290... Line 317...
290
 
317
 
291
        plx_sendword(PLX_FluidPressure);
318
        plx_sendword(PLX_FluidPressure);
292
        PutCharSerial(&uc1, instance);
319
        PutCharSerial(&uc1, instance);
293
        plx_sendword((uint16_t)reading);
320
        plx_sendword((uint16_t)reading);
294
 
321
 
295
 
-
 
296
 
-
 
297
}
322
}
298
 
323
 
299
 
324
 
300
 
325
 
301
void ProcessTiming(int instance)
326
void ProcessTiming(int instance)
Line 307... Line 332...
307
 
332
 
308
 
333
 
309
 
334
 
310
/* USER CODE END 0 */
335
/* USER CODE END 0 */
311
 
336
 
312
int main(void)
337
int main(void) {
313
{
-
 
314
 
338
 
315
  /* USER CODE BEGIN 1 */
339
        /* USER CODE BEGIN 1 */
316
 
340
 
317
  /* USER CODE END 1 */
341
        /* USER CODE END 1 */
318
 
342
 
319
  /* MCU Configuration----------------------------------------------------------*/
343
        /* MCU Configuration----------------------------------------------------------*/
320
 
344
 
321
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
345
        /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
322
  HAL_Init();
346
        HAL_Init();
323
 
347
 
324
  /* Configure the system clock */
348
        /* Configure the system clock */
325
  SystemClock_Config();
349
        SystemClock_Config();
326
 
350
 
327
  /* Initialize all configured peripherals */
351
        /* Initialize all configured peripherals */
328
  MX_GPIO_Init();
352
        MX_GPIO_Init();
329
  MX_DMA_Init();
353
        MX_DMA_Init();
330
  MX_ADC_Init();
354
        MX_ADC_Init();
331
  MX_SPI1_Init();
355
        MX_SPI1_Init();
332
  MX_TIM2_Init();
356
        MX_TIM2_Init();
333
  MX_TIM6_Init();
357
        MX_TIM6_Init();
334
  MX_USART2_UART_Init();
358
        MX_USART2_UART_Init();
335
  MX_USART1_UART_Init();
359
        MX_USART1_UART_Init();
336
 
360
 
337
  /* USER CODE BEGIN 2 */
361
        /* USER CODE BEGIN 2 */
338
        HAL_MspInit();
362
        HAL_MspInit();
339
 
363
 
340
// Not using HAL USART code
364
// Not using HAL USART code
341
        __HAL_RCC_USART1_CLK_ENABLE()
365
        __HAL_RCC_USART1_CLK_ENABLE()
342
        ; // PLX comms port
366
        ; // PLX comms port
Line 347... Line 371...
347
        init_usart_ctl(&uc2, huart2.Instance);
371
        init_usart_ctl(&uc2, huart2.Instance);
348
 
372
 
349
        EnableSerialRxInterrupt(&uc1);
373
        EnableSerialRxInterrupt(&uc1);
350
        EnableSerialRxInterrupt(&uc2);
374
        EnableSerialRxInterrupt(&uc2);
351
 
375
 
352
 
-
 
353
        HAL_SPI_MspInit(&hspi1);
376
        HAL_SPI_MspInit(&hspi1);
354
 
377
 
355
        HAL_ADC_MspInit(&hadc);
378
        HAL_ADC_MspInit(&hadc);
356
 
379
 
357
        HAL_ADC_Start_DMA(&hadc, ADC_Samples, 6);
380
        HAL_ADC_Start_DMA(&hadc, ADC_Samples, 6);
358
 
381
 
359
         HAL_ADC_Start_IT(&hadc);
382
        HAL_ADC_Start_IT(&hadc);
360
 
383
 
361
        HAL_TIM_Base_MspInit(&htim6);
384
        HAL_TIM_Base_MspInit(&htim6);
362
        HAL_TIM_Base_Start_IT(&htim6);
385
        HAL_TIM_Base_Start_IT(&htim6);
363
 
386
 
364
// initialise all the STMCubeMX stuff
387
// initialise all the STMCubeMX stuff
365
        HAL_TIM_Base_MspInit(&htim2);
388
        HAL_TIM_Base_MspInit(&htim2);
366
// Start the counter
389
// Start the counter
367
        HAL_TIM_Base_Start(&htim2);
390
        HAL_TIM_Base_Start(&htim2);
368
// Start the input capture and the interrupt
391
// Start the input capture and the interrupt
369
        HAL_TIM_IC_Start_IT(&htim2,TIM_CHANNEL_1);
392
        HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1);
370
 
393
 
371
        init_ADC_filter();
394
        init_ADC_filter();
372
 
395
 
-
 
396
        uint32_t Ticks = HAL_GetTick() + 100;
-
 
397
        int CalCounter = 0;
-
 
398
 
-
 
399
        Power_CHT_Timer = HAL_GetTick() + 10000; /* wait 10 seconds before powering up the CHT sensor */
-
 
400
 
373
  /* USER CODE END 2 */
401
        /* USER CODE END 2 */
374
 
402
 
375
  /* Infinite loop */
403
        /* Infinite loop */
376
  /* USER CODE BEGIN WHILE */
404
        /* USER CODE BEGIN WHILE */
377
        while (1) {
405
        while (1) {
378
  /* USER CODE END WHILE */
406
                /* USER CODE END WHILE */
379
 
407
 
380
  /* USER CODE BEGIN 3 */
408
                /* USER CODE BEGIN 3 */
381
     // check to see if we have any incoming data, copy and append if so, if no data then create our own frames.
-
 
382
                int c;
-
 
383
                char send = 0;
-
 
384
 
409
 
385
                // poll the  input for a stop bit or timeout
-
 
386
                if(PollSerial(&uc1))
410
                if (HAL_GetTick() > Ticks) {
387
                {
-
 
388
                  c = GetCharSerial(&uc1);
411
                        Ticks += 100;
389
                  if (c != PLX_Stop)
412
                        filter_ADC_samples();
390
                  {
-
 
391
                                PutCharSerial(&uc1,c); // echo all but the stop bit
413
                        // delay to calibrate ADC
392
                  } else { // must be a stop character
414
                        if (CalCounter < 500) {
393
                                send = 1; // start our sending process.
415
                                CalCounter += 100;
394
                        }
416
                        }
395
                }
-
 
396
 
417
 
397
                // sort out auto-sending
418
                        if (CalCounter == 400) {
398
                if (TimerFlag)
419
                                CalibrateADC();
399
                {
420
                        }
-
 
421
 
-
 
422
                        /* when the starter motor is on then power down the CHT sensors as they seem to fail */
-
 
423
 
400
                        TimerFlag = 0;
424
                        if (HAL_GPIO_ReadPin(STARTER_ON_GPIO_Port, STARTER_ON_Pin)
401
                  if (NoSerialIn)
425
                                        == GPIO_PIN_RESET) {
402
                  {
-
 
403
                        PutCharSerial(&uc1,PLX_Start);
426
                                HAL_GPIO_WritePin(ENA_AUX_5V_GPIO_Port, ENA_AUX_5V_Pin,
404
                        send = 1;
427
                                                GPIO_PIN_RESET);
405
                  }
428
                                Power_CHT_Timer = HAL_GetTick() + 500;
406
                }
-
 
407
                if (send)
429
                        } else
-
 
430
                        /* if the Power_CHT_Timer is set then wait for it to timeout, then power up CHT */
408
                {
431
                        {
409
                  send = 0;
432
                                if ((Power_CHT_Timer > 0)
410
 
-
 
-
 
433
                                                && (HAL_GetTick() > Power_CHT_Timer)) {
411
                  uint16_t val;
434
                                        Power_CHT_Timer = 0;
412
                  val = __HAL_TIM_GET_COMPARE(&htim2,TIM_CHANNEL_1);
435
                                        HAL_GPIO_WritePin(ENA_AUX_5V_GPIO_Port, ENA_AUX_5V_Pin,
413
          PutCharSerial(&uc2,(val&31) + 32);
436
                                                        GPIO_PIN_SET);
-
 
437
                                }
-
 
438
                        }
414
 
439
 
-
 
440
                        // check to see if we have any incoming data, copy and append if so, if no data then create our own frames.
-
 
441
                        int c;
-
 
442
                        char send = 0;
-
 
443
 
-
 
444
                        // poll the  input for a stop bit or timeout
-
 
445
                        if (PollSerial(&uc1)) {
-
 
446
                                c = GetCharSerial(&uc1);
-
 
447
                                if (c != PLX_Stop) {
-
 
448
                                        PutCharSerial(&uc1, c); // echo all but the stop bit
-
 
449
                                } else { // must be a stop character
-
 
450
                                        send = 1; // start our sending process.
-
 
451
                                }
-
 
452
                        }
415
 
453
 
-
 
454
                        // sort out auto-sending
-
 
455
                        if (TimerFlag) {
-
 
456
                                TimerFlag = 0;
-
 
457
                                if (NoSerialIn) {
-
 
458
                                        PutCharSerial(&uc1, PLX_Start);
-
 
459
                                        send = 1;
-
 
460
                                }
-
 
461
                        }
-
 
462
                        if (send) {
-
 
463
                                send = 0;
416
 
464
 
417
  // send the observations
-
 
418
         filter_ADC_samples();
-
 
419
                 ProcessRPM(0);
-
 
420
                 ProcessCHT(0);
465
                                uint16_t val;
421
                 ProcessBatteryVoltage(0); // Batt 1
-
 
422
                 ProcessBatteryVoltage(1); // Batt 2
-
 
423
//               ProcessBatteryVoltage(2); // oil pressure
-
 
424
//               ProcessBatteryVoltage(3); // MAP
-
 
425
                 ProcessBatteryVoltage(4); // temperature sensor
466
                                val = __HAL_TIM_GET_COMPARE(&htim2,TIM_CHANNEL_1);
426
//               ProcessBatteryVoltage(5); // vrefint
467
                                PutCharSerial(&uc2, (val & 31) + 32);
427
                 ProcessMAP(0);
-
 
428
                 ProcessOilPress(0);
-
 
429
                 ProcessTiming(0);
-
 
430
 
468
 
-
 
469
                                ProcessRPM(0);
-
 
470
 
-
 
471
                                ProcessCHT(0);
-
 
472
                        //      ProcessCHT(1);
-
 
473
                                ProcessBatteryVoltage(0); // Batt 1
431
                 PutCharSerial(&uc1,PLX_Stop);
474
                                ProcessBatteryVoltage(1); // Batt 2
-
 
475
 
-
 
476
                                ProcessCPUTemperature(0); //  built in temperature sensor
432
                }
477
 
-
 
478
                                ProcessMAP(0);
-
 
479
                                ProcessOilPress(0);
433
 
480
 
-
 
481
                                PutCharSerial(&uc1, PLX_Stop);
-
 
482
                        }
-
 
483
                }
434
        }
484
        }
435
  /* USER CODE END 3 */
485
        /* USER CODE END 3 */
436
 
486
 
437
}
487
}
438
 
-
 
439
/** System Clock Configuration
488
/** System Clock Configuration
440
*/
489
*/
441
void SystemClock_Config(void)
490
void SystemClock_Config(void)
442
{
491
{
443
 
492
 
Line 731... Line 780...
731
  __HAL_RCC_GPIOA_CLK_ENABLE();
780
  __HAL_RCC_GPIOA_CLK_ENABLE();
732
  __HAL_RCC_GPIOB_CLK_ENABLE();
781
  __HAL_RCC_GPIOB_CLK_ENABLE();
733
  __HAL_RCC_GPIOD_CLK_ENABLE();
782
  __HAL_RCC_GPIOD_CLK_ENABLE();
734
 
783
 
735
  /*Configure GPIO pins : PC13 PC14 PC15 PC6
784
  /*Configure GPIO pins : PC13 PC14 PC15 PC6
736
                           PC7 PC8 PC9 PC10
785
                           PC7 PC8 PC9 PC11
737
                           PC11 PC12 */
786
                           PC12 */
738
  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_6
787
  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_6
739
                          |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
788
                          |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11
740
                          |GPIO_PIN_11|GPIO_PIN_12;
789
                          |GPIO_PIN_12;
741
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
790
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
742
  GPIO_InitStruct.Pull = GPIO_NOPULL;
791
  GPIO_InitStruct.Pull = GPIO_NOPULL;
743
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
792
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
744
 
793
 
745
  /*Configure GPIO pins : PH0 PH1 */
794
  /*Configure GPIO pins : PH0 PH1 */
Line 768... Line 817...
768
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
817
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
769
  GPIO_InitStruct.Pull = GPIO_NOPULL;
818
  GPIO_InitStruct.Pull = GPIO_NOPULL;
770
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
819
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
771
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
820
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
772
 
821
 
773
  /*Configure GPIO pins : SPI_RESET_Pin SPI_NS_Temp_Pin */
822
  /*Configure GPIO pins : SPI_RESET_Pin SPI_NS_Temp_Pin SPI_NS_Temp2_Pin ENA_AUX_5V_Pin */
774
  GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NS_Temp_Pin;
823
  GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NS_Temp_Pin|SPI_NS_Temp2_Pin|ENA_AUX_5V_Pin;
775
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
824
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
776
  GPIO_InitStruct.Pull = GPIO_NOPULL;
825
  GPIO_InitStruct.Pull = GPIO_NOPULL;
777
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
826
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
778
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
827
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
779
 
828
 
780
  /*Configure GPIO pins : PB2 PB10 PB11 PB12
829
  /*Configure GPIO pins : PB11 PB12 PB13 PB14
781
                           PB13 PB14 PB15 PB3
830
                           PB15 PB3 PB4 PB5
782
                           PB4 PB5 PB6 PB7
831
                           PB6 PB7 PB8 PB9 */
783
                           PB8 PB9 */
-
 
784
  GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
832
  GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
785
                          |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_3
833
                          |GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
786
                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
834
                          |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
787
                          |GPIO_PIN_8|GPIO_PIN_9;
-
 
788
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
835
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
789
  GPIO_InitStruct.Pull = GPIO_NOPULL;
836
  GPIO_InitStruct.Pull = GPIO_NOPULL;
790
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
837
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
791
 
838
 
-
 
839
  /*Configure GPIO pin : STARTER_ON_Pin */
-
 
840
  GPIO_InitStruct.Pin = STARTER_ON_Pin;
-
 
841
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-
 
842
  GPIO_InitStruct.Pull = GPIO_NOPULL;
-
 
843
  HAL_GPIO_Init(STARTER_ON_GPIO_Port, &GPIO_InitStruct);
-
 
844
 
792
  /*Configure GPIO pin : PD2 */
845
  /*Configure GPIO pin : PD2 */
793
  GPIO_InitStruct.Pin = GPIO_PIN_2;
846
  GPIO_InitStruct.Pin = GPIO_PIN_2;
794
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
847
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
795
  GPIO_InitStruct.Pull = GPIO_NOPULL;
848
  GPIO_InitStruct.Pull = GPIO_NOPULL;
796
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
849
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
Line 803... Line 856...
803
 
856
 
804
  /*Configure GPIO pin Output Level */
857
  /*Configure GPIO pin Output Level */
805
  HAL_GPIO_WritePin(SPI1CD_GPIO_Port, SPI1CD_Pin, GPIO_PIN_RESET);
858
  HAL_GPIO_WritePin(SPI1CD_GPIO_Port, SPI1CD_Pin, GPIO_PIN_RESET);
806
 
859
 
807
  /*Configure GPIO pin Output Level */
860
  /*Configure GPIO pin Output Level */
808
  HAL_GPIO_WritePin(SPI_RESET_GPIO_Port, SPI_RESET_Pin, GPIO_PIN_RESET);
861
  HAL_GPIO_WritePin(GPIOB, SPI_RESET_Pin|SPI_NS_Temp2_Pin|ENA_AUX_5V_Pin, GPIO_PIN_RESET);
809
 
862
 
810
  /*Configure GPIO pin Output Level */
863
  /*Configure GPIO pin Output Level */
811
  HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, SPI_NS_Temp_Pin, GPIO_PIN_SET);
864
  HAL_GPIO_WritePin(SPI_NS_Temp_GPIO_Port, SPI_NS_Temp_Pin, GPIO_PIN_SET);
812
 
865
 
813
}
866
}