mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-11 00:39:57 +00:00
add esp32s2 saola bsp
update cdc_msc_freertos main.c to work with esp32s2 add CMake file
This commit is contained in:
parent
a3e50242b9
commit
19f977a274
10
examples/device/cdc_msc_freertos/CMakeLists.txt
Normal file
10
examples/device/cdc_msc_freertos/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# example src directory
|
||||
set(EXTRA_COMPONENT_DIRS "src")
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
project(blink)
|
1060
examples/device/cdc_msc_freertos/sdkconfig
Normal file
1060
examples/device/cdc_msc_freertos/sdkconfig
Normal file
File diff suppressed because it is too large
Load Diff
36
examples/device/cdc_msc_freertos/src/CMakeLists.txt
Normal file
36
examples/device/cdc_msc_freertos/src/CMakeLists.txt
Normal file
@ -0,0 +1,36 @@
|
||||
# TOP is absolute path to root directory of TinyUSB git repo
|
||||
set(TOP "../../../..")
|
||||
get_filename_component(TOP "${TOP}" REALPATH)
|
||||
|
||||
idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES freertos soc)
|
||||
|
||||
target_compile_options(${COMPONENT_TARGET} PUBLIC
|
||||
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
|
||||
)
|
||||
|
||||
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
|
||||
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
||||
"${FREERTOS_ORIG_INCLUDE_PATH}"
|
||||
"${TOP}/hw"
|
||||
"${TOP}/src"
|
||||
)
|
||||
|
||||
target_sources(${COMPONENT_TARGET} PUBLIC
|
||||
"${TOP}/hw/bsp/esp32s2_saola/esp32s2_saola.c"
|
||||
"${TOP}/src/tusb.c"
|
||||
"${TOP}/src/common/tusb_fifo.c"
|
||||
"${TOP}/src/device/usbd.c"
|
||||
"${TOP}/src/device/usbd_control.c"
|
||||
"${TOP}/src/class/cdc/cdc_device.c"
|
||||
"${TOP}/src/class/dfu/dfu_rt_device.c"
|
||||
"${TOP}/src/class/hid/hid_device.c"
|
||||
"${TOP}/src/class/midi/midi_device.c"
|
||||
"${TOP}/src/class/msc/msc_device.c"
|
||||
"${TOP}/src/class/net/net_device.c"
|
||||
"${TOP}/src/class/usbtmc/usbtmc_device.c"
|
||||
"${TOP}/src/class/vendor/vendor_device.c"
|
||||
"${TOP}/src/portable/espressif/esp32s2/dcd_esp32s2.c"
|
||||
)
|
||||
|
@ -56,12 +56,12 @@ StaticTimer_t static_blink;
|
||||
TimerHandle_t blink_tm;
|
||||
|
||||
// static task for usbd
|
||||
#define USBD_STACK_SIZE (3*(configMINIMAL_STACK_SIZE/2))
|
||||
#define USBD_STACK_SIZE (2*configMINIMAL_STACK_SIZE)
|
||||
StackType_t stack_usbd[USBD_STACK_SIZE];
|
||||
StaticTask_t static_task_usbd;
|
||||
|
||||
// static task for cdc
|
||||
#define CDC_STACK_SZIE configMINIMAL_STACK_SIZE
|
||||
#define CDC_STACK_SZIE (2*configMINIMAL_STACK_SIZE)
|
||||
StackType_t stack_cdc[CDC_STACK_SZIE];
|
||||
StaticTask_t static_task_cdc;
|
||||
|
||||
@ -72,11 +72,10 @@ void cdc_task(void* params);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
|
||||
// ESP32S2 entry function is app_main()
|
||||
#define main app_main
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
#else
|
||||
int main(void)
|
||||
#endif
|
||||
{
|
||||
board_init();
|
||||
|
||||
@ -91,21 +90,16 @@ int main(void)
|
||||
|
||||
// Create task
|
||||
#if CFG_TUD_CDC
|
||||
(void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, stack_cdc, &static_task_cdc);
|
||||
(void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-1, stack_cdc, &static_task_cdc);
|
||||
#endif
|
||||
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
|
||||
// skip starting scheduler for ESP32 S2 (already started)
|
||||
while(1)
|
||||
{
|
||||
vTaskSuspend(NULL);
|
||||
}
|
||||
#else
|
||||
// skip starting scheduler (and return) for ESP32-S2
|
||||
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
|
||||
vTaskStartScheduler();
|
||||
NVIC_SystemReset();
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// USB Device Driver task
|
||||
@ -186,7 +180,8 @@ void cdc_task(void* params)
|
||||
}
|
||||
}
|
||||
|
||||
taskYIELD();
|
||||
// For ESP32-S2 this delay is essential to allow idle how to run and reset wdt
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
|
||||
|
77
hw/bsp/esp32s2_saola/esp32s2_saola.c
Normal file
77
hw/bsp/esp32s2_saola/esp32s2_saola.c
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "hal/usb_hal.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define LED_PIN 21
|
||||
|
||||
// Initialize on-board peripherals : led, button, uart and USB
|
||||
void board_init(void)
|
||||
{
|
||||
// LED
|
||||
gpio_pad_select_gpio(LED_PIN);
|
||||
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
// USB Controller Hal init
|
||||
usb_hal_context_t hal = {
|
||||
.use_external_phy = false // use built-in PHY
|
||||
};
|
||||
usb_hal_init(&hal);
|
||||
}
|
||||
|
||||
// Turn LED on or off
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
gpio_set_level(LED_PIN, state);
|
||||
}
|
||||
|
||||
// Get the current state of button
|
||||
// a '1' means active (pressed), a '0' means inactive.
|
||||
uint32_t board_button_read(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get characters from UART
|
||||
int board_uart_read(uint8_t* buf, int len)
|
||||
{
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Send characters to UART
|
||||
int board_uart_write(void const * buf, int len)
|
||||
{
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user