Skip to content

Commit ce35f6a

Browse files
committed
stm32: Add more f7 examples
1 parent 40a8b89 commit ce35f6a

File tree

13 files changed

+562
-0
lines changed

13 files changed

+562
-0
lines changed

examples/stm32/f7/Makefile.include

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
##
2+
## This file is part of the libopencm3 project.
3+
##
4+
## Copyright (C) 2009 Uwe Hermann <[email protected]>
5+
## Copyright (C) 2010 Piotr Esden-Tempski <[email protected]>
6+
## Copyright (C) 2011 Fergus Noble <[email protected]>
7+
##
8+
## This library is free software: you can redistribute it and/or modify
9+
## it under the terms of the GNU Lesser General Public License as published by
10+
## the Free Software Foundation, either version 3 of the License, or
11+
## (at your option) any later version.
12+
##
13+
## This library is distributed in the hope that it will be useful,
14+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
## GNU Lesser General Public License for more details.
17+
##
18+
## You should have received a copy of the GNU Lesser General Public License
19+
## along with this library. If not, see <http://www.gnu.org/licenses/>.
20+
##
21+
22+
LIBNAME = opencm3_stm32f7
23+
DEFS = -DSTM32F7
24+
25+
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv5-sp-d16
26+
ARCH_FLAGS = -mthumb -mcpu=cortex-m7 $(FP_FLAGS)
27+
28+
################################################################################
29+
# OpenOCD specific variables
30+
31+
OOCD ?= openocd
32+
OOCD_INTERFACE ?= stlink-v2
33+
OOCD_BOARD ?= stm32f7discovery
34+
35+
################################################################################
36+
# Black Magic Probe specific variables
37+
# Set the BMP_PORT to a serial port and then BMP is used for flashing
38+
BMP_PORT ?=
39+
40+
################################################################################
41+
# texane/stlink specific variables
42+
#STLINK_PORT ?= :4242
43+
44+
45+
include ../../../../Makefile.rules
46+
47+
48+
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+
}
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 = miniblink
21+
22+
LDSCRIPT = ../stm32f7-discovery.ld
23+
24+
include ../../Makefile.include
25+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# README
2+
3+
This is the smallest-possible example program using libopencm3.
4+
5+
It's intended for the ST STM32F7DISCOVERY eval board. It should blink
6+
the GREEN LED on the board.
7+
8+
## Board connections
9+
10+
*none required*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 gpio_setup(void)
25+
{
26+
rcc_periph_clock_enable(RCC_GPIOI);
27+
28+
gpio_mode_setup(GPIOI, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO1);
29+
}
30+
31+
int main(void)
32+
{
33+
int i;
34+
35+
gpio_setup();
36+
37+
/* Blink the LED (PI1) on the board. */
38+
while (1) {
39+
gpio_toggle(GPIOI, GPIO1); /* LED on/off */
40+
for (i = 0; i < 1000000; i++) { /* Wait a bit. */
41+
__asm__("nop");
42+
}
43+
}
44+
45+
return 0;
46+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/* Linker script for ST STM32F4DISCOVERY (STM32F407VG, 1024K flash, 128K RAM). */
22+
23+
/* Define memory regions. */
24+
MEMORY
25+
{
26+
rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
27+
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 240K
28+
}
29+
30+
/* Include the common ld script. */
31+
INCLUDE libopencm3_stm32f7.ld
32+
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+
# This library is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Lesser General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This library is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Lesser General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Lesser General Public License
15+
# along with this library. If not, see <http://www.gnu.org/licenses/>.
16+
#
17+
18+
OBJS = clock.o
19+
20+
BINARY = usart_console
21+
22+
LDSCRIPT = ../stm32f7-discovery.ld
23+
24+
include ../../Makefile.include
25+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Simple USART Example
2+
--------------------
3+
4+
This example sets up a USART port and provides a few simple
5+
character handling functions to that a short interactive program
6+
can be demonstrated. It re-uses the clock setup from systick_blink
7+
and that means you could do times delays but that aspect isn't used.
8+
9+
After this example we do character handling with interrupts.

0 commit comments

Comments
 (0)