diff --git a/.vscode/settings.json b/.vscode/settings.json index b9b769f..debaaee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -63,6 +63,7 @@ "cstdint": "c", "afsk.h": "c", "main.h": "c", - "lps22hb.h": "c" + "lps22hb.h": "c", + "config.h": "c" } } \ No newline at end of file diff --git a/m20/Core/Inc/main.h b/m20/Core/Inc/main.h index 3dc0ba3..f9806c4 100644 --- a/m20/Core/Inc/main.h +++ b/m20/Core/Inc/main.h @@ -50,7 +50,6 @@ extern "C" { /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ -#include "stm32l0xx_it.h" /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ diff --git a/m20/Core/Src/main.c b/m20/Core/Src/main.c index 5fabc47..99a9392 100644 --- a/m20/Core/Src/main.c +++ b/m20/Core/Src/main.c @@ -171,12 +171,7 @@ void main_loop(void) { LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_8); LL_ADC_REG_StartConversion(ADC1); while (LL_ADC_IsActiveFlag_EOC(ADC1) == 0) {} - // ADC voltage: 3.3V, divided by ADC max value 4095 (2^12-1). That gives a - // range between 0 for 0V and 1 for 3.3V. Than it's multiplied by max - // variable value: 255, and divided by corresponding voltage: 5V, simplified - // gives 187/4550 Note: this value will not go higher than 168 corresponding - // to 3.3V max value of ADC - BatVoltage = LL_ADC_REG_ReadConversionData12(ADC1); + BatVoltage = LL_ADC_REG_ReadConversionData12(ADC1); // Raw ADC value 0-4095 LL_ADC_ClearFlag_EOS(ADC1); #if DEBUG printf("Bat voltage value: %d\r\n", BatVoltage); @@ -311,6 +306,11 @@ DelayWithIWDG(2000); // ??? #endif HorusPacket.Temp = LpsTemp; + // ADC voltage: 3.3V, divided by ADC max value 4095 (2^12-1). That gives a + // range between 0 for 0V and 1 for 3.3V. Than it's multiplied by max + // variable value: 255, and divided by corresponding voltage: 5V, simplified + // gives 187/4550 Note: this value will not go higher than 168 corresponding + // to 3.3V max value of ADC HorusPacket.BatVoltage = (BatVoltage * 187) / 4550; HorusPacket.ExtTemp = ExtTemp; HorusPacket.Hum = 0; // Not implemented @@ -332,10 +332,6 @@ DelayWithIWDG(2000); // ??? #if GPS_WATCHDOG if (GpsWatchdog.TriggerRestart) { #if GPS_TYPE == 1 - while (false) { // todo fix - LL_IWDG_ReloadCounter(IWDG); - LL_mDelay(100); - } // Wait for end of transmission (and for GPS module to start). GpsAirborne(); // Send a command to GPS module to change to airborne mode. // clear GPS buffer needed? #endif diff --git a/m20/Core/Src/stm32l0xx_it.c b/m20/Core/Src/stm32l0xx_it.c index d1803bc..50a8d80 100644 --- a/m20/Core/Src/stm32l0xx_it.c +++ b/m20/Core/Src/stm32l0xx_it.c @@ -23,8 +23,12 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "config.h" +#if HORUS_ENABLE #include "fsk4.h" +#endif +#if APRS_ENABLE #include "afsk.h" +#endif /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -164,12 +168,12 @@ void TIM2_IRQHandler(void) void TIM6_DAC_IRQHandler(void) { /* USER CODE BEGIN TIM6_DAC_IRQn 0 */ -#if LED_MODE == 2 if(LL_TIM_IsActiveFlag_UPDATE(TIM6)){ LL_TIM_ClearFlag_UPDATE(TIM6); +#if LED_MODE == 2 LED_Handler(); - } #endif + } /* USER CODE END TIM6_DAC_IRQn 0 */ /* USER CODE BEGIN TIM6_DAC_IRQn 1 */