diff --git a/configs/nucleo-l432kc/src/Makefile b/configs/nucleo-l432kc/src/Makefile index a8ba102f8d7..23adcbe525b 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 bd0b6aa7933..62afee86836 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 48f2147349e..cb98ccf2f63 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 */