mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 10:43:44 +00:00
clean up example to use CFG_TUD_ENABLED + CFG_TUD_MAX_SPEED instead of CFG_TUSB_RHPORT0_MODE
This commit is contained in:
parent
1b08672945
commit
f4c80dd218
@ -81,7 +81,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
// Init values
|
// Init values
|
||||||
sampFreq = AUDIO_SAMPLE_RATE;
|
sampFreq = AUDIO_SAMPLE_RATE;
|
||||||
|
@ -30,6 +30,20 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Board Specific Configuration
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// RHPort number used for device can be defined by board.mk, default to port 0
|
||||||
|
#ifndef BOARD_TUD_RHPORT
|
||||||
|
#define BOARD_TUD_RHPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RHPort max operational speed can defined by board.mk
|
||||||
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// COMMON CONFIGURATION
|
// COMMON CONFIGURATION
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -39,8 +53,6 @@ extern "C" {
|
|||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
|
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
@ -49,8 +61,11 @@ extern "C" {
|
|||||||
#define CFG_TUSB_DEBUG 0
|
#define CFG_TUSB_DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
// Enable Device stack
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#define CFG_TUD_ENABLED 1
|
||||||
|
|
||||||
|
// Default is max speed that hardware controller could support with on-chip PHY
|
||||||
|
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
||||||
|
|
||||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||||
@ -75,13 +90,7 @@ extern "C" {
|
|||||||
#define CFG_TUD_ENDPOINT0_SIZE 64
|
#define CFG_TUD_ENDPOINT0_SIZE 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
|
||||||
#define CFG_TUD_CDC 0
|
|
||||||
#define CFG_TUD_MSC 0
|
|
||||||
#define CFG_TUD_HID 0
|
|
||||||
#define CFG_TUD_MIDI 0
|
|
||||||
#define CFG_TUD_AUDIO 1
|
#define CFG_TUD_AUDIO 1
|
||||||
#define CFG_TUD_VENDOR 0
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// AUDIO CLASS DRIVER CONFIGURATION
|
// AUDIO CLASS DRIVER CONFIGURATION
|
||||||
|
@ -43,7 +43,9 @@
|
|||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
|
// This example only test LED & GPIO, disable both device and host stack
|
||||||
|
#define CFG_TUD_ENABLED 0
|
||||||
|
#define CFG_TUH_ENABLED 0
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
||||||
// #define CFG_TUSB_DEBUG 0
|
// #define CFG_TUSB_DEBUG 0
|
||||||
@ -63,21 +65,6 @@
|
|||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// DEVICE CONFIGURATION
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef CFG_TUD_ENDPOINT0_SIZE
|
|
||||||
#define CFG_TUD_ENDPOINT0_SIZE 64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
|
||||||
#define CFG_TUD_CDC 0
|
|
||||||
#define CFG_TUD_MSC 0
|
|
||||||
#define CFG_TUD_HID 0
|
|
||||||
#define CFG_TUD_MIDI 0
|
|
||||||
#define CFG_TUD_VENDOR 0
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,27 +30,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
// COMMON CONFIGURATION
|
// Board Specific Configuration
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// defined by board.mk
|
|
||||||
#ifndef CFG_TUSB_MCU
|
|
||||||
#error CFG_TUSB_MCU must be defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This example doesn't use an RTOS
|
|
||||||
#ifndef CFG_TUSB_OS
|
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
|
||||||
#ifndef CFG_TUSB_DEBUG
|
|
||||||
#define CFG_TUSB_DEBUG 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable Device stack
|
|
||||||
#define CFG_TUD_ENABLED 1
|
|
||||||
|
|
||||||
// RHPort number used for device can be defined by board.mk, default to port 0
|
// RHPort number used for device can be defined by board.mk, default to port 0
|
||||||
#ifndef BOARD_TUD_RHPORT
|
#ifndef BOARD_TUD_RHPORT
|
||||||
@ -62,10 +44,29 @@
|
|||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Common Configuration
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
// defined by compiler flags for flexibility
|
||||||
|
#ifndef CFG_TUSB_MCU
|
||||||
|
#error CFG_TUSB_MCU must be defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFG_TUSB_OS
|
||||||
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFG_TUSB_DEBUG
|
||||||
|
#define CFG_TUSB_DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Enable Device stack
|
||||||
|
#define CFG_TUD_ENABLED 1
|
||||||
|
|
||||||
// Default is max speed that hardware controller could support with on-chip PHY
|
// Default is max speed that hardware controller could support with on-chip PHY
|
||||||
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
||||||
|
|
||||||
|
|
||||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||||
* into those specific section.
|
* into those specific section.
|
||||||
|
@ -123,9 +123,10 @@ void usb_device_task(void* param)
|
|||||||
{
|
{
|
||||||
(void) param;
|
(void) param;
|
||||||
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
// This should be called after scheduler/kernel is started.
|
// This should be called after scheduler/kernel is started.
|
||||||
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
|
||||||
tusb_init();
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
// RTOS forever loop
|
// RTOS forever loop
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -30,14 +30,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
// COMMON CONFIGURATION
|
// Board Specific Configuration
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// defined by board.mk
|
|
||||||
#ifndef CFG_TUSB_MCU
|
|
||||||
#error CFG_TUSB_MCU must be defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// RHPort number used for device can be defined by board.mk, default to port 0
|
// RHPort number used for device can be defined by board.mk, default to port 0
|
||||||
#ifndef BOARD_TUD_RHPORT
|
#ifndef BOARD_TUD_RHPORT
|
||||||
@ -45,23 +40,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56)
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
|
|
||||||
#else
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
//--------------------------------------------------------------------
|
||||||
#if BOARD_TUD_RHPORT == 0
|
// COMMON CONFIGURATION
|
||||||
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_TUD_MAX_SPEED)
|
//--------------------------------------------------------------------
|
||||||
#elif BOARD_TUD_RHPORT == 1
|
|
||||||
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_TUD_MAX_SPEED)
|
// defined by board.mk
|
||||||
#else
|
#ifndef CFG_TUSB_MCU
|
||||||
#error "Incorrect RHPort configuration"
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This examples use FreeRTOS
|
// This examples use FreeRTOS
|
||||||
@ -77,6 +66,12 @@
|
|||||||
#define CFG_TUSB_DEBUG 0
|
#define CFG_TUSB_DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Enable Device stack
|
||||||
|
#define CFG_TUD_ENABLED 1
|
||||||
|
|
||||||
|
// Default is max speed that hardware controller could support with on-chip PHY
|
||||||
|
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
||||||
|
|
||||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||||
* into those specific section.
|
* into those specific section.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user