too static, does not work

This commit is contained in:
2023-11-20 16:49:52 +01:00
parent e1f250e8f7
commit c08d15215b
5 changed files with 28 additions and 17 deletions

View File

@ -116,10 +116,11 @@ impl<'a> PeriodicTaskRunner<'a> {
fn execute(&mut self) {
sifln!("Task Runner {}", self.period);
loop {
self.task_object.perform();
unsafe {
task_delay(self.period);
}
// self.task_object.perform();
// unsafe {
// task_delay(self.period);
// }
unsafe { task_delay(200) };
}
}
}
@ -136,7 +137,12 @@ impl<'a, const STACKSIZE: usize> PeriodicTask<'a, STACKSIZE> {
};
let runner_pointer: *mut cty::c_void = &mut instance.runner as *mut _ as *mut cty::c_void;
let stack_pointer: *mut cty::c_void = &mut instance.stack as *mut _ as *mut cty::c_void;
sifln!("giving pointer {:p} {:p}", runner_pointer, &mut instance.runner as *mut PeriodicTaskRunner);
sifln!(
"giving pointer {:p} {:p}, instance {:p}",
runner_pointer,
&mut instance.runner as *mut PeriodicTaskRunner,
&instance as *const Self
);
unsafe {
instance.task = create_task(task_entry, runner_pointer, stack_pointer, STACKSIZE);
}
@ -208,7 +214,7 @@ struct MessageQueue<T, const LENGTH: usize> {
struct MessageQueueSender<T> {
queue_id: Option<*const cty::c_void>,
_unused: Option<T> //need to constrain the sender to one message type for safety, but compiler needs that to be used
_unused: Option<T>, //need to constrain the sender to one message type for safety, but compiler needs that to be used
}
impl<T: Copy, const LENGTH: usize> MessageQueue<T, LENGTH> {
@ -233,7 +239,7 @@ impl<T: Copy, const LENGTH: usize> MessageQueue<T, LENGTH> {
fn get_sender(&self) -> MessageQueueSender<T> {
let instance: MessageQueueSender<T> = MessageQueueSender::<T> {
queue_id: Some(self.queue_id),
_unused: None
_unused: None,
};
instance
}
@ -258,7 +264,7 @@ impl<T> MessageQueueSender<T> {
fn new() -> Self {
Self {
queue_id: None,
_unused: None
_unused: None,
}
}
@ -305,7 +311,6 @@ impl Write for Outbytes {
}
}
fn mission() {
sifln!("Mission enter");
@ -323,7 +328,13 @@ fn mission() {
let mut _t1: PeriodicTask<'_, 512> = PeriodicTask::new(&mut h1);
sifln!("mission pointer {:p}", &mut _t1.runner as *mut PeriodicTaskRunner);
sifln!(
"mission pointer {:p} {:p} {} {:p}",
&_t1 as *const PeriodicTask<512>,
&mut _t1.runner as *mut PeriodicTaskRunner,
core::mem::size_of::<PeriodicTaskRunner>(),
&_t1.stack as *const _
);
//let _t2: PeriodicTask<'_, 512> = PeriodicTask::new(&mut h2);