From 752a7d249c79461b3dd77f6047ff3a917cbf3fb5 Mon Sep 17 00:00:00 2001 From: "Daniel P. Carvalho" Date: Tue, 23 Jul 2019 16:07:17 -0600 Subject: [PATCH] configs/nucleo-l432kc: Added Zero Cross sensor to nucleo-l432kc. --- configs/nucleo-l432kc/src/Makefile | 4 ++++ configs/nucleo-l432kc/src/nucleo-l432kc.h | 16 ++++++++++++++++ configs/nucleo-l432kc/src/stm32_appinit.c | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/configs/nucleo-l432kc/src/Makefile b/configs/nucleo-l432kc/src/Makefile index a8ba102f8d..23adcbe525 100644 --- a/configs/nucleo-l432kc/src/Makefile +++ b/configs/nucleo-l432kc/src/Makefile @@ -80,6 +80,10 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif +ifeq ($(CONFIG_SENSORS_ZEROCROSS),y) + CSRCS += stm32_zerocross.c +endif + ifeq ($(CONFIG_TIMER),y) CSRCS += stm32_timer.c endif diff --git a/configs/nucleo-l432kc/src/nucleo-l432kc.h b/configs/nucleo-l432kc/src/nucleo-l432kc.h index bd0b6aa793..62afee8683 100644 --- a/configs/nucleo-l432kc/src/nucleo-l432kc.h +++ b/configs/nucleo-l432kc/src/nucleo-l432kc.h @@ -110,6 +110,10 @@ #define GPIO_INT1 (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTA|GPIO_PIN3) +/* ZERO CROSS pin definition */ + +#define GPIO_ZEROCROSS (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTA|GPIO_PIN0) + /************************************************************************************ * Public Data ************************************************************************************/ @@ -231,6 +235,18 @@ int stm32_ina226initialize(FAR const char *devpath); int stm32_ina219initialize(FAR const char *devpath); #endif +/**************************************************************************** + * Name: stm32_zerocross_initialize + * + * Description: + * Initialize and register the zero cross driver + * + ****************************************************************************/ + +#ifdef CONFIG_SENSORS_ZEROCROSS +int stm32_zerocross_initialize(void); +#endif + /**************************************************************************** * Name: board_timer_driver_initialize * diff --git a/configs/nucleo-l432kc/src/stm32_appinit.c b/configs/nucleo-l432kc/src/stm32_appinit.c index 48f2147349..cb98ccf2f6 100644 --- a/configs/nucleo-l432kc/src/stm32_appinit.c +++ b/configs/nucleo-l432kc/src/stm32_appinit.c @@ -274,6 +274,17 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_SENSORS_ZEROCROSS + /* Configure the zero-crossing driver */ + + ret = stm32_zerocross_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize Zero-Cross, error %d\n", ret); + return ret; + } +#endif + #ifdef CONFIG_TIMER /* Initialize and register the timer driver */