本文整理汇总了C++中USB_PRINTF函数的典型用法代码示例。如果您正苦于以下问题:C++ USB_PRINTF函数的具体用法?C++ USB_PRINTF怎么用?C++ USB_PRINTF使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USB_PRINTF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: USB_PRINTF
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_class_video_control_pre_deinit
* Returned Value : None
* Comments :
* This function is called by common class to initialize the class driver. It
* is called in response to a select interface call by application
*
*END*--------------------------------------------------------------------*/
usb_status usb_class_video_control_pre_deinit
(
/* [IN] the class driver handle */
class_handle handle
)
{
usb_video_control_struct_t* video_control_ptr = (usb_video_control_struct_t*)handle;
usb_status status = USB_OK;
if (video_control_ptr == NULL)
{
#ifdef _DEBUG
USB_PRINTF("usb_class_video_control_pre_deinit fail\n");
#endif
return USBERR_ERROR;
}
if (video_control_ptr->control_interrupt_in_pipe != NULL)
{
status = usb_host_cancel(video_control_ptr->host_handle, video_control_ptr->control_interrupt_in_pipe, NULL);
if (status != USB_OK)
{
#ifdef _DEBUG
USB_PRINTF("error in usb_class_video_control_pre_deinit to close pipe\n");
#endif
}
}
//USB_PRINTF("Video class driver pre_deinit\n");
return USB_OK;
} /* Endbody */
示例2: USB_PRINTF
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : usb_device_process_resume
* Returned Value : USB_OK or error code
* Comments :
* Process Resume event
*
*END*-----------------------------------------------------------------*/
usb_status usb_device_assert_resume
(
/* [IN] the USB_USB_dev_initialize state structure */
usb_device_handle handle
)
{
usb_dev_state_struct_t* usb_dev_ptr;
usb_status error = USB_OK;
if (handle == NULL)
{
#if _DEBUG
USB_PRINTF("usb_device_assert_resume: handle is NULL\n");
#endif
return USBERR_ERROR;
}
usb_dev_ptr = (usb_dev_state_struct_t*)handle;
if ((usb_dev_ptr->usb_dev_interface)->dev_assert_resume != NULL)
{
error= (usb_dev_ptr->usb_dev_interface)->dev_assert_resume(usb_dev_ptr->controller_handle);
}
else
{
#if _DEBUG
USB_PRINTF("usb_device_assert_resume: dev_assert_resume is NULL\n");
#endif
error = USBERR_ERROR;
}
return error;
}
示例3: USB_PRINTF
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_class_hub_deinit
* Returned Value : None
* Comments :
* This function is called by common class to deinitialize the class driver. It
* is called in response to a select interface call by application
*
*END*--------------------------------------------------------------------*/
usb_status usb_class_hub_deinit
(
/* [IN] the class driver handle */
class_handle handle
)
{
usb_hub_class_struct_t* hub_class = (usb_hub_class_struct_t*)handle;
usb_status status = USB_OK;
if (hub_class == NULL)
{
USB_PRINTF("usb_class_hid_deinit fail\n");
return USBERR_ERROR;
}
if (hub_class->interrupt_pipe != NULL)
{
status = usb_host_close_pipe(hub_class->host_handle, hub_class->interrupt_pipe);
if (status != USB_OK)
{
USB_PRINTF("error in usb_class_hid_deinit to close pipe\n");
}
}
OS_Mem_free(handle);
//USB_PRINTF("HID class driver de-initialized\n");
return USB_OK;
} /* Endbody */
示例4: time_init
void time_init(void)
{
extern const hwtimer_devif_t kSystickDevif;
extern const hwtimer_devif_t kPitDevif;
#define HWTIMER_LL_DEVIF kPitDevif // Use hardware timer PIT
#define HWTIMER_LL_SRCCLK kBusClock // Source Clock for PIT
#define HWTIMER_LL_ID 1
#define HWTIMER_PERIOD 1000 // 1 ms interval
if (kHwtimerSuccess != HWTIMER_SYS_Init(&hwtimer, &HWTIMER_LL_DEVIF, HWTIMER_LL_ID, 5, NULL))
{
USB_PRINTF("\r\nError: hwtimer initialization.\r\n");
}
if (kHwtimerSuccess != HWTIMER_SYS_SetPeriod(&hwtimer, HWTIMER_LL_SRCCLK, HWTIMER_PERIOD))
{
USB_PRINTF("\r\nError: hwtimer set period.\r\n");
}
if (kHwtimerSuccess != HWTIMER_SYS_RegisterCallback(&hwtimer, hwtimer_callback, NULL))
{
USB_PRINTF("\r\nError: hwtimer callback registration.\r\n");
}
if (kHwtimerSuccess != HWTIMER_SYS_Start(&hwtimer))
{
USB_PRINTF("\r\nError: hwtimer start.\r\n");
}
}
示例5: USB_PRINTF
usb_status usb_class_audio_send_data
(
/* [IN] audio control class interface pointer */
audio_command_t* audio_ptr,
/* [IN] buffer pointer */
uint8_t * buffer,
/* [IN] data length */
uint32_t buf_size
)
{ /* Body */
audio_stream_struct_t* audio_class;
usb_status status = USBERR_ERROR;
//uint16_t request_value;
tr_struct_t* tr_ptr;
//usb_audio_command_t* p_endpoint_command;
if ((audio_ptr == NULL) || (audio_ptr->class_stream_handle == NULL))
{
USB_PRINTF("input parameter error\n");
return USBERR_ERROR;
}
audio_class = (audio_stream_struct_t*)audio_ptr->class_stream_handle;
if ((audio_class == NULL) || (buffer == NULL))
{
USB_PRINTF("get audio class parameter error\n");
return USBERR_ERROR;
}
audio_class->send_callback = audio_ptr->callback_fn;
audio_class->send_param = audio_ptr->callback_param;
if (audio_class->dev_handle == NULL)
{
USB_PRINTF("get audio class dev handle error\n");
return USBERR_ERROR;
}
if (usb_host_get_tr(audio_class->host_handle, usb_class_audio_send_callback, audio_class, &tr_ptr) != USB_OK)
{
USB_PRINTF("error to get tr\n");
return USBERR_ERROR;
}
tr_ptr->tx_buffer = buffer;
tr_ptr->tx_length = buf_size;
status = usb_host_send_data(audio_class->host_handle, audio_class->iso_out_pipe, tr_ptr);
if (status != USB_OK)
{
USB_PRINTF("\nError in _usb_host_send_data: %x", (unsigned int)status);
usb_host_release_tr(audio_class->host_handle, tr_ptr);
return USBERR_ERROR;
}
return USB_OK;
} /* Endbody */
示例6: USB_PRINTF
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_class_video_control_recv_data
* Returned Value : USB_OK if command has been passed on USB.
* Comments :
* This function is used to recv interrupt data
*
*END*--------------------------------------------------------------------*/
usb_status usb_class_video_control_recv_data
(
/* [IN] Class Interface structure pointer */
video_command_t* com_ptr,
/* [IN] The buffer address */
uint8_t * buffer,
/* [IN] The buffer address */
uint16_t length
)
{
usb_video_control_struct_t* video_control_ptr;
tr_struct_t* tr_ptr;
usb_status status;
if ((com_ptr == NULL) || (com_ptr->class_control_handle == NULL))
{
return USBERR_ERROR;
}
video_control_ptr = (usb_video_control_struct_t*)com_ptr->class_control_handle;
if ((video_control_ptr == NULL) || (buffer == NULL))
{
#ifdef _DEBUG
USB_PRINTF("input parameter error\n");
#endif
return USBERR_ERROR;
}
video_control_ptr->recv_callback = com_ptr->callback_fn;
video_control_ptr->recv_param = com_ptr->callback_param;
if (video_control_ptr->dev_handle == NULL)
{
return USBERR_ERROR;
}
if (usb_host_get_tr(video_control_ptr->host_handle, usb_class_video_control_recv_callback, video_control_ptr, &tr_ptr) != USB_OK)
{
#ifdef _DEBUG
USB_PRINTF("error to get tr\n");
#endif
return USBERR_ERROR;
}
tr_ptr->rx_buffer = buffer;
tr_ptr->rx_length = length;
status = usb_host_recv_data(video_control_ptr->host_handle, video_control_ptr->control_interrupt_in_pipe, tr_ptr);
if (status != USB_OK)
{
#ifdef _DEBUG
USB_PRINTF("\nError in usb_class_video_recv_data: %x", status);
#endif
usb_host_release_tr(video_control_ptr->host_handle, tr_ptr);
return USBERR_ERROR;
}
return USB_OK;
}
示例7: OS_Mutex_lock
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : usb_device_get_status
* Returned Value : USB_OK or error code
* Comments :
* Provides API to access the USB internal state.
*
*END*--------------------------------------------------------------------*/
usb_status usb_device_get_status
(
/* [IN] Handle to the USB device */
usb_device_handle handle,
/* [IN] What to get the error of */
uint8_t component,
/* [OUT] The requested error */
uint16_t* error
)
{ /* Body */
usb_dev_state_struct_t* usb_dev_ptr;
usb_dev_ptr = (usb_dev_state_struct_t*)handle;
OS_Mutex_lock(usb_dev_ptr->mutex);
if (component & USB_STATUS_ENDPOINT)
{
if ((usb_dev_ptr->usb_dev_interface)->dev_get_endpoint_status != NULL)
{
(usb_dev_ptr->usb_dev_interface)->dev_get_endpoint_status(usb_dev_ptr->controller_handle,
(uint8_t)(component),error);
}
else
{
#if _DEBUG
USB_PRINTF("usb_device_get_status: DEV_GET_ENDPOINT_STATUS is NULL\n");
#endif
OS_Mutex_unlock(usb_dev_ptr->mutex);
return USBERR_ERROR;
}
}
else
{
if ((usb_dev_ptr->usb_dev_interface)->dev_get_device_status != NULL)
{
(usb_dev_ptr->usb_dev_interface)->dev_get_device_status(usb_dev_ptr->controller_handle,
(uint8_t)(component),error);
}
else
{
#if _DEBUG
USB_PRINTF("usb_device_get_status: DEV_GET_DEVICE_STATUS is NULL\n");
#endif
OS_Mutex_unlock(usb_dev_ptr->mutex);
return USBERR_ERROR;
}
}
OS_Mutex_unlock(usb_dev_ptr->mutex);
return USB_OK;
}
示例8: Virtual_Com_App
/******************************************************************************
*
* @name Virtual_Com_App
*
* @brief
*
* @param None
*
* @return None
*
*****************************************************************************/
void Virtual_Com_App(void)
{
/* User Code */
if ((0 != g_recv_size) && (0xFFFFFFFF != g_recv_size))
{
int32_t i;
/* Copy Buffer to Send Buff */
for (i = 0; i < g_recv_size; i++)
{
//USB_PRINTF("Copied: %c\n", g_curr_recv_buf[i]);
g_curr_send_buf[g_send_size++] = g_curr_recv_buf[i];
}
g_recv_size = 0;
}
if (g_send_size)
{
uint8_t error;
uint32_t size = g_send_size;
g_send_size = 0;
error = USB_Class_CDC_Send_Data(g_app_handle, DIC_BULK_IN_ENDPOINT,
g_curr_send_buf, size);
if (error != USB_OK)
{
/* Failure to send Data Handling code here */
}
}
#if USBCFG_DEV_KEEP_ALIVE_MODE
#if (OS_ADAPTER_ACTIVE_OS == OS_ADAPTER_SDK)
if( (waitfordatareceive))
{
if(comopen == 1)
{
OS_Time_delay(30);
comopen = 0;
}
USB_PRINTF("Enter lowpower\r\n");
usb_hal_khci_disable_interrupts((uint32_t)USB0, INTR_TOKDNE);
POWER_SYS_SetMode(kDemoVlps, kPowerManagerPolicyAgreement);
waitfordatareceive = 0;
usb_hal_khci_enable_interrupts((uint32_t)USB0,INTR_TOKDNE);
USB_PRINTF("Exit lowpower\r\n");
}
#endif
#endif
return;
}
示例9: OS_Task_delete
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _usb_device_shutdown
* Returned Value : USB_OK or error code
* Comments :
* Shutdown an initialized USB device
*
*END*-----------------------------------------------------------------*/
static usb_status _usb_device_shutdown
(
/* [IN] the USB_USB_dev_initialize state structure */
usb_device_handle handle
)
{
usb_status error;
usb_dev_state_struct_t* usb_dev_ptr;
usb_dev_ptr = (usb_dev_state_struct_t*)handle;
#if USBCFG_DEV_USE_TASK
if (usb_dev_ptr->task_id != (uint32_t)OS_TASK_ERROR)
{
OS_Task_delete(usb_dev_ptr->task_id);
}
if (NULL != usb_dev_ptr->usb_dev_service_que)
{
OS_MsgQ_destroy(usb_dev_ptr->usb_dev_service_que);
}
#endif
if (usb_dev_ptr->usb_dev_interface->dev_shutdown != NULL)
{
error = (usb_dev_ptr->usb_dev_interface)->dev_shutdown(usb_dev_ptr->controller_handle);
return error;
}
else
{
#if _DEBUG
USB_PRINTF("_usb_device_shutdown: DEV_SHUTDOWN is NULL\n");
#endif
return USBERR_ERROR;
}
} /* EndBody */
示例10: usb_host_release_tr
static void usb_class_audio_send_callback
(
/* [IN] Unused */
void* tr_ptr,
/* [IN] Pointer to the class interface instance */
void* param,
/* [IN] Data buffer */
uint8_t * buffer,
/* [IN] Length of buffer */
uint32_t len,
/* [IN] Error code (if any) */
usb_status status
)
{ /* Body */
audio_stream_struct_t* audio_class = (audio_stream_struct_t*)param;
usb_status usbstatus;
usbstatus = usb_host_release_tr(audio_class->host_handle, (tr_struct_t*)tr_ptr);
if (usbstatus != USB_OK)
{
USB_PRINTF("_usb_host_release_tr failed:%x\n",(unsigned int)usbstatus);
}
if (audio_class->send_callback)
{
audio_class->send_callback(NULL, audio_class->send_param, buffer, len, status);
}
} /* Endbody */
示例11: usb_init
int usb_init(void)
{
int result;
void *ctrl;
int i, start_index = 0;
struct usb_device *dev;
gpio_init_usb(1);
running=0;
dev_index=0;
asynch_allowed=1;
usb_hub_reset();
/* first make all devices unknown */
for (i = 0; i < USB_MAX_DEVICE; i++) {
memset(&usb_dev[i], 0, sizeof(struct usb_device));
usb_dev[i].devnum = -1;
}
/* init low_level USB */
#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
/* init low_level USB */
printf("USB%d: ", i);
if (usb_lowlevel_init(i, USB_INIT_HOST, &ctrl)) {
puts("lowlevel init failed\n");
continue;
}
/*
* lowlevel init is OK, now scan the bus for devices
* i.e. search HUBs and configure them
*/
start_index = dev_index;
printf("scanning bus %d for devices... ", i);
dev = usb_alloc_new_device(ctrl);
/*
* device 0 is always present
* (root hub, so let it analyze)
*/
if (dev)
usb_new_device(dev);
if (start_index == dev_index)
puts("No USB Device found\n");
else
printf("%d USB Device(s) found\n",
dev_index - start_index);
running = 1;
}
USB_PRINTF("scan end\n");
if (!running) {
puts("USB error: all controllers failed lowlevel init\n");
return -1;
}
return 0;
}
示例12: usb_control_msg
/*
* submits a control message and waits for comletion (at least timeout * 1ms)
* If timeout is 0, we don't wait for completion (used as example to set and
* clear keyboards LEDs). For data transfers, (storage transfers) we don't
* allow control messages with 0 timeout, by previousely resetting the flag
* asynch_allowed (usb_disable_asynch(1)).
* returns the transfered length if OK or -1 if error. The transfered length
* and the current status are stored in the dev->act_len and dev->status.
*/
int usb_control_msg(struct usb_device *dev, unsigned int pipe,
unsigned char request, unsigned char requesttype,
unsigned short value, unsigned short index,
void *data, unsigned short size, int timeout)
{
if((timeout==0)&&(!asynch_allowed)) /* request for a asynch control pipe is not allowed */
return -1;
/* set setup command */
setup_packet.requesttype = requesttype;
setup_packet.request = request;
setup_packet.value = swap_16(value);
setup_packet.index = swap_16(index);
setup_packet.length = swap_16(size);
USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X\nvalue 0x%X index 0x%X length 0x%X\n",
request,requesttype,value,index,size);
dev->status=USB_ST_NOT_PROC; /*not yet processed */
submit_control_msg(dev,pipe,data,size,&setup_packet);
if(timeout==0) {
return (int)size;
}
while(timeout--) {
if(!((volatile unsigned long)dev->status & USB_ST_NOT_PROC))
break;
wait_ms(1);
}
if(dev->status==0)
return dev->act_len;
else {
return -1;
}
}
示例13: kbd_hid_get_buffer
/*FUNCTION*----------------------------------------------------------------
*
* Function Name : kbd_hid_get_buffer
* Returned Value : none
* Comments :
* used to get the buffer to store the data transferred from device.
*
*END*--------------------------------------------------------------------*/
uint32_t kbd_hid_get_buffer(void)
{
uint8_t ep_no;
usb_device_ep_struct_t *lpEp;
/* first get the max packet size from interface info */
usb_device_interface_struct_t* lpHostIntf = (usb_device_interface_struct_t*) kbd_hid_get_interface();
for (ep_no = 0; ep_no < lpHostIntf->ep_count; ep_no++)
{
lpEp = &lpHostIntf->ep[ep_no];
if (((lpEp->lpEndpointDesc->bEndpointAddress & IN_ENDPOINT) != 0) && ((lpEp->lpEndpointDesc->bmAttributes & IRRPT_ENDPOINT) != 0))
{
kbd_size = (USB_SHORT_UNALIGNED_LE_TO_HOST(lpEp->lpEndpointDesc->wMaxPacketSize) & PACKET_SIZE_MASK);
break;
}
}
if ((kbd_size != 0) && (kbd_buffer == NULL))
{
kbd_buffer = (uint8_t*) OS_Mem_alloc_uncached_zero(kbd_size);
if (kbd_buffer == NULL)
{
USB_PRINTF("allocate memory failed in hid_get_buffer\r\n");
return (uint32_t)(-1);
}
}
return 0;
}
示例14: USB_App_Callback
/******************************************************************************
*
* @name USB_App_Callback
*
* @brief This function handles the callback
*
* @param handle : handle to Identify the controller
* @param event_type : value of the event
* @param val : gives the configuration value
*
* @return None
*
*****************************************************************************/
void USB_App_Callback(uint8_t event_type, void* val,void* arg)
{
uint16_t interface_setting;
uint8_t interface_alternate;
uint8_t interface_num;
if ((event_type == USB_DEV_EVENT_BUS_RESET) || (event_type == USB_DEV_EVENT_CONFIG_CHANGED))
{
virtual_camera.attached=FALSE;
if (USB_OK == USB_Class_Video_Get_Speed(virtual_camera.video_handle, &virtual_camera.app_speed))
{
USB_Desc_Set_Speed(virtual_camera.video_handle, virtual_camera.app_speed);
}
}
else if (event_type == USB_DEV_EVENT_ENUM_COMPLETE)
{
virtual_camera.attached=TRUE;
USB_PRINTF("Virtual camera is working ... \r\n");
}
else if (event_type == USB_DEV_EVENT_ERROR)
{
/* add user code for error handling */
}
else if (event_type == USB_DEV_EVENT_INTERFACE_CHANGED)
{
interface_setting = *((uint16_t*)val);
interface_alternate = (uint8_t)(interface_setting&0x00FF);
interface_num = (uint8_t)((interface_setting>>8)&0x00FF);
if (VIDEO_STREAM_IF_INDEX == interface_num)
{
if (0 != interface_alternate)
{
virtual_camera.start_send = TRUE;
if (((uint8_t)TRUE == virtual_camera.attached) && ((uint8_t)TRUE == virtual_camera.start_send))
{
if ((uint8_t)FALSE == virtual_camera.is_sending)
{
virtual_camera.is_sending = (uint8_t)TRUE;
virtual_camera.frame_sent = 0;
virtual_camera.frame_progress = 0;
USB_Prepare_Data();
(void)USB_Class_Video_Send_Data(virtual_camera.video_handle,VIDEO_ISO_ENDPOINT,virtual_camera.image_buffer,virtual_camera.frame_send_length);
}
}
}
else
{
virtual_camera.transmit_type = 0;
virtual_camera.start_send = (uint8_t)FALSE;
if ((uint8_t)TRUE == virtual_camera.is_sending)
{
virtual_camera.is_sending = (uint8_t)FALSE;
(void)USB_Class_Video_Cancel(virtual_camera.video_handle,VIDEO_ISO_ENDPOINT,USB_SEND);
}
}
}
}
示例15: video_camera_control_task
/*
video_camera_control_task
*/
void video_camera_control_task(void)
{
usb_status status = USB_OK;
// Wait for insertion or removal event
OS_Event_wait(g_video_camera.video_camera_control_event, USB_EVENT_CTRL, FALSE, 0);
if (OS_Event_check_bit(g_video_camera.video_camera_control_event, USB_EVENT_CTRL))
OS_Event_clear(g_video_camera.video_camera_control_event, USB_EVENT_CTRL);
switch ( g_video_camera.control_state)
{
case USB_DEVICE_IDLE:
break;
case USB_DEVICE_ATTACHED:
USB_PRINTF("Video device attached\r\n");
g_video_camera.control_state = USB_DEVICE_SET_INTERFACE_STARTED;
status = usb_host_open_dev_interface(g_video_camera.host_handle, g_video_camera.dev_handle, g_video_camera.control_intf_handle, (class_handle*)&g_video_camera.video_control_handle);
if (status != USB_OK)
{
USB_PRINTF("\r\nError in _usb_hostdev_open_interface: %x\r\n", status);
return;
}
g_video_camera.video_command_ptr->class_control_handle = g_video_camera.video_control_handle;
break;
case USB_DEVICE_INTERFACE_OPENED:
break;
case USB_DEVICE_DETACHED:
status = usb_host_close_dev_interface(g_video_camera.host_handle, g_video_camera.dev_handle, g_video_camera.control_intf_handle, g_video_camera.video_control_handle);
if (status != USB_OK)
{
USB_PRINTF("error in _usb_hostdev_close_interface %x\n", status);
}
g_video_camera.control_intf_handle = NULL;
g_video_camera.video_control_handle = NULL;
USB_PRINTF("Going to idle state\r\n");
g_video_camera.control_state = USB_DEVICE_IDLE;
break;
case USB_DEVICE_OTHER:
break;
default:
break;
}
}