Skip to content

Commit

Permalink
readd engine tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
FDSoftware committed Sep 16, 2023
1 parent 24071a9 commit 2aba55b
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 251 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lto = false

[dependencies]
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
cortex-m-rt = "0.7.3"
cortex-m-semihosting = "0.5.0"
embedded-hal = "0.2.7"

Expand All @@ -51,7 +51,6 @@ serde-json-core = "0.5.0"
postcard = "1.0.4"
micromath = "2.0.0"
panic-semihosting = "0.6.0"
rtic-sync = "1.0.2"

[dependencies.stm32f4xx-hal]
version = "0.14.0"
Expand Down
376 changes: 188 additions & 188 deletions src/app/tasks/engine.rs

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/app/tasks/ignition.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// use rtic::Mutex;
// use stm32f4xx_hal::gpio::ExtiPin;
// use crate::{
// app,
// };
// pub(crate) async fn ignition_schedule(mut ctx: app::ignition_schedule::Context) {
//
// }
//
//
//
//
use rtic::Mutex;
use stm32f4xx_hal::gpio::ExtiPin;
use crate::{
app,
};
pub(crate) async fn ignition_schedule(mut ctx: app::ignition_schedule::Context<'_>) {

}




2 changes: 1 addition & 1 deletion src/app/webserial.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrayvec::ArrayVec;
use rtic::Mutex;
use rtic_sync::channel::Sender;
// use rtic_sync::channel::Sender;
use usb_device::{
bus::{UsbBus, UsbBusAllocator},
device::{UsbDevice, UsbDeviceBuilder, UsbVidPid},
Expand Down
2 changes: 1 addition & 1 deletion src/app/webserial/handle_core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rtic_sync::channel::Sender;
// use rtic_sync::channel::Sender;
use crate::{
app,
app::webserial::{SerialCode, SerialMessage, SerialStatus},
Expand Down
68 changes: 33 additions & 35 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ use crate::app::{
memory::tables::{SpiT, Tables},
logging::host,
webserial::{handle_engine, handle_pmic, handle_realtime_data,handle_tables, send_message, SerialMessage, SerialStatus,finish_message},
// tasks::{engine::ckp_trigger, engine::motor_checks, ignition::ignition_schedule}
tasks::{engine::ckp_trigger, engine::motor_checks, ignition::ignition_schedule}
};

// use panic_halt as _;
use panic_semihosting as _;
#[rtic::app(device = stm32f4xx_hal::pac, peripherals = true, dispatchers = [TIM4, TIM7, TIM8_CC])]
mod app {
use super::*;
use rtic_sync::{channel::*, make_channel};
// use rtic_sync::{channel::*, make_channel};
pub mod debug;
pub mod engine;
pub mod gpio;
Expand Down Expand Up @@ -307,8 +307,8 @@ mod app {

let mut ckp_status = VRStatus::new();

// let (cdc_sender, cdc_receiver) = make_channel!(u32, CDC_CAPACITY);
static mut cdc_channel:Channel<u32,8> = Channel::new();
// let (cdc_sender, cdc_receiver) = make_channel!(u32, CDC_CAPACITY);
// static mut cdc_channel:Channel<u32,8> = Channel::new();

// let (cdc_sender,cdc_receiver) = unsafe {cdc_channel.split()};
// let cdc_s = cdc_sender.clone();
Expand Down Expand Up @@ -555,17 +555,6 @@ mod app {
}


// #[idle]
// async fn idle(_: idle::Context) -> ! {
// loop {
// sensors_callback::spawn().unwrap();
// // motor_checks::spawn().unwrap();
// // cortex_m::asm::wfi();
// Systick::delay(50.millis()).await;
// }
// }


//TODO: reciclar para encendido
#[task(binds = TIM2, priority = 1, local = [], shared = [timer, timer3, led])]
fn timer2_exp(mut ctx: timer2_exp::Context) {
Expand Down Expand Up @@ -634,30 +623,39 @@ mod app {
);

// from: https://github.com/noisymime/speeduino/blob/master/speeduino/decoders.ino#L453
// #[task(binds = EXTI9_5,
// local = [ckp],
// shared = [led, efi_status, flash_info, efi_cfg, timer, timer3, timer4, ckp, ign_pins]
// )]
// fn ckp_trigger(ctx: ckp_trigger::Context);
//
// #[task(
// shared = [led, efi_status, efi_cfg, timer3, timer4, ckp, ign_pins],
// priority = 1
// )]
// async fn ignition_schedule(ctx: ignition_schedule::Context);

// #[task(shared = [efi_cfg, ckp, timer4, efi_status,ignition_running], priority = 1)]
// async fn motor_checks(ctx: motor_checks::Context);
#[task(binds = EXTI9_5,
local = [ckp],
shared = [led, efi_status, flash_info, efi_cfg, timer, timer3, timer4, ckp, ign_pins]
)]
fn ckp_trigger(ctx: ckp_trigger::Context);

#[task(
shared = [led, efi_status, efi_cfg, timer3, timer4, ckp, ign_pins],
priority = 1
)]
async fn ignition_schedule(ctx: ignition_schedule::Context);

#[task(shared = [efi_cfg, ckp, timer4, efi_status,ignition_running], priority = 1)]
async fn motor_checks(ctx: motor_checks::Context);

}

#[task(shared = [usb_cdc], priority = 2)]
async fn webserial_sender(mut ctx:webserial_sender::Context, mut receiver: Receiver<'static, SerialMessage, CDC_CAPACITY>){
while let Ok(message) = receiver.recv().await {
ctx.shared.usb_cdc.lock(|cdc| {
cdc.write(&finish_message(message)).unwrap();
});
// #[task(shared = [usb_cdc], priority = 2)]
// async fn webserial_sender(mut ctx:webserial_sender::Context, mut receiver: Receiver<'static, SerialMessage, CDC_CAPACITY>){
// while let Ok(message) = receiver.recv().await {
// ctx.shared.usb_cdc.lock(|cdc| {
// cdc.write(&finish_message(message)).unwrap();
// });
// }
// }

#[task(priority = 2)]
async fn engine_loop(ctx: engine_loop::Context){
loop {
motor_checks::spawn().unwrap();
Systick::delay(10.micros()).await;
}

}

// #[idle]
Expand Down

0 comments on commit 2aba55b

Please sign in to comment.