firmware for my Touchscreen E-Paper Input Module for Framework Laptop 16
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

eepy-sys: add eep(); eepy-launcher: switch to eep()

arthomnix e45edf84 d316075f

+17 -6
+3 -6
eepy-launcher/src/main.rs
··· 6 6 7 7 extern crate panic_halt; 8 8 9 - use core::arch::asm; 10 9 use core::mem::offset_of; 11 10 use core::sync::atomic::Ordering; 12 11 use usb_device::bus::UsbBusAllocator; 13 12 use eepy_gui::draw_target::EpdDrawTarget; 14 13 use eepy_gui::element::Gui; 15 - use eepy_sys::input::{has_event, next_event, set_touch_enabled}; 14 + use eepy_sys::input::{eep, next_event, set_touch_enabled}; 16 15 use eepy_sys::misc::get_serial; 17 16 use eepy_sys::usb::{self, UsbBus}; 18 17 use usb_device::prelude::*; ··· 101 100 } else if NEEDS_REFRESH.swap(false, Ordering::Relaxed) { 102 101 gui.draw_init(&mut draw_target); 103 102 draw_target.refresh(false); 104 - } else if !has_event() { 105 - // has_event() is a syscall. The SVCall exception is a WFE wakeup event, so we need two 106 - // WFEs so we don't immediately wake up. 107 - unsafe { asm!("wfe", "wfe") }; 103 + } else { 104 + eep(); 108 105 } 109 106 } 110 107 }
+14
eepy-sys/src/input.rs
··· 1 + use core::arch::asm; 1 2 use core::mem::MaybeUninit; 2 3 use crate::{syscall, SafeOption}; 3 4 use crate::input_common::Event; ··· 47 48 } 48 49 49 50 has_event != 0 51 + } 52 + 53 + /// If there are no events remaining in the event queue, allow the processor to enter a sleep state 54 + /// until there is a new event ready. 55 + #[inline(always)] 56 + pub fn eep() { 57 + if !has_event() { 58 + // SAFETY: "wfe" only (maybe) puts the processor to sleep temporarily and doesn't access any 59 + // memory so this specific instruction is safe 60 + // has_event() is a syscall. The SVCall exception is a WFE wakeup event, so we need two 61 + // WFEs so we don't immediately wake up. 62 + unsafe { asm!("wfe", "wfe"); } 63 + } 50 64 }