stm32:l0: miniblink example
Very basic, as all miniblinks.
This commit is contained in:
committed by
Karl Palsson
parent
312540a0e5
commit
1b2f9db18f
2
Makefile
2
Makefile
@@ -20,7 +20,7 @@
|
|||||||
PREFIX ?= arm-none-eabi
|
PREFIX ?= arm-none-eabi
|
||||||
#PREFIX ?= arm-elf
|
#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 += lpc13xx lpc17xx #lpc43xx
|
||||||
TARGETS += lm3s lm4f
|
TARGETS += lm3s lm4f
|
||||||
TARGETS += efm32/efm32tg efm32/efm32g efm32/efm32lg efm32/efm32gg
|
TARGETS += efm32/efm32tg efm32/efm32g efm32/efm32lg efm32/efm32gg
|
||||||
|
|||||||
44
examples/stm32/l0/Makefile.include
Normal file
44
examples/stm32/l0/Makefile.include
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
##
|
||||||
|
## This file is part of the libopencm3 project.
|
||||||
|
##
|
||||||
|
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||||
|
## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
|
||||||
|
##
|
||||||
|
## 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/>.
|
||||||
|
##
|
||||||
|
|
||||||
|
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
|
||||||
25
examples/stm32/l0/stm32l0538-disco/miniblink/Makefile
Normal file
25
examples/stm32/l0/stm32l0538-disco/miniblink/Makefile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
##
|
||||||
|
## This file is part of the libopencm3 project.
|
||||||
|
##
|
||||||
|
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||||
|
##
|
||||||
|
## 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 = miniblink
|
||||||
|
|
||||||
|
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/l0/stm32l0xx8.ld
|
||||||
|
|
||||||
|
include ../../Makefile.include
|
||||||
|
|
||||||
9
examples/stm32/l0/stm32l0538-disco/miniblink/README
Normal file
9
examples/stm32/l0/stm32l0538-disco/miniblink/README
Normal file
@@ -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.
|
||||||
|
|
||||||
60
examples/stm32/l0/stm32l0538-disco/miniblink/miniblink.c
Normal file
60
examples/stm32/l0/stm32l0538-disco/miniblink/miniblink.c
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||||
|
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user