diff --git a/Makefile b/Makefile index a7873bd..41c1825 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ PREFIX ?= arm-none-eabi #PREFIX ?= arm-elf -TARGETS := stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/l1 +TARGETS := stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/l0 stm32/l1 TARGETS += lpc13xx lpc17xx #lpc43xx TARGETS += lm3s lm4f TARGETS += efm32/efm32tg efm32/efm32g efm32/efm32lg efm32/efm32gg diff --git a/examples/stm32/l0/Makefile.include b/examples/stm32/l0/Makefile.include new file mode 100644 index 0000000..e57e0d9 --- /dev/null +++ b/examples/stm32/l0/Makefile.include @@ -0,0 +1,44 @@ +## +## This file is part of the libopencm3 project. +## +## Copyright (C) 2009 Uwe Hermann +## Copyright (C) 2010 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 . +## + +LIBNAME = opencm3_stm32l0 +DEFS = -DSTM32L0 + +FP_FLAGS ?= -msoft-float +ARCH_FLAGS = -mthumb -mcpu=cortex-m0plus $(FP_FLAGS) + +################################################################################ +# OpenOCD specific variables + +OOCD ?= openocd +OOCD_INTERFACE ?= stlink-v2-1 +OOCD_BOARD ?= stm32l0discovery + +################################################################################ +# 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 ../../../../Makefile.rules diff --git a/examples/stm32/l0/stm32l0538-disco/miniblink/Makefile b/examples/stm32/l0/stm32l0538-disco/miniblink/Makefile new file mode 100644 index 0000000..019534a --- /dev/null +++ b/examples/stm32/l0/stm32l0538-disco/miniblink/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 = miniblink + +LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/l0/stm32l0xx8.ld + +include ../../Makefile.include + diff --git a/examples/stm32/l0/stm32l0538-disco/miniblink/README b/examples/stm32/l0/stm32l0538-disco/miniblink/README new file mode 100644 index 0000000..e114b54 --- /dev/null +++ b/examples/stm32/l0/stm32l0538-disco/miniblink/README @@ -0,0 +1,9 @@ +------------------------------------------------------------------------------ +README +------------------------------------------------------------------------------ + +This is the smallest-possible example program using libopencm3. + +It's intended for the ST STM32L053-DISCOVERY eval board. It should blink +the red/green LEDs on the board in turn. + diff --git a/examples/stm32/l0/stm32l0538-disco/miniblink/miniblink.c b/examples/stm32/l0/stm32l0538-disco/miniblink/miniblink.c new file mode 100644 index 0000000..590641e --- /dev/null +++ b/examples/stm32/l0/stm32l0538-disco/miniblink/miniblink.c @@ -0,0 +1,60 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2009 Uwe Hermann + * Copyright (C) 2011 Stephen Caudle + * Copyright (C) 2012 Karl Palsson + * + * 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 + +#define LED_GREEN_PIN GPIO4 +#define LED_GREEN_PORT GPIOB +#define LED_RED_PIN GPIO5 +#define LED_RED_PORT GPIOA + +static void gpio_setup(void) +{ + /* Enable GPIOB clock. */ + rcc_periph_clock_enable(RCC_GPIOA); + rcc_periph_clock_enable(RCC_GPIOB); + + /* set pins to output mode, push pull */ + gpio_mode_setup(LED_RED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_RED_PIN); + gpio_mode_setup(LED_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_GREEN_PIN); +} + +int main(void) +{ + int i; + + gpio_setup(); + + while (1) { + /* toggle each led in turn */ + gpio_toggle(LED_GREEN_PORT, LED_GREEN_PIN); + for (i = 0; i < 100000; i++) { /* Wait a bit. */ + __asm__("nop"); + } + gpio_toggle(LED_RED_PORT, LED_RED_PIN); + for (i = 0; i < 100000; i++) { /* Wait a bit. */ + __asm__("nop"); + } + } + + return 0; +}