|
@@ -1,6 +1,7 @@
|
|
#![cfg_attr(test, allow(unused_imports))]
|
|
#![cfg_attr(test, allow(unused_imports))]
|
|
#![cfg_attr(not(test), no_std)]
|
|
#![cfg_attr(not(test), no_std)]
|
|
#![cfg_attr(not(test), no_main)]
|
|
#![cfg_attr(not(test), no_main)]
|
|
|
|
+// #![feature(generic_const_exprs)]
|
|
|
|
|
|
// custom panic handler
|
|
// custom panic handler
|
|
#[cfg(not(test))]
|
|
#[cfg(not(test))]
|
|
@@ -22,11 +23,28 @@ use stm32l4xx_hal::{
|
|
stm32::Interrupt,
|
|
stm32::Interrupt,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const TUSB322_ADDR: u8 = 0x47;
|
|
|
|
+
|
|
mod tusb322;
|
|
mod tusb322;
|
|
|
|
|
|
static FAULT_INT: Mutex<RefCell<Option<PA3<Input<PullUp>>>>> = Mutex::new(RefCell::new(None));
|
|
static FAULT_INT: Mutex<RefCell<Option<PA3<Input<PullUp>>>>> = Mutex::new(RefCell::new(None));
|
|
static FAULT_LED: Mutex<RefCell<Option<PC15<Output<PushPull>>>>> = Mutex::new(RefCell::new(None));
|
|
static FAULT_LED: Mutex<RefCell<Option<PC15<Output<PushPull>>>>> = Mutex::new(RefCell::new(None));
|
|
|
|
|
|
|
|
+// unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] {
|
|
|
|
+// core::slice::from_raw_parts(
|
|
|
|
+// (p as *const T) as *const u8,
|
|
|
|
+// core::mem::size_of::<T>(),
|
|
|
|
+// )
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// pub fn concat<T: Copy + Default, const A: usize, const B: usize>(a: &[T; A], b: &[T; B]) -> [T; A+B] {
|
|
|
|
+// let mut whole: [T; A+B] = [Default::default(); A+B];
|
|
|
|
+// let (one, two) = whole.split_at_mut(A);
|
|
|
|
+// one.copy_from_slice(a);
|
|
|
|
+// two.copy_from_slice(b);
|
|
|
|
+// whole
|
|
|
|
+// }
|
|
|
|
+
|
|
#[cfg(not(test))]
|
|
#[cfg(not(test))]
|
|
#[entry]
|
|
#[entry]
|
|
fn main() -> ! {
|
|
fn main() -> ! {
|
|
@@ -37,7 +55,6 @@ fn main() -> ! {
|
|
// Acquire a singleton instance for the chip's peripherals
|
|
// Acquire a singleton instance for the chip's peripherals
|
|
let mut dp = pac::Peripherals::take().unwrap();
|
|
let mut dp = pac::Peripherals::take().unwrap();
|
|
let cp = pac::CorePeripherals::take().unwrap();
|
|
let cp = pac::CorePeripherals::take().unwrap();
|
|
- // let cp = cortex_m::Peripherals::take().unwrap();
|
|
|
|
|
|
|
|
// Consume the raw peripheral and return a new object that implements a higher level API
|
|
// Consume the raw peripheral and return a new object that implements a higher level API
|
|
let mut flash = dp.FLASH.constrain();
|
|
let mut flash = dp.FLASH.constrain();
|
|
@@ -115,7 +132,7 @@ fn main() -> ! {
|
|
// Initialize I2C
|
|
// Initialize I2C
|
|
let mut i2c = I2c::i2c1(dp.I2C1, (scl, sda), 100.khz(), clocks, &mut rcc.apb1r1);
|
|
let mut i2c = I2c::i2c1(dp.I2C1, (scl, sda), 100.khz(), clocks, &mut rcc.apb1r1);
|
|
|
|
|
|
- tusb322::init(&mut i2c);
|
|
|
|
|
|
+ tusb322::init(TUSB322_ADDR, &mut i2c);
|
|
|
|
|
|
// Configure abstract timer that operates off systick timer
|
|
// Configure abstract timer that operates off systick timer
|
|
let mut timer = Delay::new(cp.SYST, clocks);
|
|
let mut timer = Delay::new(cp.SYST, clocks);
|