From 3976418ec1243b6caf6e661538033cd62057702c Mon Sep 17 00:00:00 2001 From: Lukasz Towarek Date: Sun, 27 Oct 2024 21:10:07 +0000 Subject: [PATCH] Add support for esp-idf 5.3 --- esp_idf/CMakeLists.txt | 3 +++ esp_idf/DFRobot_AXP313A.c | 7 +++++-- esp_idf/DFRobot_AXP313A.h | 11 ++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 esp_idf/CMakeLists.txt diff --git a/esp_idf/CMakeLists.txt b/esp_idf/CMakeLists.txt new file mode 100644 index 0000000..390b6c9 --- /dev/null +++ b/esp_idf/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "DFRobot_AXP313A.c" + INCLUDE_DIRS "." + REQUIRES driver) diff --git a/esp_idf/DFRobot_AXP313A.c b/esp_idf/DFRobot_AXP313A.c index 6c719d9..9767ea5 100644 --- a/esp_idf/DFRobot_AXP313A.c +++ b/esp_idf/DFRobot_AXP313A.c @@ -1,5 +1,8 @@ #include "DFRobot_AXP313A.h" +i2c_port_t _i2c_num; +uint8_t _addr; + static esp_err_t __attribute__((unused)) i2cWriteData(i2c_port_t i2c_num, uint8_t *data_wr, size_t size) { i2c_cmd_handle_t cmd = i2c_cmd_link_create(); @@ -7,7 +10,7 @@ static esp_err_t __attribute__((unused)) i2cWriteData(i2c_port_t i2c_num, uint8_ i2c_master_write_byte(cmd, (_addr << 1) | I2C_MASTER_WRITE, 0x1); i2c_master_write(cmd, data_wr, size, 0x1); i2c_master_stop(cmd); - esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS); + esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_PERIOD_MS); i2c_cmd_link_delete(cmd); return ret; } @@ -19,7 +22,7 @@ void begin(i2c_port_t i2c_num,uint8_t addr) uint8_t data[2]; data[0] = 0x00; data[1] = 0x04; - int ret =i2cWriteData(_i2c_num,data,2); + i2cWriteData(_i2c_num,data,2); vTaskDelay(100); } diff --git a/esp_idf/DFRobot_AXP313A.h b/esp_idf/DFRobot_AXP313A.h index ae39fd7..c843b58 100644 --- a/esp_idf/DFRobot_AXP313A.h +++ b/esp_idf/DFRobot_AXP313A.h @@ -1,5 +1,10 @@ #ifndef _DFROBOT_AXP313A_H_ #define _DFROBOT_AXP313A_H_ + +#ifdef __cplusplus +extern "C" { +#endif + #include "stdio.h" #include "driver/i2c.h" #define OV2640 0 @@ -7,9 +12,6 @@ #define TIME6S 0 #define TIME10S 0 -i2c_port_t _i2c_num; -uint8_t _addr; - /** * @brief 配置I2C通信 * @param i2c_num i2c端口 @@ -48,5 +50,8 @@ uint8_t _addr; */ void setCameraPower(float DVDD ,float AVDDorDOVDD); +#ifdef __cplusplus +} +#endif #endif