====== Bus Pirate ======
Ok so the bus pirate is very useful but a bit tricky to use.
Use sudo putty to open the terminal. To close the terminal just close the window. Bus Pirate starts
in HiZ mode and you can't turn on the PSU. Press m to select a mode. If you want to enable the PSU,
you have to be in a mode other than HiZ.
Type ''%%?%%'' to get to the help.
Here are some general notes.
* Use Putty to connect
* Baud rate 115200
* backspace deletes a character
* up arrow goes up in history
===== SPI =====
Watch [[https://www.youtube.com/watch?v=AuhFr88mjt0|this]].
The SPI port has a bunch of settings that the bus pirate can let you control.
The first one is the speed. SPI is not like I2C. It is synchronous and sends out
its own clock and this is what governs the speed. SPI is full duplex meaning
that reading and writing happens at the same time.
[ # enables SS
] # disables SS
==== Read Data ====
You enable SS with ''%%[%%''. Then you send a read instruction ''%%0x40%%'' that
is ORed with the address of the register. You then send a number of dummy bytes
and read the responses. Bus Pirate does this for you with the ''%%r%%'' command.
You then disable the chip select with ''%%]%%''.
r # reads 1 one byte
r:4 # reads 4 bytes
So, to read register ''%%0x20%%'' which you know contains 4 bytes, you type
''%%[0x60 r:4]%%''.
==== Write Data ====
To write a register you OR the register address with ''%%0x80%%''. So in Bus
Pirate, to write ''%%0xFF%%'' in register ''%%0x08%%'' is ''%%[0x88 0xFF]%%''.
===== I2C =====
I2C is a 2 wire single master databus with a 7 bit addressing scheme.
Reads and writes are done to a device address by toggling the write bit.
To write to the I2C bus, do the following:
[0xAA 0xXX]
This writes to address ''%%AA%%'' one byte of ''%%0xXX%%''. Note that the
''%%AA%%'' has the write bit flag set.
[[http://ww1.microchip.com/downloads/en/DeviceDoc/i2c.pdf|Here's a nice write-up on I2C]]