aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/boards
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-11-16 15:17:35 +0100
committerStephane D'Alu <sdalu@sdalu.com>2016-11-16 15:17:35 +0100
commit92eafe4186c4b10f991db998cb483edabb0f2ccf (patch)
treeb323f537b635bf7481fc4dec5ad3dfb802b2ac61 /os/hal/boards
parent569aa39fbad9b47efe45635850f82c040c765318 (diff)
downloadChibiOS-Contrib-92eafe4186c4b10f991db998cb483edabb0f2ccf.tar.gz
ChibiOS-Contrib-92eafe4186c4b10f991db998cb483edabb0f2ccf.tar.bz2
ChibiOS-Contrib-92eafe4186c4b10f991db998cb483edabb0f2ccf.zip
BBC micro:bit board
Diffstat (limited to 'os/hal/boards')
-rw-r--r--os/hal/boards/MICROBIT/board.c91
-rw-r--r--os/hal/boards/MICROBIT/board.h147
-rw-r--r--os/hal/boards/MICROBIT/board.mk5
3 files changed, 243 insertions, 0 deletions
diff --git a/os/hal/boards/MICROBIT/board.c b/os/hal/boards/MICROBIT/board.c
new file mode 100644
index 0000000..12f78e2
--- /dev/null
+++ b/os/hal/boards/MICROBIT/board.c
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2017 Stéphane D'Alu
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+
+#if HAL_USE_PAL || defined(__DOXYGEN__)
+
+/* RAM Banks
+ * (Values are defined in Nordic gcc_startup_nrf51.s)
+ */
+#define NRF_POWER_RAMON_ADDRESS 0x40000524
+#define NRF_POWER_RAMONB_ADDRESS 0x40000554
+#define NRF_POWER_RAMONx_RAMxON_ONMODE_Msk 0x3
+
+/**
+ * @brief PAL setup.
+ * @details Digital I/O ports static configuration as defined in @p board.h.
+ * This variable is used by the HAL when initializing the PAL driver.
+ */
+const PALConfig pal_default_config =
+{
+ .pads = {
+ PAL_MODE_OUTPUT_OPENDRAIN, /* P0.0 : SCL P19 */
+ PAL_MODE_UNCONNECTED, /* P0.1 : PAD1 P2 */
+ PAL_MODE_UNCONNECTED, /* P0.2 : PAD2 P1 */
+ PAL_MODE_UNCONNECTED, /* P0.3 : PAD3 P0 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.4 : COL1 P3 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.5 : COL2 P4 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.6 : COL3 P10 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.7 : COL4 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.8 : COL5 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.9 : COL6 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.10: COL7 P9 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.11: COL8 P7 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.12: COL9 P6 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.13: ROW1 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.14: ROW2 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.15: ROW3 */
+ PAL_MODE_UNCONNECTED, /* P0.16 P16 */
+ PAL_MODE_INPUT, /* P0.17: BTN_A P5 */
+ PAL_MODE_UNCONNECTED, /* P0.18 P8 */
+ PAL_MODE_INPUT, /* P0.19: BTN_RST */
+ PAL_MODE_UNCONNECTED, /* P0.20 P12 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.21: SPI_MOSI P15 */
+ PAL_MODE_INPUT_PULLUP, /* P0.22: SPI_MISO P14 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.23: SPI_SCK P13 */
+ PAL_MODE_OUTPUT_PUSHPULL, /* P0.24: UART_TX */
+ PAL_MODE_INPUT_PULLUP, /* P0.25: UART_RX */
+ PAL_MODE_INPUT, /* P0.26: BTN_B P11 */
+ PAL_MODE_INPUT, /* P0.27: ACC_INT2 */
+ PAL_MODE_INPUT, /* P0.28: ACC_INT1 */
+ PAL_MODE_INPUT, /* P0.29: MAG_INT1 */
+ PAL_MODE_OUTPUT_OPENDRAIN, /* P0.30: SDA P20 */
+ PAL_MODE_UNCONNECTED, /* P0.31 */
+ },
+};
+#endif
+
+/**
+ * @brief Early initialization code.
+ * @details This initialization is performed just after reset before BSS and
+ * DATA segments initialization.
+ */
+void __early_init(void)
+{
+ /* Make sure ALL RAM banks are powered on */
+ *(uint32_t *)NRF_POWER_RAMON_ADDRESS |= NRF_POWER_RAMONx_RAMxON_ONMODE_Msk;
+ *(uint32_t *)NRF_POWER_RAMONB_ADDRESS |= NRF_POWER_RAMONx_RAMxON_ONMODE_Msk;
+}
+
+/**
+ * @brief Late initialization code.
+ * @note This initialization is performed after BSS and DATA segments
+ * initialization and before invoking the main() function.
+ */
+void boardInit(void)
+{
+}
diff --git a/os/hal/boards/MICROBIT/board.h b/os/hal/boards/MICROBIT/board.h
new file mode 100644
index 0000000..7798634
--- /dev/null
+++ b/os/hal/boards/MICROBIT/board.h
@@ -0,0 +1,147 @@
+/*
+ Copyright (C) 2016 Stephane D'Alu
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/*
+ * See: https://www.microbit.co.uk/device/pins
+ * https://lancaster-university.github.io/microbit-docs/ubit/display/
+ */
+
+/* Board identifier. */
+#define BOARD_MICROBIT
+#define BOARD_NAME "micro:bit"
+
+/* Board oscillators-related settings. */
+#define NRF51_XTAL_VALUE 16000000
+#define NRF51_LFCLK_SOURCE 0 /* RC oscillator */
+
+/*
+ * IO pins assignments.
+ */
+#define IOPORT1_P0 3U
+#define IOPORT1_P1 2U
+#define IOPORT1_P2 1U
+#define IOPORT1_P3 4U
+#define IOPORT1_P4 5U
+#define IOPORT1_P5 17U
+#define IOPORT1_P6 12U
+#define IOPORT1_P7 11U
+#define IOPORT1_P8 18U
+#define IOPORT1_P9 10U
+#define IOPORT1_P10 6U
+#define IOPORT1_P11 26U
+#define IOPORT1_P12 20U
+#define IOPORT1_P13 23U
+#define IOPORT1_P14 22U
+#define IOPORT1_P15 21U
+#define IOPORT1_P16 16U
+#define IOPORT1_P19 0U
+#define IOPORT1_P20 30U
+#define IOPORT1_BTN_A 17U
+#define IOPORT1_BTN_B 26U
+#define IOPORT1_BTN_RST 19U
+#define IOPORT1_LED_COL_1 4U
+#define IOPORT1_LED_COL_2 5U
+#define IOPORT1_LED_COL_3 6U
+#define IOPORT1_LED_COL_4 7U
+#define IOPORT1_LED_COL_5 8U
+#define IOPORT1_LED_COL_6 9U
+#define IOPORT1_LED_COL_7 10U
+#define IOPORT1_LED_COL_8 11U
+#define IOPORT1_LED_COL_9 12U
+#define IOPORT1_LED_ROW_1 13U
+#define IOPORT1_LED_ROW_2 14U
+#define IOPORT1_LED_ROW_3 15U
+#define IOPORT1_PAD_1 1U
+#define IOPORT1_PAD_2 2U
+#define IOPORT1_PAD_3 3U
+#define IOPORT1_SPI_MOSI 21U
+#define IOPORT1_SPI_MISO 22U
+#define IOPORT1_SPI_SCK 23U
+#define IOPORT1_I2C_SCL 0U
+#define IOPORT1_I2C_SDA 30U
+#define IOPORT1_UART_TX 24U
+#define IOPORT1_UART_RX 25U
+#define IOPORT1_ACC_INT1 28U
+#define IOPORT1_ACC_INT2 27U
+#define IOPORT1_MAG_INT1 29U
+
+
+/*
+ * IO lines assignments.
+ */
+#define LINE_P0 PAL_LINE(IOPORT1, IOPORT1_P0)
+#define LINE_P1 PAL_LINE(IOPORT1, IOPORT1_P1)
+#define LINE_P2 PAL_LINE(IOPORT1, IOPORT1_P2)
+#define LINE_P3 PAL_LINE(IOPORT1, IOPORT1_P3)
+#define LINE_P4 PAL_LINE(IOPORT1, IOPORT1_P4)
+#define LINE_P5 PAL_LINE(IOPORT1, IOPORT1_P5)
+#define LINE_P6 PAL_LINE(IOPORT1, IOPORT1_P6)
+#define LINE_P7 PAL_LINE(IOPORT1, IOPORT1_P7)
+#define LINE_P8 PAL_LINE(IOPORT1, IOPORT1_P8)
+#define LINE_P9 PAL_LINE(IOPORT1, IOPORT1_P9)
+#define LINE_P10 PAL_LINE(IOPORT1, IOPORT1_P10)
+#define LINE_P11 PAL_LINE(IOPORT1, IOPORT1_P11)
+#define LINE_P12 PAL_LINE(IOPORT1, IOPORT1_P12)
+#define LINE_P13 PAL_LINE(IOPORT1, IOPORT1_P13)
+#define LINE_P14 PAL_LINE(IOPORT1, IOPORT1_P14)
+#define LINE_P15 PAL_LINE(IOPORT1, IOPORT1_P15)
+#define LINE_P16 PAL_LINE(IOPORT1, IOPORT1_P16)
+#define LINE_P19 PAL_LINE(IOPORT1, IOPORT1_P19)
+#define LINE_P20 PAL_LINE(IOPORT1, IOPORT1_P20)
+#define LINE_BTN_A PAL_LINE(IOPORT1, IOPORT1_BTN_A)
+#define LINE_BTN_B PAL_LINE(IOPORT1, IOPORT1_BTN_B)
+#define LINE_BTN_RST PAL_LINE(IOPORT1, IOPORT1_BTN_RST)
+#define LINE_LED_COL_1 PAL_LINE(IOPORT1, IOPORT1_LED_COL_1)
+#define LINE_LED_COL_2 PAL_LINE(IOPORT1, IOPORT1_LED_COL_2)
+#define LINE_LED_COL_3 PAL_LINE(IOPORT1, IOPORT1_LED_COL_3)
+#define LINE_LED_COL_4 PAL_LINE(IOPORT1, IOPORT1_LED_COL_4)
+#define LINE_LED_COL_5 PAL_LINE(IOPORT1, IOPORT1_LED_COL_5)
+#define LINE_LED_COL_6 PAL_LINE(IOPORT1, IOPORT1_LED_COL_6)
+#define LINE_LED_COL_7 PAL_LINE(IOPORT1, IOPORT1_LED_COL_7)
+#define LINE_LED_COL_8 PAL_LINE(IOPORT1, IOPORT1_LED_COL_8)
+#define LINE_LED_COL_9 PAL_LINE(IOPORT1, IOPORT1_LED_COL_9)
+#define LINE_LED_ROW_1 PAL_LINE(IOPORT1, IOPORT1_LED_ROW_1)
+#define LINE_LED_ROW_2 PAL_LINE(IOPORT1, IOPORT1_LED_ROW_2)
+#define LINE_LED_ROW_3 PAL_LINE(IOPORT1, IOPORT1_LED_ROW_3)
+#define LINE_PAD_1 PAL_LINE(IOPORT1, IOPORT1_PAD_1)
+#define LINE_PAD_2 PAL_LINE(IOPORT1, IOPORT1_PAD_2)
+#define LINE_PAD_3 PAL_LINE(IOPORT1, IOPORT1_PAD_3)
+#define LINE_SPI_MOSI PAL_LINE(IOPORT1, IOPORT1_SPI_MOSI)
+#define LINE_SPI_MISO PAL_LINE(IOPORT1, IOPORT1_SPI_MISO)
+#define LINE_SPI_SCK PAL_LINE(IOPORT1, IOPORT1_SPI_SCK)
+#define LINE_I2C_SCL PAL_LINE(IOPORT1, IOPORT1_I2C_SCL)
+#define LINE_I2C_SDA PAL_LINE(IOPORT1, IOPORT1_I2C_SDA)
+#define LINE_UART_TX PAL_LINE(IOPORT1, IOPORT1_UART_TX)
+#define LINE_UART_RX PAL_LINE(IOPORT1, IOPORT1_UART_RX)
+#define LINE_ACC_INT1 PAL_LINE(IOPORT1, IOPORT1_ACC_INT1)
+#define LINE_ACC_INT2 PAL_LINE(IOPORT1, IOPORT1_ACC_INT2)
+#define LINE_MAG_INT1 PAL_LINE(IOPORT1, IOPORT1_MAG_INT1)
+
+
+#if !defined(_FROM_ASM_)
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void boardInit(void);
+#ifdef __cplusplus
+}
+#endif
+#endif /* _FROM_ASM_ */
+
+#endif /* _BOARD_H_ */
diff --git a/os/hal/boards/MICROBIT/board.mk b/os/hal/boards/MICROBIT/board.mk
new file mode 100644
index 0000000..3595b1a
--- /dev/null
+++ b/os/hal/boards/MICROBIT/board.mk
@@ -0,0 +1,5 @@
+# List of all the board related files.
+BOARDSRC = ${CHIBIOS_CONTRIB}/os/hal/boards/MICROBIT/board.c
+
+# Required include directories
+BOARDINC = ${CHIBIOS_CONTRIB}/os/hal/boards/MICROBIT