Created
August 2, 2014 02:11
-
-
Save djcsdy/3b26f10019e7b11dae30 to your computer and use it in GitHub Desktop.
Clockless unidirectional serial link between a Raspberry Pi and Arduino.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clockless unidirectional serial link between a Raspberry Pi and Arduino. | |
Inspired by every Commodore 64 disk fastloader ever :). | |
Motivation: I want to send commands from a Raspberry Pi to an Adafruit | |
Gemma (a tiny Arduino-compatible). Gemma only has three GPIO pins, and one | |
of them is in use to make LEDs glow pretty colours. I don’t want to have | |
to worry about tricky timing constraints. | |
Gemma signals at 3.3V, which is the same level as the Pi. Most other | |
Arduinos signal at 5V and will require a conversion circuit to talk to the | |
Pi. | |
There are two GPIO lines, D0 and D1. | |
"pull up" = connect a line to +3.3V via a pull-up resistor. | |
"short to ground" = connect a line directly to ground. | |
"wait" = poll the state of a line every so often until it changes to the | |
expected state. | |
1. Arduino pulls up both lines and waits for one of the lines to go low. | |
2. Pi pulls up both lines and waits until it wants to send a bit. | |
3. Pi shorts one of the lines to ground. To send a zero, it shorts D0. To | |
send a one it shorts D1. Whichever line is shorted is temporarily | |
designated the 'signal' line. The other line is temporarily designated | |
the 'ack' line. | |
4. Pi waits for the ack line to go low. | |
5. Arduino detects that the signal line has gone low. If D0 is the signal | |
line, Arduino receives a zero. If D1 is the signal line, Arduino | |
receives a 1. | |
6. Arduino acknowledges the bit by shorting the ack line to ground. | |
7. Arduino waits for the signal line to go high. | |
8. Pi detects that the ack line has gone low and pulls up the signal line. | |
9. Arduino detects that the signal line has gone high and pulls up both | |
lines. | |
10. Go to 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment