Hi Dean!
I've been busy with the Keyglove code for a while making many changes
and improvements (which I've just pushed to the repository), which is
why it's taken me the better part of two weeks to reply.
> 1) Try to use the C99 types (uint8_t, uint32_t, int32_t, etc.) where
> possible. Not only does this make your code more portable/readable in
> the long term, it will also reduce the code size usage and prevent
> some subtle bugs. Those "long" counter variables you have will be
> signed 32-bit integers on the AVR8 chips, which are quite inefficient.
I've applied your first suggestion (about C99) types to both the demo
code and my whole project for consistency--thanks! I was until now
unfamiliar with the C99 type set, at least in practice. I'm sure I'd
seen them before, but I never paid attention and never learned them.
> Great work! Unfortunately I'm trying to retain the copyrights to the
> LUFA demos where I can now as a matter of policy (to keep my options
> open regarding relicencing, etc. in the future) but I'd be more than
> happy to add it to the LUFA Projects/ directory for you, where third
> party demos and project sit.
>
> ...
>
> 3) Don't forget to add your name to the copyright header before I put
> it in!
As for this, it's fine with me if you just keep the whole demo code
and all possible copyrights. I've made some slight modifications
(which I intended to do before I posted it anyway), and my name is now
entirely gone from that bit of code. It's just a demo, exactly like
the other demos, and honestly I'd rather have it be entirely yours so
you can modify/fix it however you like. Unless you really, really
don't want it, it's 100% yours. That's the least I can do to help such
a great project.
> 2) I suggest you alter the report decision selection code so that the
> report sent is selected based on which report was last send (i.e.
> switch between then in the HID task each time a report is sent). This
> will give even bandwidth between then, and will tighten the code a
> little. That way your main routine just switches between sending a
> serial string and sending a HID report.
This is an interesting concept which I don't think I fully understand
yet (especially in the much larger Keyglove project, let alone the
Demo code). One of the things I'm trying to do with the Keyglove code
is to make it as efficient as possible (duh). In light of this, is it
possible to let the USB use some kind of interrupt/event-driven
communication such that I don't have to call the CDC_Task() and
HID_Task() functions all the time when there isn't something specific
to send? I know the HID interface can receive keyboard LED reports
back from the host, and the CDC interface obviously receives serial
data from the host; neither of these events will come at predictable
times, so they have to be handled by either polling or interrupts on
the device side.
I see the HID functionality in what appears to be an interrupt/event-
driven bit of code inside the EVENT_USB_Device_ControlRequest
function. If this is called and processed automatically by the USB
library code as needed, would it therefore be safe to take HID_Task()
out of the main loop, since it's called specifically in other places
in the code right at the moment any given kb/mouse/joystick HID report
should be sent?
And, if so, is the same kind of functionality available for handling
CDC tasks?
Any pointers would be great. Actually, come to think of it, pointers
can be confusing sometimes. Maybe stick with a solution that doesn't
involve pointers. (kidding) And if there's some documentation or
discussion about this topic already, please feel free to direct me
there instead of explaining something again.
Thanks!
Jeff