diff --git a/examples/stm32/f4/stm32f429i-discovery/fancyblink/Makefile b/examples/stm32/f4/stm32f429i-discovery/fancyblink/Makefile new file mode 100644 index 0000000..2cd35ea --- /dev/null +++ b/examples/stm32/f4/stm32f429i-discovery/fancyblink/Makefile @@ -0,0 +1,25 @@ +## +## This file is part of the libopencm3 project. +## +## Copyright (C) 2009 Uwe Hermann +## +## 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 . +## + +BINARY = fancyblink + +LDSCRIPT = ../stm32f429i-discovery.ld + +include ../../Makefile.include + diff --git a/examples/stm32/f4/stm32f429i-discovery/fancyblink/README b/examples/stm32/f4/stm32f429i-discovery/fancyblink/README new file mode 100644 index 0000000..8d3d537 --- /dev/null +++ b/examples/stm32/f4/stm32f429i-discovery/fancyblink/README @@ -0,0 +1,13 @@ +------------------------------------------------------------------------------ +README +------------------------------------------------------------------------------ + +This is the smallest-possible example program using libopencm3. + +It's intended for the ST STM32F429IDISCOVERY eval board. It should blink +the LEDs on the board. + +Board connections: +------------------ + + diff --git a/examples/stm32/f4/stm32f429i-discovery/fancyblink/fancyblink.c b/examples/stm32/f4/stm32f429i-discovery/fancyblink/fancyblink.c new file mode 100644 index 0000000..fc48484 --- /dev/null +++ b/examples/stm32/f4/stm32f429i-discovery/fancyblink/fancyblink.c @@ -0,0 +1,61 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2009 Uwe Hermann + * Copyright (C) 2011 Damjan Marion + * Copyright (C) 2011 Mark Panajotovic + * + * 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 . + */ + +#include +#include + +/* Set STM32 to 168 MHz. */ +static void clock_setup(void) +{ + rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); + + /* Enable GPIOG clock. */ + rcc_periph_clock_enable(RCC_GPIOG); +} + +static void gpio_setup(void) +{ + /* Set GPIO13-14 (in GPIO port G) to 'output push-pull'. */ + gpio_mode_setup(GPIOG, GPIO_MODE_OUTPUT, + GPIO_PUPD_NONE, GPIO13 | GPIO14); +} + +int main(void) +{ + int i; + + clock_setup(); + gpio_setup(); + + /* Set two LEDs for wigwag effect when toggling. */ + gpio_set(GPIOG, GPIO13); + + /* Blink the LEDs (PG13 and PG14) on the board. */ + while (1) { + /* Toggle LEDs. */ + gpio_toggle(GPIOG, GPIO13 | GPIO14); + for (i = 0; i < 6000000; i++) { /* Wait a bit. */ + __asm__("nop"); + } + } + + return 0; +} diff --git a/examples/stm32/f4/stm32f429i-discovery/stm32f429i-discovery.ld b/examples/stm32/f4/stm32f429i-discovery/stm32f429i-discovery.ld new file mode 100644 index 0000000..8137997 --- /dev/null +++ b/examples/stm32/f4/stm32f429i-discovery/stm32f429i-discovery.ld @@ -0,0 +1,33 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2009 Uwe Hermann + * Copyright (C) 2011 Stephen Caudle + * Copyright (C) 2015 Piotr Esden-Tempski + * + * 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 . + */ + +/* Linker script for ST STM32F429IDISCOVERY (STM32F429ZI, 2048K flash, 256K RAM). */ + +/* Define memory regions. */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K /* (esden) This should be 256 but I get segfault. :( */ +} + +/* Include the common ld script. */ +INCLUDE libopencm3_stm32f4.ld +