mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
temporarily implementation of dcd_pipe_is_busy
This commit is contained in:
parent
db986b3107
commit
5ab195a73d
@ -85,17 +85,18 @@ void led_blinking_task(void * p_para)
|
||||
hid_keyboard_report_t keyboard_report TUSB_CFG_ATTR_USBRAM;
|
||||
void keyboard_device_app_task(void * p_para)
|
||||
{
|
||||
// if (tusbd_is_configured(0))
|
||||
// {
|
||||
// static uint32_t count =0;
|
||||
// if (count < 10)
|
||||
// {
|
||||
// count++;
|
||||
//
|
||||
// keyboard_report.keycode[0] = 0x04;
|
||||
// tusbd_hid_keyboard_send(0, &keyboard_report );
|
||||
// }
|
||||
// }
|
||||
if (tusbd_is_configured(0))
|
||||
{
|
||||
static uint32_t count =0;
|
||||
if (count++ < 10)
|
||||
{
|
||||
keyboard_report.keycode[0] = (count%2) ? 0x04 : 0x00;
|
||||
if (!tusbd_hid_keyboard_is_busy(0))
|
||||
{
|
||||
tusbd_hid_keyboard_send(0, &keyboard_report );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -351,6 +351,11 @@ ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
|
||||
{
|
||||
return dcd_pipe_is_busy(keyboardd_data.ept_handle);
|
||||
}
|
||||
|
||||
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_kbd_report)
|
||||
{
|
||||
//------------- verify data -------------//
|
||||
|
@ -47,22 +47,36 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// KEYBOARD Application API
|
||||
//--------------------------------------------------------------------+
|
||||
/** \addtogroup ClassDriver_HID_Keyboard Keyboard
|
||||
* @{ */
|
||||
|
||||
/** \defgroup Keyboard_Device Device
|
||||
* The interface API includes status checking function, data transferring function and callback functions
|
||||
* @{ */
|
||||
|
||||
bool tusbd_hid_keyboard_is_busy(uint8_t coreid);
|
||||
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_kbd_report);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MOUSE APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
/** \addtogroup ClassDriver_HID_Mouse Mouse
|
||||
* @{ */
|
||||
/** \defgroup Mouse_Device Device
|
||||
* @{ */
|
||||
|
||||
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_mouse_report);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD-CLASS DRIVER API
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -247,6 +247,12 @@ static inline uint8_t endpoint_to_pos(uint8_t logical_endpoint, tusb_direction_t
|
||||
return logical_endpoint + (dir == TUSB_DIR_HOST_TO_DEV ? 0 : 16);
|
||||
}
|
||||
|
||||
static inline uint8_t endpoint_phy2pos(uint8_t physical_endpoint) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t endpoint_phy2pos(uint8_t physical_endpoint)
|
||||
{
|
||||
return physical_endpoint/2 + ( (physical_endpoint%2) ? 16 : 0);
|
||||
}
|
||||
|
||||
static inline uint8_t endpoint_log2phy(uint8_t logical_endpoint, tusb_direction_t dir) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t endpoint_log2phy(uint8_t logical_endpoint, tusb_direction_t dir)
|
||||
{
|
||||
@ -288,7 +294,7 @@ tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, void *
|
||||
qtd_init(p_data, buffer, length);
|
||||
dcd_data.qhd[endpoint_data].qtd_overlay.next = (uint32_t) p_data;
|
||||
|
||||
LPC_USB0->ENDPTPRIME |= BIT_(endpoint_to_pos(0, dir));
|
||||
LPC_USB0->ENDPTPRIME |= BIT_( endpoint_phy2pos(endpoint_data) );
|
||||
}
|
||||
|
||||
//------------- Status Phase (other endpoint, opposite direction) -------------//
|
||||
@ -296,7 +302,7 @@ tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, void *
|
||||
qtd_init(p_status, NULL, 0); // zero length xfer
|
||||
dcd_data.qhd[1 - endpoint_data].qtd_overlay.next = (uint32_t) p_status;
|
||||
|
||||
LPC_USB0->ENDPTPRIME |= BIT_(endpoint_to_pos(0, 1-dir));
|
||||
LPC_USB0->ENDPTPRIME |= BIT_( endpoint_phy2pos(1 - endpoint_data) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -332,6 +338,14 @@ STATIC_ INLINE_ dcd_qhd_t* qhd_get_from_endpoint_handle(endpoint_handle_t edpt_
|
||||
return &dcd_data.qhd[edpt_hdl.index];
|
||||
}
|
||||
|
||||
bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl)
|
||||
{
|
||||
dcd_qhd_t* p_qhd = qhd_get_from_endpoint_handle(edpt_hdl);
|
||||
|
||||
// LPC_USB0->ENDPTSTAT & endpoint_phy2pos(edpt_hdl.index)
|
||||
return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active;
|
||||
}
|
||||
|
||||
tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete)
|
||||
{
|
||||
dcd_qhd_t* p_qhd = qhd_get_from_endpoint_handle(edpt_hdl);
|
||||
@ -339,21 +353,13 @@ tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t buffer[], uint16
|
||||
|
||||
ASSERT(edpt_hdl.xfer_type != TUSB_XFER_ISOCHRONOUS, TUSB_ERROR_NOT_SUPPORTED_YET);
|
||||
|
||||
// TODO pipe is busy
|
||||
// DeviceTransferDescriptor* pDTD = (DeviceTransferDescriptor*) &dTransferDescriptor[PhyEP];
|
||||
// while ( lpc_usb->ENDPTSTAT & _BIT( EP_Physical2BitPosition(PhyEP) ) ) /* Endpoint is already primed */
|
||||
// {
|
||||
// }
|
||||
|
||||
//------------- Prepare qtd -------------//
|
||||
qtd_init(p_qtd, buffer, total_bytes);
|
||||
p_qtd->int_on_complete = int_on_complete;
|
||||
|
||||
p_qhd->qtd_overlay.next = (uint32_t) p_qtd;
|
||||
|
||||
#define EP_Physical2Pos(n) ( (n)/2 + ((n)%2 ? 16 : 0 ) )
|
||||
|
||||
LPC_USB0->ENDPTPRIME |= BIT_( EP_Physical2Pos(edpt_hdl.index) ) ;
|
||||
LPC_USB0->ENDPTPRIME |= BIT_( endpoint_phy2pos(edpt_hdl.index) ) ;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user