Device Control Host API¶
The following structures and functions are used to initialize and call a control instance on the host.
-
control_ret_t control_init_i2c(unsigned char i2c_slave_address)¶
Initialize the I2C host (master) interface
- Parameters
i2c_slave_address – I2C address of the slave (controlled device)
- Returns
Whether the initialization was successful or not
-
control_ret_t control_cleanup_i2c(void)¶
Shutdown the I2C host (master) interface connection
- Returns
Whether the shutdown was successful or not
-
control_ret_t control_init_usb(int vendor_id, int product_id, int interface_num)¶
Initialize the USB host interface
- Parameters
vendor_id – Vendor ID of controlled USB device
product_id – Product ID of controlled USB device
interface_num – USB Control interface number of controlled device
- Returns
Whether the initialization was successful or not
-
control_ret_t control_cleanup_usb(void)¶
Shutdown the USB host interface connection
- Returns
Whether the shutdown was successful or not
-
control_ret_t control_query_version(control_version_t *version)¶
Checks to see that the version of control library in the device is the same as the host
- Parameters
version – Reference to control version variable that is set on this call
- Returns
Whether the checking of control library version was successful or not
-
control_ret_t control_write_command(control_resid_t resid, control_cmd_t cmd, const uint8_t payload[], size_t payload_len)¶
Request to write to controllable resource inside the device. The command consists of a resource ID, command and a byte payload of length payload_len.
- Parameters
resid – Resource ID. Indicates which resource the command is intended for
cmd – Command code. Note that this will be in the range 0x80 to 0xFF because bit 7 set indiciates a write command
payload – Array of bytes which constitutes the data payload
payload_len – Size of the payload in bytes
- Returns
Whether the write to the device was successful or not
-
control_ret_t control_read_command(control_resid_t resid, control_cmd_t cmd, uint8_t payload[], size_t payload_len)¶
Request to read from controllable resource inside the device. The command consists of a resource ID, command and a byte payload of length payload_len.
- Parameters
resid – Resource ID. Indicates which resource the command is intended for
cmd – Command code. Note that this will be in the range 0x80 to 0xFF because bit 7 set indiciates a write command
payload – Array of bytes which constitutes the data payload
payload_len – Size of the payload in bytes
- Returns
Whether the read from the device was successful or not