Skip to content

Commit

Permalink
add AFR table, fix debug with GDB
Browse files Browse the repository at this point in the history
  • Loading branch information
FDSoftware committed Aug 9, 2023
1 parent 8f3cd71 commit a385ea9
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@
runner = "arm-none-eabi-gdb -q -x debug.gdb"

rustflags = [
# `flip-link` moves stack at the end of flash
#"-C", "linker=flip-link",
"-C", "link-arg=-Tlink.x",
# "-C", "link-arg=-Tdefmt.x",
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
#"-C", "link-arg=--nmagic",
]

[build]
target = "thumbv7em-none-eabihf"

[profile.dev]
debug = false
codegen-units = 1
opt-level = "s"

[profile.release]
debug = true
opt-level = "s"
lto = true

[alias]
b = ["build", "--release", "--target", "thumbv7em-none-eabihf"]
bd = ["build", "--target", "thumbv7em-none-eabihf"]
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ lto = true
codegen-units = 1
panic = "abort"
incremental = false
debug = false
debug = true

[profile.dev]
opt-level = 's'
strip = true
debug = false
codegen-units = 1
lto = false

Expand All @@ -29,7 +31,7 @@ cortex-m-rtic = "1.1.3"
cortex-m-semihosting = "0.5.0"
panic-halt = "0.2.0"
usb-device = "0.2.9"

# alloc-cortex-m = "0.4.0"
arrayvec = { version = "0.7.2", default-features = false }
numtoa = "0.2"
usbd-serial = "0.1.1"
Expand Down
3 changes: 3 additions & 0 deletions attach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cargo b
arm-none-eabi-gdb -x ./debug.gdb ./target/thumbv7em-none-eabihf/release/open_efi
13 changes: 11 additions & 2 deletions src/app/injection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ pub fn injection_setup(table: &mut Tables, flash: &mut FlashT, fi: &FlashInfo, c
max_y: 17,
};

let mut injector_delay = TableData {
let mut tps_rpm_afr = TableData {
data: None,
crc: 0,
address: 0x4,
max_x: 17,
max_y: 17,
};

let mut injector_delay = TableData {
data: None,
crc: 0,
address: 0x5,
max_x: 8,
max_y: 8,
};
Expand All @@ -30,13 +38,14 @@ pub fn injection_setup(table: &mut Tables, flash: &mut FlashT, fi: &FlashInfo, c
let mut load_tps_deg = TableData {
data: None,
crc: 0,
address: 0x5,
address: 0x10,
max_x: 17,
max_y: 17,
};

{
table.tps_rpm_ve = tps_rpm_ve.read_from_memory(flash, &fi, crc);
table.tps_rpm_afr = tps_rpm_afr.read_from_memory(flash, &fi, crc);
table.injector_delay = injector_delay.read_from_memory(flash, &fi, crc);
table.load_tps_deg = load_tps_deg.read_from_memory(flash, &fi, crc);
}
Expand Down
1 change: 1 addition & 0 deletions src/app/memory/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub type PlotData = [[i32; 2]; 10];
pub struct Tables {
// injection
pub tps_rpm_ve: Option<DataT>,
pub tps_rpm_afr: Option<DataT>,
pub injector_delay: Option<DataT>,
pub vbat_correction: Option<PlotData>,
pub wue: Option<PlotData>,
Expand Down
38 changes: 36 additions & 2 deletions src/app/webserial/handle_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ pub fn handler(
app::send_message::spawn(SerialStatus::Ok, 0, response_buf).unwrap();
return;
}
0x02 => {
// TPS RPM AFR
table = table_data.tps_rpm_afr.unwrap();
table[row_index] = table_row;
table_data.tps_rpm_afr = Some(table);
app::send_message::spawn(SerialStatus::Ok, 0, response_buf).unwrap();
return;
}
0x10 => {
// TPS RPM VE
// TODO: read table if not read prev.
Expand All @@ -138,7 +146,7 @@ pub fn handler(
app::send_message::spawn(SerialStatus::Ok, 0, response_buf).unwrap();
return;
}
0x2..0x9 | _ => {
0x3..0x9 | _ => {
logging::host::debug!("error on get");
app::send_message::spawn(
SerialStatus::Error,
Expand Down Expand Up @@ -182,6 +190,32 @@ pub fn handler(
.unwrap();
return;
}
0x02 => {
// TPS RPM AFR
let tps_rpm_ve = TableData {
data: table_data.tps_rpm_afr,
crc: 0,
address: 0x3,
max_x: 17,
max_y: 17,
};

if table_data.tps_rpm_ve.is_some() {
tps_rpm_ve.write_to_memory(flash, flash_info, crc);
app::send_message::spawn(SerialStatus::UploadOk, 0, response_buf).unwrap();
return;
}

logging::host::debug!("Table Write TableNotLoaded - TPS AFR");

app::send_message::spawn(
SerialStatus::Error,
SerialCode::TableNotLoaded as u8,
response_buf,
)
.unwrap();
return;
}

0x10 => {
// TPS RPM VE
Expand Down Expand Up @@ -210,7 +244,7 @@ pub fn handler(
return;
}

0x2..0x9 | _ => {
0x3..0x9 | _ => {

logging::host::debug!("error on write");
app::send_message::spawn(
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ mod app {
// EFI Setup:
let mut table = Tables {
tps_rpm_ve: None,
tps_rpm_afr: None,
injector_delay: None,
load_tps_deg: None,
// get not implemented
Expand Down

0 comments on commit a385ea9

Please sign in to comment.