From e785257711ceac60f37b6537b1aa7c98a4f5d0bb Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 5 May 2026 23:56:58 +0800 Subject: [PATCH] api moves for I2C into its own dedicated thread moving I2C into its own thread mitigates lockup conditions where I2C is blocking progress on e.g. gpio pin sets and interrupt handlings --- libs/bao1x-api/src/api.rs | 11 ++++++++--- libs/bao1x-api/src/lib.rs | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/bao1x-api/src/api.rs b/libs/bao1x-api/src/api.rs index 693266a34..c2ca18da4 100644 --- a/libs/bao1x-api/src/api.rs +++ b/libs/bao1x-api/src/api.rs @@ -43,9 +43,6 @@ pub enum HalOpcode { // blocking scalar UpdatePerclk = 18, - /// I2C operations - I2c = 9, - /// Peripheral reset PeriphReset = 10, @@ -69,3 +66,11 @@ pub enum PeripheralOpcode { ReadAdcChannel = 0x100, EnableChannel = 0x101, } + +#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] +#[repr(usize)] +pub enum I2cOpcode { + InvalidCall = 0, + Transaction, + UpdatePerclk, +} diff --git a/libs/bao1x-api/src/lib.rs b/libs/bao1x-api/src/lib.rs index dadefafd9..5e471e09d 100644 --- a/libs/bao1x-api/src/lib.rs +++ b/libs/bao1x-api/src/lib.rs @@ -53,6 +53,7 @@ pub const SERVER_NAME_BAO1X_HAL: &str = "_bao1x-SoC HAL_"; /// be in a separate server to avoid lock-up issues of the server depending on itself /// for services. pub const SERVER_NAME_BAO1X_OTHERS: &str = "_HAL-everthing-else_"; +pub const SERVER_NAME_BAO1X_I2C: &str = "_bao1x-i2c_"; /// Number of boots to trigger the 'audit' command. It's set to be bigger than 1, because /// the chip tester may power cycle the chip during the provisioning process before the