1w01

The Bus Pirate’s new binary modes provide a consistent, logical way to script actions from Python, Perl, etc. We’ve already introduced the new binary bitbang, SPI, I2C, and UART modes. This post outlines the last planned binmode addition, 1-Wire functions. A completed binary mode will be in the next firmware release, for now you can grab the latest v2.7 nightly compile.

We want your scripts! If you script something for any of the new modes, in any language, we’d like to host it in the example scripts folder. We’ll send Bus Pirate probe cable kits to two authors of Bus Pirate binary mode scripts posted by the end of next week (October 24th, 2009). Here’s all the binmode documentation so far.

Binary 1-Wire mode specification follows after the break.

Binary 1-Wire mode command table

  • 00000000 – Exit to bitbang mode, responds “BBIOx”
  • 00000001 – Mode version string (1W01)
  • 00000010 – 1-Wire reset
  • 00000100 – Read byte
  • 00001000 – ROM search macro (0xf0)
  • 00001001 – ALARM search macro (0xec)
  • 0001xxxx – Bulk write, write 1-16 bytes (0=1byte!)
  • 0100wxyz – Configure peripherals, w=power, x=pullups, y=AUX, z=CS
  • 0101wxyz – Read peripherals (planned, not implemented)

Enter binary 1-Wire mode by first entering bitbang mode, then send 0×04 to enter 1-Wire mode.

Most commands are a single byte. Commands generally return 1 for success, 0 for failure.

00000000 – Exit to bitbang mode, responds “BBIOx”

This command resets the Bus Pirate into raw bitbang mode from the user terminal. It also resets to raw bitbang mode from any protocol mode. This command always returns a five byte bitbang version string “BBIOx”, where x is the current bitbang protocol version (currently 1).

00000001 – Display mode version string, responds “1Wxx”

Once in binary 1-Wire mode, send 0×01 to get the current mode version string. The Bus Pirate responds ‘1Wxx’, where xx is the protocol version (currently 01). Get the version string at any time by sending 0×01 again. This command is the same in all binary modes, the current mode can always be determined by sending 0×01.

00000010 – 1-Wire reset

Send a 1-Wire reset. Responds 0×01.

00000100 – Read byte

Reads a byte from the bus, returns the byte.

00001000 – ROM search macro (0xf0)
00001001 – ALARM search macro (0xec)

Search macros are special 1-Wire procedures that determine device addresses. The command returns 0x01, and then each 8-byte 1-Wire address located. Data ends with 8 bytes of 0xff.

0001xxxx – Bulk 1-Wire write, send 1-16 bytes (0=1byte!)

Bulk write transfers a packet of xxxx+1 bytes to the 1-Wire bus. Up to 16 data bytes can be sent at once. Note that 0000 indicates 1 byte because there’s no reason to send 0. BP replies 0×01 to each byte.

0100wxyz – Configure peripherals w=power, x=pullups, y=AUX, z=CS

Enable (1) and disable (0) Bus Pirate peripherals and pins. Bit w enables the power supplies, bit x toggles the on-board pull-up resistors, y sets the state of the auxiliary pin, and z sets the chip select pin. Features not present in a specific hardware version are ignored. Bus Pirate responds 0×01 on success.

Note: CS pin always follows the current HiZ pin configuration. AUX is always a normal pin output (0=GND, 1=3.3volts).

A read command is planned but not implemented in this version.

Advertisements