mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 01:20:19 +00:00
more example update
This commit is contained in:
parent
f4c80dd218
commit
9794a2b865
@ -90,7 +90,13 @@ extern "C" {
|
|||||||
#define CFG_TUD_ENDPOINT0_SIZE 64
|
#define CFG_TUD_ENDPOINT0_SIZE 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------- CLASS -------------//
|
||||||
#define CFG_TUD_AUDIO 1
|
#define CFG_TUD_AUDIO 1
|
||||||
|
#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
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// AUDIO CLASS DRIVER CONFIGURATION
|
// AUDIO CLASS DRIVER CONFIGURATION
|
||||||
|
@ -82,7 +82,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,6 +61,12 @@ extern "C" {
|
|||||||
#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
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@ -76,11 +94,11 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
//------------- CLASS -------------//
|
||||||
|
#define CFG_TUD_AUDIO 1
|
||||||
#define CFG_TUD_CDC 0
|
#define CFG_TUD_CDC 0
|
||||||
#define CFG_TUD_MSC 0
|
#define CFG_TUD_MSC 0
|
||||||
#define CFG_TUD_HID 0
|
#define CFG_TUD_HID 0
|
||||||
#define CFG_TUD_MIDI 0
|
#define CFG_TUD_MIDI 0
|
||||||
#define CFG_TUD_AUDIO 1
|
|
||||||
#define CFG_TUD_VENDOR 0
|
#define CFG_TUD_VENDOR 0
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -39,7 +39,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by board.mk
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
|
@ -74,7 +74,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -12,41 +12,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -60,7 +61,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -72,10 +73,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
//------------- CLASS -------------//
|
||||||
#define CFG_TUD_DFU 1
|
#define CFG_TUD_DFU 1
|
||||||
|
|
||||||
// DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
|
// DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
|
||||||
#define CFG_TUD_DFU_XFER_BUFSIZE ( OPT_MODE_HIGH_SPEED ? 512 : 64 )
|
#define CFG_TUD_DFU_XFER_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -12,41 +12,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
|
@ -55,7 +55,9 @@ void midi_task(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -55,7 +55,9 @@ void hid_task(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,45 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// Use raspberry pio-usb for device
|
|
||||||
// #define CFG_TUD_RPI_PIO_USB 1
|
|
||||||
// #define BOARD_TUD_RHPORT 1
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -82,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -56,7 +56,9 @@ void hid_task(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
|
@ -125,9 +125,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,48 +30,48 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by board.mk
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This examples use FreeRTOS
|
// This examples use FreeRTOS
|
||||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||||
|
|
||||||
// Espressif IDF requires "freertos/" prefix in include path
|
// Espressif IDF requires "freertos/" prefix in include path
|
||||||
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||||
#define CFG_TUSB_OS_INC_PATH freertos/
|
#define CFG_TUSB_OS_INC_PATH freertos/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// can be defined by compiler in DEBUG build
|
||||||
#ifndef CFG_TUSB_DEBUG
|
#ifndef CFG_TUSB_DEBUG
|
||||||
#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.
|
||||||
|
@ -80,7 +80,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -60,7 +60,9 @@ void hid_task(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
|
@ -62,7 +62,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -54,7 +54,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by board.mk
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU must be defined
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Device mode with rhport and speed defined by board.mk
|
|
||||||
#if BOARD_TUD_RHPORT == 0
|
|
||||||
#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)
|
|
||||||
#else
|
|
||||||
#error "Incorrect RHPort configuration"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -228,7 +228,9 @@ int main(void)
|
|||||||
{
|
{
|
||||||
/* initialize TinyUSB */
|
/* initialize TinyUSB */
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
/* initialize lwip, dhcp-server, dns-server, and http */
|
/* initialize lwip, dhcp-server, dns-server, and http */
|
||||||
init_lwip();
|
init_lwip();
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
#define BOARD_TUD_RHPORT 0
|
#define BOARD_TUD_RHPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#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 compiler flags for flexibility
|
||||||
#else
|
#ifndef CFG_TUSB_MCU
|
||||||
#error "Incorrect RHPort configuration"
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -102,7 +102,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
TU_LOG1("Headset running\r\n");
|
TU_LOG1("Headset running\r\n");
|
||||||
|
|
||||||
|
@ -31,30 +31,45 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// COMMON CONFIGURATION
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "usb_descriptors.h"
|
#include "usb_descriptors.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// 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
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// defined by compiler flags for flexibility
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#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
|
||||||
|
|
||||||
#ifndef CFG_TUSB_DEBUG
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// Can be set during compilation i.e.: make LOG=<value for CFG_TUSB_DEBUG> BOARD=<bsp>
|
#define CFG_TUSB_DEBUG 0
|
||||||
// Keep in mind that enabling logs when data is streaming can disrupt data flow.
|
|
||||||
// It can be very helpful though when audio unit requests are tested/debugged.
|
|
||||||
#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.
|
||||||
@ -67,7 +82,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -54,7 +54,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -12,41 +12,42 @@
|
|||||||
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
|
||||||
#define BOARD_TUD_RHPORT 0
|
#define BOARD_TUD_RHPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#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 compiler flags for flexibility
|
||||||
#else
|
#ifndef CFG_TUSB_MCU
|
||||||
#error "Incorrect RHPort configuration"
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -60,7 +61,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -55,7 +55,9 @@ void video_task(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
|
||||||
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,37 +30,42 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
// COMMON CONFIGURATION
|
// Board Specific Configuration
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// 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
|
||||||
#define BOARD_TUD_RHPORT 0
|
#define BOARD_TUD_RHPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#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 compiler flags for flexibility
|
||||||
#else
|
#ifndef CFG_TUSB_MCU
|
||||||
#error "Incorrect RHPort configuration"
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This example doesn't use an RTOS
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -74,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -93,7 +93,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
tusb_init();
|
// init device stack on configured roothub port
|
||||||
|
tud_init(BOARD_TUD_RHPORT);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -30,41 +30,42 @@
|
|||||||
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
|
||||||
#define BOARD_TUD_RHPORT 0
|
#define BOARD_TUD_RHPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
// Default to max (auto) speed for MCU with internal HighSpeed PHY
|
|
||||||
#ifndef BOARD_TUD_MAX_SPEED
|
#ifndef BOARD_TUD_MAX_SPEED
|
||||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#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 compiler flags for flexibility
|
||||||
#else
|
#ifndef CFG_TUSB_MCU
|
||||||
#error "Incorrect RHPort configuration"
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
#ifndef CFG_TUSB_DEBUG
|
||||||
// #define CFG_TUSB_DEBUG 0
|
#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
|
||||||
|
#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
|
||||||
@ -78,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user