You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/09/21 16:57:27 UTC
[mynewt-core] 02/03: hw/da1469x_charger: Update VBUS handling
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 1151419c01a55279a320fbb8d55bac5b48690c61
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Aug 11 15:14:23 2021 +0200
hw/da1469x_charger: Update VBUS handling
VBUS interrupt is now shared between USB and charger.
Interrupt handler was removed from charger code
Now charger is one of the two clients of VBUS code.
---
.../chg_ctrl/da1469x_charger/src/da1469x_charger.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c b/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
index e1d7b64..3026b01 100644
--- a/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
+++ b/hw/drivers/chg_ctrl/da1469x_charger/src/da1469x_charger.c
@@ -23,6 +23,7 @@
#include <os/mynewt.h>
#include <mcu/mcu.h>
+#include <mcu/da1469x_vbus.h>
#include <da1469x_charger/da1469x_charger.h>
#include <bsp/bsp.h>
#if MYNEWT_VAL(DA1469X_CHARGER_USE_CHARGE_CONTROL)
@@ -148,22 +149,11 @@ static struct os_event da1469x_vbus_state_changed_event = {
};
static void
-da1469x_vbus_isr(void)
+da1469x_charger_vbus_handler(bool present)
{
- CRG_TOP->VBUS_IRQ_CLEAR_REG = 1;
os_eventq_put(os_eventq_dflt_get(), &da1469x_vbus_state_changed_event);
}
-void da1469x_usb_init(void)
-{
- NVIC_SetVector(VBUS_IRQn, (uint32_t)da1469x_vbus_isr);
- CRG_TOP->VBUS_IRQ_CLEAR_REG = 1;
- NVIC_ClearPendingIRQ(VBUS_IRQn);
- CRG_TOP->VBUS_IRQ_MASK_REG = CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_FALL_Msk |
- CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_RISE_Msk;
- NVIC_EnableIRQ(VBUS_IRQn);
-}
-
static void
da1469x_charger_state_changed_cb(struct os_event *ev)
{
@@ -496,7 +486,7 @@ da1469x_charger_init(struct os_dev *dev, void *arg)
NVIC_ClearPendingIRQ(CHARGER_ERROR_IRQn);
NVIC_EnableIRQ(CHARGER_ERROR_IRQn);
- da1469x_usb_init();
+ da1469x_vbus_add_handler(da1469x_charger_vbus_handler);
#endif /* DA1469X_CHARGER_USE_CHARGE_CONTROL */
#if MYNEWT_VAL(DA1469X_CHARGER_CLI)