Skip to content

Commit

Permalink
Merge pull request #2611 from hathach/add-esp32-max3421e
Browse files Browse the repository at this point in the history
Add esp32 max3421e
  • Loading branch information
ladyada authored Apr 25, 2024
2 parents fc91e15 + 022de87 commit a0cba9b
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 52 deletions.
2 changes: 1 addition & 1 deletion examples/device/board_test/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
6 changes: 3 additions & 3 deletions examples/device/cdc_msc_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "bsp/board_api.h"
#include "tusb.h"

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -111,14 +111,14 @@ int main(void) {
#endif

// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if !TUP_MCU_ESPRESSIF
vTaskStartScheduler();
#endif

return 0;
}

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
void app_main(void) {
main();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/device/cdc_msc_freertos/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
6 changes: 3 additions & 3 deletions examples/device/hid_composite_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "tusb.h"
#include "usb_descriptors.h"

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -113,14 +113,14 @@ int main(void)
xTimerStart(blinky_tm, 0);

// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if !TUP_MCU_ESPRESSIF
vTaskStartScheduler();
#endif

return 0;
}

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
void app_main(void)
{
main();
Expand Down
2 changes: 1 addition & 1 deletion examples/device/hid_composite_freertos/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/device/video_capture/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void led_blinking_task(void* param) {
#define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE
#define VIDEO_STACK_SIZE (configMINIMAL_STACK_SIZE*4)

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define USBD_STACK_SIZE 4096
int main(void);
void app_main(void) {
Expand Down Expand Up @@ -344,7 +344,7 @@ void freertos_init_task(void) {
#endif

// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if !TUP_MCU_ESPRESSIF
vTaskStartScheduler();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion examples/device/video_capture/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/device/video_capture_2ch/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void led_blinking_task(void* param) {
#define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE
#define VIDEO_STACK_SIZE (configMINIMAL_STACK_SIZE*4)

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define USBD_STACK_SIZE 4096
int main(void);
void app_main(void) {
Expand Down Expand Up @@ -352,7 +352,7 @@ void freertos_init_task(void) {
#endif

// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if !TUP_MCU_ESPRESSIF
vTaskStartScheduler();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion examples/device/video_capture_2ch/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/host/cdc_msc_hid_freertos/src/cdc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "tusb.h"
#include "bsp/board_api.h"

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
Expand Down
11 changes: 7 additions & 4 deletions examples/host/cdc_msc_hid_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "bsp/board_api.h"
#include "tusb.h"

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -107,14 +107,14 @@ int main(void) {
xTimerStart(blinky_tm, 0);

// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if !TUP_MCU_ESPRESSIF
vTaskStartScheduler();
#endif

return 0;
}

#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
void app_main(void) {
main();
}
Expand All @@ -126,7 +126,10 @@ static void usb_host_task(void *param) {
(void) param;

// init host stack on configured roothub port
tuh_init(BOARD_TUH_RHPORT);
if (!tuh_init(BOARD_TUH_RHPORT)) {
printf("Failed to init USB Host Stack\r\n");
vTaskSuspend(NULL);
}

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
2 changes: 1 addition & 1 deletion examples/host/cdc_msc_hid_freertos/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#endif

// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
#define CFG_TUSB_OS_INC_PATH freertos/
#endif

Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/board_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
#include "tusb.h"

#if CFG_TUSB_OS == OPT_OS_FREERTOS
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
#if TUP_MCU_ESPRESSIF
// ESP-IDF need "freertos/" prefix in include path.
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
#include "freertos/FreeRTOS.h"
Expand Down
2 changes: 2 additions & 0 deletions hw/bsp/espressif/boards/adafruit_feather_esp32_v2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32")
53 changes: 53 additions & 0 deletions hw/bsp/espressif/boards/adafruit_feather_esp32_v2/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 0
#define NEOPIXEL_POWER_PIN 2
#define NEOPIXEL_POWER_STATE 1

#define BUTTON_PIN 38
#define BUTTON_STATE_ACTIVE 0

// SPI for USB host shield
#define MAX3421_SPI_HOST SPI3_HOST
#define MAX3421_SCK_PIN 5
#define MAX3421_MOSI_PIN 19
#define MAX3421_MISO_PIN 21
#define MAX3421_CS_PIN 33
#define MAX3421_INTR_PIN 15

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H_ */
2 changes: 2 additions & 0 deletions hw/bsp/espressif/boards/espressif_c3_devkitc/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32c3")
51 changes: 51 additions & 0 deletions hw/bsp/espressif/boards/espressif_c3_devkitc/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 8

#define BUTTON_PIN 9
#define BUTTON_STATE_ACTIVE 0

// SPI for USB host shield
#define MAX3421_SPI_HOST SPI2_HOST
#define MAX3421_SCK_PIN 4
#define MAX3421_MOSI_PIN 6
#define MAX3421_MISO_PIN 5
#define MAX3421_CS_PIN 10
#define MAX3421_INTR_PIN 7

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H_ */
Loading

0 comments on commit a0cba9b

Please sign in to comment.