diff options
| author | hathach <[email protected]> | 2013-11-20 12:52:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-11-20 12:52:07 +0700 |
| commit | 850fcf03f09c635015ba5b40b2ed8c303dce27ef (patch) | |
| tree | f76f1ad1f03a6fd72fa9a04fb4cce2973253227b /tinyusb | |
| parent | dbfad50d437f51073dfb29b6ddda4889417b6269 (diff) | |
refractor descriptor
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/hid.c | 4 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc175x_6x.c | 17 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc175x_6x.h | 11 |
3 files changed, 17 insertions, 15 deletions
diff --git a/tinyusb/class/hid.c b/tinyusb/class/hid.c index 97feed998..f1471f093 100644 --- a/tinyusb/class/hid.c +++ b/tinyusb/class/hid.c @@ -224,11 +224,11 @@ tusb_error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *c tusb_error_t tusb_hid_configured(USBD_HANDLE_T hUsb) { #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD - ROM_API->hw->WriteEP(hUsb , HID_EDPT_KEYBOARD_ADDR , (uint8_t* ) &hid_keyboard_report , sizeof(hid_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted + ROM_API->hw->WriteEP(hUsb , HID_KEYBOARD_EDPT_ADDR , (uint8_t* ) &hid_keyboard_report , sizeof(hid_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted #endif #ifdef TUSB_CFG_DEVICE_HID_MOUSE - ROM_API->hw->WriteEP(hUsb , HID_MOUSE_EP_IN , (uint8_t* ) &hid_mouse_report , sizeof(hid_mouse_report_t) ); // initial packet for IN endpoint, will not work if omitted + ROM_API->hw->WriteEP(hUsb , HID_MOUSE_EDPT_ADDR , (uint8_t* ) &hid_mouse_report , sizeof(hid_mouse_report_t) ); // initial packet for IN endpoint, will not work if omitted #endif return TUSB_ERROR_NONE; diff --git a/tinyusb/device/dcd_lpc175x_6x.c b/tinyusb/device/dcd_lpc175x_6x.c index 730ee7295..e46847bd3 100644 --- a/tinyusb/device/dcd_lpc175x_6x.c +++ b/tinyusb/device/dcd_lpc175x_6x.c @@ -347,7 +347,7 @@ static tusb_error_t pipe_control_write(void const * buffer, uint16_t length) { ASSERT( length !=0 || buffer == NULL, TUSB_ERROR_INVALID_PARA); - LPC_USB->USBCtrl = SLAVE_CONTROL_WRITE_ENABLE_MASK; // logical endpoint = 0 + LPC_USB->USBCtrl = USBCTRL_WRITE_ENABLE_MASK; // logical endpoint = 0 LPC_USB->USBTxPLen = length; for (uint16_t count = 0; count < length_byte2dword(length); count++) @@ -356,9 +356,10 @@ static tusb_error_t pipe_control_write(void const * buffer, uint16_t length) buffer += 4; } - LPC_USB->USBCtrl = 0; + LPC_USB->USBCtrl = 0; - sie_write(SIE_CMDCODE_ENDPOINT_SELECT+1, 0, 0); // select control IN endpoint + // select control IN & validate the endpoint + sie_write(SIE_CMDCODE_ENDPOINT_SELECT+1, 0, 0); sie_write(SIE_CMDCODE_BUFFER_VALIDATE , 0, 0); return TUSB_ERROR_NONE; @@ -366,18 +367,20 @@ static tusb_error_t pipe_control_write(void const * buffer, uint16_t length) static tusb_error_t pipe_control_read(void * buffer, uint16_t length) { - LPC_USB->USBCtrl = SLAVE_CONTROL_READ_ENABLE_MASK; // logical endpoint = 0 - while ((LPC_USB->USBRxPLen & SLAVE_RXPLEN_PACKET_READY_MASK) == 0) {} // TODO blocking, should have timeout + LPC_USB->USBCtrl = USBCTRL_READ_ENABLE_MASK; // logical endpoint = 0 + while ((LPC_USB->USBRxPLen & USBRXPLEN_PACKET_READY_MASK) == 0) {} // TODO blocking, should have timeout - uint16_t actual_length = min16_of(length, (uint16_t) (LPC_USB->USBRxPLen & SLAVE_RXPLEN_PACKET_LENGTH_MASK) ); + uint16_t actual_length = min16_of(length, (uint16_t) (LPC_USB->USBRxPLen & USBRXPLEN_PACKET_LENGTH_MASK) ); uint32_t *p_read_data = (uint32_t*) buffer; for( uint16_t count=0; count < length_byte2dword(actual_length); count++) { *p_read_data = LPC_USB->USBRxData; p_read_data++; // increase by 4 ( sizeof(uint32_t) ) } - LPC_USB->USBCtrl = 0; // TODO not needed ? + + LPC_USB->USBCtrl = 0; + // select control OUT & clear the endpoint sie_write(SIE_CMDCODE_ENDPOINT_SELECT+0, 0, 0); sie_write(SIE_CMDCODE_BUFFER_CLEAR , 0, 0); diff --git a/tinyusb/device/dcd_lpc175x_6x.h b/tinyusb/device/dcd_lpc175x_6x.h index df9e790fa..aed21edeb 100644 --- a/tinyusb/device/dcd_lpc175x_6x.h +++ b/tinyusb/device/dcd_lpc175x_6x.h @@ -122,16 +122,15 @@ enum { //------------- USBCtrl -------------// enum { - SLAVE_CONTROL_READ_ENABLE_MASK = BIT_(0), - SLAVE_CONTROL_WRITE_ENABLE_MASK = BIT_(1), - SLAVE_CONTROL_READ_ENABLE_POS = 2 + USBCTRL_READ_ENABLE_MASK = BIT_(0), + USBCTRL_WRITE_ENABLE_MASK = BIT_(1), }; //------------- USBRxPLen -------------// enum { - SLAVE_RXPLEN_PACKET_LENGTH_MASK = (BIT_(10)-1), - SLAVE_RXPLEN_DATA_VALID_MASK = BIT_(10), - SLAVE_RXPLEN_PACKET_READY_MASK = BIT_(11), + USBRXPLEN_PACKET_LENGTH_MASK = (BIT_(10)-1), + USBRXPLEN_DATA_VALID_MASK = BIT_(10), + USBRXPLEN_PACKET_READY_MASK = BIT_(11), }; //------------- SIE Command Code -------------// |
