mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
add implementation for
- tusbh_cdc_rndis_is_mounted - tusbh_cdc_rndis_get_mac_addr
This commit is contained in:
parent
ce865721a5
commit
a522263a9d
@ -91,6 +91,11 @@ bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr)
|
||||
(cdch_data[dev_addr-1].interface_protocol <= CDC_COMM_PROTOCOL_ATCOMMAND_CDMA);
|
||||
}
|
||||
|
||||
bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr)
|
||||
{
|
||||
return tusbh_cdc_is_mounted(dev_addr) && cdch_data[dev_addr-1].is_rndis;
|
||||
}
|
||||
|
||||
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify)
|
||||
{
|
||||
ASSERT( tusbh_cdc_is_mounted(dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
|
||||
|
@ -64,7 +64,7 @@ typedef enum {
|
||||
// APPLICATION PUBLIC API
|
||||
//--------------------------------------------------------------------+
|
||||
bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
|
||||
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
|
||||
|
||||
@ -73,13 +73,21 @@ void tusbh_cdc_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) ATTR_WEAK;
|
||||
|
||||
//------------- RNDIS Application Callback (overshadow CDC callbacks) -------------//
|
||||
#if TUSB_CFG_HOST_CDC_RNDIS
|
||||
|
||||
#if TUSB_CFG_HOST_CDC_RNDIS
|
||||
//--------------------------------------------------------------------+
|
||||
// RNDIS APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t tusbh_cdc_rndis_get_mac_addr(uint8_t dev_addr, uint8_t mac_address[6]);
|
||||
|
||||
//------------- RNDIS Application Callback (overshadow CDC callbacks) -------------//
|
||||
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) ATTR_WEAK;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -59,16 +59,29 @@ static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX] TUSB_CFG_ATTR_USBRAM ATTR_ALI
|
||||
|
||||
STATIC_ rndish_data_t rndish_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
// TODO Microsoft requires message length for any get command must be at least 0x400 bytes
|
||||
// TODO Microsoft requires message length for any get command must be at least 4096 bytes
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
static tusb_error_t rndis_body_subtask(void);
|
||||
static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_data_t *p_cdc,
|
||||
uint8_t const * p_mess, uint32_t mess_length,
|
||||
uint8_t * p_mess, uint32_t mess_length,
|
||||
uint8_t *p_response );
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t tusbh_cdc_rndis_get_mac_addr(uint8_t dev_addr, uint8_t mac_address[6])
|
||||
{
|
||||
ASSERT( tusbh_cdc_rndis_is_mounted(dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
|
||||
ASSERT_PTR( mac_address, TUSB_ERROR_INVALID_PARA);
|
||||
|
||||
memcpy(mac_address, rndish_data[dev_addr-1].mac_address, 6);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
@ -219,7 +232,7 @@ void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, tusb_event_t ev
|
||||
//}
|
||||
|
||||
static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_data_t *p_cdc,
|
||||
uint8_t const * p_mess, uint32_t mess_length,
|
||||
uint8_t * p_mess, uint32_t mess_length,
|
||||
uint8_t *p_response)
|
||||
{
|
||||
tusb_error_t error;
|
||||
|
@ -112,7 +112,7 @@ OSAL_TASK_FUNCTION (usbh_enumeration_task) (void* p_task_para);
|
||||
tusb_error_t usbh_init(void);
|
||||
|
||||
tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, uint8_t bRequest,
|
||||
uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data );
|
||||
uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user