mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 21:51:46 +00:00
Change NRF_APM USB detection code (#3939)
This commit is contained in:
parent
040b851615
commit
cdf86f4166
@ -555,14 +555,24 @@ void Power::readPowerStatus()
|
|||||||
#ifdef NRF_APM // Section of code detects USB power on the RAK4631 and updates the power states. Takes 20 seconds or so to detect
|
#ifdef NRF_APM // Section of code detects USB power on the RAK4631 and updates the power states. Takes 20 seconds or so to detect
|
||||||
// changes.
|
// changes.
|
||||||
|
|
||||||
|
static nrfx_power_usb_state_t prev_nrf_usb_state = (nrfx_power_usb_state_t)-1; // -1 so that state detected at boot
|
||||||
nrfx_power_usb_state_t nrf_usb_state = nrfx_power_usbstatus_get();
|
nrfx_power_usb_state_t nrf_usb_state = nrfx_power_usbstatus_get();
|
||||||
|
|
||||||
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED) {
|
// If state changed
|
||||||
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
if (nrf_usb_state != prev_nrf_usb_state) {
|
||||||
NRF_USB = OptFalse;
|
// If changed to DISCONNECTED
|
||||||
} else {
|
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED) {
|
||||||
powerFSM.trigger(EVENT_POWER_CONNECTED);
|
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
||||||
NRF_USB = OptTrue;
|
NRF_USB = OptFalse;
|
||||||
|
}
|
||||||
|
// If changed to CONNECTED / READY
|
||||||
|
else {
|
||||||
|
powerFSM.trigger(EVENT_POWER_CONNECTED);
|
||||||
|
NRF_USB = OptTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache the current state
|
||||||
|
prev_nrf_usb_state = nrf_usb_state;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Notify any status instances that are observing us
|
// Notify any status instances that are observing us
|
||||||
|
Loading…
Reference in New Issue
Block a user