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: add GetTimeMicros syscall

+25 -1
+16
eepy-sys/src/misc.rs
··· 11 11 pub enum MiscSyscall { 12 12 GetSerial = 0, 13 13 LogMessage = 1, 14 + GetTimeMicros = 2, 14 15 } 15 16 16 17 #[repr(usize)] ··· 87 88 88 89 pub fn error(message: &str) { 89 90 log(message, LogLevel::Error); 91 + } 92 + 93 + pub fn get_time_micros() -> u64 { 94 + let mut low_word: u32; 95 + let mut high_word: u32; 96 + 97 + unsafe { 98 + syscall!( 99 + SyscallNumber::Misc, 100 + out high_word in MiscSyscall::GetTimeMicros, 101 + out low_word, 102 + ) 103 + } 104 + 105 + ((high_word as u64) << 32) | low_word as u64 90 106 }
+9 -1
eepy/src/syscall.rs
··· 93 93 use defmt::{debug, error, info, trace, warn}; 94 94 use eepy_sys::header::{SLOT_SIZE, XIP_BASE}; 95 95 use eepy_sys::misc::{LogLevel, MiscSyscall}; 96 - use crate::SERIAL_NUMBER; 96 + use fw16_epd_bsp::pac::Peripherals; 97 + use crate::{SERIAL_NUMBER}; 97 98 use super::StackFrame; 98 99 99 100 pub(super) fn handle_misc(stack_values: &mut StackFrame) { 100 101 match MiscSyscall::from_repr(stack_values.r0) { 101 102 Some(MiscSyscall::GetSerial) => handle_get_serial(stack_values), 102 103 Some(MiscSyscall::LogMessage) => handle_log_message(stack_values), 104 + Some(MiscSyscall::GetTimeMicros) => handle_get_time_micros(stack_values), 103 105 None => panic!("illegal syscall"), 104 106 } 105 107 } ··· 125 127 LogLevel::Warn => warn!("[PROGRAM:{}] {}", slot_n, s), 126 128 LogLevel::Error => error!("[PROGRAM:{}] {}", slot_n, s), 127 129 } 130 + } 131 + 132 + fn handle_get_time_micros(stack_values: &mut StackFrame) { 133 + let timer = unsafe { Peripherals::steal() }.TIMER; 134 + stack_values.r1 = timer.timelr().read().bits() as usize; 135 + stack_values.r0 = timer.timehr().read().bits() as usize; 128 136 } 129 137 } 130 138