update max3421 to have hcd_int_handler_ext()

This commit is contained in:
hathach
2023-09-27 11:30:18 +07:00
parent f6ca86c3dd
commit 2f6592de7f
3 changed files with 55 additions and 32 deletions

View File

@@ -167,15 +167,30 @@ int board_getchar(void) {
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
static spi_device_handle_t max3421_spi;
SemaphoreHandle_t max3421_intr_sem;
static void IRAM_ATTR max3421_isr_handler(void* arg) {
(void) arg; // arg is gpio num
//xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
gpio_set_level(13, 1);
tuh_int_handler(1);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(max3421_intr_sem, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
gpio_set_level(13, 0);
}
static void max3421_intr_task(void* param) {
(void) param;
while (1) {
xSemaphoreTake(max3421_intr_sem, portMAX_DELAY);
tuh_int_handler(BOARD_TUH_RHPORT);
}
}
static void max3421_init(void) {
// CS pin
gpio_set_direction(MAX3421_CS_PIN, GPIO_MODE_OUTPUT);
@@ -209,6 +224,9 @@ static void max3421_init(void) {
gpio_set_level(13, 0);
// Interrupt pin
max3421_intr_sem = xSemaphoreCreateBinary();
xTaskCreate(max3421_intr_task, "max3421 intr", 2048, NULL, configMAX_PRIORITIES-1, NULL);
gpio_set_direction(MAX3421_INTR_PIN, GPIO_MODE_INPUT);
gpio_set_intr_type(MAX3421_INTR_PIN, GPIO_INTR_NEGEDGE);