weak atrribute work around removed from CCRX_Port
This commit is contained in:
@@ -117,7 +117,6 @@ void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK;
|
||||
// Endpoint API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#if !defined(TU_HAS_NO_ATTR_WEAK)
|
||||
// Invoked when a control transfer's status stage is complete.
|
||||
// May help DCD to prepare for next control transfer, this API is optional.
|
||||
void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request) TU_ATTR_WEAK;
|
||||
@@ -130,35 +129,6 @@ void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
|
||||
// This API is optional, may be useful for register-based for transferring data.
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) TU_ATTR_WEAK;
|
||||
|
||||
#else
|
||||
#if ADD_WEAK_FUNC_DCD_EDPT0_STATUS_COMPLETE
|
||||
#define DCD_EDPT0_STATUS_COMPLETE dcd_edpt0_status_complete
|
||||
#endif
|
||||
#ifndef DCD_EDPT0_STATUS_COMPLETE
|
||||
#define DCD_EDPT0_STATUS_COMPLETE NULL
|
||||
#else
|
||||
extern void DCD_EDPT0_STATUS_COMPLETE(uint8_t rhport, tusb_control_request_t const * request);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_DCD_EDPT_CLOSE
|
||||
#define DCD_EDPT_CLOSE dcd_edpt_close
|
||||
#endif
|
||||
#ifndef DCD_EDPT_CLOSE
|
||||
#define DCD_EDPT_CLOSE NULL
|
||||
#else
|
||||
extern void DCD_EDPT_CLOSE(uint8_t rhport, uint8_t ep_addr);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_DCD_EDPT_XFER_FIFO
|
||||
#define DCD_EDPT_XFER_FIFO dcd_edpt_xfer_fifo
|
||||
#endif
|
||||
#ifndef DCD_EDPT_XFER_FIFO
|
||||
#define DCD_EDPT_XFER_FIFO NULL
|
||||
#else
|
||||
extern void DCD_EDPT_XFER_FIFO(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Configure endpoint's registers according to descriptor
|
||||
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
|
||||
|
||||
|
||||
@@ -33,19 +33,6 @@
|
||||
#include "device/usbd_pvt.h"
|
||||
#include "device/dcd.h"
|
||||
|
||||
#if defined(TU_HAS_NO_ATTR_WEAK)
|
||||
static uint8_t const* (*const MAKE_WEAK_FUNC(tud_descriptor_bos_cb))(void) = TUD_DESCRIPTOR_BOS_CB;
|
||||
static uint8_t const* (*const MAKE_WEAK_FUNC(tud_descriptor_device_qualifier_cb))(void) = TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_mount_cb))(void) = TUD_MOUNT_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_umount_cb))(void) = TUD_UMOUNT_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_suspend_cb))(_Bool) = TUD_SUSPEND_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_resume_cb))(void) = TUD_RESUME_CB;
|
||||
static _Bool (*const MAKE_WEAK_FUNC(tud_vendor_control_xfer_cb))(uint8_t, uint8_t, tusb_control_request_t const *) = TUD_RESUME_CB;
|
||||
static usbd_class_driver_t const* (*const MAKE_WEAK_FUNC(usbd_app_driver_get_cb))(uint8_t*) = USBD_APP_DRIVER_GET_CB;
|
||||
static bool (*const MAKE_WEAK_FUNC(dcd_edpt_xfer_fifo))(uint8_t, uint8_t, tu_fifo_t *, uint16_t) = DCD_EDPT_XFER_FIFO;
|
||||
static void (*const MAKE_WEAK_FUNC(dcd_edpt_close))(uint8_t, uint8_t) = DCD_EDPT_CLOSE;
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_TASK_QUEUE_SZ
|
||||
#define CFG_TUD_TASK_QUEUE_SZ 16
|
||||
#endif
|
||||
@@ -61,10 +48,11 @@ static void (*const MAKE_WEAK_FUNC(dcd_edpt_close))(uint8_t, uint8_t) = DCD_EDPT
|
||||
// Invalid driver ID in itf2drv[] ep2drv[][] mapping
|
||||
enum { DRVID_INVALID = 0xFFu };
|
||||
|
||||
TU_PACK_STRUCT_BEGIN // Start of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct
|
||||
{
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
struct TU_ATTR_PACKED
|
||||
{
|
||||
volatile uint8_t connected : 1;
|
||||
@@ -75,8 +63,6 @@ typedef struct
|
||||
uint8_t remote_wakeup_support : 1; // configuration descriptor's attribute
|
||||
uint8_t self_powered : 1; // configuration descriptor's attribute
|
||||
};
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
volatile uint8_t cfg_num; // current active configuration (0x00 is not configured)
|
||||
uint8_t speed;
|
||||
@@ -84,8 +70,6 @@ typedef struct
|
||||
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
|
||||
uint8_t ep2drv[CFG_TUD_EP_MAX][2]; // map endpoint to driver ( 0xff is invalid )
|
||||
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
struct TU_ATTR_PACKED
|
||||
{
|
||||
volatile bool busy : 1;
|
||||
@@ -94,10 +78,11 @@ typedef struct
|
||||
|
||||
// TODO merge ep2drv here, 4-bit should be sufficient
|
||||
}ep_status[CFG_TUD_EP_MAX][2];
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
}usbd_device_t;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
TU_PACK_STRUCT_END // End of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
static usbd_device_t _usbd_dev;
|
||||
|
||||
@@ -257,7 +242,7 @@ static uint8_t _app_driver_count = 0;
|
||||
static inline usbd_class_driver_t const * get_driver(uint8_t drvid)
|
||||
{
|
||||
// Application drivers
|
||||
if ( MAKE_WEAK_FUNC(usbd_app_driver_get_cb) )
|
||||
if ( usbd_app_driver_get_cb )
|
||||
{
|
||||
if ( drvid < _app_driver_count ) return &_app_driver[drvid];
|
||||
drvid -= _app_driver_count;
|
||||
@@ -429,9 +414,9 @@ bool tud_init (uint8_t rhport)
|
||||
TU_ASSERT(_usbd_q);
|
||||
|
||||
// Get application driver if available
|
||||
if ( MAKE_WEAK_FUNC(usbd_app_driver_get_cb) )
|
||||
if ( usbd_app_driver_get_cb )
|
||||
{
|
||||
_app_driver = MAKE_WEAK_FUNC(usbd_app_driver_get_cb)(&_app_driver_count);
|
||||
_app_driver = usbd_app_driver_get_cb(&_app_driver_count);
|
||||
}
|
||||
|
||||
// Init class drivers
|
||||
@@ -522,7 +507,7 @@ void tud_task (void)
|
||||
usbd_reset(event.rhport);
|
||||
|
||||
// invoke callback
|
||||
if (MAKE_WEAK_FUNC(tud_umount_cb)) MAKE_WEAK_FUNC(tud_umount_cb)();
|
||||
if (tud_umount_cb) tud_umount_cb();
|
||||
break;
|
||||
|
||||
case DCD_EVENT_SETUP_RECEIVED:
|
||||
@@ -578,12 +563,12 @@ void tud_task (void)
|
||||
|
||||
case DCD_EVENT_SUSPEND:
|
||||
TU_LOG2("\r\n");
|
||||
if (MAKE_WEAK_FUNC(tud_suspend_cb)) MAKE_WEAK_FUNC(tud_suspend_cb)(_usbd_dev.remote_wakeup_en);
|
||||
if (tud_suspend_cb) tud_suspend_cb(_usbd_dev.remote_wakeup_en);
|
||||
break;
|
||||
|
||||
case DCD_EVENT_RESUME:
|
||||
TU_LOG2("\r\n");
|
||||
if (MAKE_WEAK_FUNC(tud_resume_cb)) MAKE_WEAK_FUNC(tud_resume_cb)();
|
||||
if (tud_resume_cb) tud_resume_cb();
|
||||
break;
|
||||
|
||||
case DCD_EVENT_SOF:
|
||||
@@ -630,10 +615,10 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// Vendor request
|
||||
if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR )
|
||||
{
|
||||
TU_VERIFY(MAKE_WEAK_FUNC(tud_vendor_control_xfer_cb));
|
||||
TU_VERIFY(tud_vendor_control_xfer_cb);
|
||||
|
||||
usbd_control_set_complete_callback(MAKE_WEAK_FUNC(tud_vendor_control_xfer_cb));
|
||||
return MAKE_WEAK_FUNC(tud_vendor_control_xfer_cb)(rhport, CONTROL_STAGE_SETUP, p_request);
|
||||
usbd_control_set_complete_callback(tud_vendor_control_xfer_cb);
|
||||
return tud_vendor_control_xfer_cb(rhport, CONTROL_STAGE_SETUP, p_request);
|
||||
}
|
||||
|
||||
#if CFG_TUSB_DEBUG >= 2
|
||||
@@ -913,7 +898,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
|
||||
}
|
||||
|
||||
// invoke callback
|
||||
if (MAKE_WEAK_FUNC(tud_mount_cb)) MAKE_WEAK_FUNC(tud_mount_cb)();
|
||||
if (tud_mount_cb) tud_mount_cb();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -970,9 +955,9 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
TU_LOG2(" BOS\r\n");
|
||||
|
||||
// requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
|
||||
if (!MAKE_WEAK_FUNC(tud_descriptor_bos_cb)) return false;
|
||||
if (!tud_descriptor_bos_cb) return false;
|
||||
|
||||
tusb_desc_bos_t const* desc_bos = (tusb_desc_bos_t const*)MAKE_WEAK_FUNC(tud_descriptor_bos_cb)();
|
||||
tusb_desc_bos_t const* desc_bos = (tusb_desc_bos_t const*)tud_descriptor_bos_cb();
|
||||
|
||||
uint16_t total_len;
|
||||
// Use offsetof to avoid pointer to the odd/misaligned address
|
||||
@@ -1016,9 +1001,9 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
// Host sends this request to ask why our device with USB BCD from 2.0
|
||||
// but is running at Full/Low Speed. If not highspeed capable stall this request,
|
||||
// otherwise return the descriptor that could work in highspeed mode
|
||||
if (MAKE_WEAK_FUNC(tud_descriptor_device_qualifier_cb))
|
||||
if (tud_descriptor_device_qualifier_cb)
|
||||
{
|
||||
uint8_t const* desc_qualifier = MAKE_WEAK_FUNC(tud_descriptor_device_qualifier_cb)();
|
||||
uint8_t const* desc_qualifier = tud_descriptor_device_qualifier_cb();
|
||||
TU_ASSERT(desc_qualifier);
|
||||
|
||||
// first byte of descriptor is its size
|
||||
@@ -1306,7 +1291,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
// and usbd task can preempt and clear the busy
|
||||
_usbd_dev.ep_status[epnum][dir].busy = true;
|
||||
|
||||
if (MAKE_WEAK_FUNC(dcd_edpt_xfer_fifo)(rhport, ep_addr, ff, total_bytes))
|
||||
if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes))
|
||||
{
|
||||
TU_LOG2("OK\r\n");
|
||||
return true;
|
||||
@@ -1369,10 +1354,10 @@ bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
|
||||
*/
|
||||
void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
TU_ASSERT(MAKE_WEAK_FUNC(dcd_edpt_close), /**/);
|
||||
TU_ASSERT(dcd_edpt_close, /**/);
|
||||
TU_LOG2(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
|
||||
|
||||
MAKE_WEAK_FUNC(dcd_edpt_close(rhport, ep_addr));
|
||||
dcd_edpt_close(rhport, ep_addr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,6 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index);
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid);
|
||||
|
||||
#if !defined(TU_HAS_NO_ATTR_WEAK)
|
||||
// Invoked when received GET BOS DESCRIPTOR request
|
||||
// Application return pointer to descriptor
|
||||
TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void);
|
||||
@@ -136,71 +135,6 @@ TU_ATTR_WEAK void tud_resume_cb(void);
|
||||
// Invoked when received control request with VENDOR TYPE
|
||||
TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
|
||||
#else
|
||||
#if ADD_WEAK_FUNC_TUD_DESCRIPTOR_BOS_CB
|
||||
#define TUD_DESCRIPTOR_BOS_CB tud_descriptor_bos_cb
|
||||
#endif
|
||||
#ifndef TUD_DESCRIPTOR_BOS_CB
|
||||
#define TUD_DESCRIPTOR_BOS_CB NULL
|
||||
#else
|
||||
extern uint8_t const* TUD_DESCRIPTOR_BOS_CB(void);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB
|
||||
#define TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB tud_descriptor_device_qualifier_cb
|
||||
#endif
|
||||
#ifndef TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB
|
||||
#define TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB NULL
|
||||
#else
|
||||
extern uint8_t const* TUD_DESCRIPTOR_DEVICE_QUALIFIER_CB(void);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_MOUNT_CB
|
||||
#define TUD_MOUNT_CB tud_mount_cb
|
||||
#endif
|
||||
#ifndef TUD_MOUNT_CB
|
||||
#define TUD_MOUNT_CB NULL
|
||||
#else
|
||||
extern void TUD_MOUNT_CB(void);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_UMOUNT_CB
|
||||
#define TUD_UMOUNT_CB tud_umount_cb
|
||||
#endif
|
||||
#ifndef TUD_UMOUNT_CB
|
||||
#define TUD_UMOUNT_CB NULL
|
||||
#else
|
||||
extern void TUD_UMOUNT_CB(void);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_SUSPEND_CB
|
||||
#define TUD_SUSPEND_CB tud_suspend_cb
|
||||
#endif
|
||||
#ifndef TUD_SUSPEND_CB
|
||||
#define TUD_SUSPEND_CB NULL
|
||||
#else
|
||||
extern void TUD_SUSPEND_CB(bool remote_wakeup_en);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_RESUME_CB
|
||||
#define TUD_RESUME_CB tud_resume_cb
|
||||
#endif
|
||||
#ifndef TUD_RESUME_CB
|
||||
#define TUD_RESUME_CB NULL
|
||||
#else
|
||||
extern void TUD_RESUME_CB(void);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_VENDOR_CONTROL_XFER_CB
|
||||
#define TUD_VENDOR_CONTROL_XFER_CB tud_vendor_control_xfer_cb
|
||||
#endif
|
||||
#ifndef TUD_VENDOR_CONTROL_XFER_CB
|
||||
#define TUD_VENDOR_CONTROL_XFER_CB NULL
|
||||
#else
|
||||
extern bool TUD_VENDOR_CONTROL_XFER_CB(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Binary Device Object Store (BOS) Descriptor Templates
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
extern void usbd_driver_print_control_complete_name(usbd_control_xfer_cb_t callback);
|
||||
#endif
|
||||
|
||||
#if defined(TU_HAS_NO_ATTR_WEAK)
|
||||
static void (*const MAKE_WEAK_FUNC(dcd_edpt0_status_complete))(uint8_t, tusb_control_request_t const *) = DCD_EDPT0_STATUS_COMPLETE;
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
EDPT_CTRL_OUT = 0x00,
|
||||
@@ -184,7 +180,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
|
||||
TU_ASSERT(0 == xferred_bytes);
|
||||
|
||||
// invoke optional dcd hook if available
|
||||
if (MAKE_WEAK_FUNC(dcd_edpt0_status_complete)) MAKE_WEAK_FUNC(dcd_edpt0_status_complete)(rhport, &_ctrl_xfer.request);
|
||||
if (dcd_edpt0_status_complete) dcd_edpt0_status_complete(rhport, &_ctrl_xfer.request);
|
||||
|
||||
if (_ctrl_xfer.complete_cb)
|
||||
{
|
||||
|
||||
@@ -51,22 +51,10 @@ typedef struct
|
||||
void (* sof ) (uint8_t rhport); /* optional */
|
||||
} usbd_class_driver_t;
|
||||
|
||||
#if !defined(TU_HAS_NO_ATTR_WEAK)
|
||||
// Invoked when initializing device stack to get additional class drivers.
|
||||
// Can optionally implemented by application to extend/overwrite class driver support.
|
||||
// Note: The drivers array must be accessible at all time when stack is active
|
||||
usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) TU_ATTR_WEAK;
|
||||
#else
|
||||
#if ADD_WEAK_FUNC_USBD_APP_DRIVER_GET_CB
|
||||
#define USBD_APP_DRIVER_GET_CB usbd_app_driver_get_cb
|
||||
#endif
|
||||
#ifndef USBD_APP_DRIVER_GET_CB
|
||||
#define USBD_APP_DRIVER_GET_CB NULL
|
||||
#else
|
||||
extern usbd_class_driver_t const* USBD_APP_DRIVER_GET_CB(uint8_t* driver_count);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
typedef bool (*usbd_control_xfer_cb_t)(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user