Skip to content

Commit 5cd0590

Browse files
committed
Add clock config example
1 parent 3d1acb3 commit 5cd0590

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
##
2+
## This file is part of the libopencm3 project.
3+
##
4+
## Copyright (C) 2009 Uwe Hermann <[email protected]>
5+
##
6+
## This library is free software: you can redistribute it and/or modify
7+
## it under the terms of the GNU Lesser General Public License as published by
8+
## the Free Software Foundation, either version 3 of the License, or
9+
## (at your option) any later version.
10+
##
11+
## This library is distributed in the hope that it will be useful,
12+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
## GNU Lesser General Public License for more details.
15+
##
16+
## You should have received a copy of the GNU Lesser General Public License
17+
## along with this library. If not, see <http://www.gnu.org/licenses/>.
18+
##
19+
20+
BINARY = fancyblink
21+
22+
LDSCRIPT = ../stm32f7-discovery.ld
23+
24+
include ../../Makefile.include
25+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# README
2+
3+
Minibink example with clocks enabled. This tests the PLL settings.
4+
5+
## Board connections
6+
7+
*none required*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of the libopencm3 project.
3+
*
4+
* Copyright (C) 2009 Uwe Hermann <[email protected]>
5+
* Copyright (C) 2011 Stephen Caudle <[email protected]>
6+
*
7+
* This library is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with this library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include <libopencm3/stm32/rcc.h>
22+
#include <libopencm3/stm32/gpio.h>
23+
24+
static void clock_setup(void)
25+
{
26+
rcc_clock_setup_hse_3v3(&hse_25mhz_3v3[CLOCK_3V3_216MHZ]);
27+
rcc_periph_clock_enable(RCC_GPIOI);
28+
}
29+
30+
static void gpio_setup(void)
31+
{
32+
33+
gpio_mode_setup(GPIOI, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO1);
34+
}
35+
36+
int main(void)
37+
{
38+
int i;
39+
40+
clock_setup();
41+
gpio_setup();
42+
43+
/* Blink the LED (PI1) on the board. */
44+
while (1) {
45+
46+
/* Using API function gpio_toggle(): */
47+
gpio_toggle(GPIOI, GPIO1); /* LED on/off */
48+
for (i = 0; i < 13500000; i++) { /* Wait a bit. */
49+
__asm__("nop");
50+
}
51+
}
52+
53+
return 0;
54+
}

0 commit comments

Comments
 (0)