diff --git a/src/system/gpio.c b/src/system/gpio.c --- a/src/system/gpio.c +++ b/src/system/gpio.c @@ -14,42 +14,42 @@ static uint32_t change_time_reset = 0; // Initialize GPIOs void gpio_init(void) { - GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitTypeDef GPIO_InitStruct; - // GPIO Ports Clock Enable - __GPIOA_CLK_ENABLE(); - __GPIOB_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); + // GPIO Ports Clock Enable + __GPIOA_CLK_ENABLE(); + __GPIOB_CLK_ENABLE(); + __GPIOF_CLK_ENABLE(); - // Configure LED GPIO pins - GPIO_InitStruct.Pin = LED_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); + // Configure LED GPIO pins + GPIO_InitStruct.Pin = LED_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + 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.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(SW_C_GPIO_Port, &GPIO_InitStruct); + GPIO_InitStruct.Pin = SW_A_Pin|SW_B_Pin|SW_C_Pin|SW_D_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 = SW_BTN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(SW_BTN_GPIO_Port, &GPIO_InitStruct); + GPIO_InitStruct.Pin = SW_BTN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(SW_BTN_GPIO_Port, &GPIO_InitStruct); - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); - HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); - // Define startup State - HAL_GPIO_WritePin(LED, 0); + // Define startup State + HAL_GPIO_WritePin(LED, 0); } @@ -73,17 +73,17 @@ void user_input(uint16_t* to_modify) // Increment/decrement signed variable with up/down buttons void user_input_signed(int32_t* to_modify) { - //fixme: need to cast to 16/32 bits correctly + //fixme: need to cast to 16/32 bits correctly if(CHANGE_ELAPSED) { if(!HAL_GPIO_ReadPin(SW_UP) ) { CHANGE_RESET; if (*to_modify < 32768) - (*to_modify)++; + (*to_modify)++; } else if(!HAL_GPIO_ReadPin(SW_DOWN)) { CHANGE_RESET; if (*to_modify >= -32768) - (*to_modify)--; + (*to_modify)--; } } }