diff --git a/ad7147/src/device.rs b/ad7147/src/device.rs index 04a55a32c82d271611a1bb3911356ed5de7a4731..1d0352b86eb9c0184110630f7136b8507a31c394 100644 --- a/ad7147/src/device.rs +++ b/ad7147/src/device.rs @@ -221,10 +221,10 @@ impl<STATE, const S: usize> ConfigurationBuilder<STATE, S> { stages[i] = ext_stage.0; } - let mut calibration = [false; 12]; - let mut low_int = [false; 12]; - let mut high_int = [false; 12]; - let mut conv_int = [false; 12]; + let mut calibration = [false; 13]; + let mut low_int = [false; 13]; + let mut high_int = [false; 13]; + let mut conv_int = [false; 13]; for (i, stage) in stages.iter().enumerate() { calibration[i] = stage.global.calibration_enabled; @@ -330,7 +330,7 @@ pub enum CdcBias { #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct CalibrationEnable { - stages_enable: [bool; 12], + stages_enable: [bool; 13], avg_fp_skip: FullPowerSkip, avg_lp_skip: LowPowerSkip, } @@ -431,7 +431,7 @@ pub enum PowerDownTimeout { #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct StageLowIntEnable { - stages_enable: [bool; 12], + stages_enable: [bool; 13], gpio_setup: GpioSetup, gpio_input_config: GpioInputConfig, } @@ -474,7 +474,7 @@ pub enum GpioInputConfig { #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct StageHighIntEnable { - stages_enable: [bool; 12], + stages_enable: [bool; 13], } impl StageHighIntEnable { @@ -495,7 +495,7 @@ impl StageHighIntEnable { #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct StageCompleteIntEnable { - stages_enable: [bool; 12], + stages_enable: [bool; 13], } impl StageCompleteIntEnable { diff --git a/ad7147/src/driver.rs b/ad7147/src/driver.rs index 6e55a5b2cea34adc1d1929b735540ececb9f96fc..a998331442008b0e9d1fe8d6ea398b4b9e79a136 100644 --- a/ad7147/src/driver.rs +++ b/ad7147/src/driver.rs @@ -42,7 +42,7 @@ where configuration: DeviceConfiguration<S>, delay: &mut DELAY, ) -> Result<Ad7147<I2C, Initialized, S>, E> { - let mut data = [0u16; (12 * 8) + 1]; + let mut data = [0u16; (13 * 8) + 1]; data[0] = 0x080; for (i, stage) in configuration.0.stages.iter().enumerate() { let data_idx = (i * 8) + 1; @@ -82,7 +82,7 @@ where I2C: WriteRead<Error = E> + Write<Error = E>, { pub fn read_all_stages(&mut self) -> Result<[u16; S], E> { - let mut result = [0u8; 12 * 2]; + let mut result = [0u8; 13 * 2]; self.i2c.write_read( self.address, to_be_array([STAGE_CONVERSION_RESULT_REGISTER]).as_byte_slice(), diff --git a/src/flow3r/captouch.rs b/src/flow3r/captouch.rs index 9a7c977cd4e56698bb010f50547925c33fcc5b3c..10e9db9dee1a0161204442e4b461e7c31188880f 100644 --- a/src/flow3r/captouch.rs +++ b/src/flow3r/captouch.rs @@ -216,7 +216,7 @@ fn init_captouch( i2c_top: I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, ) -> Result< ( - Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 12>, + Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 13>, Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 12>, ), hal::i2c::Error, @@ -346,6 +346,16 @@ fn init_captouch( }) .initial_offset_high(55000) .build(), + StageConfiguration::builder() + .calibration_enabled(true) + .conversion_complete_interrupt_enabled(true) + .pos_afe_offset(26) + .add_input_connection(InputConnection { + cin: CapInput::CIN12, + cdc: CdcInput::Positive, + }) + .initial_offset_high(55000) + .build(), ]) .build(); let ad7147_top = Ad7147::new(i2c_top, 0b00101100); @@ -560,7 +570,7 @@ async fn update_petals_top(interrupts: u16, measurements: [u16; 12]) { } } -static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 12] = [ +static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 13] = [ (9, PetalPosition::BASE), (9, PetalPosition::TIP), (7, PetalPosition::BASE), @@ -573,12 +583,13 @@ static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 12] = [ (1, PetalPosition::TIP), (2, PetalPosition::BASE), (2, PetalPosition::CW), + (2, PetalPosition::CCW), ]; -async fn update_petals_bot(interrupts: u16, measurements: [u16; 12]) { +async fn update_petals_bot(interrupts: u16, measurements: [u16; 13]) { let mut petals = PETALS.lock().await; for (i, m) in PETAL_MAPPPING_BOT.iter().enumerate() { - let pressed = measurements[i] > 40000; + let pressed = measurements[i] > 50000; match petals[m.0] { Flow3rPetal::TOP { ref mut ccw,