-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathblink.c
More file actions
44 lines (35 loc) · 987 Bytes
/
blink.c
File metadata and controls
44 lines (35 loc) · 987 Bytes
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
/* Blinking LED
* ____________
* This program blinks on-board LEDs of STM32F429 Discovery Kit.
* The on-board LEDs are connected to pin 13 and pin 14 of
* GPIO port G
*/
/* Includes */
#include "stm32f4xx.h"
/* Function prototypes */
int main(void);
void delay(uint32_t);
int main(void)
{
/* Enable clock for GPIOG */
RCC->AHB1ENR |= 1 << 6;
/* Set Pin 13 and Pin 14 in General Purpose Output Mode */
GPIOG->MODER &= 0x00000000;
GPIOG->MODER |= (0x01 << 2*14 | 0x01 << 2*13);
/* Set Pin 13 and Pin 14 as pull-up pins */
GPIOG->PUPDR &= 0x00000000;
GPIOG->PUPDR |= (0x01 << 2*14 | 0x01 << 2*13);
/* Set Pin 13 high */
GPIOG->ODR |= (1 << 13);
while(1)
{
delay(10000000);
GPIOG->ODR ^= (1 << 13) | (1 << 14); // Toggle LED
}
}
void delay(uint32_t s)
{
for(s; s>0; s--){
asm("NOP");
}
}