summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-02-01 16:15:19 +0700
committerGitHub <[email protected]>2021-02-01 16:15:19 +0700
commit9aa9c7e9684b29d2acb2cc61248d94f0029f672b (patch)
tree81d1ef70cc74165aa10714b93fd6f20db0b5b3a1
parentf4e2f88e89fcebdb5b73041027fa274da2743286 (diff)
parent098cf76be7e26707ba005917a6a224205b61822b (diff)
Merge pull request #623 from hathach/add-adafruit-esp32s2-boards
add adafruit esp32s2 boards
-rw-r--r--.github/workflows/build.yml3
-rw-r--r--docs/boards.md5
-rw-r--r--hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h45
-rw-r--r--hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h45
-rw-r--r--hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h43
-rw-r--r--hw/bsp/esp32s2/boards/esp32s2.c16
6 files changed, 156 insertions, 1 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 985c9ef34..8fe91c57f 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'
diff --git a/docs/boards.md b/docs/boards.md
index ded1cca93..6522c2505 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
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 000000000..43e00901d
--- /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 000000000..16e30b685
--- /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 000000000..49a2474bc
--- /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 abed39e49..358c0c803 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