You've already forked dspico-usb-examples
mirror of
https://github.com/LNH-team/dspico-usb-examples.git
synced 2026-01-09 16:27:56 -08:00
97 lines
4.3 KiB
C
97 lines
4.3 KiB
C
#pragma once
|
|
#include "usb_descriptors.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#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
|
|
//--------------------------------------------------------------------
|
|
|
|
// defined by compiler flags for flexibility
|
|
#ifndef CFG_TUSB_MCU
|
|
#define CFG_TUSB_MCU OPT_MCU_DSPICO
|
|
#endif
|
|
|
|
#define TUP_DCD_ENDPOINT_MAX 16
|
|
|
|
#ifndef CFG_TUSB_OS
|
|
#define CFG_TUSB_OS OPT_OS_CUSTOM
|
|
#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
|
|
#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.
|
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
|
* into those specific section.
|
|
* e.g
|
|
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
|
|
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
|
|
*/
|
|
#ifndef CFG_TUSB_MEM_SECTION
|
|
#define CFG_TUSB_MEM_SECTION
|
|
#endif
|
|
|
|
#ifndef CFG_TUSB_MEM_ALIGN
|
|
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
|
#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_AUDIO 1
|
|
#define CFG_TUD_VENDOR 0
|
|
|
|
//--------------------------------------------------------------------
|
|
// AUDIO CLASS DRIVER CONFIGURATION
|
|
//--------------------------------------------------------------------
|
|
|
|
#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE 32728
|
|
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_MIC_ONE_CH_DESC_LEN
|
|
#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT 1 // Number of Standard AS Interface Descriptors (4.9.1) defined per audio function - this is required to be able to remember the current alternate settings of these interfaces - We restrict us here to have a constant number for all audio functions (which means this has to be the maximum number of AS interfaces an audio function has and a second audio function with less AS interfaces just wastes a few bytes)
|
|
#define CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ 64 // Size of control request buffer
|
|
|
|
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
|
|
#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX 2 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below
|
|
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below - be aware: for different number of channels you need another descriptor!
|
|
#define CFG_TUD_AUDIO_EP_SZ_IN TUD_AUDIO_EP_SIZE(CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
|
|
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN
|
|
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ 256 //(TUD_OPT_HIGH_SPEED ? 8 : 1) * CFG_TUD_AUDIO_EP_SZ_IN // Example write FIFO every 1ms, so it should be 8 times larger for HS device
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |