HydraFW binary PIN mode guide - hydrabus/hydrafw GitHub Wiki

HydraFW binary PIN mode guide

This guide is updated towards firmware release HydraFW v0.9 Beta and later

This mode allows to freely control the HydraBus pins PA0 to PA7 (also called GPIO).

Commands

Once the PIN mode has been selected, the following commands are available :

  • 0b00000000 Return to main mode. Returns BBIO1
  • 0b00000001 Mode identification. Returns PIN1
  • 0b00000010 Read all pin
  • 0b00000011 Set pin mode on selected pins
  • 0b00000100 Disable pull on selected pins
  • 0b00000101 Set pull-up on selected pins
  • 0b00000110 Set pull-down on selected pins
  • 0b00001000 Set pin state on selected pins

Command details

Read all pin (0b00000010)

Once the command has been issued, Hydrabus will send a status byte (0x01 if success, 0x00 otherwise) and the corresponding status of each pin. LSB is always pin PA0.

Set pin mode on selected pins (0b00000011)

This command must be followed by 1 byte, representing the mode for each pin. (LSB is PA0). The mode is either 0 for output or 1 for input.

For instance, the command 0x00000011 0b00001111 sets the pins PA0 to PA3 in input mode, and pins PA4 to PA7 to output mode.

This command returns 0x01 if successful, 0x00 in case of error.

Pull-up/down commands

All these commands allow to set the pull-up/down on each pins individually. If multiple commands are issued on the same pin, only the last one will be used.

Disable pull on selected pins (0b00000100)

This command must be followed by 1 byte, representing the status for each pin. (LSB is PA0). Set the corresponding bit to 1 to disable the pull resistor (MCU internal pull up/down resistors) on the pin.

This command returns 0x01 if successful, 0x00 in case of error.

Set pull-up on selected pins (0b00000101)

This command must be followed by 1 byte, representing the status for each pin. (LSB is PA0). Set the corresponding bit to 1 to enable the MCU internal pull-up resistor on the pin.

This command returns 0x01 if successful, 0x00 in case of error.

Set pull-down on selected pins (0b00000110)

This command must be followed by 1 byte, representing the status for each pin. (LSB is PA0). Set the corresponding bit to 1 to enable the MCU internal pull-down on the pin.

This command returns 0x01 if successful, 0x00 in case of error.

Set pin state on selected pins (0b00001000)

This command must be followed by 1 byte, representing the mode for each pin. (LSB is PA0). The corresponding bit value will be written on the pin for each output pin. Obviously, setting any value on an input port will have no effect.

This command returns 0x01 if successful, 0x00 in case of error.