From e39f2801d13b8a532dca825ab163e153c2458d3a Mon Sep 17 00:00:00 2001 From: gussy Date: Fri, 5 Feb 2010 09:34:45 +0000 Subject: [PATCH] More HID work. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@173 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PiOS/STM32F10x/pios_usb.c | 4 ++- flight/PiOS/pios.c | 56 +++++++++++++++++++------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/flight/PiOS/STM32F10x/pios_usb.c b/flight/PiOS/STM32F10x/pios_usb.c index 7289396f2..bc83e9446 100644 --- a/flight/PiOS/STM32F10x/pios_usb.c +++ b/flight/PiOS/STM32F10x/pios_usb.c @@ -42,7 +42,8 @@ /* ISTR events */ /* mask defining which events has to be handled by the device application software */ -#define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM | CNTR_ESOFM | CNTR_RESETM) +/* Unused; #define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM | CNTR_ESOFM | CNTR_RESETM) */ +#define IMR_MSK (CNTR_RESETM | CNTR_SOFM | CNTR_CTRM) /* Local types */ typedef enum _DEVICE_STATE { @@ -220,6 +221,7 @@ static const USER_STANDARD_REQUESTS My_User_Standard_Requests = { static DEVICE_INFO My_Device_Info; /* USB device status */ static volatile uint32_t bDeviceState = UNCONNECTED; +__IO uint8_t bIntPackSOF = 0; /** * Initialises USB interface diff --git a/flight/PiOS/pios.c b/flight/PiOS/pios.c index 532a0038a..e40676e97 100644 --- a/flight/PiOS/pios.c +++ b/flight/PiOS/pios.c @@ -44,6 +44,7 @@ static uint8_t sdcard_available; /* Function Prototypes */ static void TaskTick(void *pvParameters); +static void TaskHIDTest(void *pvParameters); static void TaskServos(void *pvParameters); static void TaskHooks(void *pvParameters); static void TaskSDCard(void *pvParameters); @@ -61,6 +62,8 @@ int main() /* Delay system */ PIOS_DELAY_Init(); + + /* SPI Init */ PIOS_SPI_Init(); @@ -101,34 +104,14 @@ int main() PIOS_USB_Init(0); - __IO uint8_t Send_Buffer[2]; - uint8_t count = 0; - - for(;;) - { - /* Report ID */ - Send_Buffer[0] = 0x07; - - /* Report Data */ - Send_Buffer[1] = count; - USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2); - - if(count >= 255) { - count = 0; - } else { - count++; - } - - PIOS_DELAY_WaitmS(50); - } - - //PIOS_COM_ReceiveCallbackInit(CONSOLE_Parse); + PIOS_COM_ReceiveCallbackInit(CONSOLE_Parse); /* Initialise OpenPilot application */ // OpenPilotInit(); /* Create a FreeRTOS task */ xTaskCreate(TaskTick, (signed portCHAR *)"Test", configMINIMAL_STACK_SIZE , NULL, 1, NULL); + xTaskCreate(TaskHIDTest, (signed portCHAR *)"HIDTest", configMINIMAL_STACK_SIZE , NULL, 4, NULL); //xTaskCreate(TaskServos, (signed portCHAR *)"Servos", configMINIMAL_STACK_SIZE , NULL, 4, NULL); //xTaskCreate(TaskHooks, (signed portCHAR *)"Hooks", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_HOOKS, NULL); //xTaskCreate(TaskSDCard, (signed portCHAR *)"SDCard", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 2), NULL); @@ -187,6 +170,35 @@ static void TaskTick(void *pvParameters) } } +static void TaskHIDTest(void *pvParameters) +{ + portTickType xDelay = 250 / portTICK_RATE_MS;; + + __IO uint8_t Send_Buffer[2]; + uint8_t count = 0; + + for(;;) + { + /* Report ID */ + Send_Buffer[0] = 0x07; + + /* Report Data */ + Send_Buffer[1] = count; + + /* Write the data to the pipe */ + USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2); + SetEPTxValid(ENDP1); + + if(count >= 255) { + count = 0; + } else { + count++; + } + + vTaskDelay(xDelay); + } +} + static void TaskServos(void *pvParameters) { /* For testing servo outputs */