Hi, I am new here so please forgive me, if I am asking an obvious question. I have been programming for a long time and over the last year or so I have been playing around with Arduinos including the some prototype boards that will be coming out at Lynxmotion
Awhile ago I ported the Lynxmotion hexapod code (Phoenix) over to the Arduino environment and thought it might be fun to try it out on the Uno32. But the first thing I ran into was several of the libraries I was using have not been ported over to the Uno32, like the PSX_LIB library for the PS2 by Bill Porter. The problem is that he is using his own macros and the like to set and clear the IO lines. So I thought I would take a stab at this.
Recently on the Arduino, I was wanting to control two WII nunchucks on one board, but they both have the same I2C address, I found the software I2C library was too slow, so I built my own as the DigitalWriteFast. The issue I had with using DigitalWriteFast was I wanted to pass in pin numbers to the init function and DigitalWriteFast only works with constants. So what I did instead was to un-roll the digital Write, that my init code would do something like:
Code: Select all
// Some globals or class variables...
volatile uint32_t *SCLlatchPort;
// Init code
port = digitalPinToPort(SCLpin);
SCLPinBit = digitalPinToBitMask(SCLPin);
// may need to grab data to read ... like wise for SDA
Then when I needed to to change SCL to low, I would just do something like:
Or if I needed to go high I would:
Note: these were done through macros or inline functions...
So the question is, would this work on the Uno32? Also would the set and clear turn out to be atomic operations? If not what do I need to do to make them atomic? Ran into earlier problems with PS2 library was not atomic and it walked over the changes that the Servo library was making during interrupts.
Again sorry if I went too far off topic here or if the question(s) are obvious.