boards/b-g431b-esc1: register Qenco index pin

This commit is contained in:
raiden00pl 2021-11-06 19:14:32 +01:00 committed by Xiang Xiao
parent 7b595ab73a
commit f2405ccc57
2 changed files with 29 additions and 6 deletions

View File

@ -70,6 +70,13 @@
#define GPIO_BTN_USER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN10)
#ifdef CONFIG_SENSORS_QENCODER
/* Qenco index pin */
# define QENCODER_TIM4_INDEX_GPIO (GPIO_INPUT | GPIO_FLOAT |\
GPIO_EXTI | GPIO_PORTB | GPIO_PIN8)
#endif
#ifdef CONFIG_SENSORS_HALL3PHASE
/* GPIO pins used by the 3-phase Hall effect sensor */

View File

@ -40,6 +40,10 @@
#include "stm32_foc.h"
#ifdef CONFIG_SENSORS_QENCODER
# include "stm32_qencoder.h"
#endif
#include "arm_arch.h"
#include "b-g431b-esc1.h"
@ -535,6 +539,24 @@ int stm32_foc_setup(void)
if (g_foc_dev == NULL)
{
#if defined(CONFIG_SENSORS_QENCODER) || defined(CONFIG_SENSORS_HALL3PHASE)
/* Disable USB Type-C and Power Delivery Dead Battery */
modifyreg32(STM32_PWR_CR3, 0, PWR_CR3_UCPD1_DBDIS);
#endif
#if defined(CONFIG_SENSORS_QENCODER) && defined(CONFIG_STM32_QENCODER_INDEX_PIN)
/* Configure encoder index GPIO */
ret = stm32_qe_index_init(4, QENCODER_TIM4_INDEX_GPIO);
if (ret < 0)
{
mtrerr("Failed to register encoder index pin %d\n", ret);
ret = -EACCES;
goto errout;
}
#endif
/* Initialize arch specific FOC lower-half */
foc = stm32_foc_initialize(0, &g_stm32_foc_board);
@ -584,12 +606,6 @@ int stm32_adc_setup(void)
if (initialized == false)
{
#if defined(CONFIG_SENSORS_QENCODER) || defined(CONFIG_SENSORS_HALL3PHASE)
/* Disable USB Type-C and Power Delivery Dead Battery */
modifyreg32(STM32_PWR_CR3, 0, PWR_CR3_UCPD1_DBDIS);
#endif
if (g_foc_dev == NULL)
{
mtrerr("Failed to get g_foc_dev device\n");