Rev 13 | Rev 16 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 13 | Rev 14 | ||
|---|---|---|---|
| Line 66... | Line 66... | ||
| 66 | 66 | ||
| 67 | volatile char NoSerialInCTR = 0; // Missing characters coming in on USART1 |
67 | volatile char NoSerialInCTR = 0; // Missing characters coming in on USART1 |
| 68 | volatile char NoSerialIn = 0; |
68 | volatile char NoSerialIn = 0; |
| 69 | 69 | ||
| 70 | // storage for ADC |
70 | // storage for ADC |
| 71 | long ADC_Samples[6]; |
71 | uint16_t ADC_Samples[6]; |
| 72 | 72 | ||
| 73 | // Rev counter processing from original RevCounter Project |
73 | // Rev counter processing from original RevCounter Project |
| 74 | unsigned int RPM_Diff = 0; |
74 | unsigned int RPM_Diff = 0; |
| 75 | unsigned int RPM_Count_Latch = 0; |
75 | unsigned int RPM_Count_Latch = 0; |
| 76 | // accumulators |
76 | // accumulators |
| Line 267... | Line 267... | ||
| 267 | 267 | ||
| 268 | 268 | ||
| 269 | HAL_SPI_MspInit(&hspi1); |
269 | HAL_SPI_MspInit(&hspi1); |
| 270 | 270 | ||
| 271 | HAL_ADC_MspInit(&hadc); |
271 | HAL_ADC_MspInit(&hadc); |
| 272 | HAL_ADC_Start_DMA(&hadc, ADC_Samples, 6); |
- | |
| 273 | 272 | ||
| - | 273 | HAL_ADC_Start_DMA(&hadc, ADC_Samples, 6); |
|
| 274 | 274 | ||
| - | 275 | HAL_ADC_Start_IT(&hadc); |
|
| 275 | 276 | ||
| 276 | HAL_TIM_Base_MspInit(&htim6); |
277 | HAL_TIM_Base_MspInit(&htim6); |
| 277 | HAL_TIM_Base_Start_IT(&htim6); |
278 | HAL_TIM_Base_Start_IT(&htim6); |
| 278 | 279 | ||
| 279 | // initialise all the STMCubeMX stuff |
280 | // initialise all the STMCubeMX stuff |
| Line 329... | Line 330... | ||
| 329 | 330 | ||
| 330 | 331 | ||
| 331 | // send the observations |
332 | // send the observations |
| 332 | ProcessRPM(0); |
333 | ProcessRPM(0); |
| 333 | ProcessCHT(0); |
334 | ProcessCHT(0); |
| 334 | // ProcessBatteryVoltage(0); |
335 | ProcessBatteryVoltage(3); |
| 335 | // ProcessBatteryVoltage(1); |
336 | ProcessBatteryVoltage(1); |
| 336 | 337 | ||
| 337 | PutCharSerial(&uc1,PLX_Stop); |
338 | PutCharSerial(&uc1,PLX_Stop); |
| 338 | } |
339 | } |
| 339 | 340 | ||
| 340 | } |
341 | } |
| Line 405... | Line 406... | ||
| 405 | hadc.Init.ContinuousConvMode = DISABLE; |
406 | hadc.Init.ContinuousConvMode = DISABLE; |
| 406 | hadc.Init.NbrOfConversion = 6; |
407 | hadc.Init.NbrOfConversion = 6; |
| 407 | hadc.Init.DiscontinuousConvMode = DISABLE; |
408 | hadc.Init.DiscontinuousConvMode = DISABLE; |
| 408 | hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO; |
409 | hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO; |
| 409 | hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING; |
410 | hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING; |
| 410 | hadc.Init.DMAContinuousRequests = DISABLE; |
411 | hadc.Init.DMAContinuousRequests = ENABLE; |
| 411 | if (HAL_ADC_Init(&hadc) != HAL_OK) |
412 | if (HAL_ADC_Init(&hadc) != HAL_OK) |
| 412 | { |
413 | { |
| 413 | Error_Handler(); |
414 | Error_Handler(); |
| 414 | } |
415 | } |
| 415 | 416 | ||
| 416 | /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. |
417 | /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. |
| 417 | */ |
418 | */ |
| 418 | sConfig.Channel = ADC_CHANNEL_10; |
419 | sConfig.Channel = ADC_CHANNEL_10; |
| 419 | sConfig.Rank = 1; |
420 | sConfig.Rank = 1; |
| 420 | sConfig.SamplingTime = ADC_SAMPLETIME_4CYCLES; |
421 | sConfig.SamplingTime = ADC_SAMPLETIME_24CYCLES; |
| 421 | if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) |
422 | if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) |
| 422 | { |
423 | { |
| 423 | Error_Handler(); |
424 | Error_Handler(); |
| 424 | } |
425 | } |
| 425 | 426 | ||