-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
100 lines (77 loc) · 1.53 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*****************************************************
* 实现点亮第一颗流水灯
******************************************************/
#if 0
#include"stm32f10x.h"
int main(void)
{
//开gpiob时钟
*(unsigned int *)0x40021018 |= (1<<3);
//配置io为输出模式
*(unsigned int *)0x40010c00 |= (1<<(4*0));
//控制pb0输出低电平
*(unsigned int *)0x40010c0c &= ~(1<<0);
}
#endif
/*****************************************************
* 不同颜色闪烁
******************************************************/
#include "stm32f10x.h"
void Delay(unsigned int TIME)
{
while(TIME--);
}
void LED_ON_G()
{
//开gpiob时钟
*(unsigned int *)0x40021018 |= (1<<3);
//配置io为输出模式
*(unsigned int *)0x40010c00 |= (1<<(4*0));
//控制pb0输出低电平
*(unsigned int *)0x40010c0c &= ~(1<<0);
}
void LED_ON_B()
{
//初始化时钟
*(unsigned int *)0x40021018 |= (1<<3);
//配置io模式
*(unsigned int *)0X40010C00 |= (1<<(4*1));
//设置引脚
*(unsigned int *)0X40010C0c &= ~(1<<1);
}
void LED_ON_R()
{
//初始化时钟
*(unsigned int *)0x40021018 |= (1<<3);
//配置io模式
*(unsigned int *)0X40010C00 |= (1<<(4*5));
//设置引脚
*(unsigned int *)0X40010C0c &= ~(1<<5);
}
void LED_OFF()
{
//初始化时钟
*(unsigned int *)0x40021018 |= (1<<3);
//配置io模式
*(unsigned int *)0X40010C00 |= (1<<(4*5));
//设置引脚
*(unsigned int *)0X40010C0c |=0xffff;
}
int main(void)
{
while(1)
{
LED_OFF();
LED_ON_G();
Delay(0xffff);
LED_OFF();
LED_ON_R();
Delay(0xffff);
LED_OFF();
LED_ON_B();
Delay(0xffff);
}
}
void SystemInit(void)
{
}