本文整理汇总了C++中USB_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ USB_lock函数的具体用法?C++ USB_lock怎么用?C++ USB_lock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USB_lock函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG_LOG_TRACE
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : _usb_host_ch9_set_configuration
* Returned Value : USB_OK, or error status
* Comments :
* Function to process standard device request in Chapter 9.
* See Table 9-3 p. 250 of USB 2.0 specification.
*
*END*--------------------------------------------------------------------*/
USB_STATUS _usb_host_ch9_set_configuration
(
/* usb device */
_usb_device_instance_handle dev_handle,
/* configuration value */
uint_16 config
)
{ /* Body */
USB_SETUP request = req_prototype;
USB_STATUS error = USB_OK;
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("_usb_host_ch9_set_configuration");
#endif
USB_lock();
request.BMREQUESTTYPE = REQ_TYPE_DEVICE | REQ_TYPE_OUT;
request.BREQUEST = REQ_SET_CONFIGURATION;
*(uint_16*)request.WVALUE = HOST_TO_LE_SHORT(config);
error = usb_host_ch9_dev_req(dev_handle, &request, NULL);
USB_unlock();
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("_usb_host_ch9_set_configuration SUCCESSFUL");
#endif
return USB_log_error(__FILE__,__LINE__,error);
} /* EndBody */
示例2: USB_lock
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : _usb_device_call_service
* Returned Value : USB_OK or error code
* Comments :
* Calls the appropriate service for the specified type, if one is
* registered. Used internally only.
*
*END*--------------------------------------------------------------------*/
USB_STATUS _usb_device_call_service
(
/* [IN] Type of service or endpoint */
uint_8 type,
/* [IN] pointer to event structure */
PTR_USB_EVENT_STRUCT event
)
{ /* Body */
USB_DEV_STATE_STRUCT_PTR usb_dev_ptr;
SERVICE_STRUCT _PTR_ service_ptr;
usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)event->handle;
/* Needs mutual exclusion */
USB_lock();
/* Search for an existing entry for type */
for (service_ptr = usb_dev_ptr->SERVICE_HEAD_PTR;
service_ptr;
service_ptr = service_ptr->NEXT)
{
if (service_ptr->TYPE == type)
{
service_ptr->SERVICE(event,service_ptr->arg);
USB_unlock();
return USB_OK;
} /* Endif */
} /* Endfor */
USB_unlock();
return USBERR_CLOSED_SERVICE;
} /* EndBody */
示例3: ARC_DEBUG_TRACE
void _usb_device_free_XD
(
/* [IN] the dTD to enqueue */
pointer xd_ptr
)
{ /* Body */
int lockKey;
USB_DEV_STATE_STRUCT_PTR usb_dev_ptr;
usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)(((XD_STRUCT_PTR)xd_ptr)->SCRATCH_PTR->PRIVATE);
ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_TRACE, "free_XD: xd_ptr=0x%x\n", (unsigned)xd_ptr);
ARC_DEBUG_CODE(ARC_DEBUG_FLAG_STATS, (usb_dev_ptr->STATS.free_XD_count++));
/*
** This function can be called from any context, and it needs mutual
** exclusion with itself.
*/
lockKey = USB_lock();
/*
** Add the XD to the free XD queue (linked via PRIVATE) and
** increment the tail to the next descriptor
*/
USB_XD_QADD(usb_dev_ptr->XD_HEAD, usb_dev_ptr->XD_TAIL, (XD_STRUCT_PTR)xd_ptr);
usb_dev_ptr->XD_ENTRIES++;
USB_unlock(lockKey);
} /* Endbody */
示例4: USB_lock
USB_STATUS usb_class_hub_get_descriptor
(
/* [IN] The communication device common command structure */
HUB_COMMAND_PTR com_ptr,
/* [IN] descriptor buffer */
uchar_ptr buffer,
/* [IN] buffer length (or, better said, how many bytes to read) */
uchar len
)
{ /* Body */
USB_STATUS error = USB_OK;
USB_lock();
error = usb_class_hub_cntrl_common(
com_ptr,
REQ_TYPE_DEVICE | REQ_TYPE_IN | REQ_TYPE_CLASS,
REQ_GET_DESCRIPTOR,
0,
0,
len,
buffer
);
USB_unlock();
return error;
} /* EndBody */
示例5: DEBUG_LOG_TRACE
static USB_STATUS usb_class_hid_cntrl_common
(
/* [IN] The communication device common command structure */
HID_COMMAND_PTR com_ptr,
/* [IN] Bitmask of the request type */
uint_8 bmrequesttype,
/* [IN] Request code */
uint_8 brequest,
/* [IN] Value to copy into WVALUE field of the REQUEST */
uint_16 wvalue,
/* [IN] Length of the data associated with REQUEST */
uint_16 wlength,
/* [IN] Pointer to data buffer used to send/recv */
uchar_ptr data
)
{ /* Body */
USB_HID_CLASS_INTF_STRUCT_PTR if_ptr;
USB_SETUP req;
USB_STATUS status = USBERR_NO_INTERFACE;
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_hid_cntrl_common");
#endif
USB_lock();
/* Validity checking */
if (usb_host_class_intf_validate(com_ptr->CLASS_PTR)) {
if_ptr =
(USB_HID_CLASS_INTF_STRUCT_PTR)com_ptr->CLASS_PTR->class_intf_handle;
status = usb_hostdev_validate(if_ptr->G.dev_handle);
} /* Endif */
if (!status && if_ptr->IN_SETUP) {
status = USBERR_TRANSFER_IN_PROGRESS;
} /* Endif */
if (!status) {
/* Save the higher level callback and ID */
if_ptr->USER_CALLBACK = com_ptr->CALLBACK_FN;
if_ptr->USER_PARAM = com_ptr->CALLBACK_PARAM;
/* Setup the request */
req.BMREQUESTTYPE = bmrequesttype;
req.BREQUEST = brequest;
*(uint_16*)req.WVALUE = HOST_TO_LE_SHORT(wvalue);
*(uint_16*)req.WINDEX = HOST_TO_LE_SHORT(((INTERFACE_DESCRIPTOR_PTR)if_ptr->G.intf_handle)->bInterfaceNumber);
*(uint_16*)req.WLENGTH = HOST_TO_LE_SHORT(wlength);
status = _usb_hostdev_cntrl_request(if_ptr->G.dev_handle, &req, data,
usb_class_hid_cntrl_callback, if_ptr);
if (status == USB_STATUS_TRANSFER_QUEUED) {
if_ptr->IN_SETUP = TRUE;
} /* Endif */
} /* Endif */
USB_unlock();
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_hid_cntrl_common, SUCCESSFUL");
#endif
return status;
} /* Endbody */
示例6: USB_lock
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _usb_host_close_all_pipes
* Returned Value : None
* Comments :
* _usb_host_close_all_pipes routine removes the pipe from the open pipe list
*
*END*-----------------------------------------------------------------*/
void _usb_host_close_all_pipes
(
/* [IN] the USB Host state structure */
_usb_host_handle handle
)
{ /* Body */
int_16 i;
USB_HOST_STATE_STRUCT_PTR usb_host_ptr;
usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle;
USB_lock();
for (i=0; i < USBCFG_MAX_PIPES; i++) {
if (!(usb_host_ptr->PIPE_DESCRIPTOR_BASE_PTR[i].OPEN)) {
break;
} else {
/* Call the low-level routine to free the controller specific
** resources for this pipe
*/
_usb_host_close_pipe_call_interface (handle,
&usb_host_ptr->PIPE_DESCRIPTOR_BASE_PTR[i]);
/* de-initialise the pipe descriptor */
memset(&usb_host_ptr->PIPE_DESCRIPTOR_BASE_PTR[i],0,
sizeof(PIPE_DESCRIPTOR_STRUCT));
} /* Endif */
} /* Endfor */
USB_unlock();
} /* Endbody */
示例7: USB_lock
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _usb_device_cancel_transfer
* Returned Value : USB_OK or error code
* Comments :
* returns the status of the transaction on the specified endpoint.
*
*END*-----------------------------------------------------------------*/
uint_8 _usb_device_cancel_transfer
(
/* [IN] the USB_USB_dev_initialize state structure */
_usb_device_handle handle,
/* [IN] the Endpoint number */
uint_8 ep_num,
/* [IN] direction */
uint_8 direction
)
{ /* Body */
uint_8 error = USB_OK;
int lockKey;
lockKey = USB_lock();
/* Cancel transfer on the specified endpoint for the specified
** direction
*/
error = _usb_dci_vusb20_cancel_transfer(handle, ep_num, direction);
USB_unlock(lockKey);
return error;
} /* EndBody */
示例8: USB_lock
USB_STATUS usb_class_cdc_install_driver
(
CLASS_CALL_STRUCT_PTR data_instance,
char_ptr device_name
)
{
USB_DATA_CLASS_INTF_STRUCT_PTR if_ptr;
USB_STATUS status = USB_OK;
USB_lock();
/* Validity checking, always needed when passing data to lower API */
if (usb_host_class_intf_validate(data_instance)) {
if_ptr = (USB_DATA_CLASS_INTF_STRUCT_PTR) data_instance->class_intf_handle;
f_usb->DEV_PTR->DRIVER_INIT_PTR = data_instance;
f_usb->DEV_PTR->IDENTIFIER = device_name;
f_usb->DEV_PTR->IO_OPEN = _io_cdc_serial_open;
f_usb->DEV_PTR->IO_CLOSE = _io_cdc_serial_close;
f_usb->DEV_PTR->IO_READ = _io_cdc_serial_read;
f_usb->DEV_PTR->IO_WRITE = _io_cdc_serial_write;
f_usb->DEV_PTR->IO_IOCTL = _io_cdc_serial_ioctl;
f_usb->DEV_PTR->IO_UNINSTALL = _io_cdc_serial_uninstall;
f_usb->DEV_PTR->DRIVER_TYPE = 0;
if (status == IO_OK)
if_ptr->device_name = device_name;
}
USB_unlock();
return status;
}
示例9: DEBUG_LOG_TRACE
boolean usb_class_mass_storage_device_command_cancel
(
/* Handle to class struct with the key */
CLASS_CALL_STRUCT_PTR ccs_ptr,
/*Command */
COMMAND_OBJECT_PTR cmd_ptr
)
{ /* Body */
USB_MASS_CLASS_INTF_STRUCT_PTR intf_ptr;
USB_STATUS error = USBERR_NO_INTERFACE;
boolean result = FALSE;
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_mass_storage_device_command_cancel");
#endif
/* Pointer validity-checking, clear memory, init header */
USB_lock();
if (usb_host_class_intf_validate(ccs_ptr)) {
intf_ptr = (USB_MASS_CLASS_INTF_STRUCT_PTR) ccs_ptr->class_intf_handle;
error = usb_hostdev_validate (intf_ptr->G.dev_handle);
} /* Endif */
if ((error == USB_OK) || (error == USB_STATUS_TRANSFER_QUEUED)) {
result = usb_class_mass_cancelq(intf_ptr, cmd_ptr);
}
USB_unlock();
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_mass_storage_device_command_cancel, SUCCESSFUL");
#endif
return result;
} /* Endbody */
示例10: DEBUG_LOG_TRACE
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _usb_device_unstall_endpoint
* Returned Value : USB_OK or error code
* Comments :
* Unstalls the endpoint in specified direction
*
*END*-----------------------------------------------------------------*/
void _usb_device_unstall_endpoint
(
/* [IN] the USB_USB_dev_initialize state structure */
_usb_device_handle handle,
/* [IN] the Endpoint number */
uint_8 ep_num,
/* [IN] direction */
uint_8 direction
)
{ /* Body */
/* uint_8 error = 0; */
USB_DEV_STATE_STRUCT_PTR usb_dev_ptr;
usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
#ifdef _DEVICE_DEBUG_
DEBUG_LOG_TRACE("_usb_device_unstall_endpoint");
#endif
USB_lock();
_usb_dci_vusb20_unstall_endpoint(handle, ep_num, direction);
USB_unlock();
#ifdef _DEVICE_DEBUG_
DEBUG_LOG_TRACE("_usb_device_unstall_endpoint, SUCCESSFULL");
#endif
} /* EndBody */
示例11: DEBUG_LOG_TRACE
void usb_class_mass_deleteq
(
/* [IN] interface structure pointer */
USB_MASS_CLASS_INTF_STRUCT_PTR intf_ptr
)
{ /* Body */
MASS_QUEUE_STRUCT_PTR Q = &intf_ptr->QUEUE;
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_mass_deleteq");
#endif
/* Remove current command and increment FIRST modulo the Q size */
USB_lock();
if (Q->COUNT) {
Q->ELEMENTS[Q->FIRST] = NULL;
Q->FIRST = MASSQ_NEXT(Q->FIRST);
// Q->AVAILABLE = TRUE;
Q->COUNT--;
}
USB_unlock();
//if (Q->COUNT >1) {
// printf("\nMASS q size now %d", Q->COUNT );
//}
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_mass_deleteq, SUCCESSFUL");
#endif
} /* Endbody */
示例12: USB_lock
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : _usb_hostdev_cntrl_request
* Returned Value : USB_OK, or error status
* Comments :
* Function to process class- or vendor-specific control pipe device
* requests.
*
*END*--------------------------------------------------------------------*/
USB_STATUS _usb_hostdev_cntrl_request
(
/* usb device */
_usb_device_instance_handle dev_handle,
/* Device Request to send */
USB_SETUP_PTR devreq,
/* buffer to send/receive */
uchar_ptr buff_ptr,
/* callback upon completion */
tr_callback callback,
/* [IN] the parameter to pass back to the callback function */
pointer callback_param
)
{ /* Body */
DEV_INSTANCE_PTR dev_ptr;
_usb_pipe_handle pipe_handle;
TR_INIT_PARAM_STRUCT tr;
USB_STATUS error = USB_OK;
/* Verify that device handle is valid */
USB_lock();
error = usb_hostdev_validate(dev_handle);
if (error != USB_OK) {
USB_unlock();
return USBERR_DEVICE_NOT_FOUND;
} /* Endif */
dev_ptr = (DEV_INSTANCE_PTR)dev_handle;
if (dev_ptr->state < DEVSTATE_ENUM_OK) {
USB_unlock();
return USBERR_DEVICE_NOT_FOUND;
} /* Endif */
pipe_handle = dev_ptr->control_pipe;
usb_hostdev_tr_init(&tr, callback, callback_param);
/* Set TR buffer length as required */
if ((REQ_TYPE_IN & devreq->BMREQUESTTYPE) != 0) {
tr.RX_BUFFER = buff_ptr;
tr.RX_LENGTH = utoh16(devreq->WLENGTH);
} else {
tr.TX_BUFFER = buff_ptr;
tr.TX_LENGTH = utoh16(devreq->WLENGTH);
} /* EndIf */
tr.DEV_REQ_PTR = (uchar_ptr)devreq;
error = _usb_host_send_setup(dev_ptr->host, pipe_handle, &tr);
USB_unlock();
return error;
} /* EndBody */
示例13: DEBUG_LOG_TRACE
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_class_audio_stream_init
* Returned Value : None
* Comments :
* This function is called by common class to initialize the class driver
* for audio stream interface. It is called in response to a select
* interface call by application.
*
*END*--------------------------------------------------------------------*/
void usb_class_audio_stream_init
(
/* [IN] structure with USB pipe information on the interface */
PIPE_BUNDLE_STRUCT_PTR pbs_ptr,
/* [IN] stream call struct pointer */
CLASS_CALL_STRUCT_PTR ccs_ptr
)
{ /* Body */
AUDIO_STREAM_INTERFACE_STRUCT_PTR if_ptr = ccs_ptr->class_intf_handle;
USB_STATUS status;
#ifdef _HOST_DEBUG_
DEBUG_LOG_TRACE("usb_class_audio_stream_init");
#endif
/* Make sure the device is still attached */
USB_lock();
status = usb_host_class_intf_init(pbs_ptr, if_ptr, &audio_stream_anchor);
if (status == USB_OK) {
/* Check the audio stream interface alternating 1 */
if (0 != (((INTERFACE_DESCRIPTOR_PTR)if_ptr->AUDIO_G.G.intf_handle)->bNumEndpoints)) {
/*
** We generate a code_key based on the attached device. This is used to
** verify that the device has not been detached and replaced with another.
*/
ccs_ptr->code_key = 0;
ccs_ptr->code_key = usb_host_class_intf_validate(ccs_ptr);
if_ptr->AUDIO_G.IFNUM = ((INTERFACE_DESCRIPTOR_PTR)if_ptr->AUDIO_G.G.intf_handle)->bInterfaceNumber;
if_ptr->iso_in_pipe = usb_hostdev_get_pipe_handle(pbs_ptr, USB_ISOCHRONOUS_PIPE, USB_RECV);
if_ptr->iso_out_pipe = usb_hostdev_get_pipe_handle(pbs_ptr, USB_ISOCHRONOUS_PIPE, USB_SEND);
if ((if_ptr->iso_in_pipe == NULL) && (if_ptr->iso_out_pipe == NULL))
status = USBERR_OPEN_PIPE_FAILED;
} else {
status = USBERR_INIT_FAILED;
}
} /* Endif */
/* Signal that an error has occured by setting the "code_key" */
if (status) {
ccs_ptr->code_key = 0;
} /* Endif */
USB_unlock();
#ifdef _HOST_DEBUG_
if (status)
DEBUG_LOG_TRACE("usb_class_audio_stream_init, SUCCESSFUL");
else
DEBUG_LOG_TRACE("usb_class_audio_stream_init, FAILED");
#endif
} /* Endbody */
示例14: USB_lock
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_dev_list_get_memory
* Returned Value : USB_OK if memory allocated, else error code
* Comments :
* Memory is added at the end of a linked list, whose
* anchor is device.memlist-->
*
*END*--------------------------------------------------------------------*/
USB_STATUS usb_dev_list_get_memory
(
/* [IN] Pointer to the USB device */
DEV_INSTANCE_PTR dev_ptr,
/* [IN] Size of memory payload required */
uint_32 mem_size,
/* [IN] Type of memory payload required */
memory_type mem_type,
/* [OUT] Pointer to memory block's header */
pointer2 _PTR_ header_ptr
)
{ /* Body */
DEV_MEMORY_PTR mem_ptr, list_ptr;
USB_STATUS error;
USB_lock();
error = usb_hostdev_validate((pointer2)dev_ptr);
USB_unlock();
if (error != USB_OK) {
return error;
}
if ((mem_type <= USB_MEMTYPE_MIN_VALUE) ||
(mem_type >= USB_MEMTYPE_MAX_VALUE))
{
return USBERR_INVALID_MEM_TYPE;
} /* Endif */
/* get memory for header + payload, rounded up to 4-byte */
mem_ptr = (DEV_MEMORY_PTR) malloc((mem_size+MEM_HEADER_LEN+3)&0xFFFC);
if (mem_ptr == NULL) {
return USBERR_GET_MEMORY_FAILED;
}
//_mem_set_type(mem_ptr, MEM_TYPE_USB_HOST_DEVICE);
if (dev_ptr->memlist == NULL) {
dev_ptr->memlist = mem_ptr;
} else {
list_ptr = dev_ptr->memlist;
while (list_ptr->next != NULL)
list_ptr = list_ptr->next;
list_ptr->next = mem_ptr;
} /* EndIf */
mem_ptr->next = NULL;
mem_ptr->blktype = mem_type;
mem_ptr->blksize = mem_size;
*header_ptr = (pointer2)mem_ptr;
return USB_OK;
} /* Endbody */