XMega32a4u USB HID interface

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, we are using the XMega32a4u to develep a USB CDC interface. This seems to work well, but the customer now wants a HID interface

 

So far, we have tested the ASF HID generic sample code and it works well. The computer program can detect the device, and turn it off by sending some reports.

 

What we cannot do yet is to read and write data. There is an app note AVR4905 but it is little light on detail: http://www.atmel.com/Images/doc8...

 

Any help would be much appreciated.

 

Here are the PC routines we have available but we have only used findHidDevice and setFeature so far.

 

function  findHidDevice(VendorID,ProductID: LongWord ): Boolean; STDCALL;
procedure  closeDevice STDCALL;
function  writeData(Buf : PChar ): Boolean;  STDCALL;
function  readData(Buf : PChar ): Boolean; STDCALL;
function  hidRegisterDeviceNotification(hWnd : THandle ): Integer; STDCALL;
procedure  hidUnregisterDeviceNotification(hWnd : THandle ); STDCALL;
function  isMyDeviceNotification(dwData:longword): Integer; STDCALL;
function  setFeature(Buf : PChar ): Boolean; STDCALL;
function  getFeatureReportLength: Integer; STDCALL;
function  getOutputReportLength: Integer; STDCALL;

 

Electronic System Design
http://www.esdn.com.au

Last Edited: Fri. Aug 18, 2017 - 03:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We will need some more detail.

 

Have a look at this: https://github.com/kuro68k/kboot...

 

There is a host app for talking to it as well in that repo. I am using the control interface for commands and the report read/write interface for data. It makes it easier to separate commands and data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great, thanks. With the host pc app, there seems to be no exe file. Does that mean it is necessary to install and run Visual Studio?

 

I tried to run the xmega hid bootloader but it does not run for the Xmega32a4u for some reason. Looks like no interrupt vectors. Thanks anyway for the tip - will look at this again next week.

Electronic System Design
http://www.esdn.com.au

Last Edited: Mon. Aug 21, 2017 - 02:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, I didn't post any binaries. I can do that on Monday if you like. It's not extensively tested though.

 

What compiler do you use? My goal is to get it building on Linux anyway so if I can make modifications to handle that I'd like to do it.

 

You will need to change the build options for the 32a4u to locate the .text section in the bootloader area. It's set up for 128k devices.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, I have made a lot of progress today.  I now have the Write_Data and Read_Data subroutines working but putting breakpoints on the hid_report_in and hid_report_out routines. I changed the report length from 8 to 64 in the example and it still works OK. The Set Feature works the same way as Write Data but writes the feature data to a different memory location.

 

I am not sure what or how the isMyDeviceNotification works but will look into this.

 

Also, the AThidusb.dll seems to be missing two routines, the getReportInLength and getSetFeatureLength. I will see if these can be accessed. 

 

Will also look at the HID bootloader again soon. Thanks

Electronic System Design
http://www.esdn.com.au