kopia lustrzana https://github.com/sq2ips/m20-custom-firmware
fix watchdog
rodzic
c76916ad41
commit
af87b8019c
|
@ -61,7 +61,6 @@ XMDATA GpsData;
|
||||||
|
|
||||||
#ifdef GPS_WATCHDOG
|
#ifdef GPS_WATCHDOG
|
||||||
uint8_t GpsWatchdogCounter = 0;
|
uint8_t GpsWatchdogCounter = 0;
|
||||||
bool PreviousFix = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t lps_init;
|
uint8_t lps_init;
|
||||||
|
@ -119,17 +118,13 @@ PUTCHAR_PROTOTYPE {
|
||||||
void main_loop(void) {
|
void main_loop(void) {
|
||||||
#ifdef GPS_WATCHDOG
|
#ifdef GPS_WATCHDOG
|
||||||
#if GPS_TYPE == 1
|
#if GPS_TYPE == 1
|
||||||
if (NmeaData.Fix > 1 && NmeaData.Sats > 0)
|
if (NmeaData.Fix <= 1 || NmeaData.Sats == 0) {
|
||||||
PreviousFix = true;
|
|
||||||
if (PreviousFix && (NmeaData.Fix <= 1 || NmeaData.Sats == 0)) {
|
|
||||||
GpsWatchdogCounter++;
|
GpsWatchdogCounter++;
|
||||||
} else {
|
} else {
|
||||||
GpsWatchdogCounter = 0;
|
GpsWatchdogCounter = 0;
|
||||||
}
|
}
|
||||||
#elif GPS_TYPE == 2
|
#elif GPS_TYPE == 2
|
||||||
if (GpsData.Fix > 0 && GpsData.Sats > 0)
|
if (GpsData.Fix == 0 || GpsData.Sats == 0) {
|
||||||
PreviousFix = true;
|
|
||||||
if (PreviousFix && (GpsData.Fix == 0 || GpsData.Sats == 0)) {
|
|
||||||
GpsWatchdogCounter++;
|
GpsWatchdogCounter++;
|
||||||
} else {
|
} else {
|
||||||
GpsWatchdogCounter = 0;
|
GpsWatchdogCounter = 0;
|
||||||
|
@ -137,8 +132,7 @@ void main_loop(void) {
|
||||||
#endif
|
#endif
|
||||||
if (GpsWatchdogCounter >= GPS_WATCHDOG) {
|
if (GpsWatchdogCounter >= GPS_WATCHDOG) {
|
||||||
LL_GPIO_ResetOutputPin(GPS_ON_GPIO_Port, GPS_ON_Pin); // disable GPS
|
LL_GPIO_ResetOutputPin(GPS_ON_GPIO_Port, GPS_ON_Pin); // disable GPS
|
||||||
while (1) {
|
while (1) {} // trigger a restart with IWDG
|
||||||
} // trigger a restart with IWDG
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// LED
|
// LED
|
||||||
|
|
Ładowanie…
Reference in New Issue