有个例子只利用红色LED闪烁,我们修改一下,编程3个LED闪烁
while (1)
{
/* Delay 1000 ms */
SysTick_DelayTicks(500U);
GPIO_PortToggle(BOARD_LED_RED_GPIO_PORT, 1u << BOARD_LED_RED_PIN);
SysTick_DelayTicks(500U);
GPIO_PortToggle(BOARD_LED_GREEN_GPIO_PORT, 1u << BOARD_LED_GREEN_GPIO_PIN);
SysTick_DelayTicks(500U);
GPIO_PortToggle(BOARD_LED_BLUE_GPIO_PORT, 1u << BOARD_LED_BLUE_GPIO_PIN);
}
另外初始化函数也要完成另外两个LED的初始化
void BOARD_InitPins(void)
{
gpio_pin_config_t LED_RED_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
gpio_pin_config_t LED_GREEN_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
gpio_pin_config_t LED_BLUE_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
/* Initialize GPIO functionality on pin PTB25 (pin 14) */
GPIO_PinInit(BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_PIN, &LED_RED_config);
GPIO_PinInit(BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, &LED_GREEN_config);
GPIO_PinInit(BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, &LED_BLUE_config);
}
|