firmware for my Touchscreen E-Paper Input Module for Framework Laptop 16
at main 88 lines 2.2 kB view raw
1#![no_std] 2 3pub use eepy_derive::eepy_app; 4 5#[cfg(all(target_os = "none", target_arch = "arm"))] 6pub mod header; 7#[cfg(all(target_os = "none", target_arch = "arm"))] 8pub mod syscall; 9#[cfg(all(target_os = "none", target_arch = "arm"))] 10pub mod misc; 11#[cfg(all(target_os = "none", target_arch = "arm"))] 12pub mod image; 13#[cfg(all(target_os = "none", target_arch = "arm"))] 14pub mod input; 15#[cfg(all(target_os = "none", target_arch = "arm"))] 16pub mod usb; 17#[cfg(all(target_os = "none", target_arch = "arm"))] 18pub mod exec; 19#[cfg(all(target_os = "none", target_arch = "arm"))] 20pub mod critical_section; 21#[cfg(all(target_os = "none", target_arch = "arm"))] 22pub mod flash; 23#[cfg(all(target_os = "none", target_arch = "arm"))] 24pub mod kv_store; 25 26pub mod input_common; 27 28 29#[cfg(feature = "critical-section-impl")] 30#[cfg(all(target_os = "none", target_arch = "arm"))] 31mod critical_section_impl; 32 33pub use tp370pgh01::IMAGE_BYTES; 34 35/// FFI-safe version of the standard `Option` type. 36/// 37/// Convert to/from a standard `Option` using `.into()`. 38#[repr(C)] 39#[derive(Copy, Clone, Debug, Eq, PartialEq)] 40#[cfg_attr(feature = "defmt", derive(defmt::Format))] 41pub enum SafeOption<T> { 42 None, 43 Some(T), 44} 45 46impl<T> From<Option<T>> for SafeOption<T> { 47 fn from(value: Option<T>) -> Self { 48 match value { 49 None => SafeOption::None, 50 Some(v) => SafeOption::Some(v), 51 } 52 } 53} 54 55impl<T> From<SafeOption<T>> for Option<T> { 56 fn from(value: SafeOption<T>) -> Self { 57 match value { 58 SafeOption::None => None, 59 SafeOption::Some(v) => Some(v), 60 } 61 } 62} 63 64#[repr(C)] 65#[derive(Copy, Clone, Debug, Eq, PartialEq)] 66#[cfg_attr(feature = "defmt", derive(defmt::Format))] 67pub enum SafeResult<T, E> { 68 Ok(T), 69 Err(E), 70} 71 72impl<T, E> From<SafeResult<T, E>> for Result<T, E> { 73 fn from(value: SafeResult<T, E>) -> Self { 74 match value { 75 SafeResult::Ok(v) => Ok(v), 76 SafeResult::Err(e) => Err(e), 77 } 78 } 79} 80 81impl<T, E> From<Result<T, E>> for SafeResult<T, E> { 82 fn from(value: Result<T, E>) -> Self { 83 match value { 84 Ok(v) => SafeResult::Ok(v), 85 Err(e) => SafeResult::Err(e), 86 } 87 } 88}