led流水灯
This commit is contained in:
31
User/main.c
31
User/main.c
@@ -1,13 +1,34 @@
|
||||
#include "stm32f10x.h"
|
||||
#include "Delay.h"
|
||||
int main(void){
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13;
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_All;
|
||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
// GPIO_SetBits(GPIOC, GPIO_Pin_13);
|
||||
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
|
||||
GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
// GPIO_SetBits(GPIOA, GPIO_Pin_0); // 关闭led灯
|
||||
// GPIO_ResetBits(GPIOA, GPIO_Pin_0); // 打开led灯
|
||||
// GPIO_WriteBit(GPIOA, GPIO_Pin_7, Bit_RESET); // 打开led灯
|
||||
// GPIO_WriteBit(GPIOA, GPIO_Pin_0, Bit_SET); // 关闭led灯
|
||||
|
||||
while(1){
|
||||
GPIO_Write(GPIOA, ~0x00000001); // 0000 0000 0000 0001
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000002); // 0000 0000 0000 0010
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000004); // 0000 0000 0000 0100
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000008); // 0000 0000 0000 1000
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000010); // 0000 0000 0001 0000
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000020); // 0000 0000 0010 0000
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000040); // 0000 0000 0100 0000
|
||||
Delay_ms(500);
|
||||
GPIO_Write(GPIOA, ~0x00000080); // 0000 0000 1000 0000
|
||||
Delay_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user