Skip to content
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
218 changes: 124 additions & 94 deletions board/Cargo.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions board/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
embedded-hal = "0.2.7"
embedded-hal = "1.0"
nb = "1"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
Expand All @@ -21,6 +21,4 @@ rriv_board = { path = "../rriv_board" }
rriv_board_0_4_2 = { path = "../rriv_board_0_4_2" }
datalogger = { path = "../../src/datalogger" }

[dependencies.stm32f1xx-hal]
version = "0.10.0"
features = ["rt", "stm32f103", "high"]

15 changes: 9 additions & 6 deletions board/rriv_board_0_4_2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ edition = "2021"

[dependencies]
rriv_board = { path = "../rriv_board" }
embedded-hal = "0.2.7"
embedded-hal-02 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"], optional = true }
embedded-hal = { package = "embedded-hal", version = "1.0" }
embedded-hal-compat = "0.13.0"
stm32f1xx-hal = { git="https://github.com/stm32-rs/stm32f1xx-hal", features = ["stm32f103", "high"] }
nb = "1"
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"
unwrap-infallible = "0.1.5"
stm32f1xx-hal = { version = "0.10", features = ["rt", "stm32f103", "high"] }
rtt-target = "0.4.0"
usb-device = "0.2.9"
usbd-serial = "0.1.1"
embedded-sdmmc = "0.6.0"
ds323x = "0.5.1"
usb-device = "0.3.2"
usbd-serial = { git="https://github.com/nakajima/usbd-serial", rev="085c0bb" }
embedded-sdmmc = "0.8"
ds323x = "0.6.0"
usbd-storage = { version = "1.0.0", features = ["bbb", "ufi"] }
8 changes: 4 additions & 4 deletions board/rriv_board_0_4_2/src/components/eeprom.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

use embedded_hal::prelude::{
_embedded_hal_blocking_i2c_Read, _embedded_hal_blocking_i2c_Write,
_embedded_hal_blocking_i2c_WriteRead,
};
// use embedded_hal::prelude::{
// _embedded_hal_blocking_i2c_Read, _embedded_hal_blocking_i2c_Write,
// _embedded_hal_blocking_i2c_WriteRead,
// };
use crate::Board;
use rriv_board::RRIVBoard;
use rtt_target::{rprint, rprintln};
Expand Down
120 changes: 53 additions & 67 deletions board/rriv_board_0_4_2/src/components/internal_adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,78 @@ use stm32f1xx_hal::adc;
use stm32f1xx_hal::pac::ADC1;

pub struct InternalAdcConfiguration {
pins: pin_groups::InternalAdcPins,
adc_device: ADC1,
pins: pin_groups::InternalAdcPins,
adc_device: ADC1,
}

pub struct InternalAdc {
pins: pin_groups::InternalAdcPins,
adc: adc::Adc<ADC1>,
pins: pin_groups::InternalAdcPins,
adc: adc::Adc<ADC1>,
}

pub enum AdcError {
NBError(nb::Error<()>),
NotConfigured,
ReadError,
NBError(nb::Error<()>),
NotConfigured,
ReadError,
}

impl InternalAdcConfiguration {
pub fn new(pins: pin_groups::InternalAdcPins, adc1: ADC1) -> Self {
return InternalAdcConfiguration {
pins,
adc_device: adc1,
pub fn new(pins: pin_groups::InternalAdcPins, adc1: ADC1) -> Self {
return InternalAdcConfiguration {
pins,
adc_device: adc1,
};
}
}

pub fn build(self, clocks: &Clocks) -> InternalAdc {

let adc_device = self.adc_device;
let adc = adc::Adc::adc1(adc_device, *clocks);
return InternalAdc::new(self.pins, adc);
}
pub fn build(self, clocks: &Clocks) -> InternalAdc {
let adc_device = self.adc_device;
let adc = adc::Adc::adc1(adc_device, clocks);
return InternalAdc::new(self.pins, adc);
}
}

impl InternalAdc {
pub fn new(pins: pin_groups::InternalAdcPins, adc: adc::Adc<ADC1>) -> Self {

return InternalAdc {
pins,
adc,
pub fn new(pins: pin_groups::InternalAdcPins, adc: adc::Adc<ADC1>) -> Self {
return InternalAdc { pins, adc };
}
}

pub fn enable(&mut self, delay: &mut SysDelay) {
self.pins.enable_avdd.set_low();
delay.delay_ms(100_u16);
}

pub fn disable(&mut self){
self.pins.enable_avdd.set_high();
}


pub fn shutdown(mut self) -> InternalAdcConfiguration {
self.disable();
let adc_device = self.adc.release();
return InternalAdcConfiguration::new(self.pins, adc_device);

}

pub fn read(&mut self, channel: u8) -> Result<u16, AdcError> {
pub fn enable(&mut self, delay: &mut SysDelay) {
self.pins.enable_avdd.set_low();
delay.delay_ms(100_u16);
}

let res: Result<u16, nb::Error<()>> = match channel {
1 => self.adc.read(&mut self.pins.channel1),
2 => self.adc.read(&mut self.pins.channel2),
3 => self.adc.read(&mut self.pins.channel3),
4 => self.adc.read(&mut self.pins.channel4),
5 => self.adc.read(&mut self.pins.channel5),
_ => return Err(AdcError::ReadError)
};
pub fn disable(&mut self) {
self.pins.enable_avdd.set_high();
}


match res {
Ok(value) => return Ok(value),
Err(error) => return Err(AdcError::NBError(error)),
}

}
pub fn shutdown(mut self) -> InternalAdcConfiguration {
self.disable();
let adc_device = self.adc.release();
return InternalAdcConfiguration::new(self.pins, adc_device);
}

pub fn read_battery_level(&mut self) -> Result<u16, AdcError> {

let res = self.adc.read(&mut self.pins.vin_measure);

match res {
Ok(value) => return Ok(value),
Err(error) => return Err(AdcError::NBError(error)),
pub fn read(&mut self, channel: u8) -> Result<u16, AdcError> {
let res: Result<u16, nb::Error<()>> = match channel {
1 => self.adc.read(&mut self.pins.channel1),
2 => self.adc.read(&mut self.pins.channel2),
3 => self.adc.read(&mut self.pins.channel3),
4 => self.adc.read(&mut self.pins.channel4),
5 => self.adc.read(&mut self.pins.channel5),
_ => return Err(AdcError::ReadError),
};

match res {
Ok(value) => return Ok(value),
Err(error) => return Err(AdcError::NBError(error)),
}
}

}

pub fn read_battery_level(&mut self) -> Result<u16, AdcError> {
let res = self.adc.read(&mut self.pins.vin_measure);

}
match res {
Ok(value) => return Ok(value),
Err(error) => return Err(AdcError::NBError(error)),
}
}
}
Loading