STM32函数GPIO_WriteBit问题
发布网友
发布时间:2022-05-17 03:24
我来回答
共1个回答
热心网友
时间:2023-09-27 16:31
看stm32 library的资料应该这样写的:
GPIO_WriteBit(GPIOD,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2,Bit_SET);
这是函数的说明
void GPIO_WriteBit ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_Pin,
BitAction BitVal
)
Parameters:
GPIOx,: where x can be (A..G) to select the GPIO peripheral.
GPIO_Pin,: specifies the port bit to be written. This parameter can be one of GPIO_Pin_x where x can be (0..15).
BitVal,: specifies the value to be written to the selected bit. This parameter can be one of the BitAction enum values:
Bit_RESET: to clear the port pin
Bit_SET: to set the port pin
在stm32f10x_gpio.h
108行
typedef enum
{ Bit_RESET = 0,
Bit_SET
}BitAction;
stm32f10x_gpio.c里的原函数:
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
{
/* Check the parameters */
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
GPIOx->BSRR = GPIO_Pin;
}
else
{
GPIOx->BRR = GPIO_Pin;
}
}