mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
boards/nucleo32-common: factorize common code for nucleo 32 boards
This commit is contained in:
parent
0b7ce88585
commit
0ef714650b
3
boards/nucleo32-common/Makefile
Normal file
3
boards/nucleo32-common/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = nucleo32_common
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
3
boards/nucleo32-common/Makefile.features
Normal file
3
boards/nucleo32-common/Makefile.features
Normal file
@ -0,0 +1,3 @@
|
||||
# Various common features of Nucleo boards
|
||||
FEATURES_PROVIDED += cpp
|
||||
FEATURES_PROVIDED += arduino
|
5
boards/nucleo32-common/Makefile.include
Normal file
5
boards/nucleo32-common/Makefile.include
Normal file
@ -0,0 +1,5 @@
|
||||
# include nucleo common serial configuration
|
||||
include $(RIOTBOARD)/nucleo-common/Makefile.include.serial
|
||||
|
||||
# add the common header files to the include path
|
||||
INCLUDES += -I$(RIOTBOARD)/nucleo32-common/include
|
66
boards/nucleo32-common/include/arduino_board.h
Normal file
66
boards/nucleo32-common/include/arduino_board.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Inria
|
||||
*
|
||||
* 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_nucleo32-common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Board specific configuration for the Arduino API
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef ARDUINO_BOARD_H
|
||||
#define ARDUINO_BOARD_H
|
||||
|
||||
#include "arduino_pinmap.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The on-board LED is connected to pin 13 on this board
|
||||
*/
|
||||
#define ARDUINO_LED (13)
|
||||
|
||||
/**
|
||||
* @brief Look-up table for the Arduino's digital pins
|
||||
*/
|
||||
static const gpio_t arduino_pinmap[] = {
|
||||
ARDUINO_PIN_0,
|
||||
ARDUINO_PIN_1,
|
||||
ARDUINO_PIN_2,
|
||||
ARDUINO_PIN_3,
|
||||
ARDUINO_PIN_4,
|
||||
ARDUINO_PIN_5,
|
||||
ARDUINO_PIN_6,
|
||||
ARDUINO_PIN_7,
|
||||
ARDUINO_PIN_8,
|
||||
ARDUINO_PIN_9,
|
||||
ARDUINO_PIN_10,
|
||||
ARDUINO_PIN_11,
|
||||
ARDUINO_PIN_12,
|
||||
ARDUINO_PIN_13,
|
||||
ARDUINO_PIN_A0,
|
||||
ARDUINO_PIN_A1,
|
||||
ARDUINO_PIN_A2,
|
||||
ARDUINO_PIN_A3,
|
||||
ARDUINO_PIN_A4,
|
||||
ARDUINO_PIN_A5,
|
||||
ARDUINO_PIN_A6,
|
||||
ARDUINO_PIN_A7
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARDUINO_BOARD_H */
|
||||
/** @} */
|
66
boards/nucleo32-common/include/arduino_pinmap.h
Normal file
66
boards/nucleo32-common/include/arduino_pinmap.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Inria
|
||||
*
|
||||
* 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_nucleo32-common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Mapping from MCU pins to Arduino pins
|
||||
*
|
||||
* You can use the defines in this file for simplified interaction with the
|
||||
* Arduino specific pin numbers.
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef ARDUINO_PINMAP_H
|
||||
#define ARDUINO_PINMAP_H
|
||||
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mapping of MCU pins to Arduino pins
|
||||
* @{
|
||||
*/
|
||||
#define ARDUINO_PIN_0 GPIO_PIN(PORT_A, 10)
|
||||
#define ARDUINO_PIN_1 GPIO_PIN(PORT_A, 9)
|
||||
#define ARDUINO_PIN_2 GPIO_PIN(PORT_A, 12)
|
||||
#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 0)
|
||||
#define ARDUINO_PIN_4 GPIO_PIN(PORT_B, 7)
|
||||
#define ARDUINO_PIN_5 GPIO_PIN(PORT_B, 6)
|
||||
#define ARDUINO_PIN_6 GPIO_PIN(PORT_B, 1)
|
||||
#define ARDUINO_PIN_7 GPIO_PIN(PORT_C, 14)
|
||||
|
||||
#define ARDUINO_PIN_8 GPIO_PIN(PORT_C, 15)
|
||||
#define ARDUINO_PIN_9 GPIO_PIN(PORT_A, 8)
|
||||
#define ARDUINO_PIN_10 GPIO_PIN(PORT_A, 11)
|
||||
#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5)
|
||||
#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4)
|
||||
#define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 3) /* on-board LED */
|
||||
|
||||
#define ARDUINO_PIN_A0 GPIO_PIN(PORT_A, 0)
|
||||
#define ARDUINO_PIN_A1 GPIO_PIN(PORT_A, 1)
|
||||
#define ARDUINO_PIN_A2 GPIO_PIN(PORT_A, 3)
|
||||
#define ARDUINO_PIN_A3 GPIO_PIN(PORT_A, 4)
|
||||
#define ARDUINO_PIN_A4 GPIO_PIN(PORT_A, 5)
|
||||
#define ARDUINO_PIN_A5 GPIO_PIN(PORT_A, 6)
|
||||
#define ARDUINO_PIN_A6 GPIO_PIN(PORT_A, 7)
|
||||
#define ARDUINO_PIN_A7 GPIO_PIN(PORT_A, 2)
|
||||
/** @ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARDUINO_PINMAP_H */
|
||||
/** @} */
|
52
boards/nucleo32-common/include/board_common.h
Normal file
52
boards/nucleo32-common/include/board_common.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Inria
|
||||
*
|
||||
* 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_nucleo32-common STM Nucleo-32 Common
|
||||
* @ingroup boards
|
||||
* @brief Common files for STM Nucleo-32 boards
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common pin definitions and board configuration options
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef BOARD_COMMON_H
|
||||
#define BOARD_COMMON_H
|
||||
|
||||
#include "cpu.h"
|
||||
#include "periph_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Macros for controlling the on-board LED (LD3).
|
||||
* @{
|
||||
*/
|
||||
#define LED0_PIN GPIO_PIN(PORT_B, 3)
|
||||
#define LED0_MASK (1 << 3)
|
||||
#define LED0_ON (GPIOB->BSRR = LED0_MASK)
|
||||
#define LED0_OFF (GPIOB->BSRR = (LED0_MASK << 16))
|
||||
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
||||
*/
|
||||
void board_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_COMMON_H */
|
||||
/** @} */
|
46
boards/nucleo32-common/include/gpio_params.h
Normal file
46
boards/nucleo32-common/include/gpio_params.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Inria
|
||||
*
|
||||
* 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_nucleo32-common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Board specific configuration of direct mapped GPIOs
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef GPIO_PARAMS_H
|
||||
#define GPIO_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
#include "saul/periph.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIO pin configuration
|
||||
*/
|
||||
static const saul_gpio_params_t saul_gpio_params[] =
|
||||
{
|
||||
{
|
||||
.name = "LD3(green)",
|
||||
.pin = LED0_PIN,
|
||||
.mode = GPIO_OUT
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GPIO_PARAMS_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user