Fixed battery charging and USB detection
This commit is contained in:
committed by
Malte Langermann
parent
48d0ec49ed
commit
11c0bb55e0
@@ -42,8 +42,16 @@ enum ChargeState
|
||||
CHARGE_FINISHED
|
||||
};
|
||||
|
||||
#define IS_UCHARGER_ACTIVE() gpio_read(UCHARGER_GPIO) ? 1 : 0
|
||||
#define IS_UCHARGER_CHARGE_END_ACTIVE() gpio_read(UCHARGER_CHARGE_END_GPIO) ? 1 : 0
|
||||
#if defined(UCHARGER_GPIO_PIN_INV)
|
||||
#define IS_UCHARGER_ACTIVE() gpio_read(UCHARGER_GPIO) ? 0 : 1
|
||||
#else
|
||||
#define IS_UCHARGER_ACTIVE() gpio_read(UCHARGER_GPIO) ? 1 : 0
|
||||
#endif
|
||||
#if defined(UCHARGER_CHARGE_END_GPIO_PIN_INV)
|
||||
#define IS_UCHARGER_CHARGE_END_ACTIVE() gpio_read(UCHARGER_CHARGE_END_GPIO) ? 0 : 1
|
||||
#else
|
||||
#define IS_UCHARGER_CHARGE_END_ACTIVE() gpio_read(UCHARGER_CHARGE_END_GPIO) ? 1 : 0
|
||||
#endif
|
||||
#if defined(UCHARGER_EN_GPIO)
|
||||
#define ENABLE_UCHARGER() gpio_set(UCHARGER_EN_GPIO)
|
||||
#define DISABLE_UCHARGER() gpio_clear(UCHARGER_EN_GPIO)
|
||||
|
||||
@@ -237,6 +237,10 @@ int usbPlugged()
|
||||
static uint8_t lastState = 0;
|
||||
|
||||
uint8_t state = gpio_read(UCHARGER_GPIO) ? 1 : 0;
|
||||
#if defined(UCHARGER_GPIO_PIN_INV)
|
||||
state = !state;
|
||||
#endif
|
||||
|
||||
if (state == lastState)
|
||||
debouncedState = state;
|
||||
else
|
||||
|
||||
@@ -359,6 +359,11 @@
|
||||
// Chargers (USB and wireless)
|
||||
#define UCHARGER_GPIO GPIO_PIN(GPIOB, 14) // PB.14 input
|
||||
#define UCHARGER_CHARGE_END_GPIO GPIO_PIN(GPIOB, 13) // PB.13 input
|
||||
#if defined(RADIO_NB4P)
|
||||
#define UCHARGER_GPIO_PIN_INV
|
||||
#define UCHARGER_CHARGE_END_GPIO_PIN_INV
|
||||
#endif
|
||||
|
||||
#if defined(RADIO_PL18) || defined(RADIO_PL18EV)
|
||||
#define UCHARGER_EN_GPIO GPIO_PIN(GPIOG, 3) // PG.03 output
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user