From b5d0e38cbb4739f2d0a38462e037c338bed2f43d Mon Sep 17 00:00:00 2001 From: Arthur Bonnaudet Date: Fri, 13 Oct 2023 11:43:16 +0200 Subject: [PATCH] Add `io_seproxyhal_enable_io()` function `io_seproxyhal_enable_io()` and `io_seproxyhal_disable_io()` allow to turn on and off USB connection. --- include/os_io_seproxyhal.h | 1 + src/os_io_seproxyhal.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/os_io_seproxyhal.h b/include/os_io_seproxyhal.h index b8e35a0a7..3c68669e0 100644 --- a/include/os_io_seproxyhal.h +++ b/include/os_io_seproxyhal.h @@ -291,6 +291,7 @@ void io_seproxyhal_setup_ticker(unsigned int interval_ms); void io_seproxyhal_power_off(bool criticalBattery); void io_seproxyhal_se_reset(void); void io_seproxyhal_disable_io(void); +void io_seproxyhal_enable_io(void); #ifdef HAVE_PIEZO_SOUND typedef enum tune_index_e { diff --git a/src/os_io_seproxyhal.c b/src/os_io_seproxyhal.c index d89af470a..090f3b958 100644 --- a/src/os_io_seproxyhal.c +++ b/src/os_io_seproxyhal.c @@ -1111,12 +1111,26 @@ static const unsigned char seph_io_usb_disconnect[] = { 1, SEPROXYHAL_TAG_USB_CONFIG_DISCONNECT, }; + void io_seproxyhal_disable_io(void) { // usb off io_seproxyhal_spi_send(seph_io_usb_disconnect, sizeof(seph_io_usb_disconnect)); } +static const unsigned char seph_io_usb_connect[] = { + SEPROXYHAL_TAG_USB_CONFIG, + 0, + 1, + SEPROXYHAL_TAG_USB_CONFIG_CONNECT, +}; + +void io_seproxyhal_enable_io(void) +{ + // usb on + io_seproxyhal_spi_send(seph_io_usb_connect, sizeof(seph_io_usb_connect)); +} + void io_seproxyhal_backlight(unsigned int flags, unsigned int backlight_percentage) { G_io_seproxyhal_spi_buffer[0] = SEPROXYHAL_TAG_SET_SCREEN_CONFIG;