alpha
Login
or
Join now
arthomnix.dev
/
eepy
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
firmware for my Touchscreen E-Paper Input Module for Framework Laptop 16
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
eepy: add GetTimeMicros syscall
author
arthomnix
date
1 year ago
(Feb 6, 2025, 6:19 PM UTC)
commit
95a717d7
95a717d70060588697b97a9b99e877f849e99d15
parent
0060e136
0060e1361a42aa69f932a044846a3af30d8f8254
+25
-1
2 changed files
Expand all
Collapse all
Unified
Split
eepy
src
syscall.rs
eepy-sys
src
misc.rs
+16
eepy-sys/src/misc.rs
Reviewed
···
11
11
pub enum MiscSyscall {
12
12
GetSerial = 0,
13
13
LogMessage = 1,
14
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
91
+
}
92
92
+
93
93
+
pub fn get_time_micros() -> u64 {
94
94
+
let mut low_word: u32;
95
95
+
let mut high_word: u32;
96
96
+
97
97
+
unsafe {
98
98
+
syscall!(
99
99
+
SyscallNumber::Misc,
100
100
+
out high_word in MiscSyscall::GetTimeMicros,
101
101
+
out low_word,
102
102
+
)
103
103
+
}
104
104
+
105
105
+
((high_word as u64) << 32) | low_word as u64
90
106
}
+9
-1
eepy/src/syscall.rs
Reviewed
···
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
96
-
use crate::SERIAL_NUMBER;
96
96
+
use fw16_epd_bsp::pac::Peripherals;
97
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
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
130
+
}
131
131
+
132
132
+
fn handle_get_time_micros(stack_values: &mut StackFrame) {
133
133
+
let timer = unsafe { Peripherals::steal() }.TIMER;
134
134
+
stack_values.r1 = timer.timelr().read().bits() as usize;
135
135
+
stack_values.r0 = timer.timehr().read().bits() as usize;
128
136
}
129
137
}
130
138