sync tinyusb code

This commit is contained in:
hathach committed 2018-08-30 16:12:59 +07:00
1 parent 057cba9a93
commit fe479b7e2e
9 files changed
+43 -73

No files matched your search

@@ -146,12 +146,20 @@ void tud_cdc_n_read_flush (uint8_t itf)
uint32_t tud_cdc_n_write_char(uint8_t itf, char ch)
{
return tu_fifo_write(&_cdcd_itf[itf].tx_ff, &ch) ? 1 : 0;
return tud_cdc_n_write(itf, &ch, 1);
}
uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
{
return tu_fifo_write_n(&_cdcd_itf[itf].tx_ff, buffer, bufsize);
uint16_t ret = tu_fifo_write_n(&_cdcd_itf[itf].tx_ff, buffer, bufsize);
// flush if queue more than endpoint size
if ( tu_fifo_count(&_cdcd_itf[itf].tx_ff) >= CFG_TUD_CDC_EPSIZE )
{
tud_cdc_n_write_flush(itf);
}
return ret;
}
bool tud_cdc_n_write_flush (uint8_t itf)
@@ -348,14 +356,4 @@ tusb_error_t cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u
return TUSB_ERROR_NONE;
}
#if CFG_TUD_CDC_FLUSH_ON_SOF
void cdcd_sof(uint8_t rhport)
{
for(uint8_t i=0; i<CFG_TUD_CDC; i++)
{
tud_cdc_n_flush(i);
}
}
#endif
#endif
@@ -116,12 +116,6 @@ tusb_error_t cdcd_control_request_st (uint8_t rhport, tusb_control_request_t con
tusb_error_t cdcd_xfer_cb (uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes);
void cdcd_reset (uint8_t rhport);
#if CFG_TUD_CDC_FLUSH_ON_SOF
void cdcd_sof(uint8_t rhport);
#else
#define cdcd_sof NULL
#endif
#endif
#ifdef __cplusplus
+6 -3
View File
@@ -107,7 +107,7 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.open = cdcd_open,
.control_req_st = cdcd_control_request_st,
.xfer_cb = cdcd_xfer_cb,
.sof = cdcd_sof,
.sof = NULL,
.reset = cdcd_reset
},
#endif
@@ -250,6 +250,9 @@ tusb_error_t usbd_init (void)
// To enable the TASK_ASSERT style (quick return on false condition) in a real RTOS, a task must act as a wrapper
// and is used mainly to call subtasks. Within a subtask return statement can be called freely, the task with
// forever loop cannot have any return at all.
// Within tinyusb stack, all task's code must be placed in subtask to be able to support multiple RTOS
// including none.
void usbd_task( void* param)
{
(void) param;
@@ -306,7 +309,7 @@ static tusb_error_t usbd_main_st(void)
}
else
{
STASK_ASSERT(false);
verify_breakpoint();
}
}
@@ -577,7 +580,7 @@ void dcd_bus_event(uint8_t rhport, usbd_bus_event_type_t bus_event)
case USBD_BUS_EVENT_SOF:
{
#if CFG_TUD_CDC_FLUSH_ON_SOF
#if 0
usbd_task_event_t task_event =
{
.rhport = rhport,
@@ -38,13 +38,10 @@
#include "tusb_option.h"
#if TUSB_OPT_DEVICE_ENABLED
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DESC_AUTO
#include "tusb.h"
#if CFG_TUD_DESC_AUTO
//--------------------------------------------------------------------+
// Auto Description Default Configure & Validation
//--------------------------------------------------------------------+
@@ -634,6 +631,3 @@ tud_desc_set_t const _usbd_auto_desc_set =
};
#endif
#endif
+3 -1
View File
@@ -61,8 +61,10 @@ enum
typedef void (*osal_task_func_t)( void * );
#if CFG_TUSB_OS == OPT_OS_NONE
#include "osal_none.h"
#define OSAL_TASK_BEGIN
#define OSAL_TASK_END
#include "osal_none.h"
#else
#if CFG_TUSB_OS == OPT_OS_FREERTOS
#include "osal_freeRTOS.h"
+9 -16
View File
@@ -79,18 +79,6 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
#define TASK_RESTART \
_state = 0
#define OSAL_TASK_BEGIN \
static uint16_t _state = 0; \
ATTR_UNUSED static uint32_t _timeout = 0; \
(void) _timeout; \
switch(_state) { \
case 0: {
#define OSAL_TASK_END \
default: TASK_RESTART; break; \
}} \
return;
#define osal_task_delay(msec) \
do { \
_timeout = tusb_hal_millis(); \
@@ -102,11 +90,16 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
//--------------------------------------------------------------------+
// SUBTASK (a sub function that uses OS blocking services & called by a task
//--------------------------------------------------------------------+
#define OSAL_SUBTASK_BEGIN OSAL_TASK_BEGIN
#define OSAL_SUBTASK_BEGIN \
static uint16_t _state = 0; \
ATTR_UNUSED static uint32_t _timeout = 0; \
(void) _timeout; \
switch(_state) { \
case 0: {
#define OSAL_SUBTASK_END \
default: TASK_RESTART; break; \
}} \
#define OSAL_SUBTASK_END \
default: TASK_RESTART; break; \
}} \
return TUSB_ERROR_NONE;
#define STASK_INVOKE(_subtask, _status) \
@@ -261,10 +261,6 @@ void tusb_hal_nrf_power_event (uint32_t event)
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk |
USBD_INTEN_EP0SETUP_Msk | USBD_INTEN_EP0DATADONE_Msk | USBD_INTEN_ENDEPIN0_Msk | USBD_INTEN_ENDEPOUT0_Msk;
#if CFG_TUD_CDC && CFG_TUD_CDC_FLUSH_ON_SOF
NRF_USBD->INTENSET |= USBD_INTEN_SOF_Msk;
#endif
// Enable interrupt, Priorities 0,1,4,5 (nRF52) are reserved for SoftDevice
NVIC_SetPriority(USBD_IRQn, USB_NVIC_PRIO);
NVIC_ClearPendingIRQ(USBD_IRQn);
+7 -6
View File
@@ -36,6 +36,10 @@
*/
/**************************************************************************/
#include "tusb_option.h"
#if TUSB_OPT_HOST_ENABLED || TUSB_OPT_DEVICE_ENABLED
#define _TINY_USB_SOURCE_FILE_
#include "tusb.h"
@@ -82,10 +86,7 @@ void tusb_task(void)
/* Debug
*------------------------------------------------------------------*/
#if CFG_TUSB_DEBUG
char const* const tusb_strerr[TUSB_ERROR_COUNT] =
{
ERROR_TABLE(ERROR_STRING)
};
char const* const tusb_strerr[TUSB_ERROR_COUNT] = { ERROR_TABLE(ERROR_STRING) };
#endif
#endif // host or device enabled
+7 -18
View File
@@ -100,17 +100,16 @@
((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 1 : 0) + \
((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : 0))
#define CONTROLLER_DEVICE_NUMBER (\
((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 1 : 0) + \
((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : 0))
#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
#define TUSB_OPT_DEVICE_ENABLED (CONTROLLER_DEVICE_NUMBER > 0)
#define TUH_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : -1) )
#define TUSB_OPT_HOST_ENABLED ( TUH_OPT_RHPORT >= 0 )
#define TUD_OPT_RHPORT ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : -1))
#define TUD_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : -1) )
#define TUSB_OPT_DEVICE_ENABLED ( TUD_OPT_RHPORT >= 0 )
#if !MODE_HOST_SUPPORTED && !TUSB_OPT_DEVICE_ENABLED
#error please configure at least 1 CFG_TUSB_CONTROLLER_N_MODE to OPT_MODE_HOST and/or OPT_MODE_DEVICE
#if ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST)) || ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE))
#error "tinyusb does not support same modes on more than 1 roothub port"
#endif
//--------------------------------------------------------------------+
@@ -136,16 +135,6 @@
#define CFG_TUSB_OS OPT_OS_NONE
#endif
#ifndef tu_malloc
#include <stdlib.h>
#define tu_malloc malloc
#endif
#ifndef tu_free
#define tu_free free
#endif
//--------------------------------------------------------------------
// DEVICE OPTIONS
//--------------------------------------------------------------------