当前位置:首页 > 单片机 > 单片机
[导读]STM32读具体GPIOx的某一位是1还是01 /**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

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 }



本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭