Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for esp-idf 5.3 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions esp_idf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(SRCS "DFRobot_AXP313A.c"
INCLUDE_DIRS "."
REQUIRES driver)
7 changes: 5 additions & 2 deletions esp_idf/DFRobot_AXP313A.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#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();
i2c_master_start(cmd);
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;
}
Expand All @@ -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);
}

Expand Down
11 changes: 8 additions & 3 deletions esp_idf/DFRobot_AXP313A.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef _DFROBOT_AXP313A_H_
#define _DFROBOT_AXP313A_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "stdio.h"
#include "driver/i2c.h"
#define OV2640 0
#define OV7725 1
#define TIME6S 0
#define TIME10S 0

i2c_port_t _i2c_num;
uint8_t _addr;

/**
* @brief 配置I2C通信
* @param i2c_num i2c端口
Expand Down Expand Up @@ -48,5 +50,8 @@ uint8_t _addr;
*/
void setCameraPower(float DVDD ,float AVDDorDOVDD);

#ifdef __cplusplus
}
#endif

#endif