From 490b5d699429ecc64a98b7e4fcbe2f5a34a5e959 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 21 Sep 2022 16:09:27 +1000 Subject: [PATCH] Fix -fpermissive errors --- main/gay-ipod-fw.cpp | 6 +++--- main/gpio-expander.cpp | 6 ++---- main/gpio-expander.h | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/main/gay-ipod-fw.cpp b/main/gay-ipod-fw.cpp index e2bdf648..5d8e677c 100644 --- a/main/gay-ipod-fw.cpp +++ b/main/gay-ipod-fw.cpp @@ -28,7 +28,7 @@ static const char* TAG = "MAIN"; esp_err_t init_i2c(void) { - int i2c_port = 0; + i2c_port_t port = I2C_NUM_0; i2c_config_t config = { .mode = I2C_MODE_MASTER, .sda_io_num = I2C_SDA_IO, @@ -42,8 +42,8 @@ esp_err_t init_i2c(void) { .clk_flags = 0, }; - ESP_ERROR_CHECK(i2c_param_config(i2c_port, &config)); - ESP_ERROR_CHECK(i2c_driver_install(i2c_port, config.mode, 0, 0, 0)); + ESP_ERROR_CHECK(i2c_param_config(port, &config)); + ESP_ERROR_CHECK(i2c_driver_install(port, config.mode, 0, 0, 0)); // TODO: INT line // TODO: add devices to the bus (DAC and GPIO expander) diff --git a/main/gpio-expander.cpp b/main/gpio-expander.cpp index 3aadb63e..2ed9c11f 100644 --- a/main/gpio-expander.cpp +++ b/main/gpio-expander.cpp @@ -22,8 +22,7 @@ esp_err_t GpioExpander::Write() { i2c_master_write_byte(handle, port_b_, true); i2c_master_stop(handle); - // TODO: timeout - esp_err_t ret = i2c_master_cmd_begin(0, handle, 0); + esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, handle, PCA8575_TIMEOUT); i2c_cmd_link_delete(handle); return ret; @@ -43,8 +42,7 @@ esp_err_t GpioExpander::Read() { i2c_master_read_byte(handle, &input_b_, I2C_MASTER_LAST_NACK); i2c_master_stop(handle); - // TODO: timeout - esp_err_t ret = i2c_master_cmd_begin(0, handle, 0); + esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, handle, PCA8575_TIMEOUT); i2c_cmd_link_delete(handle); return ret; diff --git a/main/gpio-expander.h b/main/gpio-expander.h index c63ee431..26668f46 100644 --- a/main/gpio-expander.h +++ b/main/gpio-expander.h @@ -8,6 +8,7 @@ #include "driver/i2c.h" #define PCA8575_ADDRESS (0x20) +#define PCA8575_TIMEOUT (5) namespace gay_ipod {