mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2025-12-12 10:18:54 +01:00
Merge branch 'master' of yatao-nas:/home/yatli/git/PicoCalc
This commit is contained in:
commit
f305e6def6
@ -83,25 +83,3 @@ int read_battery() {
|
|||||||
}
|
}
|
||||||
return -1;
|
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];
|
|
||||||
}
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
void init_i2c_kbd();
|
void init_i2c_kbd();
|
||||||
int read_i2c_kbd();
|
int read_i2c_kbd();
|
||||||
int read_battery();
|
int read_battery();
|
||||||
int read_bootmode();
|
|
||||||
|
|
||||||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
||||||
#define bitClear(value, bit) ((value) &= ~(1 << (bit)))
|
#define bitClear(value, bit) ((value) &= ~(1 << (bit)))
|
||||||
|
|||||||
@ -314,6 +314,27 @@ void final_selection_callback(const char *path)
|
|||||||
load_firmware_by_path(path);
|
load_firmware_by_path(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int read_bootmode()
|
||||||
|
{
|
||||||
|
int key = keypad_get_key();
|
||||||
|
int _x;
|
||||||
|
DEBUG_PRINT("read_bootmode key = %d\n", key);
|
||||||
|
while((_x = keypad_get_key()) > 0) {
|
||||||
|
// drain the keypad input buffer
|
||||||
|
DEBUG_PRINT("read_bootmode subsequent key = %d\n", _x);
|
||||||
|
}
|
||||||
|
int bootmode = 0; // Default boot mode
|
||||||
|
if (key == KEY_ARROW_UP)
|
||||||
|
{
|
||||||
|
bootmode = 1; // SD card boot mode
|
||||||
|
}
|
||||||
|
else if (key == KEY_ARROW_DOWN)
|
||||||
|
{
|
||||||
|
bootmode = 2; // Firmware update mode
|
||||||
|
}
|
||||||
|
return bootmode;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
uint32_t cur_time,last_time=0;
|
uint32_t cur_time,last_time=0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user