找到
2
篇与
STM32
相关的结果
-
LED流水灯 #include "stm32f10x.h" // Device header #include "Delay.h" int main(void) { // 1. 使能GPIOA时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // 2. 配置GPIOA的PA0引脚 GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // 配置为推挽输出模式 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; // 选择PA0引脚 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 设置输出速度为50MHz GPIO_Init(GPIOA, &GPIO_InitStructure); // 初始化GPIOA的PA0引脚 while(1) { GPIO_Write(GPIOA, ~0x0001); Delay_ms(500); GPIO_Write(GPIOA, ~0x0002); Delay_ms(500); GPIO_Write(GPIOA, ~0x0004); Delay_ms(500); GPIO_Write(GPIOA, ~0x0008); Delay_ms(500); } }
-
点灯 #include "stm32f10x.h" // Device header int main() { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_SetBits(GPIOC, GPIO_Pin_13); //将PC13号口置于高电平 GPIO_ResetBits(GPIOC, GPIO_Pin_13); //将PC13号口置于低电平 while(1) { } }