diff --git a/src/system/gpio.c b/src/system/gpio.c --- a/src/system/gpio.c +++ b/src/system/gpio.c @@ -30,11 +30,15 @@ void gpio_init(void) HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); - GPIO_InitStruct.Pin = SW_A_Pin|SW_B_Pin|SW_C_Pin|SW_D_Pin; + GPIO_InitStruct.Pin = SW_A_Pin|SW_B_Pin|SW_C_Pin|SW_D_Pin|AUX_INPUT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(SW_C_GPIO_Port, &GPIO_InitStruct); + GPIO_InitStruct.Pin = AUX_RETURN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + HAL_GPIO_Init(AUX_RETURN_GPIO_Port, &GPIO_InitStruct); + GPIO_InitStruct.Pin = SW_BTN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; @@ -50,6 +54,7 @@ void gpio_init(void) // Define startup State HAL_GPIO_WritePin(LED, 0); + HAL_GPIO_WritePin(AUX_RETURN, 0); } @@ -69,6 +74,23 @@ void user_input(uint16_t* to_modify) } } +// Increment/decrement unsigned variable with up/down buttons +void user_input_min_max(uint16_t* to_modify, uint16_t min, uint16_t max) +{ + if(CHANGE_ELAPSED) { + if(!HAL_GPIO_ReadPin(SW_UP) && ((*to_modify) < max)) + { + CHANGE_RESET; + (*to_modify)++; + } + else if(!HAL_GPIO_ReadPin(SW_DOWN) && ((*to_modify) > min)) + { + CHANGE_RESET; + (*to_modify)--; + } + } +} + // Increment/decrement signed variable with up/down buttons void user_input_signed(int32_t* to_modify)