Arduino Due as USB HID device (Native USB port)

Hello!

I'd like to implement such a example with AFS: Arduino Due (SAM3x8e) as USB HID device with 1 USB interface and 4 endpoints (1 control + 2 interrupt in + 1 interrupt out). Each interrupt_in endpoint has its own callback. If data is received at interrupt_in_1, toggle led 1, else toggle led 2. I cannot get how to do it using ASF.

Could you please help me with the questions I cannot answer myself using manuals from Atmel?

  1. Should we modify USB interrupt handler directly?

  2. How can we get what did trigger USB interrupt? According to SAM3x datasheet there are many interrupt sources, but only one general flag is set. After getting a USB interrupt we should check different registers to get the exact source. Is there a way to do that using ASF, without register magic?

  3. What are predefined callbacks? In manuals there are UDI callbacks for connect/disconnect and for power management. I cannot find data sent/data received callbacks and cannot get how to write and register them.

  4. Is it adequate to use different endpoints for different effectors? I.e. I have 2 step motors and want interrupt callback to be as fast as possible. Is it better to give the motors a "personal" endpoint each, or have a single endpoint at price of a bit harder report_out parsing?

  5. May be it is better to switch from ASF to something different? Are there something LUFA port for SAM?

  6. What is the best way to communicate with the device? LibUSB or something different?

Best,
Gryph

Those are pretty advanced questions. I've never been that deep into the USB functions myself so my answers may not be entirely useful.

  1. Probably. While you don't normally expect to modify library functions, the Arduino system is all open-source so you can modify stuff if you find a need for it.

  2. The register magic should be encapsulated in macros. You should see examples in other code where a macro is used to test for a specific bit in the register, using the name of the bit specified in the datasheet. That way all of your code is using names for the bits and it will be portable to other processors from the same family, even though it's not portable across families.

        1. Don't know.

Gryphon88:
Hello!

I'd like to implement such a example with AFS: Arduino Due (SAM3x8e) as USB HID device with 1 USB interface and 4 endpoints (1 control + 2 interrupt in + 1 interrupt out). Each interrupt_in endpoint has its own callback. If data is received at interrupt_in_1, toggle led 1, else toggle led 2. I cannot get how to do it using ASF.

Could you please help me with the questions I cannot answer myself using manuals from Atmel?

  1. Should we modify USB interrupt handler directly?

  2. How can we get what did trigger USB interrupt? According to SAM3x datasheet there are many interrupt sources, but only one general flag is set. After getting a USB interrupt we should check different registers to get the exact source. Is there a way to do that using ASF, without register magic?

  3. What are predefined callbacks? In manuals there are UDI callbacks for connect/disconnect and for power management. I cannot find data sent/data received callbacks and cannot get how to write and register them.

  4. Is it adequate to use different endpoints for different effectors? I.e. I have 2 step motors and want interrupt callback to be as fast as possible. Is it better to give the motors a "personal" endpoint each, or have a single endpoint at price of a bit harder report_out parsing?

  5. May be it is better to switch from ASF to something different? Are there something LUFA port for SAM?

  6. What is the best way to communicate with the device? LibUSB or something different?

Best,
Gryph

Please read your PM