Still / back to poking at Kinetis SDK 2.2, and the USB device protocol stack.
Doesn't help that MCUXpresso doesn't (yet) support configuring devices, selecting optional SDK features (like the USB stack) to be incorporated into projects, configuring USB descriptors, and crud like that.
Also doesn't help that the USB demo projects are all for bare metal (I need FreeRTOS), drag along their own copies of the USB stack (of uncertain vintage), and generally are not so exemplary.
But! Today I managed to get the mouse-lite demo running with FreeRTOS, in a freshly-created project, using the current version of the USB stack. So now I have a starting point that isn't dragging along too much code in support of device classes that NXP supports but I'm not using.
Yet to be done: much. I guess the next thing is to replace the HID-mouse descriptors with TMC descriptors, adding the appropriate sorts of endpoints, and figure out what connects to the endpoints and where I intercept class-level activity on endpoint 0 and process the things required for TMC.
A certain amount of study and meditation is called for.
... just about to embark on the mysteries of the fuel injection system.
Update: By late evening, I have it being recognized by the usbtmc
kernel driver, including a proper response to the class-specific GET CAPABILITIES
request, and - finally! - receiving data from the host on the Bulk Out endpoint.
So now I need to do a bunch of structuring: shoving received data into a queue so a command-processing task can deal with it; buffering up responses; dealing with the pesky TMC message headers; setting things up so that the response data gets sent to the Bulk In endpoint; putting in application hooks for all the extra fiddly functions; hooking it up to my SCPI parser (which will probably need some restructuring); doing something or other with the Interrupt In endpoint (said something presumably being in accordance with the USBTMC-USB488 specs); ....
But none of this is mysterious. Implementing my own class driver (of sorts) with this USB stack was mysterious. The rest is pretty much routine, though a certain amount of architectural ponderment at this stage may save a lot of headaches later on.
And I still need to change the way the SCPI command tables are built. I should have a Ruby script search through the C source files for magic comments containing XML, extract the XML, merge, and then spit out a properly structured table as a new C source file.
Comments