From c0c98928875735f0728bc86ba3caf0dbb1c7a8ac Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 25 Aug 2021 11:17:09 -0400 Subject: [PATCH] Add adafruit_led_glasses_nrf52840 --- .github/workflows/build.yml | 1 + .../adafruit_led_glasses_nrf52840/board.c | 38 +++++++++++++++++++ .../mpconfigboard.h | 30 +++++++++++++++ .../mpconfigboard.mk | 10 +++++ .../adafruit_led_glasses_nrf52840/pins.c | 19 ++++++++++ 5 files changed, 98 insertions(+) create mode 100644 ports/nrf/boards/adafruit_led_glasses_nrf52840/board.c create mode 100644 ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.h create mode 100644 ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk create mode 100644 ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a29a702d87..8e2c35f966 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -209,6 +209,7 @@ jobs: - "TG-Watch" - "adafruit_feather_rp2040" - "adafruit_itsybitsy_rp2040" + - "adafruit_led_glasses_nrf52840" - "adafruit_macropad_rp2040" - "adafruit_neokey_trinkey_m0" - "adafruit_proxlight_trinkey_m0" diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/board.c b/ports/nrf/boards/adafruit_led_glasses_nrf52840/board.c new file mode 100644 index 0000000000..688cfb4ded --- /dev/null +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.h b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.h new file mode 100644 index 0000000000..7b6a61d797 --- /dev/null +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.h @@ -0,0 +1,30 @@ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Adafruit LED Glasses Driver nRF52840" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_NEOPIXEL (&pin_P1_15) + +#define MICROPY_HW_LED_STATUS (&pin_P0_31) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 00) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P1_00 +#define SPI_FLASH_MISO_PIN &pin_P0_21 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_20 +#endif + +// Board does not have a 32kHz crystal. It does have a 32MHz crystal, in the module. +#define BOARD_HAS_32KHZ_XTAL (0) + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_14) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_16) diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk new file mode 100644 index 0000000000..5d90582865 --- /dev/null +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x239A +USB_PID = 0x810E +USB_PRODUCT = "nRF52840 LED Glasses Driver" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_CHIP = nrf52840 + + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c new file mode 100644 index 0000000000..0c6ca12d92 --- /dev/null +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c @@ -0,0 +1,19 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_00) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_27) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);