@@ -4,6 +4,8 @@ use critical_section::Mutex;
44use fugit:: { HertzU32 , RateExtU32 } ;
55#[ cfg( feature = "rp2040" ) ]
66use rp2040_hal as hal;
7+ #[ cfg( feature = "rp235x" ) ]
8+ use rp235x_hal as hal;
79use hal:: {
810 clocks:: init_clocks_and_plls,
911 gpio:: { FunctionI2C , Pin , PullUp } ,
@@ -17,15 +19,21 @@ use super::{Controller, FIFOBuffer, Generator, MutexCell, Target, TargetState};
1719
1820pub struct State {
1921 controller : Option < Controller > ,
20- timer : hal:: Timer ,
22+ #[ cfg( feature = "rp2040" ) ]
23+ timer : Timer ,
24+ #[ cfg( feature = "rp235x" ) ]
25+ timer : Timer < hal:: timer:: CopyableTimer0 > ,
2126 resets : hal:: pac:: RESETS ,
2227 ref_clock_freq : HertzU32 ,
2328}
2429
2530static TARGET : MutexCell < Option < Target > > = Mutex :: new ( RefCell :: new ( None ) ) ;
2631
2732static PAYLOAD : MutexCell < TargetState > = MutexCell :: new ( RefCell :: new ( TargetState :: new ( ) ) ) ;
33+ #[ cfg( feature = "rp2040" ) ]
2834static TIMER : MutexCell < Option < Timer > > = MutexCell :: new ( RefCell :: new ( None ) ) ;
35+ #[ cfg( feature = "rp235x" ) ]
36+ static TIMER : MutexCell < Option < Timer < hal:: timer:: CopyableTimer0 > > > = MutexCell :: new ( RefCell :: new ( None ) ) ;
2937
3038macro_rules! assert_vec_eq {
3139 ( $e: expr) => {
@@ -67,7 +75,10 @@ pub fn setup<T: ValidAddress>(xtal_freq_hz: u32, addr: T) -> State {
6775 . ok ( )
6876 . unwrap ( ) ;
6977
78+ #[ cfg( feature = "rp2040" ) ]
7079 let timer = hal:: Timer :: new ( pac. TIMER , & mut pac. RESETS , & clocks) ;
80+ #[ cfg( feature = "rp235x" ) ]
81+ let timer = hal:: Timer :: new_timer0 ( pac. TIMER0 , & mut pac. RESETS , & clocks) ;
7182
7283 // The single-cycle I/O block controls our GPIO pins
7384 let mut sio = hal:: Sio :: new ( pac. SIO ) ;
@@ -111,8 +122,8 @@ pub fn setup<T: ValidAddress>(xtal_freq_hz: u32, addr: T) -> State {
111122 . get_mut ( 1 )
112123 . expect ( "core 1 is not available" )
113124 . spawn ( STACK . take ( ) . unwrap ( ) , || {
114- pac :: NVIC :: unpend ( hal:: pac:: Interrupt :: I2C1_IRQ ) ;
115- pac :: NVIC :: unmask ( hal:: pac:: Interrupt :: I2C1_IRQ ) ;
125+ cortex_m :: peripheral :: NVIC :: unpend ( hal:: pac:: Interrupt :: I2C1_IRQ ) ;
126+ cortex_m :: peripheral :: NVIC :: unmask ( hal:: pac:: Interrupt :: I2C1_IRQ ) ;
116127
117128 loop {
118129 cortex_m:: asm:: wfi ( )
0 commit comments