improve poweroff sequence

When powering off the modem, we must assert the RESET line only when the 
modem has shut down (otherwise it'll cause a hard reset and won't allow 
the modem to shut down properly).

This commit also polls the STATUS pin during poweroff and quits 
immediately once this pin goes high.
This commit is contained in:
Arnaud Ferraris
2020-12-10 17:05:44 +01:00
parent 1170a2c7f7
commit 47b2f71b6f
3 changed files with 27 additions and 8 deletions

View File

@@ -25,6 +25,16 @@ static gboolean quit_timeout_cb(struct EG25Manager *manager)
return FALSE;
}
static gboolean gpio_poll_cb(struct EG25Manager *manager)
{
if (gpio_check_poweroff(manager)) {
quit_timeout_cb(manager);
return FALSE;
}
return TRUE;
}
static gboolean quit_app(struct EG25Manager *manager)
{
g_message("Request to quit...");
@@ -33,10 +43,7 @@ static gboolean quit_app(struct EG25Manager *manager)
g_message("Powering down the modem...");
gpio_sequence_shutdown(manager);
manager->modem_state = EG25_STATE_FINISHING;
/*
* TODO: add a polling function to check STATUS and RI pins state
* (that way we could reduce the poweroff delay)
*/
g_timeout_add(500, G_SOURCE_FUNC(gpio_poll_cb), manager);
g_timeout_add_seconds(30, G_SOURCE_FUNC(quit_timeout_cb), manager);
}