lib/stm32/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  
  /* Enable the BUTTON Clock */
  BUTTONx_GPIO_CLK_ENABLE(Button);
  
  if(ButtonMode == BUTTON_MODE_GPIO)
  {
    /* Configure Button pin as input */
    GPIO_InitStruct.Pin = BUTTON_PIN[Button];
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
    HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
  }
  
  if(ButtonMode == BUTTON_MODE_EXTI)
  {
    /* Configure Button pin as input with External interrupt */
    GPIO_InitStruct.Pin = BUTTON_PIN[Button];
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 
    HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
    
    /* Enable and set Button EXTI Interrupt to the lowest priority */
    HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
    HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
  }
}
/**
  * @brief  Configures Button GPIO and EXTI Line.
  * @param  Button: Specifies the Button to be configured.
  *   This parameter should be: BUTTON_KEY
  * @param  ButtonMode: Specifies Button mode.
  *   This parameter can be one of following parameters:   
  *     @arg BUTTON_MODE_GPIO: Button will be used as simple IO 
  *     @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
  *                            generation capability  
  * @retval None
  */
@brief  Configures Button GPIO and EXTI Line.
@param  Button: Specifies the Button to be configured.
This parameter should be: BUTTON_KEY
@param  ButtonMode: Specifies Button mode.
This parameter can be one of following parameters:
@arg BUTTON_MODE_GPIO: Button will be used as simple IO
@arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
generation capability
@retval None
@brief Configures Button GPIO and EXTI Line . @param Button : Specifies the Button to be configured . This parameter should be : BUTTON_KEY @param ButtonMode : Specifies Button mode . This parameter can be one of following parameters : @arg BUTTON_MODE_GPIO : Button will be used as simple IO @arg BUTTON_MODE_EXTI : Button will be connected to EXTI line with interrupt generation capability @retval None
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  BUTTONx_GPIO_CLK_ENABLE(Button);
  if(ButtonMode == BUTTON_MODE_GPIO)
  {
    GPIO_InitStruct.Pin = BUTTON_PIN[Button];
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
    HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
  }
  if(ButtonMode == BUTTON_MODE_EXTI)
  {
    GPIO_InitStruct.Pin = BUTTON_PIN[Button];
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 
    HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
    HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
    HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
  }
}
void BSP_PB_Init ( Button_TypeDef Button , ButtonMode_TypeDef ButtonMode ) { GPIO_InitTypeDef GPIO_InitStruct ; BUTTONx_GPIO_CLK_ENABLE ( Button ) ; if ( ButtonMode == BUTTON_MODE_GPIO ) { GPIO_InitStruct . Pin = BUTTON_PIN [ Button ] ; GPIO_InitStruct . Mode = GPIO_MODE_INPUT ; GPIO_InitStruct . Pull = GPIO_PULLDOWN ; GPIO_InitStruct . Speed = GPIO_SPEED_FAST ; HAL_GPIO_Init ( BUTTON_PORT [ Button ] , & GPIO_InitStruct ) ; } if ( ButtonMode == BUTTON_MODE_EXTI ) { GPIO_InitStruct . Pin = BUTTON_PIN [ Button ] ; GPIO_InitStruct . Pull = GPIO_NOPULL ; GPIO_InitStruct . Mode = GPIO_MODE_IT_FALLING ; HAL_GPIO_Init ( BUTTON_PORT [ Button ] , & GPIO_InitStruct ) ; HAL_NVIC_SetPriority ( ( IRQn_Type ) ( BUTTON_IRQn [ Button ] ) , 0x0F , 0x00 ) ; HAL_NVIC_EnableIRQ ( ( IRQn_Type ) ( BUTTON_IRQn [ Button ] ) ) ; } }
@brief  Configures Button GPIO and EXTI Line.
@brief Configures Button GPIO and EXTI Line .
/* Enable the BUTTON Clock */ /* Configure Button pin as input */ /* Configure Button pin as input with External interrupt */ /* Enable and set Button EXTI Interrupt to the lowest priority */