kopia lustrzana https://github.com/sq2ips/m20-custom-firmware
Added GPS watchdog.
rodzic
20e31dd0cd
commit
8672d67253
|
@ -18,6 +18,8 @@ const static float QRG_FSK4[] = {435100000}; // Transmitted frequencies array, s
|
|||
|
||||
#define GPS_TYPE 1 // Type of GPS module: 1 - u-blox | 2 - XM1110
|
||||
|
||||
#define GPS_WATCHDOG 3 // number of frames without gps fix to trigger restart
|
||||
|
||||
#define PA_FSK4 10 // RF power setting for horus transmission values 0-63
|
||||
#define RF_BOOST_ACTIVE 1 // RF booster enabled for transmissions about 15dB gain, but more power consumed - normally should be ON(1).
|
||||
|
||||
|
|
|
@ -59,6 +59,11 @@ const static uint8_t GPS_airborne[44] = {
|
|||
XMDATA GpsData;
|
||||
#endif
|
||||
|
||||
#ifdef GPS_WATCHDOG
|
||||
uint8_t GpsWatchdogCounter = 0;
|
||||
bool PreviousFix = false;
|
||||
#endif
|
||||
|
||||
uint8_t lps_init;
|
||||
|
||||
HorusBinaryPacket HorusPacket;
|
||||
|
@ -112,6 +117,30 @@ PUTCHAR_PROTOTYPE {
|
|||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
void main_loop(void) {
|
||||
#ifdef GPS_WATCHDOG
|
||||
#if GPS_TYPE == 1
|
||||
if (NmeaData.Fix > 1 && NmeaData.Sats > 0)
|
||||
PreviousFix = true;
|
||||
if (PreviousFix && (NmeaData.Fix <= 1 || NmeaData.Sats == 0)) {
|
||||
GpsWatchdogCounter++;
|
||||
} else {
|
||||
GpsWatchdogCounter = 0;
|
||||
}
|
||||
#elif GPS_TYPE == 2
|
||||
if (GpsData.Fix > 0 && GpsData.Sats > 0)
|
||||
PreviousFix = true;
|
||||
if (PreviousFix && (GpsData.Fix == 0 || GpsData.Sats == 0)) {
|
||||
GpsWatchdogCounter++;
|
||||
} else {
|
||||
GpsWatchdogCounter = 0;
|
||||
}
|
||||
#endif
|
||||
if (GpsWatchdogCounter >= GPS_WATCHDOG) {
|
||||
LL_GPIO_ResetOutputPin(GPS_ON_GPIO_Port, GPS_ON_Pin); // disable GPS
|
||||
while (1) {
|
||||
} // trigger a restart with IWDG
|
||||
}
|
||||
#endif
|
||||
// LED
|
||||
#if LED_MODE == 1
|
||||
LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
|
|
Ładowanie…
Reference in New Issue