sd_boot: move readboot logic to bootloader.

This commit is contained in:
Yatao Li
2025-06-15 18:36:30 +08:00
parent fa3ad399d7
commit 7f62e15f55
3 changed files with 21 additions and 23 deletions

View File

@@ -83,25 +83,3 @@ int read_battery() {
}
return -1;
}
int read_bootmode() {
int retval;
unsigned char msg[2];
msg[0] = 0x0e; // REG_ID_BOOT
if (i2c_inited == 0) return -1;
retval = i2c_write_timeout_us(I2C_KBD_MOD, I2C_KBD_ADDR, msg, 1, false, 500000);
if (retval == PICO_ERROR_GENERIC || retval == PICO_ERROR_TIMEOUT) {
DEBUG_PRINT("Boot I2C write err\n");
return -1;
}
sleep_ms(16);
retval = i2c_read_timeout_us(I2C_KBD_MOD, I2C_KBD_ADDR, (unsigned char *) msg, 2, false, 500000);
if (retval == PICO_ERROR_GENERIC || retval == PICO_ERROR_TIMEOUT || msg[0] != 0x0e) {
DEBUG_PRINT("Boot I2C read err\n");
return -1;
}
return msg[1];
}

View File

@@ -16,7 +16,6 @@
void init_i2c_kbd();
int read_i2c_kbd();
int read_battery();
int read_bootmode();
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitClear(value, bit) ((value) &= ~(1 << (bit)))