From 8d973a36eda2b42a5443506852e73864ac1d4e47 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 1 Feb 2021 15:16:38 +0700 Subject: [PATCH 1/3] add adafruit esp32s2 boards - metro esp32s2 - feather esp32s2 - magtag 29" gray --- .../boards/adafruit_feather_esp32s2/board.h | 45 +++++++++++++++++++ .../boards/adafruit_magtag_29gray/board.h | 45 +++++++++++++++++++ .../boards/adafruit_metro_esp32s2/board.h | 43 ++++++++++++++++++ hw/bsp/esp32s2/boards/esp32s2.c | 16 ++++++- 4 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h create mode 100644 hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h create mode 100644 hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h diff --git a/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h b/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h new file mode 100644 index 00000000..43e00901 --- /dev/null +++ b/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020, Ha Thach (tinyusb.org) + * + * 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. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define NEOPIXEL_PIN 33 +#define NEOPIXEL_POWER_PIN 21 +#define NEOPIXEL_POWER_STATE 1 + +#define BUTTON_PIN 0 +#define BUTTON_STATE_ACTIVE 0 + +#ifdef __cplusplus + } +#endif + +#endif /* BOARD_H_ */ diff --git a/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h b/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h new file mode 100644 index 00000000..16e30b68 --- /dev/null +++ b/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020, Ha Thach (tinyusb.org) + * + * 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. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define NEOPIXEL_PIN 1 +#define NEOPIXEL_POWER_PIN 21 +#define NEOPIXEL_POWER_STATE 0 + +#define BUTTON_PIN 0 +#define BUTTON_STATE_ACTIVE 0 + +#ifdef __cplusplus + } +#endif + +#endif /* BOARD_H_ */ diff --git a/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h b/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h new file mode 100644 index 00000000..49a2474b --- /dev/null +++ b/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020, Ha Thach (tinyusb.org) + * + * 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. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define NEOPIXEL_PIN 45 + +#define BUTTON_PIN 0 +#define BUTTON_STATE_ACTIVE 0 + +#ifdef __cplusplus + } +#endif + +#endif /* BOARD_H_ */ diff --git a/hw/bsp/esp32s2/boards/esp32s2.c b/hw/bsp/esp32s2/boards/esp32s2.c index abed39e4..358c0c80 100644 --- a/hw/bsp/esp32s2/boards/esp32s2.c +++ b/hw/bsp/esp32s2/boards/esp32s2.c @@ -34,18 +34,29 @@ #include "driver/periph_ctrl.h" #include "driver/rmt.h" + +#ifdef NEOPIXEL_PIN #include "led_strip.h" +static led_strip_t *strip; +#endif //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ static void configure_pins(usb_hal_context_t *usb); -static led_strip_t *strip; // Initialize on-board peripherals : led, button, uart and USB void board_init(void) { + +#ifdef NEOPIXEL_PIN + #ifdef NEOPIXEL_POWER_PIN + gpio_reset_pin(NEOPIXEL_POWER_PIN); + gpio_set_direction(NEOPIXEL_POWER_PIN, GPIO_MODE_OUTPUT); + gpio_set_level(NEOPIXEL_POWER_PIN, NEOPIXEL_POWER_STATE); + #endif + // WS2812 Neopixel driver with RMT peripheral rmt_config_t config = RMT_DEFAULT_CONFIG_TX(NEOPIXEL_PIN, RMT_CHANNEL_0); config.clk_div = 2; // set counter clock to 40MHz @@ -56,6 +67,7 @@ void board_init(void) led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel); strip = led_strip_new_rmt_ws2812(&strip_config); strip->clear(strip, 100); // off led +#endif // Button gpio_pad_select_gpio(BUTTON_PIN); @@ -102,8 +114,10 @@ static void configure_pins(usb_hal_context_t *usb) // Turn LED on or off void board_led_write(bool state) { +#ifdef NEOPIXEL_PIN strip->set_pixel(strip, 0, (state ? 0x88 : 0x00), 0x00, 0x00); strip->refresh(strip, 100); +#endif } // Get the current state of button From b30b35bf08b303077cdb4ed3aa28d36121e12fff Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 1 Feb 2021 15:21:29 +0700 Subject: [PATCH 2/3] update board list --- docs/boards.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/boards.md b/docs/boards.md index ded1cca9..6522c250 100644 --- a/docs/boards.md +++ b/docs/boards.md @@ -11,6 +11,9 @@ This code base already had supported for a handful of following boards (sorted a ### Espressif ESP32-S2 +- Adafruit Feather ESP32-S2 +- [Adafruit Magtag 2.9" E-Ink WiFi Display](https://www.adafruit.com/product/4800) +- [Adafruit Metro ESP32-S2](https://www.adafruit.com/product/4775) - [ESP32-S2-Kaluga-1](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html) - [ESP32-S2-Saola-1](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html) @@ -90,6 +93,8 @@ This code base already had supported for a handful of following boards (sorted a ### Raspberry PI RP2040 +- [Adafruit Feather RP2040](https://www.adafruit.com/product/4884) +- [Adafruit ItsyBitsy RP2040](https://www.adafruit.com/product/4888) - [Raspberry PI PICO](https://www.raspberrypi.org/products/raspberry-pi-pico/) ### Sony From 098cf76be7e26707ba005917a6a224205b61822b Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 1 Feb 2021 15:23:21 +0700 Subject: [PATCH 3/3] add adafruit boards to ci build --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 985c9ef3..8fe91c57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -161,6 +161,9 @@ jobs: matrix: board: # Alphabetical order + - 'adafruit_feather_esp32s2' + - 'adafruit_magtag_29gray' + - 'adafruit_metro_esp32s2' - 'espressif_kaluga_1' - 'espressif_saola_1'