This commit is contained in:
hathach 2018-04-10 20:41:04 +07:00
parent a9267cd9ff
commit 58c86bae1d
7 changed files with 40 additions and 44 deletions

View File

@ -397,7 +397,7 @@ static uint32_t slip_uart_open(void)
void tud_cdc_rx_cb(uint8_t port)
{
while ( tud_cdc_available() )
while ( tud_cdc_available() && !rx_buffer_overflowed() )
{
int8_t ch = tud_cdc_read_char();
handle_rx_byte((uint8_t) ch);

View File

@ -38,7 +38,7 @@
#include "msc_device_app.h"
#if TUSB_CFG_DEVICE_MSC
#if CFG_TUSB_DEVICE_MSC
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+

View File

@ -49,7 +49,7 @@
extern "C" {
#endif
#if TUSB_CFG_DEVICE_MSC
#if CFG_TUSB_DEVICE_MSC
enum
{
@ -62,7 +62,7 @@ enum
If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
#if TUSB_CFG_MCU==MCU_LPC11UXX || TUSB_CFG_MCU==MCU_LPC13UXX
#if CFG_TUSB_MCU==MCU_LPC11UXX || CFG_TUSB_MCU==MCU_LPC13UXX
#define MSCD_APP_ROMDISK
#else // defaults is ram disk
#define MSCD_APP_RAMDISK

View File

@ -38,7 +38,7 @@
#include "msc_device_app.h"
#if TUSB_CFG_DEVICE_MSC && defined (MSCD_APP_RAMDISK)
#if CFG_TUSB_DEVICE_MSC && defined (MSCD_APP_RAMDISK)
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@ -47,7 +47,7 @@
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
TUSB_CFG_ATTR_USBRAM ATTR_USB_MIN_ALIGNMENT
CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN
uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
{
//------------- Boot Sector -------------//

View File

@ -36,60 +36,56 @@
*/
/**************************************************************************/
#ifndef _TUSB_TUSB_CONFIG_H_
#define _TUSB_TUSB_CONFIG_H_
#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION
// COMMON CONFIGURATION
//--------------------------------------------------------------------+
//#define TUSB_CFG_MCU will be passed from IDE/command line for easy board/mcu switching
#define CFG_TUSB_CONTROLLER_0_MODE (TUSB_MODE_DEVICE)
#define TUSB_CFG_CONTROLLER_0_MODE (TUSB_MODE_DEVICE)
//#define TUSB_CFG_CONTROLLER_1_MODE (TUSB_MODE_DEVICE)
#define CFG_TUSB_DEBUG 2
#define CFG_TUSB_OS TUSB_OS_NONE
//#define CFG_TUSB_OS_TASK_PRIO 0
//--------------------------------------------------------------------+
// DEVICE CONFIGURATION
//--------------------------------------------------------------------+
#define TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE 64
#define CFG_TUSB_DEVICE_ENDOINT0_SIZE 64
//------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 0
#define TUSB_CFG_DEVICE_HID_MOUSE 0
#define TUSB_CFG_DEVICE_HID_GENERIC 0 // not supported yet
#define TUSB_CFG_DEVICE_MSC 0
#define TUSB_CFG_DEVICE_CDC 1
#define CFG_TUSB_DEVICE_HID_KEYBOARD 0
#define CFG_TUSB_DEVICE_HID_MOUSE 0
#define CFG_TUSB_DEVICE_HID_GENERIC 0 // not supported yet
#define CFG_TUSB_DEVICE_MSC 0
#define CFG_TUSB_DEVICE_CDC 1
//--------------------------------------------------------------------+
// COMMON CONFIGURATION
//--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 2
#define TUSB_CFG_OS TUSB_OS_NONE // be passed from IDE/command line for easy project switching
//#define TUSB_CFG_OS_TASK_PRIO 0 // be passed from IDE/command line for easy project switching
#define TUSB_CFG_TICKS_HZ 1000
/*------------------------------------------------------------------*/
/* CLASS
* TUD Stand for Tiny Usb Device
*------------------------------------------------------------------*/
//#define TUSB_CFG_OS TUSB_OS_NONE
// FIFO size of CDC TX and RX
#define CFG_TUD_CDC_BUFSIZE 1024
// TX is sent automatically in Start of Frame event.
// If not enabled, application must call tud_cdc_flush() periodically
#define CFG_TUD_CDC_FLUSH_ON_SOF 1
//--------------------------------------------------------------------+
// USB RAM PLACEMENT
//--------------------------------------------------------------------+
#define TUSB_CFG_ATTR_USBRAM
// LPC11uxx and LPC13uxx requires each buffer has to be 64-byte alignment
#if TUSB_CFG_MCU == MCU_LPC11UXX || TUSB_CFG_MCU == MCU_LPC13UXX
#define ATTR_USB_MIN_ALIGNMENT ATTR_ALIGNED(64)
#elif defined NRF52840_XXAA
#define ATTR_USB_MIN_ALIGNMENT ATTR_ALIGNED(4)
#else
#define ATTR_USB_MIN_ALIGNMENT
#endif
#define CFG_TUSB_ATTR_USBRAM
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_TUSB_CONFIG_H_ */
#endif /* _TUSB_CONFIG_H_ */

View File

@ -53,7 +53,7 @@ tusb_desc_device_t const desc_device =
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE,
.bMaxPacketSize0 = CFG_TUSB_DEVICE_ENDOINT0_SIZE,
.idVendor = CFG_VENDORID,
.idProduct = CFG_PRODUCTID,
@ -85,7 +85,7 @@ app_descriptor_configuration_t const desc_configuration =
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(500)
},
#if TUSB_CFG_DEVICE_CDC
#if CFG_TUSB_DEVICE_CDC
// IAD points to CDC Interfaces
.cdc =
{
@ -199,7 +199,7 @@ app_descriptor_configuration_t const desc_configuration =
},
#endif
#if TUSB_CFG_DEVICE_MSC
#if CFG_TUSB_DEVICE_MSC
.msc =
{
.interface =

View File

@ -50,7 +50,7 @@
// each combination of interfaces need to have a unique productid, as windows will bind & remember device driver after the first plug.
// Auto ProductID layout's Bitmap: (MSB) MassStorage | Generic | Mouse | Key | CDC (LSB)
#ifndef CFG_PRODUCTID
#define PRODUCTID_BITMAP(interface, n) ( (TUSB_CFG_DEVICE_##interface) << (n) )
#define PRODUCTID_BITMAP(interface, n) ( (CFG_TUSB_DEVICE_##interface) << (n) )
#define CFG_PRODUCTID (0x4000 | ( PRODUCTID_BITMAP(CDC, 0) | PRODUCTID_BITMAP(HID_KEYBOARD, 1) | \
PRODUCTID_BITMAP(HID_MOUSE, 2) | PRODUCTID_BITMAP(HID_GENERIC, 3) | \
PRODUCTID_BITMAP(MSC, 4) ) )
@ -60,7 +60,7 @@
#define ITF_NUM_MSC 2
// total number of interfaces
#define ITF_TOTAL (TUSB_CFG_DEVICE_CDC*2 + TUSB_CFG_DEVICE_MSC)
#define ITF_TOTAL (CFG_TUSB_DEVICE_CDC*2 + CFG_TUSB_DEVICE_MSC)
//--------------------------------------------------------------------+
// Endpoints Address & Max Packet Size
@ -87,7 +87,7 @@ typedef struct ATTR_PACKED
{
tusb_desc_configuration_t configuration;
#if TUSB_CFG_DEVICE_CDC
#if CFG_TUSB_DEVICE_CDC
struct ATTR_PACKED
{
tusb_desc_interface_assoc_t iad;
@ -107,7 +107,7 @@ typedef struct ATTR_PACKED
}cdc;
#endif
#if TUSB_CFG_DEVICE_MSC
#if CFG_TUSB_DEVICE_MSC
struct ATTR_PACKED
{
tusb_desc_interface_t interface;