test
This commit is contained in:
1383
changes.patch
Normal file
1383
changes.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,9 @@
|
||||
#include "i2c.h"
|
||||
#include "driver/i2c_master.h"
|
||||
#include "lepton_system.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
// #include "freertos/FreeRTOS.h"
|
||||
// #include "freertos/semphr.h"
|
||||
|
||||
@@ -42,7 +45,6 @@ i2c_master_dev_handle_t LEPTON_DEV_HANDLE;
|
||||
|
||||
esp_err_t i2c_master_bus_detect_devices(i2c_master_bus_handle_t handle)
|
||||
{
|
||||
const uint16_t probe_timeout_ms = 50; // timeout in milliseconds
|
||||
uint8_t address;
|
||||
bool found_any = false;
|
||||
|
||||
@@ -53,7 +55,7 @@ esp_err_t i2c_master_bus_detect_devices(i2c_master_bus_handle_t handle)
|
||||
fflush(stdout);
|
||||
address = i;
|
||||
|
||||
esp_err_t ret = i2c_master_probe(handle, address, probe_timeout_ms);
|
||||
esp_err_t ret = i2c_master_probe(handle, address, I2C_MASTER_FREQ_HZ);
|
||||
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
@@ -70,13 +72,13 @@ esp_err_t i2c_master_bus_detect_devices(i2c_master_bus_handle_t handle)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t i2c_master_init(gpio_num_t scl_pin, gpio_num_t sda_pin)
|
||||
esp_err_t i2c_master_init()
|
||||
{
|
||||
|
||||
i2c_master_bus_config_t i2c0_bus_cfg = {
|
||||
.i2c_port = I2C_MASTER_NUM,
|
||||
.sda_io_num = sda_pin,
|
||||
.scl_io_num = scl_pin,
|
||||
.sda_io_num = GPIO_NUM_4,
|
||||
.scl_io_num = GPIO_NUM_5,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.glitch_ignore_cnt = 7,
|
||||
.flags = {
|
||||
@@ -86,7 +88,10 @@ esp_err_t i2c_master_init(gpio_num_t scl_pin, gpio_num_t sda_pin)
|
||||
};
|
||||
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c0_bus_cfg, &i2c0_bus_hdl));
|
||||
|
||||
i2c_master_bus_detect_devices(i2c0_bus_hdl);
|
||||
for (uint8_t i = 0; i < 10;i++) {
|
||||
i2c_master_bus_detect_devices(i2c0_bus_hdl);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
i2c_device_config_t LEPTON_DEV_CFG = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
|
@@ -49,5 +49,5 @@ extern i2c_master_dev_handle_t LEPTON_DEV_HANDLE;
|
||||
//
|
||||
// I2C API
|
||||
//
|
||||
esp_err_t i2c_master_init(gpio_num_t scl_pin, gpio_num_t sda_pin);
|
||||
esp_err_t i2c_master_init();
|
||||
#endif
|
@@ -23,7 +23,7 @@ bool lepton_io_init()
|
||||
printf("[LEP SYS] Lepton I/O Initialization\n");
|
||||
|
||||
// Attempt to initialize the I2C Master
|
||||
ret = i2c_master_init(I2C_MASTER_SCL_PIN, I2C_MASTER_SDA_PIN);
|
||||
ret = i2c_master_init();
|
||||
if (ret != ESP_OK) {
|
||||
printf("[LEP SYS] Error: I2C Master initialization failed\n");
|
||||
return false;
|
||||
|
@@ -21,8 +21,6 @@
|
||||
|
||||
#define I2C_TIMEOUT_MS_VALUE 2000
|
||||
|
||||
#define I2C_MASTER_SDA_PIN GPIO_NUM_4 // SDA
|
||||
#define I2C_MASTER_SCL_PIN GPIO_NUM_5 // SCL
|
||||
#define CCI_ADDRESS 0x2A
|
||||
|
||||
// I2C
|
||||
|
Reference in New Issue
Block a user