Skip to content

Commit

Permalink
boards: added support for Calliope mini
Browse files Browse the repository at this point in the history
  • Loading branch information
haukepetersen committed Nov 21, 2016
1 parent 9c7d9eb commit df27ad2
Show file tree
Hide file tree
Showing 12 changed files with 739 additions and 0 deletions.
7 changes: 7 additions & 0 deletions boards/calliope-mini/Makefile
@@ -0,0 +1,7 @@
MODULE = board

ifneq (,$(filter mini,$(USEMODULE)))
DIRS += mini
endif

include $(RIOTBASE)/Makefile.base
8 changes: 8 additions & 0 deletions boards/calliope-mini/Makefile.dep
@@ -0,0 +1,8 @@
ifneq (,$(filter mini,$(USEMODULE)))
USEMODULE += xtimer
USEMODULE += mineplex
endif

ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
14 changes: 14 additions & 0 deletions boards/calliope-mini/Makefile.features
@@ -0,0 +1,14 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_hwrng
FEATURES_PROVIDED += periph_rtt
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

# Various other features (if any)
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += radio_nrfmin

# The board MPU family (used for grouping by the CI system)
FEATURES_MCU_GROUP = cortex_m0_1
28 changes: 28 additions & 0 deletions boards/calliope-mini/Makefile.include
@@ -0,0 +1,28 @@
# define the used CPU
export CPU = nrf51
export CPU_MODEL = nrf51x22xxab

# define the default port depending on the host OS
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))

# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

# we support flashing through plain fscopy or using JLink
FLASHTOOL ?= fscopy
ifeq (fscopy,$(FLASHTOOL))
export OFLAGS = -O ihex
export HEXFILE = $(ELFFILE:.elf=.hex)
export FFLAGS =
export DEBUGGER_FLAGS =

export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER =
export DEBUGSERVER =
else ifeq (jlink,$(FLASHTOOL))
export JLINK_DEVICE := nrf51822
include $(RIOTBOARD)/Makefile.include.jlink
else
$(info ERROR: invalid flash tool specified)
endif
32 changes: 32 additions & 0 deletions boards/calliope-mini/board.c
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 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 boards_calliope-mini
* @{
*
* @file
* @brief Board initialization code for the Calliope mini
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/

#include "board.h"
#include "periph/gpio.h"

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

/* initialize the mini's buttons */
gpio_init(BTN0_PIN, GPIO_IN);
gpio_init(BTN1_PIN, GPIO_IN);
}
65 changes: 65 additions & 0 deletions boards/calliope-mini/dist/flash.sh
@@ -0,0 +1,65 @@
#!/bin/sh

# 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.

# The Calliope mini can be flashed through accessing it as a mass storage
# device. To upload a new firmware, simply copy your binary onto this device.
#
# Under Ubuntu/Mint the default mount-point is /media/$(USER)/MINI
#
# @author Hauke Petersen <hauke.petersen@fu-berlin.de>
# @author Oliver Hahm <oliver.hahm@inria.fr>

OS=`uname`
DID_MOUNT=false
NAME="MINI"

# set the mount path depending on the OS
if [ ${OS} = "Linux" ]
then
MOUNT=/media/${USER}/${NAME}
elif [ ${OS} = "Darwin" ]
then
MOUNT=/Volumes/${NAME}
else
echo ""
echo "ERROR: No mount point defined for your OS"
echo "Please copy the binary manually to your Calliope mini"
echo ""
exit
fi

# check if device was mounted
mount | grep ${MOUNT} > /dev/null
if [ $? -eq 1 ]
then
mount ${MOUNT}
if [ $? -eq 1 ]
then
echo ""
echo "ERROR: could not mount your Calliope mini"
echo ""
exit
else
DID_MOUNT=true
fi
fi

# copy new binary to device
cp ${HEXFILE} ${MOUNT}
# make sure hexfile was written
sync

# unmount the device if we have manually mounted it before
if [ ${DID_MOUNT} = true ]
then
umount ${MOUNT}
fi

echo ""
echo "UPLOAD SUCCESFUL"
echo ""
93 changes: 93 additions & 0 deletions boards/calliope-mini/include/board.h
@@ -0,0 +1,93 @@
/*
* Copyright (C) 2016 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 boards_mini Calliope mini
* @ingroup boards
* @brief Board specific files for the Calliope mini
* @{
*
* @file
* @brief Board specific configuration for the Calliope mini
*
* @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

/**
* @brief Xtimer configuration
* @{
*/
#define XTIMER_DEV (0)
#define XTIMER_CHAN (0)
#define XTIMER_WIDTH (24)
#define XTIMER_BACKOFF (40)
/** @} */

/**
* @brief LED matrix pin configuration
* @{
*/
#define MINI_LED_COL1 GPIO_PIN(0, 4)
#define MINI_LED_COL2 GPIO_PIN(0, 5)
#define MINI_LED_COL3 GPIO_PIN(0, 6)
#define MINI_LED_COL4 GPIO_PIN(0, 7)
#define MINI_LED_COL5 GPIO_PIN(0, 8)
#define MINI_LED_COL6 GPIO_PIN(0, 9)
#define MINI_LED_COL7 GPIO_PIN(0, 10)
#define MINI_LED_COL8 GPIO_PIN(0, 11)
#define MINI_LED_COL9 GPIO_PIN(0, 12)
#define MINI_LED_ROW1 GPIO_PIN(0, 13)
#define MINI_LED_ROW2 GPIO_PIN(0, 14)
#define MINI_LED_ROW3 GPIO_PIN(0, 15)
/** @} */

/**
* @brief Button configuration
* @{
*/
#define BTN0_PIN GPIO_PIN(0, 17)
#define BTN1_PIN GPIO_PIN(0, 26)
/** @} */

/**
* @brief MMA8653 accelerometer configuration
* @{
*/
#define MMA8653_PARAM_I2C I2C_0,
#define MMA8653_PARAM_ADDR 0x1d
/** @} */

/**
* @brief MAG3110 magnetometer configuration
* @{
*/
#define MAG3110_PARAM_I2C I2C_0,
#define MAG3110_PARAM_ADDR 0x0e
/** @} */

/**
* @brief Initialize the board, also triggers the CPU initialization
*/
void board_init(void);

#ifdef __cplusplus
}
#endif

#endif /** BOARD_H */
/** @} */
51 changes: 51 additions & 0 deletions boards/calliope-mini/include/gpio_params.h
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2016 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 boards_calliope-mini
* @{
*
* @file
* @brief Board specific configuration of direct mapped GPIOs
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/

#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 = "Button A",
.pin = BTN0_PIN,
.mode = GPIO_IN
},
{
.name = "Button B",
.pin = BTN1_PIN,
.mode = GPIO_IN
},
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
90 changes: 90 additions & 0 deletions boards/calliope-mini/include/mini.h
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2016 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 boards_calliope-mini
* @{
*
* @file
* @brief Calliope mini specific LED handling
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/

#ifndef MINI_H_
#define MINI_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Number of rows of the LED matrix
*/
#define MINI_MATRIX_ROWS (5U)

/**
* @brief Number of columns of the LED matrix
*/
#define MINI_MATRIX_COLS (5U)

/**
* @brief Initialize the Calliope mini's LED matrix
*/
void mini_matrix_init(void);

/**
* @brief Turn on a single LED in the LED matrix
*
* @param[in] row row of the LED
* @param[in] col column of the LED
*/
void mini_matrix_on(uint8_t row, uint8_t col);

/**
* @brief Turn off a single LED in the LED matrix
*
* @param[in] row row of the LED
* @param[in] col column of the LED
*/
void mini_matrix_off(uint8_t row, uint8_t col);

/**
* @brief Write the given 'image' to the LED matrix
*
* In the given buffer, each byte represents one LED in the matrix, hence the
* buffer MUST be at least 25 byte wide. A byte value of `0` turns an LED off,
* while any other value turns it on.
*
* @param[in] buf new data to display, MUST be at least 25 byte
*/
void mini_matrix_set_raw(const uint8_t *buf);

/**
* @brief Write the given character to the matrix, using the Mineplex font
*
* @param[in] c character to display
*/
void mini_matrix_set_char(char c);

/**
* @brief Shift the given string through the LED matrix
*
* @param[in] str string do display
* @param[in] delay delay between each step [in us]
*/
void mini_matrix_shift_str(const char *str, uint32_t delay);

#ifdef __cplusplus
}
#endif

#endif /* MINI_H_ */
/** @} */

0 comments on commit df27ad2

Please sign in to comment.