A manual switch to select normal/reverse polarity on the keyboard connection would do the trick, but something automatic would be cool.
Are the circuit schematics available for viewing? Because now that I think about it, you shouldn't even need the 5V line coming from the Mac, right? Since the board is powered by USB and not by the Mac? And I'm not sure you need the ground line connected to the Mac either. Both the Mac and your board should be at the same ground potential, through their power supplies to your home's wiring, but it might be bad practice to rely on that. If you could omit both the power and ground connections, then using a reverse-polarity cable wouldn't hurt anything. Then you could modify your software to swap the clock and data connections if it saw that "data" was changing at a faster rate than "clock".
If you don't want to eliminate the ground connection, then a reverse-polarity cable would connect the Mac's 5V to the board's ground, which is bad. You could use a diode to constrain the current to only flow in one direction, or a polyfuse to break the circuit if the current got too high, which would prevent any damage, but the board wouldn't work with the wrong cable.
I was going to suggest an automatic circuit consisting of a couple of transistors, but after more thought I'm not sure if it would actually work reliably. If the two (unknown) power connections from the Mac are A and B, then you want to connect the board's ground to A if B is 5V, and connect the board's ground to B if A is 5V. I think you could use two NPN transistors as switches. Both transistors would have their collector connected to the board's ground. T1 would have its emitter connected to A and base connected to B, and T2 would have its emitter connected to B and base connected to A. You'd also need a current-limiting resistor in the base connections. But I'm not totally certain this would work, for a few reasons I don't feel like describing now. Maybe the manual switch combined with a polyfuse isn't such a bad idea.
Are the circuit schematics available for viewing? Because now that I think about it, you shouldn't even need the 5V line coming from the Mac, right? Since the board is powered by USB and not by the Mac? And I'm not sure you need the ground line connected to the Mac either. Both the Mac and your board should be at the same ground potential, through their power supplies to your home's wiring, but it might be bad practice to rely on that. If you could omit both the power and ground connections, then using a reverse-polarity cable wouldn't hurt anything. Then you could modify your software to swap the clock and data connections if it saw that "data" was changing at a faster rate than "clock".If you don't want to eliminate the ground connection, then a reverse-polarity cable would connect the Mac's 5V to the board's ground, which is bad. You could use a diode to constrain the current to only flow in one direction, or a polyfuse to break the circuit if the current got too high, which would prevent any damage, but the board wouldn't work with the wrong cable.
I was going to suggest an automatic circuit consisting of a couple of transistors, but after more thought I'm not sure if it would actually work reliably. If the two (unknown) power connections from the Mac are A and B, then you want to connect the board's ground to A if B is 5V, and connect the board's ground to B if A is 5V. I think you could use two NPN transistors as switches. Both transistors would have their collector connected to the board's ground. T1 would have its emitter connected to A and base connected to B, and T2 would have its emitter connected to B and base connected to A. You'd also need a current-limiting resistor in the base connections. But I'm not totally certain this would work, for a few reasons I don't feel like describing now. Maybe the manual switch combined with a polyfuse isn't such a bad idea.
