Dear freind,
i want to develop application to read adc value from stm32 kit to pc through usb.
for that i have transfer more bytes from kit to pc.
i have been using STM32_USBHID on kit side and HID_Client on host side.
also the application note below giving example to send more bytes from pc to kit.
http://www.keil.com/appnotes/docs/apnt_195.asp
my need is vice versa. to transfer 8/16/32/64 bytes from kit to pc instead of byte.
so please help me by providing sample application code to transfer more bytes from kit to pc
with regards
S.Venugopal
There is no difference between STM32 and NXP LPC families for the KEIL USB stack code, except for the handlers which directly touch to the USB engine. Then, you can apply many forum posts on LPC to STM32, too.
This post fits to your request, for the firmware side.
LPC2148 usb controller http://www.keil.com/forum/docs/thread11137.asp 13-Nov-2007 15:23 GMT, posted by Tsuneo Chinzei
Tsuneo
Dear Tsuneo Chinzei
i'd modified as per your instruction in the following to send more bytes from kit to pc (for example 2bytes). After finishing and downloading on frontend vcc++ client application 1.we can able to select the Device 2.The name of the device string is displayed
after that all boxes in the False state. no value is printed on IDC_INPUT edit box.
if you can provide me your mail id i'd forward my code. only my necessity is to print 16bit value instead of 8bit in the input buttons box.
expecting your kind reply. below shown is modification. *********************************************** in demo.c
BYTE InReport[INREPORT_SIZE];
void GetInReport (void) { InReport[1] = 0x55; InReport[0] = 0xaa;
} *********************************************** in demo.h
#define INREPORT_SIZE 64 extern BYTE InReport[INREPORT_SIZE]; *********************************************** in usbuser.c
#if USB_CONFIGURE_EVENT void USB_Configure_Event (void) {
if (USB_Configuration){/* Check if USB is configured */ GetInReport(); //USB_WriteEP(0x81, &InReport, sizeof(InReport)); USB_WriteEP(0x81, &InReport[0], sizeof(InReport)); } } #endif
void USB_EndPoint1 (DWORD event) { GetInReport(); // USB_WriteEP(0x81, &InReport, sizeof(InReport)); USB_WriteEP(0x81, &InReport[0], sizeof(InReport)); } *********************************************** in hiduser.c
BOOL HID_GetReport (void) {
/* ReportID = SetupPacket.wValue.WB.L; */ switch (SetupPacket.wValue.WB.H) { case HID_REPORT_INPUT: GetInReport(); EP0Buf[0] = InReport[0]; //*************** EP0Buf[1] = InReport[1]; //**************** break; case HID_REPORT_OUTPUT: return (FALSE); /* Not Supported */ case HID_REPORT_FEATURE: /* EP0Buf[] = ...; */ /* break; */ return (FALSE); /* Not Supported */ } return (TRUE); } **************************************************** in hiddesc.c
/* HID Report Descriptor */ const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(2), HID_LogicalMin(0), HID_LogicalMax(0xff), // HID_ReportCount(8), // HID_ReportSize(2), HID_ReportCount(8), HID_ReportSize(INREPORT_SIZE), HID_Input(HID_Data | HID_Variable | HID_Absolute), // HID_ReportCount(1), // HID_ReportSize(6), // HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(8), HID_ReportSize(1), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, };
in usb configuration /* USB Configuration Descriptor */
const BYTE USB_ConfigDescriptor[] =
// WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ *******************************************************in the HID_Client VC++ program in the HIDClientDlg.cpp
void CHIDClientDlg::OnInput() { // int n; int x,y; char buf[16];
x = InReport[1]; x = (x << 8); y = InReport[2]; x = x | y ; // if (InValue == InReport[1]) return;
// if (z == x) return; // z = x; // InValue = InReport[1];
// for (n = 0; n < 8; n++) { // m_Input[n].SetCheck((InValue & (1 << n)) ? 1 : 0); // } // sprintf(buf, "%04d", InValue); sprintf(buf, "%05x",x);
m_In.SetWindowText(buf); } *******************************************************
Can you, please, tell use why you think anyone would care to read your code, if you can't even read the instructions, and format it as code? Does it look readable to you?
The instructions on how to post code are clearly visibile just above the message input box.
Dear Mr.WesterMark
sorry. i'm new to the forum. so that i'd noticed the formating.
i'd modified as per your instruction in the following to send more bytes from kit to pc (for example 2 bytes)
//******************************************* //in demo.c BYTE InReport[INREPORT_SIZE]; void GetInReport (void) { InReport[1] = 0x55; InReport[0] = 0xaa; } //******************************************* //in demo.h #define INREPORT_SIZE 64 extern BYTE InReport[INREPORT_SIZE]; //******************************************* //in usbuser.c #if USB_CONFIGURE_EVENT void USB_Configure_Event (void) { if (USB_Configuration){/*Check if USB is configured*/ GetInReport(); //USB_WriteEP(0x81, &InReport, sizeof(InReport)); USB_WriteEP(0x81, &InReport[0], sizeof(InReport)); } } #endif void USB_EndPoint1 (DWORD event) { GetInReport(); // USB_WriteEP(0x81, &InReport, sizeof(InReport)); USB_WriteEP(0x81, &InReport[0], sizeof(InReport)); } //******************************************* //in hiduser.c BOOL HID_GetReport (void) { /* ReportID = SetupPacket.wValue.WB.L; */ switch (SetupPacket.wValue.WB.H) { case HID_REPORT_INPUT: GetInReport(); EP0Buf[0] = InReport[0]; //********** EP0Buf[1] = InReport[1]; //********** break; case HID_REPORT_OUTPUT: return (FALSE); /* Not Supported */ case HID_REPORT_FEATURE: /* EP0Buf[] = ...; */ /* break; */ return (FALSE); /* Not Supported */ } return (TRUE); } //******************************************* //in hiddesc.c /* HID Report Descriptor */ const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(2), HID_LogicalMin(0), HID_LogicalMax(0xff), // HID_ReportCount(8), // HID_ReportSize(2), HID_ReportCount(8), HID_ReportSize(INREPORT_SIZE), HID_Input(HID_Data | HID_Variable | HID_Absolute), // HID_ReportCount(1), // HID_ReportSize(6), // HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(8), HID_ReportSize(1), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, }; //in usb configuration //USB Configuration Descriptor const BYTE USB_ConfigDescriptor[] = // WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ //******************************************* //in the HID_Client VC++ program in the HIDClientDlg.cpp void CHIDClientDlg::OnInput() { // int n; int x,y; char buf[16]; x = InReport[1]; x = (x << 8); y = InReport[2]; x = x | y ; // if (InValue == InReport[1]) return; // if (z == x) return; // z = x; // InValue = InReport[1]; // for (n = 0; n < 8; n++) { // m_Input[n].SetCheck((InValue & (1 << n)) ? 1 : 0); // } // sprintf(buf, "%04d", InValue); sprintf(buf, "%05x",x); m_In.SetWindowText(buf); } //*******************************************
.
if you intend to send 2 bytes, why doesn't your report size reflect that?
HID_ReportSize(1),
hi Tamir Michael,
i'd modified the hid report size to 64 through Inreport size. it highlighted in Bold
/* HID Report Descriptor */ const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(2), HID_LogicalMin(0), HID_LogicalMax(0xff), // HID_ReportCount(8), // HID_ReportSize(2), HID_ReportCount(8), HID_ReportSize(INREPORT_SIZE), HID_Input(HID_Data | HID_Variable | HID_Absolute),
only the output(Led indication) is 1 byte.