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: added board nucleo f401 #2601

Closed
wants to merge 10 commits into from
4 changes: 4 additions & 0 deletions boards/nucleo-f401/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tell the Makefile.base which module to build
MODULE = $(BOARD)_base

include $(RIOTBASE)/Makefile.base
9 changes: 9 additions & 0 deletions boards/nucleo-f401/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_adc

FEATURES_MCU_GROUP = cortex_m4
59 changes: 59 additions & 0 deletions boards/nucleo-f401/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# define the cpu used by the nucleo-f401 board
export CPU = stm32f4
export CPU_MODEL = stm32f401re

#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 CXX = $(PREFIX)g++
export AR = $(PREFIX)ar
export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh

# define build specific options
CPU_USAGE = -mcpu=cortex-m4
FPU_USAGE = -mfloat-abi=hard -mfpu=fpv4-sp-d16
export CFLAGS += -ggdb -g3 -std=gnu99 -O0 -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-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 -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset

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

# 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
60 changes: 60 additions & 0 deletions boards/nucleo-f401/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright? Most files say "2014 fu berlin", is that correct? at least the year is wrong...

*
* 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 boards_nucleo-f401
* @{
*
* @file
* @brief Board specific implementations for the STM32F4Discovery evaluation board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
Copy link
Contributor

Choose a reason for hiding this comment

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

copy&paste?

*
* @}
*/

#include "board.h"

static void leds_init(void);

void board_init(void)
{
/* initialize the boards LEDs, this is done first for debugging purposes */
leds_init();

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

/**
* @brief Initialize the boards on-board LEDs (LD2)
*
* 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:
* - LD2: PA5
*/
static void leds_init(void)
{
/* enable clock for port GPIOD */
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;

/* configure pins as general outputs */
LED_PORT->MODER &= ~(uint32_t)(0xC00);
LED_PORT->MODER |= (uint32_t)(0x400);
/* set output speed high-speed */
LED_PORT->OSPEEDR |= (uint32_t)(0xC00);
/* set output type to push-pull */
LED_PORT->OTYPER &= ~(uint32_t)(0x20);
/* disable pull resistors */
LED_PORT->PUPDR &= ~(uint32_t)(0xC00);

/* turn LED off */
LED_PORT->BSRRH = 0x20;
}
1 change: 1 addition & 0 deletions boards/nucleo-f401/dist/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source [find board/st_nucleo_f4.cfg]
86 changes: 86 additions & 0 deletions boards/nucleo-f401/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
Copy link
Contributor

Choose a reason for hiding this comment

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

...

*
* 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 boards_stm32f4discovery STM32F4Discovery
* @ingroup boards
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong board

* @brief Board specific files for the STM32F4Discovery board
* @{
*
* @file
* @brief Board specific definitions for the STM32F4Discovery evaluation board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/

#ifndef __BOARD_H
#define __BOARD_H

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

#ifdef __cplusplus
extern "C" {
#endif

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

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

/**
* @name Define UART device and baudrate for stdio
* @{
*/
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_RX_BUFSIZE (64U)
/** @} */

/**
* @name LED pin definitions
* @{
*/
#define LED_PORT GPIOA
#define LD1_PIN (1 << 5)
/** @} */
Copy link
Contributor

Choose a reason for hiding this comment

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

also add
#define LD1_GPIO GPIO(PORT_A,5)


/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LD1_ON (LED_PORT->BSRRL = LD1_PIN)
#define LD1_OFF (LED_PORT->BSRRH = LD1_PIN)
#define LD1_TOGGLE (LED_PORT->ODR ^= LD1_PIN)

/* for compatability to other boards */
#define LED_RED_ON
#define LED_RED_OFF
#define LED_RED_TOGGLE

#define LED_GREEN_ON LD1_ON
#define LED_GREEN_OFF LD1_OFF
#define LED_GREEN_TOGGLE LD1_TOGGLE
Copy link
Contributor

Choose a reason for hiding this comment

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

please add

#define LED_ORANGE_ON
#define LED_ORANGE_OFF
#define LED_ORANGE_TOGGLE

/** @} */

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

#ifdef __cplusplus
}
#endif

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