Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
@@ -15,8 +15,9 @@ static bool dummy_comms_start(painter_device_t device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void dummy_comms_stop(painter_device_t device) {
|
||||
static bool dummy_comms_stop(painter_device_t device) {
|
||||
// No-op.
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t dummy_comms_send(painter_device_t device, const void *data, uint32_t byte_count) {
|
||||
|
||||
@@ -35,7 +35,9 @@ uint32_t qp_comms_i2c_send_data(painter_device_t device, const void *data, uint3
|
||||
return qp_comms_i2c_send_raw(device, data, byte_count);
|
||||
}
|
||||
|
||||
void qp_comms_i2c_stop(painter_device_t device) {}
|
||||
bool qp_comms_i2c_stop(painter_device_t device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Command+Data I2C support
|
||||
@@ -43,9 +45,9 @@ void qp_comms_i2c_stop(painter_device_t device) {}
|
||||
static const uint8_t cmd_byte = 0x00;
|
||||
static const uint8_t data_byte = 0x40;
|
||||
|
||||
void qp_comms_i2c_cmddata_send_command(painter_device_t device, uint8_t cmd) {
|
||||
bool qp_comms_i2c_cmddata_send_command(painter_device_t device, uint8_t cmd) {
|
||||
uint8_t buf[2] = {cmd_byte, cmd};
|
||||
qp_comms_i2c_send_raw(device, &buf, 2);
|
||||
return qp_comms_i2c_send_raw(device, &buf, 2);
|
||||
}
|
||||
|
||||
uint32_t qp_comms_i2c_cmddata_send_data(painter_device_t device, const void *data, uint32_t byte_count) {
|
||||
@@ -58,7 +60,7 @@ uint32_t qp_comms_i2c_cmddata_send_data(painter_device_t device, const void *dat
|
||||
return byte_count;
|
||||
}
|
||||
|
||||
void qp_comms_i2c_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
|
||||
bool qp_comms_i2c_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
|
||||
uint8_t buf[32];
|
||||
for (size_t i = 0; i < sequence_len;) {
|
||||
uint8_t command = sequence[i];
|
||||
@@ -67,12 +69,17 @@ void qp_comms_i2c_bulk_command_sequence(painter_device_t device, const uint8_t *
|
||||
buf[0] = cmd_byte;
|
||||
buf[1] = command;
|
||||
memcpy(&buf[2], &sequence[i + 3], num_bytes);
|
||||
qp_comms_i2c_send_raw(device, buf, num_bytes + 2);
|
||||
if (!qp_comms_i2c_send_raw(device, buf, num_bytes + 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (delay > 0) {
|
||||
wait_ms(delay);
|
||||
}
|
||||
i += (3 + num_bytes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const painter_comms_with_command_vtable_t i2c_comms_cmddata_vtable = {
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct qp_comms_i2c_config_t {
|
||||
bool qp_comms_i2c_init(painter_device_t device);
|
||||
bool qp_comms_i2c_start(painter_device_t device);
|
||||
uint32_t qp_comms_i2c_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
||||
void qp_comms_i2c_stop(painter_device_t device);
|
||||
bool qp_comms_i2c_stop(painter_device_t device);
|
||||
|
||||
extern const painter_comms_with_command_vtable_t i2c_comms_cmddata_vtable;
|
||||
|
||||
|
||||
@@ -45,11 +45,12 @@ uint32_t qp_comms_spi_send_data(painter_device_t device, const void *data, uint3
|
||||
return byte_count - bytes_remaining;
|
||||
}
|
||||
|
||||
void qp_comms_spi_stop(painter_device_t device) {
|
||||
bool qp_comms_spi_stop(painter_device_t device) {
|
||||
painter_driver_t * driver = (painter_driver_t *)device;
|
||||
qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config;
|
||||
spi_stop();
|
||||
gpio_write_pin_high(comms_config->chip_select_pin);
|
||||
return true;
|
||||
}
|
||||
|
||||
const painter_comms_vtable_t spi_comms_vtable = {
|
||||
@@ -97,14 +98,15 @@ uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void *da
|
||||
return qp_comms_spi_send_data(device, data, byte_count);
|
||||
}
|
||||
|
||||
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) {
|
||||
bool qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) {
|
||||
painter_driver_t * driver = (painter_driver_t *)device;
|
||||
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
||||
gpio_write_pin_low(comms_config->dc_pin);
|
||||
spi_write(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
|
||||
bool qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
|
||||
painter_driver_t * driver = (painter_driver_t *)device;
|
||||
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
||||
for (size_t i = 0; i < sequence_len;) {
|
||||
@@ -126,6 +128,8 @@ void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const
|
||||
}
|
||||
i += (3 + num_bytes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const painter_comms_with_command_vtable_t spi_comms_with_dc_vtable = {
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct qp_comms_spi_config_t {
|
||||
bool qp_comms_spi_init(painter_device_t device);
|
||||
bool qp_comms_spi_start(painter_device_t device);
|
||||
uint32_t qp_comms_spi_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
||||
void qp_comms_spi_stop(painter_device_t device);
|
||||
bool qp_comms_spi_stop(painter_device_t device);
|
||||
|
||||
extern const painter_comms_vtable_t spi_comms_vtable;
|
||||
|
||||
@@ -39,9 +39,9 @@ typedef struct qp_comms_spi_dc_reset_config_t {
|
||||
} qp_comms_spi_dc_reset_config_t;
|
||||
|
||||
bool qp_comms_spi_dc_reset_init(painter_device_t device);
|
||||
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
|
||||
bool qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
|
||||
uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
||||
void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
|
||||
bool qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
|
||||
|
||||
extern const painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user