Quote:
Originally Posted by jwakeman
This I figured out on my own today and I just finished up the first draft of a class for implementing the SPI interface with the sensor. I uploaded the project to our repository ( http://code.google.com/p/first-team63/source/browse/#svn%2Ftrunk%2FDevelopment%2FApps%2FcRIO%2FAS5030_ SPI). I can also attach the code here as a zip if anyone requests. Joe, I would appreciate your comments on this code if you have a moment to look over it. I used the sample code in one of the specs as a reference. One thing I wasn't sure about was a function they were using called DIO_HIGH_IMP() that they didn't show the definition of. This function was to change the mode of the DIO pin to input mode. I just kinda left this out of my code and i am hoping that is ok because we are using the DIO pin as output only in the 4 line configuration.
|
Looks like you are bit-banging the SPI interface. There is an SPI engine built in to the FPGA that will do this stuff for you and will be much faster. The functions to access it are in the ChipObject dir in the WPILib source. This is a pretty difficult interface to use, though... it's just the register interface. Thanks to the contributions of Peter Johnson from team 294, the next WPILib for C++ update will include an SPI class that is easier to use. You may want to consider holding out for that.
Quote:
Originally Posted by jwakeman
I think I will see how my SPI interface treats me before I dive into this one! I am gathering though that the AnalogTrigger and AnalogTriggerOutput class would somehow be used to create a simulated DigitalInput to pass to the Encoder class? This one looks tough...
|
Fair enough. The AnalogTrigger will give you AnalogTriggerOutput objects which if you look at their header file, inherit from DigitalSource. The Encoders take DigitalSource type objects as parameters for the A and B channels.
-Joe