-
Notifications
You must be signed in to change notification settings - Fork 0
PaddleFish Serial Protocol
Command Protocol is used to send/receive commands to/from device. The communication is always started by host (PC, mobile application, etc.).
This command set is used to read/write I2C device registers. There are three basic commands in Command Protocol:
This command is used to read byte array at specified register address from specified I2C device.
Structure:
|CMD_START|CMD_READ_BYTES|dev_i2c_address|register_address|length|CRC|CMD_END|
Where:
CMD_START: 0xA5 constant for command start
CMD_READ_BYTES: 0xC0 constant for read bytes command
dev_i2c_address: i2c address of the device to be read from
register_address: starting register address of the device
length: data length to be read
CRC: Cyclic redundancy check (Not implemented yet!)
CMD_END: 0x0C constant for command end
This command is used to write byte array to specified register address at specified I2C device.
Structure:
|CMD_START|CMD_WRITE_BYTES|dev_i2c_address|register_address|length|CMD_END|[data_array...]|CMD_END|
Where:
CMD_START: 0xA5 constant for command start
CMD_WRITE_BYTES: 0xC1 constant for read bytes command
dev_i2c_address: i2c address of the device to be read from
register_address: starting register address of the device
length: data length to be read
CMD_END: 0x0C constant for command end
[data_array...]: data array to be sent
CMD_END: 0x0C constant for command end
This command write bits to a byte by using a mask
Structure:
|CMD_START|CMD_WRITE_BITES|dev_i2c_address|register_address|data|mask|CRC|CMD_END|
Where:
CMD_START: 0xA5 constant for command start
CMD_WRITE_BITS: 0xC2 constant for write bites command
dev_i2c_address: i2c address of the device to be read from
register_address: register address of the device
data: 8 bit data to be written
mask: 8 bit mask
CMD_END: 0x0C constant for command end
Structure:
|CMD_ANS|data|CMD_END|
Where:
CMD_ANS: 0xA6 constant for command answer
data: data read from I2C device register
CMD_END: 0x0C constant for command end