This project was started with the idea of turning a USB device into a kind of IO Swiss-knife, so that many things could be done with a single program. The use-case was to implement a remote-control, first to read the durations, and next to write them back. I had success in the read, by adjusting for code-delays. (The writes require more accurate timings, and i wrote a separate app for that. See chaukasalshi.blogspot.in/2015/03/pic-micro-remote-for-tata-sky.html ) This project is based on Microchips Custom HID MLA project. Not all files are provided, only the main ones that were changed. The app_device_hid_custom.* files replaced with app_device_hid_io.*. Actually, i wanted to abstract the io routines into pin_io module, which would be independent of protocol, i.e USB/Serial/Other. And to create it as a standalone project with as few files as possible. Some such items are TODO, i may not get time to finish them. i have used the 18F4550 for this project. Probably, the project is quite primitive, considering the level of expertise on these forums, but i hope it may help somebody to begin.
The project files are available here : github.com/manojmo/pic_micro/tree/master/hid_io
Firing the IO commands :This is done using the pyusb framework. The hid_io_test.py file has the code to send the commands and receive the results. Just as a POC, the results can be saved to a .JS file, and viewed as a chart in mychart.html, using the Chart.js framework. That needs to be downloaded separately. The script also has a facility to adjust results, based on expected timing inaccuracies. For the sampling commands, num_samples are specified, and the script will calculate the number of packets and loop to receive them.
Common featuresThe framework is generic, and the commands accept input like which pin to use, what delay intervals, etc. (As a result, accurate timing is an issue. ). There is a debug feature that can return you the actual time taken for an interval. (not very exact) Routines are provided to measure and execute 2^24 cycle delays. Timings can be specified in uS or mS. There are flags for each command, to provide additional control. All sampling commands also specify an IDLE state/value, and sampling does to start until the input changes from the IDLE state/value. This is useful for manually-triggered sampling, like reading from a remote.
The commands are