This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 59786bf boards/nucleo-f302r8: add 3ph Hall sensor support 59786bf is described below commit 59786bf208c7805351bb6986c5d0667ee133f2ff Author: raiden00pl <raide...@railab.me> AuthorDate: Sat Dec 4 14:51:42 2021 +0100 boards/nucleo-f302r8: add 3ph Hall sensor support --- boards/arm/stm32/nucleo-f302r8/src/nucleo-f302r8.h | 11 +++++++++++ boards/arm/stm32/nucleo-f302r8/src/stm32_bringup.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/boards/arm/stm32/nucleo-f302r8/src/nucleo-f302r8.h b/boards/arm/stm32/nucleo-f302r8/src/nucleo-f302r8.h index f4c5b16..4e4edf8 100644 --- a/boards/arm/stm32/nucleo-f302r8/src/nucleo-f302r8.h +++ b/boards/arm/stm32/nucleo-f302r8/src/nucleo-f302r8.h @@ -77,6 +77,17 @@ #define NUCLEOF302R8_PWMTIMER 1 +#ifdef CONFIG_SENSORS_HALL3PHASE +/* GPIO pins used by the 3-phase Hall effect sensor */ + +# define GPIO_HALL_PHA (GPIO_INPUT | GPIO_SPEED_2MHz | \ + GPIO_PORTA | GPIO_PIN15) +# define GPIO_HALL_PHB (GPIO_INPUT | GPIO_SPEED_2MHz | \ + GPIO_PORTB | GPIO_PIN3) +# define GPIO_HALL_PHC (GPIO_INPUT | GPIO_SPEED_2MHz | \ + GPIO_PORTB | GPIO_PIN10) +#endif + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/boards/arm/stm32/nucleo-f302r8/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f302r8/src/stm32_bringup.c index 3b1e172..0d81f27 100644 --- a/boards/arm/stm32/nucleo-f302r8/src/stm32_bringup.c +++ b/boards/arm/stm32/nucleo-f302r8/src/stm32_bringup.c @@ -27,6 +27,8 @@ #include <sys/types.h> #include <syslog.h> +#include <stm32.h> + #include <nuttx/board.h> #ifdef CONFIG_USERLED @@ -41,6 +43,10 @@ # include "board_qencoder.h" #endif +#ifdef CONFIG_SENSORS_HALL3PHASE +# include "board_hall3ph.h" +#endif + #include "nucleo-f302r8.h" /**************************************************************************** @@ -144,6 +150,20 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_HALL3PHASE + /* Initialize and register the 3-phase Hall effect sensor driver */ + + ret = board_hall3ph_initialize(0, GPIO_HALL_PHA, GPIO_HALL_PHB, + GPIO_HALL_PHC); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to register the hall : %d\n", + ret); + return ret; + } +#endif + UNUSED(ret); return OK; }