Skip to content

Commit

Permalink
More work; remove device, as it seems to be best practices to leave t…
Browse files Browse the repository at this point in the history
…hat to the user
  • Loading branch information
Finomnis committed Nov 24, 2023
1 parent d7bc1b5 commit 47ff70a
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 269 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ optional = true
[dependencies.rtic-sync]
version = "1.0.2"

[dependencies.cortex-m]
version = "0.7"

#######################
# imxrt-rs dependencies
#######################
Expand Down Expand Up @@ -141,7 +144,6 @@ codegen-units = 256
######################################

[dev-dependencies]
cortex-m = "0.7"
imxrt-rt = { workspace = true }
menu = "0.4.0"
rtic = { version = "2.0.1", features = ["thumbv7-backend"] }
Expand Down
2 changes: 2 additions & 0 deletions run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cargo objcopy --example=hal_trng --features=board/teensy4 --target=thumbv7em-none-eabihf -- -O ihex firmware.hex
teensy_loader_cli --mcu=TEENSY40 -wsv .\firmware.hex
42 changes: 20 additions & 22 deletions src/common/lpspi.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
//! TODO
use eh1::delay::DelayUs;
pub use eh1::spi::Mode;

use imxrt_dma::channel::Channel;
use rtic_sync::arbiter::Arbiter;

use crate::{gpio, ral};
use crate::ral;
use cortex_m::interrupt::Mutex;

mod bus;
mod device;
mod disabled;
mod eh1_impl;
mod error;
mod status_watcher;

use status_watcher::StatusWatcher;

/// TODO
pub enum LpspiDma {
Expand Down Expand Up @@ -54,34 +57,29 @@ pub struct Pins<SDO, SDI, SCK> {
pub sck: SCK,
}

/// The internal driver implementation
struct LpspiDriver<const N: u8> {}

struct LpspiDataInner<const N: u8> {
driver: LpspiDriver<N>,
dma: LpspiDma,
clk_frequency: u32,
timer: Option<&'static mut dyn DelayUs>,
lpspi: ral::lpspi::Instance<N>,
// TODO: interrupt stuff
}

/// Static shared data allocated by the user
pub struct LpspiData<const N: u8> {
bus: Arbiter<LpspiDataInner<N>>,
// TODO: interrupt register struct
shared: Mutex<LpspiDataInner<N>>,
lpspi: status_watcher::StatusWatcher<N>,
}

/// TODO
pub struct LpspiBus<const N: u8> {
data: &'static LpspiData<N>,
mode: Mode,
baud_rate: u32,
pub struct Lpspi<'a, const N: u8> {
dma: LpspiDma,
source_clock_hz: u32,
data: &'a LpspiData<N>,
rx_fifo_size: u32,
tx_fifo_size: u32,
}

/// TODO
pub struct LpspiDevice<const N: u8, CS> {
data: &'static LpspiData<N>,
cs: gpio::Output<CS>,
/// An LPSPI peripheral which is temporarily disabled.
pub struct Disabled<'a, 'b, const N: u8> {
bus: &'a mut Lpspi<'b, N>,
men: bool,
}

/// TODO
Expand Down
Loading

0 comments on commit 47ff70a

Please sign in to comment.