Driver for USB IO kit startedBy Chris Williams. Published: 7th Mar 2006, 23:40:09 | Permalink | Printable
Plus coping with two USB stacksA draft version of a driver for a USB based hardware interface board has been produced for the Castle stack. Dave Higton was offered a Velleman IO kit as a challenge by a colleague to produce a suitable driver for. Earlier this week Dave asked for interested RISC OS using electronics enthusiasts to contact him for a copy of the software.
The kit is available from outlets such as Maplin, and is designed to control external devices and instruments from a computer. It features five digital inputs, two analogue inputs, eight digital outputs, and two analogue outputs.
Engineer Dave said: "I have managed to get it to work. But it's not finished yet."
Dave added it should be a straight forward process to produce a version of the driver software for the Simtec USB stack. Up to four units can be used at once on one computer; the limit being due to the way the boards uniquely identify themselves to the host machine.
He explained: "What I have written is a demo programme: click the icons, and watch the digital outputs go on and off - they have LEDs. For a real application, you'd want something different.
"The point of asking people with an interest to contact me is that I may be able to provide information that will help them write their applications.
"The inputs and outputs are quite standard interface levels, except that the digital outputs are from a ULN2803A, which means they are open collector Darlington outputs capable of controlling up to 50V and several hundred milliamps."
Previously, Dave produced a driver for a USB radio and controlled his central heating from an A3010.
Writing software for both USB standards
He has created USB driver software for both the Castle and Simtec stacks, which are software incompatible with each other.
Dave said: "Initialising the USB pipes is entirely different in the two stacks; the Castle one is far easier and less lines of code. The Simtec stack is not well documented in terms of examples, or in terms of a recipe of steps to go through to open, use and close a pipe."
A pipe in this case is a communications channel between the USB stack and a particular piece of functionality in the USB device, along which data and messages are exchanged. Dave also identified a fault in the Castle USB stack which made it impossible to create a pipe to a particular type of device functionality, known as an interrupt mode output endpoint. This was eventually fixed in RISC OS 5.11 allowing Dave to finish his USB radio driver.
He continued: "Sending a USB message is different in the two stacks, but the difficulty is handled by different procedures of the same name and same specification. Sending data isn't hard. Lack of documentation was an issue in both cases, though trial and error was easier with the Castle stack because it deals with streams, very much like file handling, so there aren't many options to try. Much the same comments apply to receiving data."
When a program finishes, it must release the USB related resources which it may have acquired from RISC OS. Dave also found a bug in the Castle stack which causes resources to be wasted when the USB radio is unplugged while the relevant software is still running; repeating this a couple of hundred times would result in the USB system running out of 'handles' - identification numbers attached to acquired resources - which would lead to further problems until the machine is restarted.
Dave continued: "The Simtec USB HID Input module grabs the radio and won't let go, so it is currently not possible to use this application along with a USB keyboard or mouse, for example. However, Matt Edgar at STD tells me that this is being worked on. It wouldn't surprise me if there is a new Snafu [firmware] release in the near future."
Previous: Middleton battles 'misinformation'
Next: BBC Micro ARM7 co-processor available
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
'Why we love drag and drop on RISC OS'
Users not taking the ROS desktop for granted
12 comments, latest by JGZimmerle on 8/8/06 3:56PM. Published: 6 Aug 2006
Beta Castle C compiler released
Second round of beta testing, subscriptions nearing end
1 comment, latest by TonyStill on 24/4/06 10:32PM. Published: 24 Apr 2006
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •