From 707bfe2ff460c45558e77a13b0eff9eb13f2e22f Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Thu, 11 Jul 2019 14:18:32 +0200 Subject: [PATCH] chore(libcard10): Refactor pmic interface Signed-off-by: Rahix <rahix@rahix.de> --- lib/card10/pmic.c | 19 ++----------------- lib/card10/pmic.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/card10/pmic.c b/lib/card10/pmic.c index 30519a07..30c7d3a2 100644 --- a/lib/card10/pmic.c +++ b/lib/card10/pmic.c @@ -4,7 +4,6 @@ #include <stdint.h> #include <stdio.h> -static void pmic_interrupt_callback(void*_); static const gpio_cfg_t pmic_interrupt_pin = { PORT_0, PIN_12, GPIO_FUNC_IN, GPIO_PAD_PULL_UP }; @@ -77,30 +76,16 @@ void pmic_init(void) GPIO_RegisterCallback(&pmic_interrupt_pin, pmic_interrupt_callback, NULL); GPIO_IntConfig(&pmic_interrupt_pin, GPIO_INT_EDGE, GPIO_INT_FALLING); GPIO_IntEnable(&pmic_interrupt_pin); + NVIC_SetPriority((IRQn_Type)MXC_GPIO_GET_IRQ(pmic_interrupt_pin.port), 2); NVIC_EnableIRQ((IRQn_Type)MXC_GPIO_GET_IRQ(pmic_interrupt_pin.port)); -/* Dropout Detector Rising */ -#define MAX77650_INT_DOD_R (1 << 6) -/* Thermal Alarm 2 Rising */ -#define MAX77650_INT_TJAL2_R (1 << 5) -/* Thermal Alarm 1 Rising */ -#define MAX77650_INT_TJAL1_R (1 << 4) -/* nEN Rising */ -#define MAX77650_INT_nEN_R (1 << 3) -/* nEN Falling */ -#define MAX77650_INT_nEN_F (1 << 2) -/* GPI Rising */ -#define MAX77650_INT_GPI_R (1 << 1) -/* GPI Falling */ -#define MAX77650_INT_GPI_F (1 << 0) - /* Setup power button interrupt */ MAX77650_setINT_M_GLBL(~(MAX77650_INT_nEN_R | MAX77650_INT_nEN_F)); /* Clear existing interrupts */ MAX77650_getINT_GLBL(); } -static void pmic_interrupt_callback(void*_) +__attribute__((weak)) void pmic_interrupt_callback(void*_) { interrupt_pending = true; } diff --git a/lib/card10/pmic.h b/lib/card10/pmic.h index fb522c15..f913c99b 100644 --- a/lib/card10/pmic.h +++ b/lib/card10/pmic.h @@ -4,10 +4,28 @@ #include <stdint.h> #include <stdbool.h> +/* Dropout Detector Rising */ +#define MAX77650_INT_DOD_R (1 << 6) +/* Thermal Alarm 2 Rising */ +#define MAX77650_INT_TJAL2_R (1 << 5) +/* Thermal Alarm 1 Rising */ +#define MAX77650_INT_TJAL1_R (1 << 4) +/* nEN Rising */ +#define MAX77650_INT_nEN_R (1 << 3) +/* nEN Falling */ +#define MAX77650_INT_nEN_F (1 << 2) +/* GPI Rising */ +#define MAX77650_INT_GPI_R (1 << 1) +/* GPI Falling */ +#define MAX77650_INT_GPI_F (1 << 0) + void pmic_init(void); void pmic_set_led(uint8_t led, uint8_t val); void pmic_poll(void); +/* weak, so it can be overwritten by applications */ +void pmic_interrupt_callback(void*_); + typedef void (*pmic_button_callback_fn)(bool falling); void pmic_set_button_callback(pmic_button_callback_fn cb); -- GitLab