Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

echoplayer: add charger detection and USB current limit setting

Note that USB current limiting is more or less wishful
thinking; only the charge current is limited, but the
system could easily draw more than 100 mA by itself.

Change-Id: I1083b015f0abea5a39a602ca8d7b142d3613b46b

authored by

Aidan MacDonald and committed by
Solomon Peachy
bc32d43c cd20bc7d

+21 -5
+1 -3
firmware/export/config/echor1.h
··· 108 108 #define USB_PRODUCT_ID 0xEC01 109 109 #define USB_DEVBSS_ATTR __attribute__((aligned(32))) 110 110 #define HAVE_USB_POWER 111 - //#define HAVE_USB_CHARGING_ENABLE 112 - //#define HAVE_USB_CHARGING_IN_THREAD 113 - //#define TARGET_USB_CHARGING_DEFAULT USB_CHARGING_FORCE 111 + #define HAVE_USB_CHARGING_ENABLE 114 112 #define HAVE_BOOTLOADER_USB_MODE 115 113 #endif 116 114
+20 -2
firmware/target/arm/stm32/echoplayer/power-echoplayer.c
··· 25 25 static struct mutex power_1v8_lock; 26 26 static int power_1v8_refcount; 27 27 28 + /* TODO: calibrate battery curve */ 28 29 unsigned short battery_level_disksafe = 3500; 29 30 unsigned short battery_level_shutoff = 3400; 30 31 ··· 87 88 power_off(); 88 89 } 89 90 91 + #ifdef HAVE_USB_CHARGING_ENABLE 92 + void usb_charging_maxcurrent_change(int maxcurrent) 93 + { 94 + const int conf_500ma = GPIOF_OUTPUT(0, GPIO_TYPE_PUSH_PULL, 95 + GPIO_SPEED_LOW, GPIO_PULL_DISABLED); 96 + const int conf_100ma = GPIOF_INPUT(GPIO_PULL_DISABLED); 97 + 98 + if (maxcurrent > 100) 99 + gpio_configure_single(GPIO_CHARGER_CHARGING, conf_500ma); 100 + else 101 + gpio_configure_single(GPIO_CHARGER_CHARGING, conf_100ma); 102 + } 103 + #endif 104 + 90 105 unsigned int power_input_status(void) 91 106 { 92 - return POWER_INPUT_USB_CHARGER; 107 + if (gpio_get_level(GPIO_USB_VBUS)) 108 + return POWER_INPUT_USB_CHARGER; 109 + 110 + return POWER_INPUT_NONE; 93 111 } 94 112 95 113 bool charging_state(void) 96 114 { 97 - return true; 115 + return gpio_get_level(GPIO_CHARGER_CHARGING) == 0; 98 116 } 99 117 100 118 int _battery_voltage(void)