1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

HID receiving still not working.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@180 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2010-02-09 07:39:49 +00:00 committed by gussy
parent c1a013e383
commit 818fa05608
4 changed files with 75 additions and 25 deletions

View File

@ -161,7 +161,7 @@ static const uint8_t PIOS_USB_ConfigDescriptor[PIOS_USB_SIZ_CONFIG_DESC] = {
0x81, /* bEndpointAddress: Endpoint Address (IN) */
0x03, /* bmAttributes: Interrupt endpoint */
64,//0x02, /* wMaxPacketSize: 2 Bytes max */
0x00, 0x20, /* bInterval: Polling Interval (32 ms) */
0x00, 2,//0x20, /* bInterval: Polling Interval (2 ms) */
/* 34 */
0x07, /* bLength: Endpoint Descriptor size */
@ -171,7 +171,7 @@ static const uint8_t PIOS_USB_ConfigDescriptor[PIOS_USB_SIZ_CONFIG_DESC] = {
/* Endpoint Address (OUT) */
0x03, /* bmAttributes: Interrupt endpoint */
64,//0x02, /* wMaxPacketSize: 2 Bytes max */
0x00, 0x20, /* bInterval: Polling Interval (20 ms) */
0x00, 8,//0x20, /* bInterval: Polling Interval (8 ms) */
/* 41 */
};
@ -255,15 +255,14 @@ int32_t PIOS_USB_Init(uint32_t mode)
if(mode != 2) {
/* Note: usually no need to duplicate this for external drivers */
pInformation = &My_Device_Info;
pInformation->Ctrl_Info.Usb_wLength = 64; /* TODO: Is this required? */
/* Following hooks/pointers should be replaced by external drivers */
memcpy(&Device_Table, (DEVICE *) &My_Device_Table, sizeof(Device_Table));
pProperty = (DEVICE_PROP *) &My_Device_Property;
pUser_Standard_Requests = (USER_STANDARD_REQUESTS *) &My_User_Standard_Requests;
#ifndef DISABLE_HID
pEpInt_OUT[0] = PIOS_USB_HID_EP1_OUT_Callback;
#endif
}
PIOS_USB_HID_ChangeConnectionState(0);
@ -348,8 +347,6 @@ int32_t PIOS_USB_Init(uint32_t mode)
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
pInformation->Ctrl_Info.Usb_wLength = 64;
/* No error */
return 0;
}

View File

@ -7,6 +7,8 @@
* @brief USB HID functions
* @see The GNU Public License (GPL) Version 3
* @defgroup PIOS_USB_HID USB HID Functions
* @notes This implements a very simple HID device with a simple data in
* and data out endpoints.
* @{
*
*****************************************************************************/
@ -48,10 +50,12 @@ static uint8_t *PIOS_USB_HID_GetReportDescriptor(uint16_t Length);
static uint8_t *PIOS_USB_HID_GetProtocolValue(uint16_t Length);
static const uint8_t PIOS_USB_HID_ReportDescriptor[PIOS_USB_HID_SIZ_REPORT_DESC] = {
#if 0
0x05, 0x8c, /* USAGE_PAGE (ST Page) */
0x09, 0x01, /* USAGE (Demo Kit) */
0xa1, 0x01, /* COLLECTION (Application) */
/* 6 */
#endif
#if 0
/* Led 1 */
0x85, 0x01, /* REPORT_ID (1) */
@ -134,7 +138,7 @@ static const uint8_t PIOS_USB_HID_ReportDescriptor[PIOS_USB_HID_SIZ_REPORT_DESC]
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
/* 121 */
#endif
#if 0
/* In Control */
0x85, 0x06, // Report ID (6)
0x95, 0x02, // REPORT_COUNT (2)
@ -171,12 +175,47 @@ static const uint8_t PIOS_USB_HID_ReportDescriptor[PIOS_USB_HID_SIZ_REPORT_DESC]
0x75, 0x08, // REPORT_SIZE (8)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x01, // USAGE (Vendor Usage 1)
0x09, 0x02, // USAGE (Vendor Usage 1)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
/*66*/
#endif
#if 0
0x75, 0x08, // report size = 8 bits
0x15, 0x00, // logical minimum = 0
0x26, 0xff, 0x00, // logical maximum = 255
0xc0 /* END_COLLECTION */
/*67*/
/* In Data */
0x95, 64, // report count (64 bytes)
0x09, 0x01, // usage
0x81, 0x02, // Input (array)
/* Out Data */
0x95, 64, // report count (64 bytes)
0x09, 0x02, // usage
0x91, 0x02, // Output (array)
/*25*/
#endif
0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */
0x09, 0x01, /* Usage (Vendor Defined) */
0xa1, 0x01, /* Collection (Vendor Defined) */
#if 1
0x09, 0x02, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */
0x95, 8, /* Report Count (64) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0xff, /* Logical Maximum (255) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x09, 0x03, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */
0x95, 8, /* Report Count (64) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0xff, /* Logical Maximum (255) */
0x91, 0x02, /* Output (Data, Variable, Absolute) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
#endif
0xc0 /* End Collection */
};
static ONE_DESCRIPTOR PIOS_USB_HID_Report_Descriptor = {(uint8_t *) PIOS_USB_HID_ReportDescriptor, PIOS_USB_HID_SIZ_REPORT_DESC};
static ONE_DESCRIPTOR PIOS_USB_HID_Hid_Descriptor = {(uint8_t*) PIOS_USB_HID_ReportDescriptor + PIOS_USB_HID_OFF_HID_DESC, PIOS_USB_HID_SIZ_HID_DESC};
@ -281,19 +320,23 @@ static uint8_t *PIOS_USB_HID_GetProtocolValue(uint16_t Length)
*/
void PIOS_USB_HID_EP1_OUT_Callback(void)
{
uint8_t Receive_Buffer[2];
uint32_t DataLength = 0;
const char *buff = "\rACK\r";
PIOS_COM_SendBuffer(GPS, (uint8_t *)buff, sizeof(buff));
/* Read received data (2 bytes) */
//USB_SIL_Read(ENDP1, Receive_Buffer);
uint8_t Receive_Buffer[64];
//uint32_t DataLength = 0;
/* Read received data (64 bytes) */
//USB_SIL_Read(EP1_OUT, Receive_Buffer);
/* Get the number of received data on the selected Endpoint */
DataLength = GetEPRxCount(ENDP1 & 0x7F);
//DataLength = GetEPRxCount(ENDP1 & 0x7F);
/* Use the memory interface function to write to the selected endpoint */
PMAToUserBufferCopy((uint8_t *) Receive_Buffer, GetEPRxAddr(ENDP1 & 0x7F), DataLength);
//PMAToUserBufferCopy((uint8_t *) Receive_Buffer, GetEPRxAddr(ENDP1 & 0x7F), DataLength);
/* Do stuff here */
//PIOS_COM_SendBuffer(GPS, Receive_Buffer, sizeof(Receive_Buffer));
SetEPRxStatus(ENDP1, EP_RX_VALID);
}

View File

@ -28,7 +28,13 @@
#define PIOS_USB_HID_H
/* Global Definitions */
#define PIOS_USB_HID_SIZ_REPORT_DESC 67
//#define PIOS_USB_HID_SIZ_REPORT_DESC 26
//#define PIOS_USB_HID_SIZ_REPORT_DESC 67
//#define PIOS_USB_HID_SIZ_REPORT_DESC 122
#define PIOS_USB_HID_SIZ_REPORT_DESC 34
//#define PIOS_USB_HID_SIZ_REPORT_DESC 23
//#define PIOS_USB_HID_SIZ_REPORT_DESC 28
#define PIOS_USB_HID_REPORT_DESCRIPTOR 0x22
#define PIOS_USB_HID_HID_DESCRIPTOR_TYPE 0x21
#define PIOS_USB_HID_OFF_HID_DESC 0x12

View File

@ -62,8 +62,6 @@ int main()
/* Delay system */
PIOS_DELAY_Init();
/* SPI Init */
PIOS_SPI_Init();
@ -179,12 +177,18 @@ static void TaskHIDTest(void *pvParameters)
for(;;)
{
Send_Buffer[0] = 0x01;
Send_Buffer[1] = 't';
Send_Buffer[2] = 'e';
Send_Buffer[3] = 's';
Send_Buffer[4] = 't';
Send_Buffer[5] = '!';
Send_Buffer[6] = '!';
Send_Buffer[1] = 'e';
Send_Buffer[2] = 'l';
Send_Buffer[3] = 'l';
Send_Buffer[4] = 'o';
Send_Buffer[5] = ' ';
Send_Buffer[6] = 'W';
Send_Buffer[7] = 'o';
Send_Buffer[8] = 'r';
Send_Buffer[9] = 'l';
Send_Buffer[10] = 'd';
Send_Buffer[11] = '!';
Send_Buffer[12] = 0;
/* Write the data to the pipe */
UserToPMABufferCopy((uint8_t*) Send_Buffer, GetEPTxAddr(EP1_IN & 0x7F), 64);