29#if (CFG_TUH_ENABLED && CFG_TUH_CDC && CFG_TUH_CDC_RNDIS)
40#define OSAL_SUBTASK_BEGIN
41#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
43#define STASK_RETURN(_error) return _error;
44#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
45#define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
51#define RNDIS_MSG_PAYLOAD_MAX (1024*4)
54CFG_TUH_MEM_SECTION CFG_TUH_MEM_ALIGN
static uint8_t
msg_payload[RNDIS_MSG_PAYLOAD_MAX];
65 uint8_t * p_mess, uint32_t mess_length,
66 uint8_t *p_response );
73 TU_ASSERT( tusbh_cdc_rndis_is_mounted(
dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
74 TU_VERIFY( mac_address, TUSB_ERROR_INVALID_PARA);
78 return TUSB_ERROR_NONE;
97 static uint8_t relative_addr;
101 for (relative_addr = 0; relative_addr < CFG_TUH_DEVICE_MAX; relative_addr++)
116 tu_memclr(
rndish_data,
sizeof(rndish_data_t)*CFG_TUH_DEVICE_MAX);
121 for(uint8_t i=0; i<CFG_TUH_DEVICE_MAX; i++)
136 .
type = RNDIS_MSG_INITIALIZE,
141 .max_xfer_size = 0x4000
146 .
type = RNDIS_MSG_QUERY,
156 .
type = RNDIS_MSG_SET,
178 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
196 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
213 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
218 tusbh_cdc_rndis_mounted_cb(
dev_addr);
225 if ( pipehandle_is_equal(pipe_hdl, p_cdc->pipe_notification) )
235 uint8_t * p_mess, uint32_t mess_length,
246 mess_length, p_mess),
249 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
254 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
261 RNDIS_MSG_PAYLOAD_MAX, p_response),
264 if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
OSAL_TASK_FUNCTION() cdch_rndis_task(void *param;)
static rndis_msg_set_t const msg_set_packet_filter
static rndis_msg_initialize_t const msg_init
static tusb_error_t send_message_get_response_subtask(uint8_t dev_addr, cdch_data_t *p_cdc, uint8_t *p_mess, uint32_t mess_length, uint8_t *p_response)
CFG_TUH_MEM_SECTION static CFG_TUH_MEM_ALIGN uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX]
static rndish_data_t rndish_data[CFG_TUH_DEVICE_MAX]
static CFG_TUH_MEM_SECTION uint8_t msg_notification[CFG_TUH_DEVICE_MAX][8]
static tusb_error_t rndis_body_subtask(void)
tusb_error_t tusbh_cdc_rndis_get_mac_addr(uint8_t dev_addr, uint8_t mac_address[6])
static rndis_msg_query_t const msg_query_permanent_addr
struct rndis_msg_query_t rndis_msg_set_t
@ RNDIS_OID_GEN_CURRENT_PACKET_FILTER
Current packet filter (encoded)
@ RNDIS_OID_802_3_PERMANENT_ADDRESS
Permanent station address.
@ RNDIS_PACKET_TYPE_DIRECTED
Directed packets. Directed packets contain a destination address equal to the station address of the ...
@ RNDIS_PACKET_TYPE_BROADCAST
Broadcast packets.
@ RNDIS_PACKET_TYPE_MULTICAST
Multicast address packets sent to addresses in the multicast address list.
@ RNDIS_STATUS_SUCCESS
Success.
void rndish_close(uint8_t dev_addr)
tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes)
@ CDC_REQUEST_SEND_ENCAPSULATED_COMMAND
is used to issue a command in the format of the supported control protocol of the Communications Clas...
@ CDC_REQUEST_GET_ENCAPSULATED_RESPONSE
is used to request a response in the format of the supported control protocol of the Communications C...
static TU_ATTR_ALWAYS_INLINE bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec)
static TU_ATTR_ALWAYS_INLINE bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
static TU_ATTR_ALWAYS_INLINE void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
static TU_ATTR_ALWAYS_INLINE osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t *semdef)
TU_ATTR_WEAK void osal_task_delay(uint32_t msec)
static void * memcpy(void *dst, const void *src, size_t n)
Initialize Complete Message.
uint32_t type
Message Type, must be RNDIS_MSG_INITIALIZE_CMPLT.
uint32_t status
The initialization status of the device, has value from rndis_msg_status_t.
uint32_t max_xfer_size
The maximum size, in bytes, of any single bus data transfer that the device expects to receive from t...
uint32_t max_packet_per_xfer
The maximum number of concatenated RNDIS_MSG_PACKET messages that the device can handle in a single b...
uint32_t type
Message type, must be RNDIS_MSG_INITIALIZE.
uint32_t buffer_offset
The offset, in bytes, from the beginning of request_id field where the response data for the query is...
uint32_t status
The status of processing for the query request, has value from rndis_msg_status_t.
uint32_t type
Message Type, must be RNDIS_MSG_QUERY_CMPLT.
uint32_t type
Message Type, must be RNDIS_MSG_QUERY.
uint32_t status
The status of processing for the request message request by the device to which this message is the r...
uint32_t type
Message Type.
@ TUSB_REQ_RCPT_INTERFACE
static TU_ATTR_ALWAYS_INLINE bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)