Archive for December, 2007

I am DONE

Tuesday, December 18th, 2007

Finally! I’ve graduated with my Bachelor’s Degree in Computer Engineering from Western Michigan University. I’m quite excited about this, as you can imagine. At the moment, I’m out searching for jobs… ironically, I’ve had more fun constructing my computer engineering focused resume than actually searching for jobs. So if you’re looking for an embedded engineer, software engineer, or web developer, I may be your man. Check the resume out for more details.

Update: I have a job! More details to be announced in the future.

PSoC USB SuiteUSB .NET (CyUSB) Asynchronous Wrapper

Saturday, December 8th, 2007

This is the first of a few pieces of software I’ve written for my Senior Design project here at WMU. We created a device using a Cypress PSoC, and I wrote the user interface for the project in C#. I will be releasing a number of components from this project as open source.

If you’ve used the Cypress SuiteUSB .NET library, you’ll notice that they say asynchronously sending and receiving data to and from the device is the difficult way to access the device. Of course, one thing that contributes to the difficulty of using their interface is that its nothing like any other .NET asynchronous operations. If you have used .NET asynchronous sockets or file writing… well, you probably realize that the way Cypress decided to implement their library is definitely NOT .NET oriented, and in general is rather annoying for .NET programmers to use.

Well, it annoyed the heck out of me too, so I wrote a nice wrapper for it. Now, asynchronous sending and receiving is trivial. 🙂

This will allow you to wrap the EndPoints exposed by any CyUSBDevice, so that you can call .NET-style Begin/End asynchronous calls that use IO completion ports to work nicely and quickly. I do not have any benchmarks for it at this time, but I’d bet that it works faster than Cypress’s library.. of course, I could be wrong.

Does NOT support Isochronous transfers. Probably does not support ControlEndPoints either.

A set of demo code is provided.

Usage

It’s pretty trivial to use this class. Create an instance of it, then use it like any other BeginXXX/EndXXX pair in .NET. For example:

CyUSBAsyncWrapper usbComm;

// create the wrapper
private void Init(CyUSBDevice usbDevice){
	usbComm = new CyUSBAsyncWrapper(usbDevice.BulkOutEndPt);
}

// call this to begin transferring the data
private void SendData(byte [] data) {
	usbComm.BeginTransfer(data, data.Length, new AsyncCallback(EndTransfer), data);
}

// called on another thread when the transfer is complete
void EndTransfer(IAsyncResult result) {
	usbComm.EndTransfer(result);
}

Licensed under a BSD-style license. Let me know if you find any bugs.

Download: Link