diff options
| author | hathach <[email protected]> | 2013-07-05 11:46:12 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-07-05 11:46:12 +0700 |
| commit | c08c655fd120033f33fc40464018c743c646a512 (patch) | |
| tree | fbc0a3cbd48c45c09a1bb1b00b8ee4ed99935abd /tinyusb/class | |
| parent | 9d50b0fa6a6a42d79bc35ccccf212af805a93ae6 (diff) | |
implementing initializing for RNDIS
Diffstat (limited to 'tinyusb/class')
| -rw-r--r-- | tinyusb/class/cdc_host.c | 20 | ||||
| -rw-r--r-- | tinyusb/class/cdc_rndis_host.c | 43 | ||||
| -rw-r--r-- | tinyusb/class/cdc_rndis_host.h | 1 |
3 files changed, 63 insertions, 1 deletions
diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c index ac4338853..e0f4501ec 100644 --- a/tinyusb/class/cdc_host.c +++ b/tinyusb/class/cdc_host.c @@ -47,6 +47,7 @@ //--------------------------------------------------------------------+ #include "common/common.h" #include "cdc_host.h" +#include "cdc_rndis_host.h" //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF @@ -128,6 +129,9 @@ void cdch_init(void) tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) { + tusb_error_t error; + + OSAL_SUBTASK_BEGIN if ( CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL != p_interface_desc->bInterfaceSubClass) { @@ -194,13 +198,23 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con } } +#if TUSB_CFG_HOST_CDC_RNDIS // TODO move to rndis_host.c + //------------- RNDIS -------------// + if ( 0xff == p_cdc->interface_protocol ) + { + OSAL_SUBTASK_INVOKED_AND_WAIT( rndish_open_subtask(dev_addr, p_cdc), error ); + } + + if ( TUSB_ERROR_NONE != error ) // device is not an rndis +#endif + // FIXME mounted class flag is not set yet if (tusbh_cdc_mounted_cb) { tusbh_cdc_mounted_cb(dev_addr); } - return TUSB_ERROR_NONE; + OSAL_SUBTASK_END } void cdch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) @@ -232,6 +246,10 @@ void cdch_close(uint8_t dev_addr) err3 = hcd_pipe_close(p_cdc->pipe_out); } +#if TUSB_CFG_HOST_CDC_RNDIS + +#endif + memclr_(p_cdc, sizeof(cdch_data_t)); if (tusbh_cdc_unmounted_isr) diff --git a/tinyusb/class/cdc_rndis_host.c b/tinyusb/class/cdc_rndis_host.c index 3ba2db7a3..ebb3285bb 100644 --- a/tinyusb/class/cdc_rndis_host.c +++ b/tinyusb/class/cdc_rndis_host.c @@ -52,6 +52,7 @@ //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ +static uint8_t msg_notification[TUSB_CFG_HOST_DEVICE_MAX][8] TUSB_CFG_ATTR_USBRAM; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION @@ -90,4 +91,46 @@ static tusb_error_t rndis_body_subtask(void) OSAL_SUBTASK_END } + + +tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc) +{ + tusb_error_t error; + + static rndis_msg_initialize_t msg_init = + { + .type = RNDIS_MSG_INITIALIZE, + .length = sizeof(rndis_msg_initialize_t), + .request_id = 1, // TODO should use some magic number + .major_version = 1, + .minor_version = 0, + .max_xfer_size = 0x4000 // TODO mimic windows + }; + + static tusb_control_request_t control_request = + { + .bmRequestType = { + .direction = TUSB_DIR_HOST_TO_DEV, + .type = TUSB_REQUEST_TYPE_CLASS, + .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE + }, + .bRequest = SEND_ENCAPSULATED_COMMAND, + .wLength = sizeof(rndis_msg_initialize_t) +// .wIndex = p_cdc->interface_number, + }; + + OSAL_SUBTASK_BEGIN + + control_request.wIndex = p_cdc->interface_number; + + OSAL_SUBTASK_INVOKED_AND_WAIT ( usbh_control_xfer_subtask(dev_addr, &control_request, (uint8_t*)&msg_init), error ) ; + + if ( tusbh_cdc_rndis_mounted_cb ) + { + tusbh_cdc_rndis_mounted_cb(dev_addr); + } + + OSAL_SUBTASK_END +} + #endif diff --git a/tinyusb/class/cdc_rndis_host.h b/tinyusb/class/cdc_rndis_host.h index a61866479..ce8e4bced 100644 --- a/tinyusb/class/cdc_rndis_host.h +++ b/tinyusb/class/cdc_rndis_host.h @@ -54,6 +54,7 @@ extern "C" { #endif +tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc) ATTR_WARN_UNUSED_RESULT; #ifdef __cplusplus } |
