implement HostPowerManagement for Model 100

This requires the corresponding change in the GD32 Arduino core
that adds USBCore_::isSuspended.

Signed-off-by: Taylor Yu <tlyu@mit.edu>
master
Taylor Yu 2 years ago
parent 9bf6eba010
commit 04d608c9f6

@ -20,6 +20,10 @@
#include <Arduino.h> // IWYU pragma: keep
#include <stdint.h> // for uint8_t
#ifdef ARDUINO_ARCH_GD32
#include "USBCore.h"
#endif
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK
// This is a terrible hack until Arduino#6964 gets implemented.
@ -54,6 +58,22 @@ EventHandlerResult HostPowerManagement::beforeEachCycle() {
}
#endif
#ifdef ARDUINO_ARCH_GD32
if (USBCore().isSuspended()) {
if (!was_suspended_) {
was_suspended_ = true;
hostPowerManagementEventHandler(Suspend);
} else {
hostPowerManagementEventHandler(Sleep);
}
} else {
if (was_suspended_) {
was_suspended_ = false;
hostPowerManagementEventHandler(Resume);
}
}
#endif
return EventHandlerResult::OK;
}

Loading…
Cancel
Save