diff --git a/bia_microddr_hid_rpt_desc.hid b/bia_microddr_hid_rpt_desc.hid new file mode 100644 index 0000000..06dd6e0 Binary files /dev/null and b/bia_microddr_hid_rpt_desc.hid differ diff --git a/firmware/bia_microddr.X/nbproject/configurations.xml b/firmware/bia_microddr.X/nbproject/configurations.xml index f9e76d4..a550ba9 100644 --- a/firmware/bia_microddr.X/nbproject/configurations.xml +++ b/firmware/bia_microddr.X/nbproject/configurations.xml @@ -78,6 +78,7 @@ + ../../bootloader/bia_microddr_bootloader.X/dist/default/production/bia_microddr_bootloader.X.production.hex false false @@ -224,6 +225,7 @@ value="Press to browse for a specific firmware version"/> + diff --git a/firmware/src/dancepad.c b/firmware/src/dancepad.c index 654ab34..8396e69 100644 --- a/firmware/src/dancepad.c +++ b/firmware/src/dancepad.c @@ -65,20 +65,29 @@ typedef union _INTPUT_CONTROLS_TYPEDEF } INPUT_CONTROLS; // USB data must exist within the USB RAM memory space +uint8_t joystick_output[64] __at(0x500); INPUT_CONTROLS joystick_input __at(0x600); // handle to the last data transmission - allows us to check if it completed USB_VOLATILE USB_HANDLE lastTransmission = 0; +USB_VOLATILE USB_HANDLE lastReceived = 0; void DANCEPAD_Initialize() { lastTransmission = 0; //enable the HID endpoint - USBEnableEndpoint(JOYSTICK_EP, USB_IN_ENABLED | USB_HANDSHAKE_ENABLED | USB_DISALLOW_SETUP); + USBEnableEndpoint(JOYSTICK_EP, USB_IN_ENABLED | USB_OUT_ENABLED | USB_HANDSHAKE_ENABLED | USB_DISALLOW_SETUP); + + lastReceived = HIDRxPacket(JOYSTICK_EP,&(joystick_output[0]),64); } void DANCEPAD_Tasks() { + if (!HIDRxHandleBusy(lastReceived)) + { + lastReceived = HIDRxPacket(JOYSTICK_EP,&(joystick_output[0]),64); + } + // do not start another transmission if the previous one isn't completed if(HIDTxHandleBusy(lastTransmission)) return; diff --git a/firmware/src/usb_config.h b/firmware/src/usb_config.h index a142ff0..5f803d2 100644 --- a/firmware/src/usb_config.h +++ b/firmware/src/usb_config.h @@ -170,7 +170,8 @@ #define HID_INT_OUT_EP_SIZE 64 #define HID_INT_IN_EP_SIZE 64 #define HID_NUM_OF_DSC 1 -#define HID_RPT01_SIZE 74 +//#define HID_RPT01_SIZE 74 +#define HID_RPT01_SIZE 54 /** DEFINITIONS ****************************************************/ diff --git a/firmware/src/usb_descriptors.c b/firmware/src/usb_descriptors.c index 8b70368..0ab4413 100644 --- a/firmware/src/usb_descriptors.c +++ b/firmware/src/usb_descriptors.c @@ -170,7 +170,7 @@ const uint8_t configDescriptor1[]={ /* Configuration Descriptor */ 0x09,//sizeof(USB_CFG_DSC), // Size of this descriptor in bytes USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type - DESC_CONFIG_WORD(0x0022), // Total length of data for this cfg + DESC_CONFIG_WORD(0x0029), // Total length of data for this cfg 1, // Number of interfaces in this cfg 1, // Index value of this configuration 0, // Configuration string index @@ -204,6 +204,14 @@ const uint8_t configDescriptor1[]={ _INTERRUPT, //Attributes DESC_CONFIG_WORD(64), //size 0x01, //Interval + + /* Endpoint Descriptor */ + 0x07,/*sizeof(USB_EP_DSC)*/ + USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor + JOYSTICK_EP | _EP_OUT, //EndpointAddress + _INTERRUPT, //Attributes + DESC_CONFIG_WORD(64), //size + 0x01, //Interval }; @@ -238,7 +246,34 @@ const uint8_t *const USB_SD_Ptr[]= }; const struct{uint8_t report[HID_RPT01_SIZE];}hid_rpt01={{ - 0x05,0x01, //USAGE_PAGE (Generic Desktop) + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x05, // USAGE (Game Pad) + 0xa1, 0x01, // COLLECTION (Application) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x35, 0x00, // PHYSICAL_MINIMUM (0) + 0x45, 0x01, // PHYSICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x06, // REPORT_COUNT (6) + 0x05, 0x09, // USAGE_PAGE (Button) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, 0x06, // USAGE_MAXIMUM (Button 6) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x02, // REPORT_COUNT (2) + 0x81, 0x01, // INPUT (Cnst,Ary,Abs) + 0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1) + 0x09, 0x01, // USAGE (Vendor Usage 1) + 0xa1, 0x01, // COLLECTION (Application) + 0x19, 0x01, // USAGE_MINIMUM (Vendor Usage 1) + 0x29, 0x40, // USAGE_MAXIMUM (Vendor Usage 2) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x40, // REPORT_COUNT (1) + 0x91, 0x00, // OUTPUT (Data,Ary,Abs) + 0xc0, // END_COLLECTION + 0xc0 // + /*0x05,0x01, //USAGE_PAGE (Generic Desktop) 0x09,0x05, //USAGE (Game Pad) 0xA1,0x01, //COLLECTION (Application) 0x15,0x00, // LOGICAL_MINIMUM(0) @@ -273,7 +308,7 @@ const struct{uint8_t report[HID_RPT01_SIZE];}hid_rpt01={{ 0x75,0x08, // REPORT_SIZE(8) 0x95,0x04, // REPORT_COUNT(4) 0x81,0x02, // INPUT(Data,Var,Abs) - 0xC0 //END_COLLECTION + 0xC0*/ //END_COLLECTION } }; /** EOF usb_descriptors.c ***************************************************/