boards/nucleo-f302r8: add 3ph Hall sensor support

This commit is contained in:
raiden00pl 2021-12-04 14:51:42 +01:00 committed by Xiang Xiao
parent 4dfefb4e06
commit 59786bf208
2 changed files with 31 additions and 0 deletions

View File

@ -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
****************************************************************************/

View File

@ -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;
}