Skip to content

Commit

Permalink
stm32l1: initial port for the nucleo-l1 board and stm32l1 cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseichinger committed Jan 12, 2015
1 parent db58a8b commit ccd8b45
Show file tree
Hide file tree
Showing 32 changed files with 10,524 additions and 0 deletions.
3 changes: 3 additions & 0 deletions boards/nucleo-l1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE =$(BOARD)_base

include $(RIOTBASE)/Makefile.base
2 changes: 2 additions & 0 deletions boards/nucleo-l1/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FEATURES_PROVIDED += periph_gpio periph_uart periph_spi periph_i2c periph_cpuid
FEATURES_PROVIDED += cpp
56 changes: 56 additions & 0 deletions boards/nucleo-l1/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## the cpu to build for
export CPU = stm32l1
export CPU_MODEL = stm32l152ret6

#define the default port depending on the host OS
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyACM0
else ifeq ($(OS),Darwin)
PORT ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: add support for windows as host platform
endif
export PORT

# define tools used for building the project
export PREFIX = arm-none-eabi-
export CC = $(PREFIX)gcc
export CXX = $(PREFIX)g++
export AR = $(PREFIX)ar
export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh

# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=

# define build specific options
export CPU_USAGE = -mcpu=cortex-m3
export FPU_USAGE =
export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mthumb-interwork -nostartfiles
export CFLAGS += -ffunction-sections -fdata-sections -fno-builtin
export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mthumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export TERMFLAGS += -p "$(PORT)"

# use the nano-specs of the NewLib when available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
export LINKFLAGS += -specs=nano.specs -lc -lnosys
endif

# export board specific includes to the global includes-listing
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
60 changes: 60 additions & 0 deletions boards/nucleo-l1/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/

/**
* @ingroup board_nucleo-l1
* @{
*
* @file board.c
* @brief Board specific implementations for the nucleo-l1 board
*
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
*
* @}
*/

#include "board.h"
#include "cpu.h"

static void leds_init(void);

void board_init(void)
{
/* initialize the CPU */
cpu_init();

/* initialize the boards LEDs */
leds_init();
}

/**
* @brief Initialize the boards on-board LEDs
*
* The LED initialization is hard-coded in this function. As the LED is soldered
* onto the board it is fixed to its CPU pins.
*
* The green LED is connected to pin PA5
*/
static void leds_init(void)
{
/* enable clock for port GPIOE */
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;

/* set output speed to 50MHz */
LED_GREEN_PORT->OSPEEDR |= 0x00000c00;
/* set output type to push-pull */
LED_GREEN_PORT->OTYPER &= ~(0x00000020);
/* configure pins as general outputs */
LED_GREEN_PORT->MODER &= ~(0x00000c00);
LED_GREEN_PORT->MODER |= 0x00000400;
/* disable pull resistors */
LED_GREEN_PORT->PUPDR &= ~(0x00000c00);

/* turn all LEDs off */
LED_GREEN_PORT->BRR = 0x00c0;
}
10 changes: 10 additions & 0 deletions boards/nucleo-l1/dist/debug-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

echo "##"
echo "## Starting debug server"
echo "##"

openocd -f "${RIOTBOARD}/${BOARD}/dist/openocd.cfg" \
-c "init" \
-c "targets" \
-c "reset halt"
11 changes: 11 additions & 0 deletions boards/nucleo-l1/dist/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

if [ ! -f "$2" ]; then
echo "ELF-file $2 does not exist"
exit 1
fi

echo "##"
echo "## Debugging $2"
echo "##"
arm-none-eabi-gdb -tui -command="$1" $2
13 changes: 13 additions & 0 deletions boards/nucleo-l1/dist/flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo "##"
echo "## Flashing $1"
echo "##"

openocd -f "${RIOTBOARD}/${BOARD}/dist/openocd.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "program $1 0x8000000 verify" \
-c "reset run"\
-c "shutdown"
1 change: 1 addition & 0 deletions boards/nucleo-l1/dist/gdb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tar extended-remote :3333
6 changes: 6 additions & 0 deletions boards/nucleo-l1/dist/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# stml1 Target
source [find interface/stlink-v2-1.cfg]

transport select hla_swd

source [find target/stm32l.cfg]
10 changes: 10 additions & 0 deletions boards/nucleo-l1/dist/reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "##"
echo "## Resetting $1"
echo "##"

openocd -f "${RIOTBOARD}/${BOARD}/dist/openocd.cfg" \
-c "init" \
-c "reset run"\
-c "shutdown"
93 changes: 93 additions & 0 deletions boards/nucleo-l1/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/

/**
* @defgroup board_nucleo-l1 nucleo-l1
* @ingroup boards
* @brief Board specific files for the nucleo-l1 board.
* @{
*
* @file
* @brief Board specific definitions for the nucleo-l1 board.
*
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
*/

#ifndef BOARD_H_
#define BOARD_H_

#include <stdint.h>

#include "cpu.h"
#include "periph_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Define the nominal CPU core clock in this board
*/
#define F_CPU CLOCK_CORECLOCK

/**
* @name Define the UART to be used as stdio and its baudrate
* @{
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
* @name Assign the hardware timer
*/
#define HW_TIMER TIMER_0

/**
* @name LED pin definitions
* @{
*/
#define LED_GREEN_PORT (GPIOA)
#define LED_GREEN_PIN (5)
/** @} */

/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LED_RED_ON
#define LED_RED_OFF
#define LED_RED_TOGGLE

#define LED_GREEN_ON (LED_GREEN_PORT->ODR &= ~(1<<LED_GREEN_PIN))
#define LED_GREEN_OFF (LED_GREEN_PORT->ODR |= (1<<LED_GREEN_PIN))
#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1<<LED_GREEN_PIN))

#define LED_ORANGE_ON
#define LED_ORANGE_OFF
#define LED_ORANGE_TOGGLE
/** @} */

/**
* @name Define the type for the radio packet length for the transceiver
*/
typedef uint8_t radio_packet_length_t;

/**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
*/
void board_init(void);

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H_ */
/** @} */
/** @} */
Loading

0 comments on commit ccd8b45

Please sign in to comment.