×
单片机 > 单片机程序设计 > 详情

STM32 常用GPIO操作函数记录

发布时间:2020-05-18 发布时间:
|

STM32读具体GPIOx的某一位是1还是0



 1 /**

 2   * @brief  Reads the specified input port pin.

 3   * @param  GPIOx: where x can be (A..G) to select the GPIO peripheral.

 4   * @param  GPIO_Pin:  specifies the port bit to read.

 5   *   This parameter can be GPIO_Pin_x where x can be (0..15).

 6   * @retval The input port pin value.

 7   */

 8 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)

 9 {

10   uint8_t bitstatus = 0x00;

11   

12   /* Check the parameters */

13   assert_param(IS_GPIO_ALL_PERIPH(GPIOx));

14   assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); 

15   

16   if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)

17   {

18     bitstatus = (uint8_t)Bit_SET;

19   }

20   else

21   {

22     bitstatus = (uint8_t)Bit_RESET;

23   }

24   return bitstatus;

25 }


 



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
ARM 汇编的必知必会