summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-09-27 12:33:36 +0700
committerhathach <[email protected]>2023-09-27 12:34:45 +0700
commit6dc64eaa28ab905063233895345ba3c1186b836d (patch)
tree55aec25223a191b6216ff8c54bddc5cd5b8b7673
parent2f6592de7f94851cfcca411242398c5da7b792de (diff)
max3421 communication work with esp32 up to enumeration, seems still have a bit of issue
-rw-r--r--.idea/cmake.xml7
-rw-r--r--examples/host/cdc_msc_hid_freertos/src/cdc_app.c2
-rw-r--r--examples/host/cdc_msc_hid_freertos/src/main.c3
-rw-r--r--hw/bsp/espressif/boards/family.c15
4 files changed, 20 insertions, 7 deletions
diff --git a/.idea/cmake.xml b/.idea/cmake.xml
index 747f0fb58..ddeeb69fd 100644
--- a/.idea/cmake.xml
+++ b/.idea/cmake.xml
@@ -56,6 +56,13 @@
<configuration PROFILE_NAME="portenta_c33" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=portenta_c33 -DLOG=3" />
<configuration PROFILE_NAME="metro_m4_express" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m4_express -DLOG=3 -DLOGGER=RTT -DMAX3421_HOST=1" />
<configuration PROFILE_NAME="metro_m0_express" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=metro_m0_express -DLOG=3 -DLOGGER=RTT -DMAX3421_HOST=1" />
+ <configuration PROFILE_NAME="metro esp32s2" ENABLED="false" TOOLCHAIN_NAME="ESP-IDF" GENERATION_OPTIONS="-DBOARD=adafruit_metro_esp32s2 -DMAX3421_HOST=1 -DLOG=2">
+ <ADDITIONAL_GENERATION_ENVIRONMENT>
+ <envs>
+ <env name="ESPBAUD" value="1500000" />
+ </envs>
+ </ADDITIONAL_GENERATION_ENVIRONMENT>
+ </configuration>
</configurations>
</component>
</project> \ No newline at end of file
diff --git a/examples/host/cdc_msc_hid_freertos/src/cdc_app.c b/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
index fc2b1228d..943e534d8 100644
--- a/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
+++ b/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
@@ -68,7 +68,7 @@ void cdc_app_task(void* param) {
}
}
- taskYIELD();
+ vTaskDelay(1);
}
}
diff --git a/examples/host/cdc_msc_hid_freertos/src/main.c b/examples/host/cdc_msc_hid_freertos/src/main.c
index d5574789f..88e742ee2 100644
--- a/examples/host/cdc_msc_hid_freertos/src/main.c
+++ b/examples/host/cdc_msc_hid_freertos/src/main.c
@@ -40,6 +40,7 @@
#include "freertos/timers.h"
#define USBH_STACK_SIZE 4096
+ #define CDC_STACK_SZIE 2048
#else
#include "FreeRTOS.h"
#include "semphr.h"
@@ -49,9 +50,9 @@
// Increase stack size when debug log is enabled
#define USBH_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
+ #define CDC_STACK_SZIE (3*configMINIMAL_STACK_SIZE/2)
#endif
-#define CDC_STACK_SZIE (3*configMINIMAL_STACK_SIZE/2)
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTOTYPES
diff --git a/hw/bsp/espressif/boards/family.c b/hw/bsp/espressif/boards/family.c
index a04e1e7c5..5226f7e61 100644
--- a/hw/bsp/espressif/boards/family.c
+++ b/hw/bsp/espressif/boards/family.c
@@ -83,7 +83,6 @@ void board_init(void) {
gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
gpio_set_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN_ONLY : GPIO_PULLUP_ONLY);
-#if CFG_TUD_ENABLED
// USB Controller Hal init
periph_module_reset(PERIPH_USB_MODULE);
periph_module_enable(PERIPH_USB_MODULE);
@@ -93,7 +92,6 @@ void board_init(void) {
};
usb_hal_init(&hal);
configure_pins(&hal);
-#endif
#if CFG_TUH_ENABLED && CFG_TUH_MAX3421
max3421_init();
@@ -157,8 +155,9 @@ int board_uart_write(void const *buf, int len) {
}
int board_getchar(void) {
- char c;
- return (uart_read_bytes(UART_NUM_0, &c, 1, 0) > 0) ? (int) c : (-1);
+// char c;
+// return (uart_read_bytes(UART_NUM_0, &c, 1, 0) > 0) ? (int) c : (-1);
+ return -1;
}
//--------------------------------------------------------------------+
@@ -187,7 +186,7 @@ static void max3421_intr_task(void* param) {
while (1) {
xSemaphoreTake(max3421_intr_sem, portMAX_DELAY);
- tuh_int_handler(BOARD_TUH_RHPORT);
+ hcd_int_handler_ext(BOARD_TUH_RHPORT, false);
}
}
@@ -251,6 +250,12 @@ void tuh_max3421_spi_cs_api(uint8_t rhport, bool active) {
bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const *tx_buf, size_t tx_len, uint8_t *rx_buf, size_t rx_len) {
(void) rhport;
+ if (tx_len == 0) {
+ // fifo read, transmit rx_buf as dummy
+ tx_buf = rx_buf;
+ tx_len = rx_len;
+ }
+
spi_transaction_t xact = {
.length = tx_len << 3, // length in bits
.rxlength = rx_len << 3, // length in bits