test
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
#include "i2c.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
#define CCI_MAX_WAIT_TICKS 5000
|
||||
|
||||
@@ -64,7 +64,7 @@ static void cci_wait_busy_clear_check(char* cmd);
|
||||
*/
|
||||
void cci_set_reg(uint16_t cmd, int len, uint16_t* buf)
|
||||
{
|
||||
char cmd_buf[11]; // sized for 'cmd 0xNNNN<NULL>'
|
||||
char cmd_buf[12]; // sized for 'cmd 0xNNNN<NULL>'
|
||||
int ret = 1;
|
||||
|
||||
cci_last_status_error = false;
|
||||
@@ -554,7 +554,7 @@ void cc_run_oem_reboot()
|
||||
cci_wait_busy_clear();
|
||||
cci_write_register(CCI_REG_COMMAND, CCI_CMD_OEM_RUN_REBOOT);
|
||||
// Sleep to allow camera to reboot and run FFC
|
||||
delay(6000);
|
||||
vTaskDelay(pdMS_TO_TICKS(6000));
|
||||
cci_wait_busy_clear_check("CCI_CMD_OEM_RUN_REBOOT");
|
||||
}
|
||||
|
||||
@@ -631,10 +631,10 @@ static int cci_write_register(uint16_t reg, uint16_t value)
|
||||
{
|
||||
// Write the register address and value
|
||||
uint8_t write_buf[4] = {
|
||||
reg >> 8 & 0xff,
|
||||
reg & 0xff,
|
||||
value >> 8 & 0xff,
|
||||
value & 0xff
|
||||
uint8_t (reg >> 8 & 0xff),
|
||||
uint8_t (reg & 0xff),
|
||||
uint8_t (value >> 8 & 0xff),
|
||||
uint8_t (value & 0xff)
|
||||
};
|
||||
if (i2c_master_write_slave(CCI_ADDRESS, write_buf, sizeof(write_buf)) != ESP_OK) {
|
||||
printf("[CCI] Error: failed to write CCI register %02x with value %02x\n", reg, value);
|
||||
|
@@ -83,7 +83,7 @@ esp_err_t i2c_master_read_slave(uint8_t addr7, uint8_t *data_rd, size_t size)
|
||||
}
|
||||
i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin((i2c_port_t)I2C_MODE_MASTER, cmd, 1000 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin((i2c_port_t)I2C_MODE_MASTER, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
return ret;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ esp_err_t i2c_master_write_slave(uint8_t addr7, uint8_t *data_wr, size_t size)
|
||||
i2c_master_write_byte(cmd, (addr7 << 1) | I2C_MASTER_WRITE, ACK_CHECK_EN);
|
||||
i2c_master_write(cmd, data_wr, size, ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin((i2c_port_t)I2C_MODE_MASTER, cmd, 1000 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin((i2c_port_t)I2C_MODE_MASTER, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "i2c.h"
|
||||
#include "vospi.h"
|
||||
#include <cstring>
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
// lepton image and telem buffer
|
||||
@@ -45,12 +44,12 @@ bool lepton_io_init()
|
||||
}
|
||||
|
||||
// initialize GPIO pins
|
||||
pinMode(LEP_VSYNC_PIN, INPUT);
|
||||
gpio_set_direction(LEP_VSYNC_PIN, GPIO_MODE_INPUT);
|
||||
#ifdef LEP_RESET_PIN
|
||||
pinMode(LEP_RESET_PIN, OUTPUT);
|
||||
digitalWrite(LEP_RESET_PIN, LEP_RESET_ON);
|
||||
delay(10);
|
||||
digitalWrite(LEP_RESET_PIN, LEP_RESET_OFF);
|
||||
gpio_set_direction(LEP_RESET_PIN, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(LEP_RESET_PIN, LEP_RESET_ON);
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
gpio_set_level(LEP_RESET_PIN, LEP_RESET_OFF);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "driver/i2c.h"
|
||||
|
||||
//
|
||||
// Hardware Configuration
|
||||
@@ -13,13 +14,13 @@
|
||||
// #define I2C_MASTER_SDA_PIN 21 // SDA 5
|
||||
// #define I2C_MASTER_SCL_PIN 22 // SCL 8
|
||||
|
||||
#define LEP_MISO_PIN 40 // SPI_MISO 12
|
||||
#define LEP_VSYNC_PIN 41 // GPIO3/VSYNC 15
|
||||
#define LEP_SCK_PIN 47 // SPI_CLK 18
|
||||
#define LEP_CSN_PIN 14 // SPI_CS 10
|
||||
#define LEP_RESET_PIN 20 // RESET_L 17
|
||||
#define LEP_MISO_PIN GPIO_NUM_40 // SPI_MISO 12
|
||||
#define LEP_VSYNC_PIN GPIO_NUM_41 // GPIO3/VSYNC 15
|
||||
#define LEP_SCK_PIN GPIO_NUM_47 // SPI_CLK 18
|
||||
#define LEP_CSN_PIN GPIO_NUM_14 // SPI_CS 10
|
||||
#define LEP_RESET_PIN GPIO_NUM_20 // RESET_L 17
|
||||
|
||||
#define I2C_MASTER_SDA_PIN 4 // SDA 5
|
||||
#define I2C_MASTER_SDA_PIN GPIO_NUM_4 // SDA 5
|
||||
#define I2C_MASTER_SCL_PIN 5 // SCL 8
|
||||
|
||||
// I2C
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "vospi.h"
|
||||
#include <string.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
|
||||
static bool lep_is_radiometric = false;
|
||||
@@ -57,7 +57,7 @@ bool lepton_init()
|
||||
// If this is successful, we assume further communication will be successful
|
||||
rsp = cci_run_ping();
|
||||
if (rsp != 0) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,16 +86,16 @@ bool lepton_init()
|
||||
// Configure Radiometry for TLinear enabled, auto-resolution
|
||||
cci_set_radiometry_enable_state(CCI_RADIOMETRY_ENABLED);
|
||||
rsp = cci_get_radiometry_enable_state();
|
||||
printf("[LEP UTIL] Lepton Radiometry = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Radiometry = %ld\n", rsp);
|
||||
if (rsp != CCI_RADIOMETRY_ENABLED) {
|
||||
// Make one more effort
|
||||
delay(10);
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
printf("[LEP UTIL] Retry Set Lepton Radiometry\n");
|
||||
cci_set_radiometry_enable_state(CCI_RADIOMETRY_ENABLED);
|
||||
rsp = cci_get_radiometry_enable_state();
|
||||
printf("[LEP UTIL] Lepton Radiometry = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Radiometry = %ld\n", rsp);
|
||||
if (rsp != CCI_RADIOMETRY_ENABLED) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -104,17 +104,17 @@ bool lepton_init()
|
||||
val = (lep_stP->agc_set_enabled) ? CCI_RADIOMETRY_TLINEAR_DISABLED : CCI_RADIOMETRY_TLINEAR_ENABLED;
|
||||
cci_set_radiometry_tlinear_enable_state((cci_radiometry_tlinear_enable_state_t)val);
|
||||
rsp = cci_get_radiometry_tlinear_enable_state();
|
||||
printf("[LEP UTIL] Lepton Radiometry TLinear = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Radiometry TLinear = %ld\n", rsp);
|
||||
if (rsp != val) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
cci_set_radiometry_tlinear_auto_res(CCI_RADIOMETRY_AUTO_RES_ENABLED);
|
||||
rsp = cci_get_radiometry_tlinear_auto_res();
|
||||
printf("[LEP UTIL] Lepton Radiometry Auto Resolution = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Radiometry Auto Resolution = %ld\n", rsp);
|
||||
if (rsp != CCI_RADIOMETRY_AUTO_RES_ENABLED) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -122,9 +122,9 @@ bool lepton_init()
|
||||
// Enable AGC calcs for a smooth transition between modes
|
||||
cci_set_agc_calc_enable_state(CCI_AGC_ENABLED);
|
||||
rsp = cci_get_agc_calc_enable_state();
|
||||
printf("[LEP UTIL] Lepton AGC Calcs = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton AGC Calcs = %ld\n", rsp);
|
||||
if (rsp != CCI_AGC_ENABLED) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,18 +132,18 @@ bool lepton_init()
|
||||
val = (lep_stP->agc_set_enabled) ? CCI_AGC_ENABLED : CCI_AGC_DISABLED;
|
||||
cci_set_agc_enable_state((cci_agc_enable_state_t)val);
|
||||
rsp = cci_get_agc_enable_state();
|
||||
printf("[LEP UTIL] Lepton AGC = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton AGC = %ld\n", rsp);
|
||||
if (rsp != val) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable telemetry
|
||||
cci_set_telemetry_enable_state(CCI_TELEMETRY_ENABLED);
|
||||
rsp = cci_get_telemetry_enable_state();
|
||||
printf("[LEP UTIL] Lepton Telemetry = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Telemetry = %ld\n", rsp);
|
||||
if (rsp != CCI_TELEMETRY_ENABLED) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
vospi_include_telem(true);
|
||||
@@ -161,9 +161,9 @@ bool lepton_init()
|
||||
}
|
||||
cci_set_gain_mode((cc_gain_mode_t)val);
|
||||
rsp = cci_get_gain_mode();
|
||||
printf("[LEP UTIL] Lepton Gain Mode = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton Gain Mode = %ld\n", rsp);
|
||||
if (rsp != val) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ bool lepton_init()
|
||||
// Finally enable VSYNC on Lepton GPIO3
|
||||
cci_set_gpio_mode(LEP_OEM_GPIO_MODE_VSYNC);
|
||||
rsp = cci_get_gpio_mode();
|
||||
printf("[LEP UTIL] Lepton GPIO Mode = %d\n", rsp);
|
||||
printf("[LEP UTIL] Lepton GPIO Mode = %ld\n", rsp);
|
||||
if (rsp != LEP_OEM_GPIO_MODE_VSYNC) {
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%d)\n", rsp);
|
||||
printf("[LEP UTIL] Error: Lepton communication failed (%ld)\n", rsp);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user