Skip to content

Commit a0cba9b

Browse files
authored
Merge pull request #2611 from hathach/add-esp32-max3421e
Add esp32 max3421e
2 parents fc91e15 + 022de87 commit a0cba9b

File tree

24 files changed

+157
-52
lines changed

24 files changed

+157
-52
lines changed

examples/device/board_test/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#endif
5050

5151
// Espressif IDF requires "freertos/" prefix in include path
52-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
52+
#if TUP_MCU_ESPRESSIF
5353
#define CFG_TUSB_OS_INC_PATH freertos/
5454
#endif
5555

examples/device/cdc_msc_freertos/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "bsp/board_api.h"
3131
#include "tusb.h"
3232

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

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

118118
return 0;
119119
}
120120

121-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
121+
#if TUP_MCU_ESPRESSIF
122122
void app_main(void) {
123123
main();
124124
}

examples/device/cdc_msc_freertos/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#endif
6060

6161
// Espressif IDF requires "freertos/" prefix in include path
62-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
62+
#if TUP_MCU_ESPRESSIF
6363
#define CFG_TUSB_OS_INC_PATH freertos/
6464
#endif
6565

examples/device/hid_composite_freertos/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "tusb.h"
3232
#include "usb_descriptors.h"
3333

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

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

120120
return 0;
121121
}
122122

123-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
123+
#if TUP_MCU_ESPRESSIF
124124
void app_main(void)
125125
{
126126
main();

examples/device/hid_composite_freertos/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#endif
6060

6161
// Espressif IDF requires "freertos/" prefix in include path
62-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
62+
#if TUP_MCU_ESPRESSIF
6363
#define CFG_TUSB_OS_INC_PATH freertos/
6464
#endif
6565

examples/device/video_capture/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void led_blinking_task(void* param) {
288288
#define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE
289289
#define VIDEO_STACK_SIZE (configMINIMAL_STACK_SIZE*4)
290290

291-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
291+
#if TUP_MCU_ESPRESSIF
292292
#define USBD_STACK_SIZE 4096
293293
int main(void);
294294
void app_main(void) {
@@ -344,7 +344,7 @@ void freertos_init_task(void) {
344344
#endif
345345

346346
// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
347-
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
347+
#if !TUP_MCU_ESPRESSIF
348348
vTaskStartScheduler();
349349
#endif
350350
}

examples/device/video_capture/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#endif
5959

6060
// Espressif IDF requires "freertos/" prefix in include path
61-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
61+
#if TUP_MCU_ESPRESSIF
6262
#define CFG_TUSB_OS_INC_PATH freertos/
6363
#endif
6464

examples/device/video_capture_2ch/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void led_blinking_task(void* param) {
296296
#define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE
297297
#define VIDEO_STACK_SIZE (configMINIMAL_STACK_SIZE*4)
298298

299-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
299+
#if TUP_MCU_ESPRESSIF
300300
#define USBD_STACK_SIZE 4096
301301
int main(void);
302302
void app_main(void) {
@@ -352,7 +352,7 @@ void freertos_init_task(void) {
352352
#endif
353353

354354
// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
355-
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
355+
#if !TUP_MCU_ESPRESSIF
356356
vTaskStartScheduler();
357357
#endif
358358
}

examples/device/video_capture_2ch/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#endif
5959

6060
// Espressif IDF requires "freertos/" prefix in include path
61-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
61+
#if TUP_MCU_ESPRESSIF
6262
#define CFG_TUSB_OS_INC_PATH freertos/
6363
#endif
6464

examples/host/cdc_msc_hid_freertos/src/cdc_app.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "tusb.h"
2828
#include "bsp/board_api.h"
2929

30-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
30+
#if TUP_MCU_ESPRESSIF
3131
// ESP-IDF need "freertos/" prefix in include path.
3232
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
3333
#include "freertos/FreeRTOS.h"

examples/host/cdc_msc_hid_freertos/src/main.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "bsp/board_api.h"
3131
#include "tusb.h"
3232

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

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

114114
return 0;
115115
}
116116

117-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
117+
#if TUP_MCU_ESPRESSIF
118118
void app_main(void) {
119119
main();
120120
}
@@ -126,7 +126,10 @@ static void usb_host_task(void *param) {
126126
(void) param;
127127

128128
// init host stack on configured roothub port
129-
tuh_init(BOARD_TUH_RHPORT);
129+
if (!tuh_init(BOARD_TUH_RHPORT)) {
130+
printf("Failed to init USB Host Stack\r\n");
131+
vTaskSuspend(NULL);
132+
}
130133

131134
if (board_init_after_tusb) {
132135
board_init_after_tusb();

examples/host/cdc_msc_hid_freertos/src/tusb_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#endif
4545

4646
// Espressif IDF requires "freertos/" prefix in include path
47-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
47+
#if TUP_MCU_ESPRESSIF
4848
#define CFG_TUSB_OS_INC_PATH freertos/
4949
#endif
5050

hw/bsp/board_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939
#include "tusb.h"
4040

4141
#if CFG_TUSB_OS == OPT_OS_FREERTOS
42-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
42+
#if TUP_MCU_ESPRESSIF
4343
// ESP-IDF need "freertos/" prefix in include path.
4444
// CFG_TUSB_OS_INC_PATH should be defined accordingly.
4545
#include "freertos/FreeRTOS.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Apply board specific content here
2+
set(IDF_TARGET "esp32")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2020, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef BOARD_H_
28+
#define BOARD_H_
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
#define NEOPIXEL_PIN 0
35+
#define NEOPIXEL_POWER_PIN 2
36+
#define NEOPIXEL_POWER_STATE 1
37+
38+
#define BUTTON_PIN 38
39+
#define BUTTON_STATE_ACTIVE 0
40+
41+
// SPI for USB host shield
42+
#define MAX3421_SPI_HOST SPI3_HOST
43+
#define MAX3421_SCK_PIN 5
44+
#define MAX3421_MOSI_PIN 19
45+
#define MAX3421_MISO_PIN 21
46+
#define MAX3421_CS_PIN 33
47+
#define MAX3421_INTR_PIN 15
48+
49+
#ifdef __cplusplus
50+
}
51+
#endif
52+
53+
#endif /* BOARD_H_ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Apply board specific content here
2+
set(IDF_TARGET "esp32c3")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2020, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef BOARD_H_
28+
#define BOARD_H_
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
#define NEOPIXEL_PIN 8
35+
36+
#define BUTTON_PIN 9
37+
#define BUTTON_STATE_ACTIVE 0
38+
39+
// SPI for USB host shield
40+
#define MAX3421_SPI_HOST SPI2_HOST
41+
#define MAX3421_SCK_PIN 4
42+
#define MAX3421_MOSI_PIN 6
43+
#define MAX3421_MISO_PIN 5
44+
#define MAX3421_CS_PIN 10
45+
#define MAX3421_INTR_PIN 7
46+
47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
51+
#endif /* BOARD_H_ */

0 commit comments

Comments
 (0)