Example #1
0
/**
  * @brief  Sets or clears the selected data port bit.
  * @param  GPIOx : Select the GPIO peripheral number (x = A to I).
  * @param  GPIO_Pin: Specifies the port bit to be written.
  *           This parameter can be one of the following values:
  *            @arg GPIO_Pin_0: Pin 0
  *            @arg GPIO_Pin_1: Pin 1
  *            @arg GPIO_Pin_2: Pin 2
  *            @arg GPIO_Pin_3: Pin 3
  *            @arg GPIO_Pin_4: Pin 4
  *            @arg GPIO_Pin_5: Pin 5
  *            @arg GPIO_Pin_6: Pin 6
  *            @arg GPIO_Pin_7: Pin 7
  * @param  GPIO_BitVal: specifies the desired status to be written.
  *         This parameter can be SET or RESET
  * @retval None
  */
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal)
{
    /* Check the parameters */
    assert_param(IS_GPIO_PIN(GPIO_Pin));
    assert_param(IS_STATE_VALUE(GPIO_BitVal));

    if (GPIO_BitVal != RESET) {
        GPIOx->ODR |= GPIO_Pin;

    } else {
        GPIOx->ODR &= (uint8_t)(~GPIO_Pin);
    }
}
/**
  * @brief  Sets or clears the selected data port bit.
  * @param  GPIOx       Select the GPIO peripheral number (x = A to D).
  * @param  GPIO_Pin: Specifies the port bit to be written.
  *           This parameter can be one of the following values:
  *            @arg GPIO_Pin_0: Pin 0
  *            @arg GPIO_Pin_1: Pin 1
  *            @arg GPIO_Pin_2: Pin 2
  *            @arg GPIO_Pin_3: Pin 3
  *            @arg GPIO_Pin_4: Pin 4
  *            @arg GPIO_Pin_5: Pin 5
  *            @arg GPIO_Pin_6: Pin 6
  *            @arg GPIO_Pin_7: Pin 7   
  * @param  GPIO_BitVal: specifies the desired status to be written.
  *         This parameter can be SET or RESET
  * @retval None
  */
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal)
{
  /* Check the parameters */
  assert_param(IS_GPIO_PIN(GPIO_Pin));
  assert_param(IS_STATE_VALUE(GPIO_BitVal));

  if (GPIO_BitVal != RESET)
  {
    SetBit(GPIOx->ODR, GPIO_Pin);

  }
  else
  {
    ClrBit(GPIOx->ODR, GPIO_Pin);
  }
}