Skip to content

fix: 24LC01 #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions board/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// "probe": "1366:0101:000801023227", // Modify to match yours if needed, or keep commented
"flashingConfig": {
"flashingEnabled": true,
"resetAfterFlashing": true,
"haltAfterReset": false
},
"coreConfigs": [
Expand All @@ -35,7 +34,6 @@
]
}
],
"runtimeExecutable": "probe-rs",
"env": {
// "RUST_LOG": "trace", // If you set this variable, check the VSCode console log window for the location of the log file.
"RUST_BACKTRACE": "1",
Expand Down Expand Up @@ -83,6 +81,50 @@
}
},
"consoleLogLevel": "Console", //Info, Debug
}
},
// Build Rust Binary in Release Mode (app)
{
"type": "probe-rs-debug",
"preLaunchTask": "RRIV: Build Release",
"request": "launch",
"name": "Build & Run Release Rust Binary",
"cwd": "${workspaceFolder}",
"chip": "STM32F103RE",
"wireProtocol": "Swd",
"runtimeExecutable":"probe-rs",
// "probe": "1366:0101:000801023227", // Modify to match yours if needed, or keep commented
"flashingConfig": {
"flashingEnabled": true,
"haltAfterReset": false
},
"coreConfigs": [
{
"programBinary": "${workspaceFolder}/target/thumbv7m-none-eabi/release/app",
"svdFile": "${workspaceFolder}/STM32F103xx.svd",
"rttEnabled": true,
"rttChannelFormats": [
{
"channelNumber": 0,
"dataFormat": "String", // Format RTT data as String data
"showTimestamps": true // Include host-side timestamps for every line of data transferred from the target RTT output
},
{
"channelNumber": 1,
"dataFormat": "BinaryLE" // Treat data as raw binary data, and do not format in any way
}
]
}
],
"env": {
// "RUST_LOG": "trace", // If you set this variable, check the VSCode console log window for the location of the log file.
"RUST_BACKTRACE": "1",
},
"linux": {
"env": {
"PATH": "${env:HOME}/.cargo/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${env:HOME}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin",
}
},
"consoleLogLevel": "Console", //Info, Debug
},
],
}
29 changes: 26 additions & 3 deletions board/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"version": "2.0.0",
"tasks": [
{
"label": "RRIV: Build Static C FFI Lib",
"label": "RRIV: Build App Binary Crate",
"type": "cargo",
"command": "build",
"args": [
"-p=rrivrust"
"-p=app"
],
"problemMatcher": [
"$rustc"
Expand All @@ -17,10 +17,11 @@
},
},
{
"label": "RRIV: Build App Binary Crate",
"label": "RRIV: Build Release App Binary Crate",
"type": "cargo",
"command": "build",
"args": [
"--release",
"-p=app"
],
"problemMatcher": [
Expand All @@ -30,6 +31,28 @@
"kind": "build",
"isDefault": false
},
},
{
"label": "RRIV: Clean",
"type": "cargo",
"command": "clean",
"args": [
"--release",
],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": false
},
},
{
"label": "RRIV: Build Release",
"dependsOn": [
"RRIV: Clean",
"RRIV: Build Release App Binary Crate"
]
},
{
"label": "RRIV: Build Board Crate",
Expand Down
20 changes: 12 additions & 8 deletions board/Cargo.lock

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

4 changes: 2 additions & 2 deletions board/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"

# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
# panic-halt = "0.2.0"panic = "abort"
panic-abort = "0.3.2"
panic-halt = "0.2.0"
# panic-abort = "0.3.2"
# panic_rtt = "0.3.0"


Expand Down
12 changes: 12 additions & 0 deletions board/app/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::process::Command;

fn macos_copy_memory_x() {
// Put `memory.x` in our output directory and ensure it's
Expand Down Expand Up @@ -46,4 +47,15 @@ fn main() {
// https://doc.rust-lang.org/rustc/command-line-arguments.html#option-l-search-path
println!("cargo:rustc-link-search=./target/thumbv7m-none-eabi/debug");
// println!("cargo:rustc-link-lib=static=rriv_0_4");

let branch = Command::new("git")
.arg("rev-parse")
.arg("--abbrev-ref")
.arg("HEAD")
.output()
.expect("Failed to get git branch");

let branch_name = String::from_utf8_lossy(&branch.stdout).trim().to_string();
println!("cargo:rustc-env=GIT_BRANCH={}", branch_name);

}
2 changes: 1 addition & 1 deletion board/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![feature(prelude_2024)]
#![no_main]

extern crate panic_abort;
extern crate panic_halt;

use core::{prelude::rust_2024::*, u8};
use cortex_m_rt::entry;
Expand Down
2 changes: 1 addition & 1 deletion board/rriv_board/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::boxed::Box;

pub const EEPROM_DATALOGGER_SETTINGS_SIZE: usize = 64;
pub const EEPROM_SENSOR_SETTINGS_SIZE: usize = 64;
pub const EEPROM_TOTAL_SENSOR_SLOTS: usize = 12;
pub const EEPROM_TOTAL_SENSOR_SLOTS: usize = 2;

enum AdcSelect {
Internal,
Expand Down
1 change: 1 addition & 0 deletions board/rriv_board_0_4_2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ usbd-serial = "0.1.1"
embedded-sdmmc = "0.6.0"
ds323x = "0.5.1"
one-wire-bus = "0.1.1"
i2c_hung_fix = "0.1.0"
11 changes: 10 additions & 1 deletion board/rriv_board_0_4_2/src/components/external_adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ impl ExternalAdc {
}
}





pub fn start(&mut self, delay: &mut impl embedded_hal::blocking::delay::DelayMs<u8> ) {
Expand All @@ -22,7 +24,14 @@ impl ExternalAdc {
pub fn enable(&mut self, delay: &mut impl embedded_hal::blocking::delay::DelayMs<u8>) {

self.pins.enable.set_low();
// delay.delay_ms(20); // let the chip get power, maybe not needed?
delay.delay_ms(250); // let the chip get power

}

pub fn disable(&mut self, delay: &mut impl embedded_hal::blocking::delay::DelayMs<u8>) {

self.pins.enable.set_high();
delay.delay_ms(250); // let the chip power down

}

Expand Down
5 changes: 4 additions & 1 deletion board/rriv_board_0_4_2/src/components/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ impl Storage {
let result = volume_manager.open_volume(embedded_sdmmc::VolumeIdx(0));
let volume = match result {
Ok(volume0) => {rprintln!("Volume 0 Success: {:?}", volume0); volume0 },
Err(error) => panic!("Volume 0 error: {:?}", error),
Err(error) => {
rprintln!("Volume 0 error: {:?}", error);
panic!("sd card error");
}
};

// let volume = volume_manager.open_volume(embedded_sdmmc::VolumeIdx(0)).unwrap();
Expand Down
Loading