Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32f7: Add nucleo-f767zi example #187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
PREFIX ?= arm-none-eabi
#PREFIX ?= arm-elf

TARGETS := stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/l0 stm32/l1
TARGETS := stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/f7 stm32/l0 stm32/l1
TARGETS += lpc/lpc13xx lpc/lpc17xx #lpc/lpc43xx
TARGETS += tiva/lm3s tiva/lm4f
TARGETS += efm32/efm32tg efm32/efm32g efm32/efm32lg efm32/efm32gg
Expand Down
48 changes: 48 additions & 0 deletions examples/stm32/f7/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <[email protected]>
## Copyright (C) 2010 Piotr Esden-Tempski <[email protected]>
## Copyright (C) 2011 Fergus Noble <[email protected]>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
##

# You should use linker script generation! Specify device!
ifeq ($(DEVICE),)
LIBNAME = opencm3_stm32f7
DEFS += -DSTM32F7

FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m7 $(FP_FLAGS)
endif

################################################################################
# OpenOCD specific variables

OOCD ?= openocd
OOCD_INTERFACE ?= stlink-v2
OOCD_TARGET ?= stm32f7x

################################################################################
# Black Magic Probe specific variables
# Set the BMP_PORT to a serial port and then BMP is used for flashing
BMP_PORT ?=

################################################################################
# texane/stlink specific variables
#STLINK_PORT ?= :4242


include ../../../../rules.mk
32 changes: 32 additions & 0 deletions examples/stm32/f7/nucleo-f767zi/nucleo-f767zi.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <[email protected]>
* Copyright (C) 2011 Stephen Caudle <[email protected]>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

/* Linker script for Nucleo F411RE (STM32F411RE, 512K flash, 128K RAM). */

/* Define memory regions. */
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 512K
}

/* Include the common ld script. */
INCLUDE cortex-m-generic.ld

26 changes: 26 additions & 0 deletions examples/stm32/f7/nucleo-f767zi/usart/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <[email protected]>
## Copyright (C) 2015 Chuck McManis <[email protected]>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
##

BINARY = usart

LDSCRIPT = ../nucleo-f767zi.ld

include ../../Makefile.include

21 changes: 21 additions & 0 deletions examples/stm32/f7/nucleo-f767zi/usart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# README

This example program sends repeating sequence of characters "0123456789" on
USART3 on the ST Nucleo F767ZI eval board.

The sending is done in a blocking way.

Note that the Nucleo board exports the serial port as an ttyACM device on
Linux or a COM port on Windows. On Linux, if you can locate the correct
serial port as

/dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066CFF515056805087171825-if02

(note there will be differences based on the serial number of your board)
this may also show up as /dev/ttyACM0 if it was the first serial port
enumerated, if you have additional serial devices attached to the USB port
of your system they may show up as additional ttyACM1/ttyACM2/... etc.

Connect to the port using `screen /dev/ttyACM0 115200` where you replace
the serial port with the one for your system.

85 changes: 85 additions & 0 deletions examples/stm32/f7/nucleo-f767zi/usart/usart.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <[email protected]>
* Copyright (C) 2011 Stephen Caudle <[email protected]>
* Copyright (C) 2015 Chuck McManis <[email protected]>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>

static void clock_setup(void)
{
/* Enable clocks for LED & USART3. */
rcc_periph_clock_enable(RCC_GPIOB);
rcc_periph_clock_enable(RCC_GPIOD);

/* Enable clocks for USART3. */
rcc_periph_clock_enable(RCC_USART3);
}

static void usart_setup(void)
{
/* Setup USART3 parameters. */
usart_set_baudrate(USART3, 115200);
usart_set_databits(USART3, 8);
usart_set_stopbits(USART3, USART_STOPBITS_1);
usart_set_mode(USART3, USART_MODE_TX);
usart_set_parity(USART3, USART_PARITY_NONE);
usart_set_flow_control(USART3, USART_FLOWCONTROL_NONE);

/* Finally enable the USART. */
usart_enable(USART3);
}

static void gpio_setup(void)
{
/* Setup GPIO pin GPIO0 on GPIO port B for LED. */
gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO0);

/* Setup GPIO pins for USART3 transmit. */
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO8);

/* Setup USART3 TX pin as alternate function. */
gpio_set_af(GPIOD, GPIO_AF7, GPIO8);
}

int main(void)
{
int i, j = 0, c = 0;

clock_setup();
gpio_setup();
usart_setup();

/* Blink the LED on the board with every transmitted byte. */
while (1) {
gpio_toggle(GPIOB, GPIO0); /* LED on/off */
usart_send_blocking(USART3, c + '0'); /* USART3: Send byte. */
c = (c == 9) ? 0 : c + 1; /* Increment c. */
if ((j++ % 80) == 0) { /* Newline after line full. */
usart_send_blocking(USART3, '\r');
usart_send_blocking(USART3, '\n');
}
for (i = 0; i < 300000; i++) { /* Wait a bit. */
__asm__("NOP");
}
}

return 0;
}