mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
Merge pull request #6082 from haukepetersen/add_board_microbit
boards: added support for BBC micro:bit
This commit is contained in:
commit
87261a7be1
7
boards/microbit/Makefile
Normal file
7
boards/microbit/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
MODULE = board
|
||||
|
||||
ifneq (,$(filter microbit,$(USEMODULE)))
|
||||
DIRS += microbit
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
8
boards/microbit/Makefile.dep
Normal file
8
boards/microbit/Makefile.dep
Normal file
@ -0,0 +1,8 @@
|
||||
ifneq (,$(filter microbit,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += mineplex
|
||||
endif
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
14
boards/microbit/Makefile.features
Normal file
14
boards/microbit/Makefile.features
Normal file
@ -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
boards/microbit/Makefile.include
Normal file
28
boards/microbit/Makefile.include
Normal file
@ -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.SLAB_USBtoUART*)))
|
||||
|
||||
# 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
boards/microbit/board.c
Normal file
32
boards/microbit/board.c
Normal file
@ -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_microbit
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Board initialization code for the BBC micro:bit
|
||||
*
|
||||
* @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 micro:bit's buttons */
|
||||
gpio_init(BTN0_PIN, GPIO_IN);
|
||||
gpio_init(BTN1_PIN, GPIO_IN);
|
||||
}
|
||||
65
boards/microbit/dist/flash.sh
vendored
Executable file
65
boards/microbit/dist/flash.sh
vendored
Executable file
@ -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 micro:bit 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)/MICROBIT
|
||||
#
|
||||
# @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
# @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
|
||||
OS=`uname`
|
||||
DID_MOUNT=false
|
||||
NAME="MICROBIT"
|
||||
|
||||
# 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 micro:bit"
|
||||
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 micro:bit"
|
||||
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
boards/microbit/include/board.h
Normal file
93
boards/microbit/include/board.h
Normal file
@ -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_microbit BBC micro:bit
|
||||
* @ingroup boards
|
||||
* @brief Board specific files for the BBC micro:bit
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Board specific configuration for the BBC micro:bit
|
||||
*
|
||||
* @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 MICROBIT_LED_COL1 GPIO_PIN(0, 4)
|
||||
#define MICROBIT_LED_COL2 GPIO_PIN(0, 5)
|
||||
#define MICROBIT_LED_COL3 GPIO_PIN(0, 6)
|
||||
#define MICROBIT_LED_COL4 GPIO_PIN(0, 7)
|
||||
#define MICROBIT_LED_COL5 GPIO_PIN(0, 8)
|
||||
#define MICROBIT_LED_COL6 GPIO_PIN(0, 9)
|
||||
#define MICROBIT_LED_COL7 GPIO_PIN(0, 10)
|
||||
#define MICROBIT_LED_COL8 GPIO_PIN(0, 11)
|
||||
#define MICROBIT_LED_COL9 GPIO_PIN(0, 12)
|
||||
#define MICROBIT_LED_ROW1 GPIO_PIN(0, 13)
|
||||
#define MICROBIT_LED_ROW2 GPIO_PIN(0, 14)
|
||||
#define MICROBIT_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
boards/microbit/include/gpio_params.h
Normal file
51
boards/microbit/include/gpio_params.h
Normal file
@ -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_microbit
|
||||
* @{
|
||||
*
|
||||
* @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
boards/microbit/include/microbit.h
Normal file
90
boards/microbit/include/microbit.h
Normal file
@ -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_microbit
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief BBC micro:bit specific LED handling
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef MICROBIT_H
|
||||
#define MICROBIT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of rows of the LED matrix
|
||||
*/
|
||||
#define MICROBIT_MATRIX_ROWS (5U)
|
||||
|
||||
/**
|
||||
* @brief Number of columns of the LED matrix
|
||||
*/
|
||||
#define MICROBIT_MATRIX_COLS (5U)
|
||||
|
||||
/**
|
||||
* @brief Initialize the micro:bit's LED matrix
|
||||
*/
|
||||
void microbit_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 microbit_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 microbit_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 microbit_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 microbit_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 microbit_matrix_shift_str(const char *str, uint32_t delay);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MICROBIT_H */
|
||||
/** @} */
|
||||
123
boards/microbit/include/periph_conf.h
Normal file
123
boards/microbit/include/periph_conf.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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_microbit
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Peripheral configuration for the BBC micro:bit
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_H
|
||||
#define PERIPH_CONF_H
|
||||
|
||||
#include "periph_cpu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Clock configuration
|
||||
*
|
||||
* @note The radio will not work with the internal RC oscillator!
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define CLOCK_CORECLOCK (16000000U) /* fixed for all NRF51822 */
|
||||
#define CLOCK_CRYSTAL (0U) /* set to 0: internal RC oscillator
|
||||
16: 16MHz crystal
|
||||
32: 32MHz crystal */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Timer configuration
|
||||
* @{
|
||||
*/
|
||||
static const timer_conf_t timer_config[] = {
|
||||
{
|
||||
.dev = NRF_TIMER0,
|
||||
.channels = 3,
|
||||
.bitmode = TIMER_BITMODE_BITMODE_24Bit,
|
||||
.irqn = TIMER0_IRQn
|
||||
},
|
||||
{
|
||||
.dev = NRF_TIMER1,
|
||||
.channels = 3,
|
||||
.bitmode = TIMER_BITMODE_BITMODE_16Bit,
|
||||
.irqn = TIMER1_IRQn
|
||||
},
|
||||
{
|
||||
.dev = NRF_TIMER2,
|
||||
.channels = 3,
|
||||
.bitmode = TIMER_BITMODE_BITMODE_16Bit,
|
||||
.irqn = TIMER2_IRQn
|
||||
}
|
||||
};
|
||||
|
||||
#define TIMER_0_ISR isr_timer0
|
||||
#define TIMER_1_ISR isr_timer1
|
||||
#define TIMER_2_ISR isr_timer2
|
||||
|
||||
#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Real time counter configuration
|
||||
* @{
|
||||
*/
|
||||
#define RTT_NUMOF (1U)
|
||||
#define RTT_IRQ_PRIO 1
|
||||
|
||||
#define RTT_DEV NRF_RTC1
|
||||
#define RTT_IRQ RTC1_IRQn
|
||||
#define RTT_ISR isr_rtc1
|
||||
#define RTT_MAX_VALUE (0xffffff)
|
||||
#define RTT_FREQUENCY (10) /* in Hz */
|
||||
#define RTT_PRESCALER (3275U) /* run with 10 Hz */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief UART configuration
|
||||
* @{
|
||||
*/
|
||||
#define UART_NUMOF (1U)
|
||||
/* UART pin configuration */
|
||||
#define UART_HWFLOWCTRL 0
|
||||
#define UART_PIN_RX 25
|
||||
#define UART_PIN_TX 24
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief ADC configuration
|
||||
*
|
||||
* The configuration consists simply of a list of channels that should be used
|
||||
* @{
|
||||
*/
|
||||
#define ADC_NUMOF (0)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Radio device configuration
|
||||
*
|
||||
* The radio is not guarded by a NUMOF define, as the radio is selected by its
|
||||
* own module in the build system.
|
||||
* @{
|
||||
*/
|
||||
#define RADIO_IRQ_PRIO 1
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_H */
|
||||
/** @} */
|
||||
1
boards/microbit/microbit/Makefile
Normal file
1
boards/microbit/microbit/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
247
boards/microbit/microbit/microbit.c
Normal file
247
boards/microbit/microbit/microbit.c
Normal file
@ -0,0 +1,247 @@
|
||||
/*
|
||||
* 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_microbit
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief BBC micro:bit specific LED matrix handling
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "microbit.h"
|
||||
#include "mineplex.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "periph/timer.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* @brief The visible number of rows and columns of the LED matrix
|
||||
*/
|
||||
#define ROWS MICROBIT_MATRIX_ROWS
|
||||
#define COLS MICROBIT_MATRIX_COLS
|
||||
|
||||
/**
|
||||
* @brief The electrical number of rows and columns
|
||||
*/
|
||||
#define ROWS_HW (3)
|
||||
#define COLS_HW (9)
|
||||
|
||||
/**
|
||||
* @brief The refresh rate used for drawing the contents
|
||||
*
|
||||
* We want a refresh rate of at least 50Hz (->20ms), so the LEDs do not flicker.
|
||||
*/
|
||||
#define REFRESH (6000) /* 6ms * 3 rows -> ~55Hz */
|
||||
|
||||
/**
|
||||
* @brief GPIO pins driving the rows
|
||||
*/
|
||||
static const gpio_t rows[ROWS_HW] = {
|
||||
MICROBIT_LED_ROW1,
|
||||
MICROBIT_LED_ROW2,
|
||||
MICROBIT_LED_ROW3
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief GPIO pins driving the columns
|
||||
*/
|
||||
static const gpio_t cols[COLS_HW] = {
|
||||
MICROBIT_LED_COL1,
|
||||
MICROBIT_LED_COL2,
|
||||
MICROBIT_LED_COL3,
|
||||
MICROBIT_LED_COL4,
|
||||
MICROBIT_LED_COL5,
|
||||
MICROBIT_LED_COL6,
|
||||
MICROBIT_LED_COL7,
|
||||
MICROBIT_LED_COL8,
|
||||
MICROBIT_LED_COL9,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Map electrical layout to visible layout
|
||||
*
|
||||
* The electrical layout of the matrix is different than the visible layout
|
||||
* (3x9 -> 5x5). This array maps from the visible 5 by 5 layout to the actual
|
||||
* 3 by 9 layout used by the hardware.
|
||||
*/
|
||||
static const uint8_t pixmap[5][5] = {
|
||||
{ 0, 12, 1, 13, 2 },
|
||||
{ 21, 22, 23, 24, 25 },
|
||||
{ 10, 8, 11, 26, 9 },
|
||||
{ 7, 6, 5, 4, 3 },
|
||||
{ 20, 15, 18, 14, 19 }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Buffer holding the current 'image' that is displayed
|
||||
*/
|
||||
static uint8_t framebuf[ROWS_HW * COLS_HW] = { 0 };
|
||||
|
||||
/**
|
||||
* @brief Internal counter to keep track of which row needs to be refreshed
|
||||
* next
|
||||
*/
|
||||
static unsigned cur_row = 0;
|
||||
|
||||
/**
|
||||
* @brief Write a Mineplex encoded character into the given buffer
|
||||
*
|
||||
* @param[in] c character to write
|
||||
* @param[out] buf buffer to write the encoded character into, MUST be able to
|
||||
* hold 25 byte
|
||||
*/
|
||||
static void char2buf(char c, uint8_t *buf)
|
||||
{
|
||||
const uint8_t *raw = mineplex_char(c);
|
||||
|
||||
/* set each row */
|
||||
for (int row = 0; row < ROWS; row++) {
|
||||
for (int col = 0; col < COLS; col++) {
|
||||
buf[(row * COLS) + col] = (raw[row] & (1 << col));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Shift out and replace an image with the next, column by column
|
||||
*
|
||||
* @param[in|out] cur current 'image', will be overwritten
|
||||
* @param[in] next image to shift in
|
||||
* @param[in] delay delay between each column
|
||||
*/
|
||||
static void shift_next(uint8_t *cur, const uint8_t *next, uint32_t delay)
|
||||
{
|
||||
for (int i = 0; i < COLS; i++) {
|
||||
for (int r = 0; r < ROWS; r++) {
|
||||
for (int c = 0; c < (COLS - 1); c++) {
|
||||
cur[(r * COLS) + c] = cur[(r * COLS) + c + 1];
|
||||
}
|
||||
cur[(r * COLS) + COLS - 1] = next[(r * COLS) + i];
|
||||
}
|
||||
microbit_matrix_set_raw((uint8_t *)cur);
|
||||
xtimer_usleep(delay);
|
||||
}
|
||||
}
|
||||
|
||||
static void refresh(void *arg, int channel)
|
||||
{
|
||||
(void)arg;
|
||||
(void)channel;
|
||||
|
||||
/* set next refresh */
|
||||
timer_set(TIMER_DEV(2), 0, REFRESH);
|
||||
|
||||
/* disable current row */
|
||||
gpio_clear(rows[cur_row]);
|
||||
/* goto next row */
|
||||
cur_row = ((++cur_row) < ROWS_HW) ? cur_row : 0;
|
||||
/* setup columns */
|
||||
int base = (COLS_HW * cur_row);
|
||||
for (int i = 0; i < COLS_HW; i++) {
|
||||
gpio_write(cols[i], !(framebuf[base + i]));
|
||||
}
|
||||
/* and finally enable the new row */
|
||||
gpio_set(rows[cur_row]);
|
||||
}
|
||||
|
||||
void microbit_matrix_init(void)
|
||||
{
|
||||
/* initialize columns 1-9 */
|
||||
gpio_init(MICROBIT_LED_COL1, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL2, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL3, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL4, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL5, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL6, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL7, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL8, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_COL9, GPIO_OUT);
|
||||
/* and rows from 1-3 */
|
||||
gpio_init(MICROBIT_LED_ROW1, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_ROW2, GPIO_OUT);
|
||||
gpio_init(MICROBIT_LED_ROW3, GPIO_OUT);
|
||||
|
||||
/* all columns are set to high */
|
||||
gpio_set(MICROBIT_LED_COL1);
|
||||
gpio_set(MICROBIT_LED_COL2);
|
||||
gpio_set(MICROBIT_LED_COL3);
|
||||
gpio_set(MICROBIT_LED_COL4);
|
||||
gpio_set(MICROBIT_LED_COL5);
|
||||
gpio_set(MICROBIT_LED_COL6);
|
||||
gpio_set(MICROBIT_LED_COL7);
|
||||
gpio_set(MICROBIT_LED_COL8);
|
||||
gpio_set(MICROBIT_LED_COL9);
|
||||
/* all rows are set to low */
|
||||
gpio_clear(MICROBIT_LED_ROW1);
|
||||
gpio_clear(MICROBIT_LED_ROW2);
|
||||
gpio_clear(MICROBIT_LED_ROW3);
|
||||
|
||||
/* and finally initialize and start the refresh timer */
|
||||
timer_init(TIMER_DEV(2), 1000000, refresh, NULL);
|
||||
timer_set(TIMER_DEV(2), 0, REFRESH);
|
||||
}
|
||||
|
||||
void microbit_matrix_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
if ((row >= 5) || (col >= 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
framebuf[pixmap[row][col]] = 0x01;
|
||||
}
|
||||
|
||||
void microbit_matrix_off(uint8_t row, uint8_t col)
|
||||
{
|
||||
if ((row >= 5) || (col >= 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
framebuf[pixmap[row][col]] = 0x00;
|
||||
}
|
||||
|
||||
void microbit_matrix_set_raw(const uint8_t *buf) {
|
||||
for (int row = 0; row < ROWS; row++) {
|
||||
for (int col = 0; col < COLS; col++) {
|
||||
framebuf[pixmap[row][col]] = buf[(row * COLS) + col];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void microbit_matrix_set_char(char c)
|
||||
{
|
||||
uint8_t buf[ROWS * COLS];
|
||||
|
||||
char2buf(c, buf);
|
||||
microbit_matrix_set_raw(buf);
|
||||
}
|
||||
|
||||
void microbit_matrix_shift_str(const char *str, uint32_t delay)
|
||||
{
|
||||
uint8_t curbuf[ROWS][COLS];
|
||||
uint8_t newbuf[ROWS][COLS];
|
||||
|
||||
char2buf(' ', (uint8_t *)curbuf);
|
||||
microbit_matrix_set_raw((uint8_t *)curbuf);
|
||||
while (*str) {
|
||||
char2buf(*str++, (uint8_t *)newbuf);
|
||||
shift_next((uint8_t *)curbuf, (uint8_t *)newbuf, delay);
|
||||
}
|
||||
char2buf(' ', (uint8_t *)newbuf);
|
||||
shift_next((uint8_t *)curbuf, (uint8_t *)newbuf, delay);
|
||||
}
|
||||
@ -16,7 +16,7 @@ BOARD_BLACKLIST := arduino-duemilanove arduino-mega2560 arduino-uno chronos \
|
||||
BOARD_INSUFFICIENT_MEMORY := airfy-beacon nrf51dongle nrf6310 nucleo-f103 \
|
||||
nucleo-f334 pca10000 pca10005 spark-core \
|
||||
stm32f0discovery weio yunjia-nrf51822 nucleo-f072 \
|
||||
cc2650stk nucleo-f030 nucleo-f070
|
||||
cc2650stk nucleo-f030 nucleo-f070 microbit
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
|
||||
@ -11,7 +11,7 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon cc2650stk msb-430 msb-430h pca10000 pc
|
||||
nrf51dongle nrf6310 nucleo-f103 nucleo-f334 \
|
||||
spark-core stm32f0discovery telosb \
|
||||
weio wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1 nucleo-f072 \
|
||||
nucleo-f030 nucleo-f070
|
||||
nucleo-f030 nucleo-f070 microbit
|
||||
|
||||
# use ethos (ethernet over serial) for network communication and stdio over
|
||||
# UART, but not on native, as native has a tap interface towards the host.
|
||||
|
||||
@ -10,7 +10,8 @@ RIOTBASE ?= $(CURDIR)/../..
|
||||
BOARD_INSUFFICIENT_MEMORY := airfy-beacon chronos msb-430 msb-430h nrf51dongle \
|
||||
nrf6310 nucleo-f103 nucleo-f334 pca10000 pca10005 spark-core \
|
||||
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \
|
||||
yunjia-nrf51822 z1 nucleo-f072 nucleo-f030 nucleo-f070
|
||||
yunjia-nrf51822 z1 nucleo-f072 nucleo-f030 nucleo-f070 \
|
||||
microbit
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
|
||||
@ -11,7 +11,7 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon chronos msb-430 msb-430h nrf51dongle \
|
||||
nrf6310 nucleo-f103 nucleo-f334 pca10000 pca10005 \
|
||||
spark-core stm32f0discovery telosb weio wsn430-v1_3b \
|
||||
wsn430-v1_4 yunjia-nrf51822 z1 nucleo-f072 nucleo-f030 \
|
||||
nucleo-f070
|
||||
nucleo-f070 microbit
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
|
||||
@ -10,7 +10,8 @@ RIOTBASE ?= $(CURDIR)/../..
|
||||
BOARD_INSUFFICIENT_MEMORY := airfy-beacon chronos msb-430 msb-430h nrf51dongle \
|
||||
nrf6310 pca10000 pca10005 spark-core \
|
||||
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \
|
||||
yunjia-nrf51822 z1 nucleo-f072 nucleo-f030 nucleo-f070
|
||||
yunjia-nrf51822 z1 nucleo-f072 nucleo-f030 nucleo-f070 \
|
||||
microbit
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
|
||||
59
sys/include/mineplex.h
Normal file
59
sys/include/mineplex.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 sys_mineplex 5x5 Font 'Mineplex'
|
||||
* @ingroup sys
|
||||
* @brief The Mineplex font for containing 5x5 pixel ASCII characters
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface definition to access the Mineplex font
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef MINEPLEX_H_
|
||||
#define MINEPLEX_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The width of a single character in pixel
|
||||
*/
|
||||
#define MINEPLEX_CHAR_W (5U)
|
||||
|
||||
/**
|
||||
* @brief The height of a single character in pixel
|
||||
*/
|
||||
#define MINEPLEX_CHAR_H (5U)
|
||||
|
||||
/**
|
||||
* @brief Get the Mineplex representation of a given ASCII character
|
||||
*
|
||||
* The function returns the pointer to a 5 byte pointer containing the Mineplex
|
||||
* representation of the given ASCII character. The Mineplex character is
|
||||
* encoded row wise from top to bottom using the least significant 5 bit, where
|
||||
* byte 1, bit 1 is the top left pixel of the encoded character.
|
||||
*
|
||||
* @param[in] c character to translate
|
||||
*
|
||||
* @return a 5 byte big buffer containing the encoded Mineplex character
|
||||
*/
|
||||
const uint8_t *mineplex_char(char c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MINEPLEX_H_ */
|
||||
/** @} */
|
||||
1
sys/mineplex/Makefile
Normal file
1
sys/mineplex/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
136
sys/mineplex/mineplex.c
Normal file
136
sys/mineplex/mineplex.c
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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 sys_mineplex
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief This file contains the actual font data table
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "mineplex.h"
|
||||
|
||||
/**
|
||||
* @brief The first and the last ASCII character contained in the table
|
||||
*/
|
||||
#define ASCII_MIN (0x20)
|
||||
#define ASCII_MAX (0x7e)
|
||||
|
||||
/**
|
||||
* @brief Table containing the Mineplex encoded ASCII characters
|
||||
*/
|
||||
static const uint8_t mineplex[][MINEPLEX_CHAR_H] = {
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 20 SPACE*/
|
||||
{ 0x02, 0x02, 0x02, 0x00, 0x02 }, /* 21 ! */
|
||||
{ 0x0a, 0x0a, 0x00, 0x00, 0x00 }, /* 22 " */
|
||||
{ 0x0a, 0x1f, 0x0a, 0x1f, 0x0a }, /* 23 # */
|
||||
{ 0x1f, 0x05, 0x1f, 0x14, 0x1f }, /* 24 $ */
|
||||
{ 0x11, 0x08, 0x04, 0x02, 0x11 }, /* 25 % */
|
||||
{ 0x02, 0x05, 0x0e, 0x05, 0x0e }, /* 26 & */
|
||||
{ 0x04, 0x04, 0x00, 0x00, 0x00 }, /* 27 ' */
|
||||
{ 0x0c, 0x02, 0x02, 0x02, 0x0c }, /* 28 ( */
|
||||
{ 0x06, 0x08, 0x08, 0x08, 0x06 }, /* 29 ) */
|
||||
{ 0x00, 0x0a, 0x04, 0x0a, 0x00 }, /* 2a * */
|
||||
{ 0x00, 0x04, 0x0e, 0x04, 0x00 }, /* 2b + */
|
||||
{ 0x00, 0x00, 0x00, 0x02, 0x02 }, /* 2c , */
|
||||
{ 0x00, 0x00, 0x0e, 0x00, 0x00 }, /* 2d - */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x02 }, /* 2e . */
|
||||
{ 0x10, 0x08, 0x04, 0x02, 0x01 }, /* 2f / */
|
||||
{ 0x06, 0x09, 0x09, 0x09, 0x06 }, /* 30 0 */
|
||||
{ 0x06, 0x04, 0x04, 0x04, 0x0e }, /* 31 1 */
|
||||
{ 0x06, 0x09, 0x04, 0x02, 0x0f }, /* 32 2 */
|
||||
{ 0x06, 0x09, 0x04, 0x09, 0x06 }, /* 33 3 */
|
||||
{ 0x09, 0x09, 0x0f, 0x08, 0x08 }, /* 34 4 */
|
||||
{ 0x0f, 0x01, 0x07, 0x08, 0x07 }, /* 35 5 */
|
||||
{ 0x0e, 0x01, 0x07, 0x09, 0x06 }, /* 36 6 */
|
||||
{ 0x0f, 0x08, 0x08, 0x08, 0x08 }, /* 37 7 */
|
||||
{ 0x06, 0x09, 0x06, 0x09, 0x06 }, /* 38 8 */
|
||||
{ 0x06, 0x09, 0x0e, 0x08, 0x07 }, /* 39 9 */
|
||||
{ 0x00, 0x02, 0x00, 0x00, 0x02 }, /* 3a : */
|
||||
{ 0x00, 0x02, 0x00, 0x02, 0x02 }, /* 3b ; */
|
||||
{ 0x08, 0x04, 0x02, 0x04, 0x08 }, /* 3c < */
|
||||
{ 0x00, 0x0f, 0x00, 0x0f, 0x00 }, /* 3d = */
|
||||
{ 0x02, 0x04, 0x08, 0x04, 0x02 }, /* 3e > */
|
||||
{ 0x06, 0x09, 0x04, 0x00, 0x04 }, /* 3f ? */
|
||||
{ 0x0e, 0x19, 0x1d, 0x15, 0x0e }, /* 40 @ */
|
||||
{ 0x0f, 0x09, 0x0f, 0x09, 0x09 }, /* 41 A */
|
||||
{ 0x07, 0x09, 0x07, 0x09, 0x07 }, /* 42 B */
|
||||
{ 0x0f, 0x01, 0x01, 0x01, 0x0f }, /* 43 C */
|
||||
{ 0x07, 0x09, 0x09, 0x09, 0x07 }, /* 44 D */
|
||||
{ 0x0f, 0x01, 0x07, 0x01, 0x0f }, /* 45 E */
|
||||
{ 0x0f, 0x01, 0x07, 0x01, 0x01 }, /* 46 F */
|
||||
{ 0x0f, 0x01, 0x0d, 0x09, 0x0f }, /* 47 G */
|
||||
{ 0x09, 0x09, 0x0f, 0x09, 0x09 }, /* 48 H */
|
||||
{ 0x0e, 0x04, 0x04, 0x04, 0x0e }, /* 49 I */
|
||||
{ 0x08, 0x08, 0x08, 0x09, 0x06 }, /* 4a J */
|
||||
{ 0x09, 0x05, 0x03, 0x05, 0x09 }, /* 4b K */
|
||||
{ 0x01, 0x01, 0x01, 0x01, 0x0f }, /* 4c L */
|
||||
{ 0x1f, 0x15, 0x15, 0x11, 0x11 }, /* 4d M */
|
||||
{ 0x09, 0x0b, 0x0d, 0x09, 0x09 }, /* 4e N */
|
||||
{ 0x0f, 0x09, 0x09, 0x09, 0x0f }, /* 4f O */
|
||||
{ 0x0f, 0x09, 0x0f, 0x01, 0x01 }, /* 50 P */
|
||||
{ 0x0f, 0x09, 0x09, 0x05, 0x0b }, /* 51 Q */
|
||||
{ 0x0f, 0x09, 0x07, 0x09, 0x09 }, /* 52 R */
|
||||
{ 0x0f, 0x01, 0x0f, 0x08, 0x0f }, /* 53 S */
|
||||
{ 0x1f, 0x04, 0x04, 0x04, 0x04 }, /* 54 T */
|
||||
{ 0x09, 0x09, 0x09, 0x09, 0x0f }, /* 55 U */
|
||||
{ 0x09, 0x09, 0x09, 0x09, 0x06 }, /* 56 V */
|
||||
{ 0x11, 0x11, 0x15, 0x15, 0x1f }, /* 57 W */
|
||||
{ 0x11, 0x0a, 0x04, 0x0a, 0x11 }, /* 58 X */
|
||||
{ 0x11, 0x0a, 0x04, 0x04, 0x04 }, /* 59 Y */
|
||||
{ 0x1f, 0x08, 0x04, 0x02, 0x1f }, /* 5a Z */
|
||||
{ 0x0e, 0x02, 0x02, 0x02, 0x0e }, /* 5b [ */
|
||||
{ 0x01, 0x02, 0x04, 0x08, 0x10 }, /* 5c \ */
|
||||
{ 0x0e, 0x08, 0x08, 0x08, 0x0e }, /* 5d ] */
|
||||
{ 0x04, 0x0a, 0x00, 0x00, 0x00 }, /* 5e ^ */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x0f }, /* 5f _ */
|
||||
{ 0x06, 0x08, 0x00, 0x00, 0x00 }, /* 60 ` */
|
||||
{ 0x0f, 0x09, 0x0f, 0x09, 0x09 }, /* 61 a */
|
||||
{ 0x07, 0x09, 0x07, 0x09, 0x07 }, /* 62 b */
|
||||
{ 0x0f, 0x01, 0x01, 0x01, 0x0f }, /* 63 c */
|
||||
{ 0x07, 0x09, 0x09, 0x09, 0x07 }, /* 64 d */
|
||||
{ 0x0f, 0x01, 0x07, 0x01, 0x0f }, /* 65 e */
|
||||
{ 0x0f, 0x01, 0x07, 0x01, 0x01 }, /* 66 f */
|
||||
{ 0x0f, 0x01, 0x0d, 0x09, 0x0f }, /* 67 g */
|
||||
{ 0x09, 0x09, 0x0f, 0x09, 0x09 }, /* 68 h */
|
||||
{ 0x0e, 0x04, 0x04, 0x04, 0x0e }, /* 69 i */
|
||||
{ 0x08, 0x08, 0x08, 0x09, 0x06 }, /* 6a j */
|
||||
{ 0x09, 0x05, 0x03, 0x05, 0x09 }, /* 6b k */
|
||||
{ 0x01, 0x01, 0x01, 0x01, 0x0f }, /* 6c l */
|
||||
{ 0x1f, 0x15, 0x15, 0x11, 0x11 }, /* 6d m */
|
||||
{ 0x09, 0x0b, 0x0d, 0x09, 0x09 }, /* 6e n */
|
||||
{ 0x0f, 0x09, 0x09, 0x09, 0x0f }, /* 6f o */
|
||||
{ 0x0f, 0x09, 0x0f, 0x01, 0x01 }, /* 70 p */
|
||||
{ 0x0f, 0x09, 0x09, 0x05, 0x0b }, /* 71 q */
|
||||
{ 0x0f, 0x09, 0x07, 0x09, 0x09 }, /* 72 r */
|
||||
{ 0x0f, 0x01, 0x0f, 0x08, 0x0f }, /* 73 s */
|
||||
{ 0x1f, 0x04, 0x04, 0x04, 0x04 }, /* 74 t */
|
||||
{ 0x09, 0x09, 0x09, 0x09, 0x0f }, /* 75 u */
|
||||
{ 0x09, 0x09, 0x09, 0x09, 0x06 }, /* 76 v */
|
||||
{ 0x11, 0x11, 0x15, 0x15, 0x1f }, /* 77 w */
|
||||
{ 0x11, 0x0a, 0x04, 0x0a, 0x11 }, /* 78 x */
|
||||
{ 0x11, 0x0a, 0x04, 0x04, 0x04 }, /* 79 y */
|
||||
{ 0x1f, 0x08, 0x04, 0x02, 0x1f }, /* 7a z */
|
||||
{ 0x0c, 0x02, 0x03, 0x02, 0x0c }, /* 7b { */
|
||||
{ 0x04, 0x04, 0x04, 0x04, 0x04 }, /* 7c | */
|
||||
{ 0x03, 0x04, 0x0c, 0x04, 0x03 }, /* 7d } */
|
||||
{ 0x00, 0x0a, 0x05, 0x00, 0x00 } /* 7e ~ */
|
||||
};
|
||||
|
||||
const uint8_t *mineplex_char(char c)
|
||||
{
|
||||
if ((c < ASCII_MIN) || (c > ASCII_MAX)) {
|
||||
return mineplex[0];
|
||||
}
|
||||
return mineplex[((int)c) - ASCII_MIN];
|
||||
}
|
||||
12
tests/board_microbit/Makefile
Normal file
12
tests/board_microbit/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
APPLICATION = board_microbit
|
||||
include ../Makefile.tests_common
|
||||
|
||||
BOARD = microbit
|
||||
|
||||
# This test application is for the BBC micro:bit only
|
||||
BOARD_WHITELIST := microbit
|
||||
|
||||
# We want to test the microbit support module
|
||||
USEMODULE += microbit
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
13
tests/board_microbit/README.md
Normal file
13
tests/board_microbit/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
Background
|
||||
==========
|
||||
The BBC micro:bit board comes with its own little utility library, that makes
|
||||
some of the boards unique feature like the 5x5 LED matrix usable to RIOT.
|
||||
|
||||
This test application is therefore specialized for only that board and its
|
||||
purpose is to test and showcase the board specific utility library.
|
||||
|
||||
|
||||
Expected result
|
||||
===============
|
||||
When running this application, you should see the string
|
||||
`Welcome RIOT @ micro:bit!` scrolling by on the boards LED matrix.
|
||||
40
tests/board_microbit/main.c
Normal file
40
tests/board_microbit/main.c
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test the BBC micro:bit support library
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "timex.h"
|
||||
#include "microbit.h"
|
||||
|
||||
#define DELAY (120 * MS_IN_USEC)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("Welcome to RIOT!\n");
|
||||
puts("Please refer to the README.md for more information about this app\n");
|
||||
|
||||
microbit_matrix_init();
|
||||
|
||||
while (1) {
|
||||
microbit_matrix_shift_str("Welcome RIOT @ micro:bit!", DELAY);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -5,7 +5,7 @@ BOARD_INSUFFICIENT_MEMORY := cc2650stk chronos msb-430 msb-430h mbed_lpc1768 \
|
||||
stm32f0discovery pca10000 pca10005 \
|
||||
yunjia-nrf51822 spark-core airfy-beacon nucleo-f103 \
|
||||
nucleo-f334 nrf51dongle nrf6310 weio nucleo-f072 \
|
||||
nucleo-f030 nucleo-f070
|
||||
nucleo-f030 nucleo-f070 microbit
|
||||
|
||||
DISABLE_MODULE += auto_init
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon cc2650stk chronos msb-430 msb-430h pca
|
||||
weio waspmote-pro nucleo-f072 arduino-uno \
|
||||
arduino-duemilanove sodaq-autonomo arduino-zero \
|
||||
nucleo-f030 nucleo-f070 nucleo-f091 pba-d-01-kw2x \
|
||||
saml21-xpro
|
||||
saml21-xpro microbit
|
||||
|
||||
USEMODULE += embunit
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user