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

board/cpu: Added support for the stm32f3discovery board and stm32f3 cpu #1456

Merged
merged 4 commits into from Jul 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions boards/stm32f3discovery/Makefile
@@ -0,0 +1,4 @@
# tell the Makefile.base which module to build
MODULE = $(BOARD)_base

include $(RIOTBASE)/Makefile.base
47 changes: 47 additions & 0 deletions boards/stm32f3discovery/Makefile.include
@@ -0,0 +1,47 @@
# define the cpu used by the stm32f3-discovery board
export CPU = stm32f3
export CPU_MODEL = stm32f303vc

#define the default port depending on the host OS
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyUSB0
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 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.py
export FLASHER = st-flash
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of this PR, but shouldn't we outsource this to something like cortex_m3_common?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #1510


# define build specific options
CPU_USAGE = -mcpu=cortex-m4
FPU_USAGE = -mfloat-abi=hard -mfpu=fpv4-sp-d16
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 += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mthumb-interwork -nostartfiles
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x8000000
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(BINDIR)/$(APPLICATION).elf

# use newLib nano-specs if 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
67 changes: 67 additions & 0 deletions boards/stm32f3discovery/board.c
@@ -0,0 +1,67 @@
/*
* 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_stm32f3discovery
* @{
*
* @file
* @brief Board specific implementations for the STM32F3Discovery evaluation board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/

#include "board.h"

static void leds_init(void);

void board_init(void)
{
/* initialize the boards LEDs */
leds_init();

/* initialize the CPU */
cpu_init();
}

/**
* @brief Initialize the boards on-board LEDs (LD3 to LD10)
*
* The LED initialization is hard-coded in this function. As the LEDs are soldered
* onto the board they are fixed to their CPU pins.
*
* The LEDs are connected to the following pins:
* - LD3: PE9
* - LD4: PE8
* - LD5: PE10
* - LD6: PE15
* - LD7: PE11
* - LD8: PE14
* - LD9: PE12
* - LD10: PE13
*/
static void leds_init(void)
{
/* enable clock for port GPIOE */
RCC->AHBENR |= RCC_AHBENR_GPIOEEN;

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

/* turn all LEDs off */
LED_PORT->BRR = 0xff00;
}
4 changes: 4 additions & 0 deletions boards/stm32f3discovery/dist/debug.sh
@@ -0,0 +1,4 @@
#!/bin/sh

echo "Debugging $1"
arm-none-eabi-gdb -tui -command=$1 $2
1 change: 1 addition & 0 deletions boards/stm32f3discovery/dist/gdb.conf
@@ -0,0 +1 @@
tar extended-remote :4242
103 changes: 103 additions & 0 deletions boards/stm32f3discovery/include/board.h
@@ -0,0 +1,103 @@
/*
* 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_stm32f3discovery STM32F3Discovery
* @ingroup boards
* @brief Board specific files for the STM32F3Discovery board
* @{
*
* @file
* @brief Board specific definitions for the STM32F3Discovery evaluation board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/

#ifndef __BOARD_H
#define __BOARD_H

#include "cpu.h"

/**
* Define the nominal CPU core clock in this board
*/
#define F_CPU (72000000UL)

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

/**
* @name Define the UART used for stdio
* @{
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
/** @} */

/**
* @name LED pin definitions
* @{
*/
#define LED_PORT GPIOE
#define LD3_PIN (1 << 9)
#define LD4_PIN (1 << 8)
#define LD5_PIN (1 << 10)
#define LD6_PIN (1 << 15)
#define LD7_PIN (1 << 11)
#define LD8_PIN (1 << 14)
#define LD9_PIN (1 << 12)
#define LD10_PIN (1 << 13)
/** @} */

/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LD3_ON (LED_PORT->BSRRL = LD3_PIN)
#define LD3_OFF (LED_PORT->BSRRH = LD3_PIN)
#define LD3_TOGGLE (LED_PORT->ODR ^= LD3_PIN)
#define LD4_ON (LED_PORT->BSRRL = LD4_PIN)
#define LD4_OFF (LED_PORT->BSRRH = LD4_PIN)
#define LD4_TOGGLE (LED_PORT->ODR ^= LD4_PIN)
#define LD5_ON (LED_PORT->BSRRL = LD5_PIN)
#define LD5_OFF (LED_PORT->BSRRH = LD5_PIN)
#define LD5_TOGGLE (LED_PORT->ODR ^= LD5_PIN)
#define LD6_ON (LED_PORT->BSRRL = LD6_PIN)
#define LD6_OFF (LED_PORT->BSRRH = LD6_PIN)
#define LD6_TOGGLE (LED_PORT->ODR ^= LD6_PIN)
#define LD7_ON (LED_PORT->BSRRL = LD7_PIN)
#define LD7_OFF (LED_PORT->BSRRH = LD7_PIN)
#define LD7_TOGGLE (LED_PORT->ODR ^= LD7_PIN)
#define LD8_ON (LED_PORT->BSRRL = LD8_PIN)
#define LD8_OFF (LED_PORT->BSRRH = LD8_PIN)
#define LD8_TOGGLE (LED_PORT->ODR ^= LD8_PIN)
#define LD9_ON (LED_PORT->BSRRL = LD9_PIN)
#define LD9_OFF (LED_PORT->BSRRH = LD9_PIN)
#define LD9_TOGGLE (LED_PORT->ODR ^= LD9_PIN)
#define LD10_ON (LED_PORT->BSRRL = LD10_PIN)
#define LD10_OFF (LED_PORT->BSRRH = LD10_PIN)
#define LD10_TOGGLE (LED_PORT->ODR ^= LD10_PIN)
/* for compatability to other boards */
#define LED_GREEN_ON LD4_ON
#define LED_GREEN_OFF LD4_OFF
#define LED_GREEN_TOGGLE LD4_TOGGLE
#define LED_RED_ON LD5_ON
#define LED_RED_OFF LD5_OFF
#define LED_RED_TOGGLE LD5_TOGGLE
/** @} */

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

#endif /** __BOARD_H */
/** @} */