- Posts: 84
USB HID on modular builds
- IMback!
- Topic Author
- Offline
On modular builds (devo7e) USB HID dosent work, as expected, but I think we should hide the USB HID protocol in the menu, because its misleading and the error mesage (no /worng protocoll module) falsly suggests user error
Please Log in or Create an account to join the conversation.
- FDR
- Offline
AFAIK it should work...
Please Log in or Create an account to join the conversation.
- SadSack
- Offline
- Posts: 317
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
see:
ifdef MODULAR
PROTO_EXTRA_C = $(wildcard target/common_devo/protocol/*.c)
else
SRC_C += $(wildcard target/common_devo/protocol/*.c) \
$(wildcard target/common_devo/hid/*.c)
endif
and protocol/Makefile.inc dosent contain a rule for a USBHID module
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
Ill give it a spin immidiatly
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
Please Log in or Create an account to join the conversation.
- FDR
- Offline
When you are in USB mode, pressing the ENT button turns it off...
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
here is the errors.txt
and elfs
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Unfortunately I found this comment I left there:
//HID is too big for the devo7e, and building as a module will be tricky
I'll look at it a bit more. If the USB stack can be fit in 4kb, it is still possible we can enable it.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Note that you'll get some compile warnings. This is not ready to be incorporated in to a production build, it is just a proof of concept.
diff -r 6cec02426da6 src/protocol/usbhid.c
--- a/src/protocol/usbhid.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/protocol/usbhid.c Sun Dec 01 11:59:07 2013 -0800
@@ -65,12 +65,13 @@
return 50000;
}
+extern void HID_Enable();
static void initialize()
{
CLOCK_StopTimer();
num_channels = Model.num_channels;
PrevXferComplete = 1;
- USB_Enable(1, 1);
+ HID_Enable();
CLOCK_StartTimer(1000, usbhid_cb);
}
diff -r 6cec02426da6 src/target/common_devo/hid/hid_devo.c
--- a/src/target/common_devo/hid/hid_devo.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_devo.c Sun Dec 01 11:59:07 2013 -0800
@@ -14,11 +14,10 @@
*/
#ifdef MODULAR
- //Allows the linker to properly relocate
- #define DEVO_Cmds PROTO_Cmds
#pragma long_calls
//This is otherwise included in the main binary
#include "usb_regs.c"
+ #include <string.h>
#endif
#include "usb_lib.h"
@@ -34,3 +33,23 @@
USB_SIL_Write(EP1_IN, (u8 *)packet, num_channels);
SetEPTxValid(ENDP1);
}
+
+extern void (*pEpInt_IN[7])(void);
+extern void (*pEpInt_OUT[7])(void);
+extern void (*HID_pEpInt_IN[7])(void);
+extern void (*HID_pEpInt_OUT[7])(void);
+extern DEVICE_PROP HID_Device_Property;
+extern USER_STANDARD_REQUESTS HID_User_Standard_Requests;
+extern void USB_Enable(u8 type, u8 use_interrupt);
+void ModuleHID_Init() {
+ memcpy(pEpInt_IN, HID_pEpInt_IN, sizeof(pEpInt_IN));
+ memcpy(pEpInt_OUT, HID_pEpInt_OUT, sizeof(pEpInt_OUT));
+ Device_Property = &HID_Device_Property;
+ User_Standard_Requests = &HID_User_Standard_Requests;
+}
+
+extern void (*_HID_Init)();
+void HID_Enable() {
+ _HID_Init = ModuleHID_Init;
+ USB_Enable(1, 1);
+}
diff -r 6cec02426da6 src/target/common_devo/hid/hid_usb_desc.c
--- a/src/target/common_devo/hid/hid_usb_desc.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_usb_desc.c Sun Dec 01 11:59:07 2013 -0800
@@ -13,6 +13,9 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
+#ifdef MODULAR
+ #pragma long_calls
+#endif
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "hid_usb_desc.h"
@@ -160,7 +163,7 @@
'o', 0, 'n', 0, ' ', 0, 'G', 0, 'a', 0, 'm', 0, 'e', 0,
'P', 0, 'a', 0, 'd', 0
};
-uint8_t Joystick_StringSerial[JOYSTICK_SIZ_STRING_SERIAL] =
+const uint8_t Joystick_StringSerial[JOYSTICK_SIZ_STRING_SERIAL] =
{
JOYSTICK_SIZ_STRING_SERIAL, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
diff -r 6cec02426da6 src/target/common_devo/hid/hid_usb_desc.h
--- a/src/target/common_devo/hid/hid_usb_desc.h Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_usb_desc.h Sun Dec 01 11:59:07 2013 -0800
@@ -49,7 +49,7 @@
extern const uint8_t Joystick_StringLangID[JOYSTICK_SIZ_STRING_LANGID];
extern const uint8_t Joystick_StringVendor[JOYSTICK_SIZ_STRING_VENDOR];
extern const uint8_t Joystick_StringProduct[JOYSTICK_SIZ_STRING_PRODUCT];
-extern uint8_t Joystick_StringSerial[JOYSTICK_SIZ_STRING_SERIAL];
+extern const uint8_t Joystick_StringSerial[JOYSTICK_SIZ_STRING_SERIAL];
#endif /* __USB_DESC_H */
diff -r 6cec02426da6 src/target/common_devo/hid/hid_usb_endp.c
--- a/src/target/common_devo/hid/hid_usb_endp.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_usb_endp.c Sun Dec 01 11:59:07 2013 -0800
@@ -13,6 +13,9 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
+#ifdef MODULAR
+ #pragma long_calls
+#endif
/* Includes ------------------------------------------------------------------*/
#ifdef STM32L1XX_MD
#include "stm32l1xx.h"
diff -r 6cec02426da6 src/target/common_devo/hid/hid_usb_istr.c
--- a/src/target/common_devo/hid/hid_usb_istr.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_usb_istr.c Sun Dec 01 11:59:07 2013 -0800
@@ -13,6 +13,10 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
+#ifdef MODULAR
+ #pragma long_calls
+#endif
+
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "hid_usb_prop.h"
@@ -29,7 +33,7 @@
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* function pointers to non-control endpoints service routines */
-void (*HID_pEpInt_IN[7])(void) =
+void (* const HID_pEpInt_IN[7])(void) =
{
HID_EP1_IN_Callback,
HID_EP2_IN_Callback,
@@ -40,7 +44,7 @@
HID_EP7_IN_Callback,
};
-void (*HID_pEpInt_OUT[7])(void) =
+void (* const HID_pEpInt_OUT[7])(void) =
{
HID_EP1_OUT_Callback,
HID_EP2_OUT_Callback,
diff -r 6cec02426da6 src/target/common_devo/hid/hid_usb_prop.c
--- a/src/target/common_devo/hid/hid_usb_prop.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/hid/hid_usb_prop.c Sun Dec 01 11:59:07 2013 -0800
@@ -13,6 +13,10 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
+#ifdef MODULAR
+ #pragma long_calls
+#endif
+
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "hid_usb_conf.h"
@@ -38,7 +42,7 @@
1
};
*/
-DEVICE_PROP HID_Device_Property =
+const DEVICE_PROP HID_Device_Property =
{
Joystick_init,
Joystick_Reset,
@@ -53,7 +57,7 @@
0,
0x40 /*MAX PACKET SIZE*/
};
-USER_STANDARD_REQUESTS HID_User_Standard_Requests =
+const USER_STANDARD_REQUESTS HID_User_Standard_Requests =
{
Joystick_GetConfiguration,
Joystick_SetConfiguration,
@@ -66,31 +70,31 @@
Joystick_SetDeviceAddress
};
-ONE_DESCRIPTOR HID_Device_Descriptor =
+const ONE_DESCRIPTOR HID_Device_Descriptor =
{
(uint8_t*)Joystick_DeviceDescriptor,
JOYSTICK_SIZ_DEVICE_DESC
};
-ONE_DESCRIPTOR HID_Config_Descriptor =
+const ONE_DESCRIPTOR HID_Config_Descriptor =
{
(uint8_t*)Joystick_ConfigDescriptor,
JOYSTICK_SIZ_CONFIG_DESC
};
-ONE_DESCRIPTOR Joystick_Report_Descriptor =
+const ONE_DESCRIPTOR Joystick_Report_Descriptor =
{
(uint8_t *)Joystick_ReportDescriptor,
JOYSTICK_SIZ_REPORT_DESC
};
-ONE_DESCRIPTOR Mouse_Hid_Descriptor =
+const ONE_DESCRIPTOR Mouse_Hid_Descriptor =
{
(uint8_t*)Joystick_ConfigDescriptor + JOYSTICK_OFF_HID_DESC,
JOYSTICK_SIZ_HID_DESC
};
-ONE_DESCRIPTOR HID_String_Descriptor[4] =
+const ONE_DESCRIPTOR HID_String_Descriptor[4] =
{
{(uint8_t*)Joystick_StringLangID, JOYSTICK_SIZ_STRING_LANGID},
{(uint8_t*)Joystick_StringVendor, JOYSTICK_SIZ_STRING_VENDOR},
diff -r 6cec02426da6 src/target/common_devo/msc2/usb_devo8.c
--- a/src/target/common_devo/msc2/usb_devo8.c Sun Dec 01 08:31:07 2013 -0800
+++ b/src/target/common_devo/msc2/usb_devo8.c Sun Dec 01 11:59:07 2013 -0800
@@ -61,22 +61,28 @@
User_Standard_Requests = &MSC_User_Standard_Requests;
}
+#ifdef MODULAR
+void (*_HID_Init)();
+#endif
void HID_Init() {
-#ifndef MODULAR
- //HID is too big for the devo7e, and building as a module will be tricky
memcpy(pEpInt_IN, HID_pEpInt_IN, sizeof(pEpInt_IN));
memcpy(pEpInt_OUT, HID_pEpInt_OUT, sizeof(pEpInt_OUT));
Device_Property = &HID_Device_Property;
User_Standard_Requests = &HID_User_Standard_Requests;
-#endif
}
+
void USB_Enable(u8 type, u8 use_interrupt)
{
if (type == 0) {
//Mass Storage
MSC_Init();
} else if (type == 1) {
+#ifndef MODULAR
HID_Init();
+#else
+ if(_HID_Init)
+ _HID_Init();
+#endif
}
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO10);
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
EDIT: nevermind my error
im out of time today anyways
Please Log in or Create an account to join the conversation.
- IMback!
- Topic Author
- Offline
- Posts: 84
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- victzh
- Offline
- Posts: 1386
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- victzh
- Offline
- Posts: 1386
It seems I figured why it did not work with your patch - you changed the name of the module to suit the module system requirement - removed space, so my old model did not work and I did not pay enough attention to figure it out. This time I was sure I'm doing something wrong, so I looked more thoroughly.
Please Log in or Create an account to join the conversation.
- Home
- Forum
- News, Announcements and Feedback
- Feedback & Questions
- USB HID on modular builds