- #include "N32G45x.h"
- int main() {
- // 使能GPIO时钟
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
- // 配置GPIOA的第0号引脚为推挽输出模式
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- while(1) {
- // 点亮LED
- GPIO_SetBits(GPIOA, GPIO_Pin_0);
- // 延时
- for(int i = 0; i < 1000000; ++i);
- // 熄灭LED
- GPIO_ResetBits(GPIOA, GPIO_Pin_0);
- // 延时
- for(int i = 0; i < 1000000; ++i);
- }
- }
|