mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
Merge branch 'refactor/i2c_testapp_c++' into 'master'
refactor(i2c_test_apps): Refactor from C to C++ Closes IDF-13806 See merge request espressif/esp-idf!41126
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
set(srcs "test_app_main.c"
|
||||
"test_i2c_common.c"
|
||||
"test_i2c_common.cpp"
|
||||
)
|
||||
|
||||
if(CONFIG_SOC_I2C_SUPPORT_SLAVE AND CONFIG_SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE)
|
||||
list(APPEND srcs "test_i2c_multi.c")
|
||||
list(APPEND srcs "test_i2c_multi.cpp")
|
||||
|
||||
if(CONFIG_SOC_I2C_SLAVE_SUPPORT_BROADCAST)
|
||||
list(APPEND srcs "test_i2c_broadcast.c")
|
||||
list(APPEND srcs "test_i2c_broadcast.cpp")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR)
|
||||
list(APPEND srcs "test_i2c_10bit.c")
|
||||
list(APPEND srcs "test_i2c_10bit.cpp")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_I2C_SUPPORTED)
|
||||
list(APPEND srcs "test_lp_i2c.c")
|
||||
list(APPEND srcs "test_lp_i2c.cpp")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_I2C_SUPPORT_SLEEP_RETENTION AND CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
|
||||
list(APPEND srcs "test_i2c_sleep_retention.c")
|
||||
list(APPEND srcs "test_i2c_sleep_retention.cpp")
|
||||
endif()
|
||||
|
||||
if(CONFIG_I2C_ISR_IRAM_SAFE)
|
||||
list(APPEND srcs "test_i2c_iram.c")
|
||||
list(APPEND srcs "test_i2c_iram.cpp")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM)
|
||||
list(APPEND srcs "test_i2c_flash_text.c")
|
||||
list(APPEND srcs "test_i2c_flash_text.cpp")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
|
@@ -6,35 +6,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define I2C_SLAVE_SCL_IO 18 /*!<gpio number for i2c slave clock */
|
||||
#define I2C_SLAVE_SDA_IO 19 /*!<gpio number for i2c slave data */
|
||||
#define I2C_SLAVE_SCL_IO GPIO_NUM_18 /*!<gpio number for i2c slave clock */
|
||||
#define I2C_SLAVE_SDA_IO GPIO_NUM_19 /*!<gpio number for i2c slave data */
|
||||
|
||||
#define I2C_MASTER_SCL_IO 18 /*!< gpio number for I2C master clock */
|
||||
#define I2C_MASTER_SDA_IO 19 /*!< gpio number for I2C master data */
|
||||
#define I2C_MASTER_SCL_IO GPIO_NUM_18 /*!< gpio number for I2C master clock */
|
||||
#define I2C_MASTER_SDA_IO GPIO_NUM_19 /*!< gpio number for I2C master data */
|
||||
#else
|
||||
#define I2C_SLAVE_SCL_IO 4 /*!<gpio number for i2c slave clock */
|
||||
#define I2C_SLAVE_SDA_IO 2 /*!<gpio number for i2c slave data */
|
||||
#define I2C_SLAVE_SCL_IO GPIO_NUM_4 /*!<gpio number for i2c slave clock */
|
||||
#define I2C_SLAVE_SDA_IO GPIO_NUM_2 /*!<gpio number for i2c slave data */
|
||||
|
||||
#define I2C_MASTER_SCL_IO 4 /*!< gpio number for I2C master clock */
|
||||
#define I2C_MASTER_SDA_IO 2 /*!< gpio number for I2C master data */
|
||||
#define I2C_MASTER_SCL_IO GPIO_NUM_4 /*!< gpio number for I2C master clock */
|
||||
#define I2C_MASTER_SDA_IO GPIO_NUM_2 /*!< gpio number for I2C master data */
|
||||
#endif
|
||||
|
||||
#if SOC_LP_I2C_SUPPORTED
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#define LP_I2C_SCL_IO 4
|
||||
#define LP_I2C_SDA_IO 5
|
||||
#define LP_I2C_SCL_IO GPIO_NUM_4
|
||||
#define LP_I2C_SDA_IO GPIO_NUM_5
|
||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
||||
#define LP_I2C_SCL_IO 3
|
||||
#define LP_I2C_SDA_IO 2
|
||||
#define LP_I2C_SCL_IO GPIO_NUM_3
|
||||
#define LP_I2C_SDA_IO GPIO_NUM_2
|
||||
#else
|
||||
#define LP_I2C_SCL_IO 7
|
||||
#define LP_I2C_SDA_IO 6
|
||||
#define LP_I2C_SCL_IO GPIO_NUM_7
|
||||
#define LP_I2C_SDA_IO GPIO_NUM_6
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -20,7 +21,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
|
||||
static QueueHandle_t event_queue;
|
||||
static uint8_t *temp_data;
|
||||
@@ -50,27 +50,25 @@ static void i2c_slave_read_test_10bit(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x134,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.addr_bit_len = I2C_ADDR_BIT_LEN_10,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH,
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH,
|
||||
i2c_slv_config.slave_addr = 0x134;
|
||||
i2c_slv_config.addr_bit_len = I2C_ADDR_BIT_LEN_10;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -100,22 +98,20 @@ static void i2c_master_write_test_10bit(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_10,
|
||||
.device_address = 0x134,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_10;
|
||||
dev_cfg.device_address = 0x134;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -142,22 +138,20 @@ TEST_CASE_MULTIPLE_DEVICES("I2C master write slave test 10 bit", "[i2c][test_env
|
||||
static void master_read_slave_test_10bit(void)
|
||||
{
|
||||
uint8_t data_rd[DATA_LENGTH] = {0};
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_10,
|
||||
.device_address = 0x134,
|
||||
.scl_speed_hz = 100000,
|
||||
.scl_wait_us = 20000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_10;
|
||||
dev_cfg.device_address = 0x134;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
dev_cfg.scl_wait_us = 20000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -183,24 +177,22 @@ static void slave_write_buffer_test_10bit(void)
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x134,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.addr_bit_len = I2C_ADDR_BIT_LEN_10,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x134;
|
||||
i2c_slv_config.addr_bit_len = I2C_ADDR_BIT_LEN_10;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -20,7 +21,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
|
||||
static QueueHandle_t event_queue;
|
||||
static uint8_t *temp_data;
|
||||
@@ -49,22 +49,20 @@ static void i2c_master_write_test_broadcast(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x00,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x00;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -92,27 +90,25 @@ static void i2c_slave_read_test_broadcast(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.flags.broadcast_en = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
i2c_slv_config.flags.broadcast_en = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
@@ -19,21 +19,20 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
#include "driver/uart.h"
|
||||
#include "test_board.h"
|
||||
|
||||
static const char TAG[] = "test-i2c";
|
||||
|
||||
// Make it as a local test, because don't know where there happened to be any pull-up on CI.
|
||||
TEST_CASE("I2C master initialize without pins pull-up ", "[i2c][ignore]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = false, // no pull-up
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = false; // no pull-up
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config_1, &bus_handle));
|
||||
@@ -44,23 +43,21 @@ TEST_CASE("I2C master initialize without pins pull-up ", "[i2c][ignore]")
|
||||
|
||||
TEST_CASE("I2C bus install-uninstall test", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t i2c_mst_handle1;
|
||||
|
||||
#if SOC_HP_I2C_NUM > 1
|
||||
i2c_master_bus_config_t i2c_mst_config_2 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = 1,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_2 = {};
|
||||
i2c_mst_config_2.i2c_port = 1;
|
||||
i2c_mst_config_2.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_2.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_2.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_2.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t i2c_mst_handle2;
|
||||
#endif
|
||||
// Install master bus 0
|
||||
@@ -84,13 +81,12 @@ TEST_CASE("I2C bus install-uninstall test", "[i2c]")
|
||||
|
||||
TEST_CASE("I2C driver memory leaking check", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
int size = esp_get_free_heap_size();
|
||||
@@ -105,35 +101,31 @@ TEST_CASE("I2C driver memory leaking check", "[i2c]")
|
||||
|
||||
TEST_CASE("I2C device add & remove check", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config_1, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg_1 = {
|
||||
.scl_speed_hz = 100 * 1000,
|
||||
.device_address = 0x10,
|
||||
};
|
||||
i2c_device_config_t dev_cfg_1 = {};
|
||||
dev_cfg_1.device_address = 0x10;
|
||||
dev_cfg_1.scl_speed_hz = 100 * 1000;
|
||||
i2c_master_dev_handle_t dev_1;
|
||||
i2c_master_bus_add_device(bus_handle, &dev_cfg_1, &dev_1);
|
||||
|
||||
i2c_device_config_t dev_cfg_2 = {
|
||||
.scl_speed_hz = 100 * 1000,
|
||||
.device_address = 0x20,
|
||||
};
|
||||
i2c_device_config_t dev_cfg_2 = {};
|
||||
dev_cfg_2.device_address = 0x20;
|
||||
dev_cfg_2.scl_speed_hz = 100 * 1000;
|
||||
i2c_master_dev_handle_t dev_2;
|
||||
i2c_master_bus_add_device(bus_handle, &dev_cfg_2, &dev_2);
|
||||
|
||||
i2c_device_config_t dev_cfg_3 = {
|
||||
.scl_speed_hz = 100 * 1000,
|
||||
.device_address = 0x30,
|
||||
};
|
||||
i2c_device_config_t dev_cfg_3 = {};
|
||||
dev_cfg_3.device_address = 0x30;
|
||||
dev_cfg_3.scl_speed_hz = 100 * 1000;
|
||||
i2c_master_dev_handle_t dev_3;
|
||||
i2c_master_bus_add_device(bus_handle, &dev_cfg_3, &dev_3);
|
||||
|
||||
@@ -149,23 +141,22 @@ TEST_CASE("I2C peripheral allocate all", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_handle_t bus_handle[SOC_HP_I2C_NUM];
|
||||
for (int i = 0; i < SOC_HP_I2C_NUM; i++) {
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = -1,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = -1;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config_1, &bus_handle[i]));
|
||||
}
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = -1,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = -1;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle_2;
|
||||
|
||||
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, i2c_new_master_bus(&i2c_mst_config_1, &bus_handle_2));
|
||||
@@ -184,24 +175,23 @@ TEST_CASE("I2C master clock frequency test", "[i2c]")
|
||||
{
|
||||
uint8_t data_wr[500] = { 0 };
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.trans_queue_depth = 30,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.trans_queue_depth = 30;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
.flags.disable_ack_check = 1,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
dev_cfg.flags.disable_ack_check = true;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -230,13 +220,13 @@ TEST_CASE("I2C master probe device test", "[i2c]")
|
||||
{
|
||||
// 0x22,33,44,55 does not exist on the I2C bus, so it's expected to return `not found` error
|
||||
// TODO: Add exist slave for testing probe success after i2c slave is merged.
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config_1 = {};
|
||||
i2c_mst_config_1.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config_1.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config_1.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config_1.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config_1, &bus_handle));
|
||||
@@ -251,22 +241,21 @@ TEST_CASE("probe test after general call (0x00 0x06)", "[i2c]")
|
||||
{
|
||||
uint8_t data_wr[1] = { 0x06 };
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg1 = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x00,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg1 = {};
|
||||
dev_cfg1.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg1.device_address = 0x00;
|
||||
dev_cfg1.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle1;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg1, &dev_handle1));
|
||||
@@ -302,33 +291,31 @@ static IRAM_ATTR bool test_master_tx_done_callback(i2c_master_dev_handle_t i2c_d
|
||||
*/
|
||||
TEST_CASE("I2C master transaction non-blocking mode with large amount of transaction", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_bus_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.glitch_ignore_cnt = 7,
|
||||
.trans_queue_depth = 37,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_bus_config = {};
|
||||
i2c_bus_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_bus_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_bus_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_bus_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_bus_config.glitch_ignore_cnt = 7;
|
||||
i2c_bus_config.trans_queue_depth = 37;
|
||||
i2c_bus_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_bus_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 400000,
|
||||
.flags.disable_ack_check = true,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 400000;
|
||||
dev_cfg.flags.disable_ack_check = true;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
|
||||
i2c_master_event_callbacks_t cbs = {
|
||||
.on_trans_done = test_master_tx_done_callback,
|
||||
};
|
||||
i2c_master_event_callbacks_t cbs = {};
|
||||
cbs.on_trans_done = test_master_tx_done_callback;
|
||||
|
||||
i2c_master_register_event_callbacks(dev_handle, &cbs, NULL);
|
||||
|
||||
uint32_t cnt = 7;
|
||||
@@ -366,21 +353,19 @@ TEST_CASE("I2C master transaction non-blocking mode with large amount of transac
|
||||
|
||||
static void _test_i2c_new_bus_device(i2c_master_bus_handle_t *bus_handle, i2c_master_dev_handle_t *dev_handle)
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(*bus_handle, &dev_cfg, dev_handle));
|
||||
}
|
||||
@@ -448,29 +433,27 @@ TEST_CASE("I2C peripheral allocate slave all", "[i2c]")
|
||||
{
|
||||
i2c_slave_dev_handle_t dev_handle[SOC_HP_I2C_NUM];
|
||||
for (int i = 0; i < SOC_HP_I2C_NUM; i++) {
|
||||
i2c_slave_config_t i2c_slv_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = -1,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config_1 = {};
|
||||
i2c_slv_config_1.i2c_port = -1;
|
||||
i2c_slv_config_1.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config_1.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config_1.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config_1.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config_1.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config_1.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config_1, &dev_handle[i]));
|
||||
}
|
||||
i2c_slave_config_t i2c_slv_config_1 = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = -1,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config_1 = {};
|
||||
i2c_slv_config_1.i2c_port = -1;
|
||||
i2c_slv_config_1.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config_1.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config_1.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config_1.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config_1.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config_1.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config_1.flags.enable_internal_pullup = true;
|
||||
i2c_slave_dev_handle_t dev_handle_2;
|
||||
|
||||
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, i2c_new_slave_device(&i2c_slv_config_1, &dev_handle_2));
|
@@ -4,13 +4,12 @@
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "test_flash_utils.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_flash.h"
|
||||
#include "test_flash_utils.h"
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
@@ -61,7 +60,7 @@ static bool IRAM_ATTR gptimer_alarm_suspend_cb(gptimer_handle_t timer, const gpt
|
||||
TEST_CASE("Flash suspend support on i2c", "[i2c]")
|
||||
{
|
||||
// Init context.
|
||||
spi_flash_test_context_t *context = heap_caps_calloc(1, sizeof(spi_flash_test_context_t), MALLOC_CAP_DEFAULT);
|
||||
spi_flash_test_context_t *context = static_cast<spi_flash_test_context_t *>(heap_caps_calloc(1, sizeof(spi_flash_test_context_t), MALLOC_CAP_DEFAULT));
|
||||
assert(context != NULL);
|
||||
|
||||
context->sem = xSemaphoreCreateBinary();
|
||||
@@ -69,48 +68,43 @@ TEST_CASE("Flash suspend support on i2c", "[i2c]")
|
||||
|
||||
spi_flash_suspend_test_init(&context->flash_handle);
|
||||
|
||||
i2c_master_bus_config_t i2c_bus_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = 0,
|
||||
.scl_io_num = 6,
|
||||
.sda_io_num = 7,
|
||||
.glitch_ignore_cnt = 7,
|
||||
.trans_queue_depth = 37,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_bus_config = {};
|
||||
i2c_bus_config.i2c_port = 0;
|
||||
i2c_bus_config.sda_io_num = GPIO_NUM_7;
|
||||
i2c_bus_config.scl_io_num = GPIO_NUM_6;
|
||||
i2c_bus_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_bus_config.glitch_ignore_cnt = 7;
|
||||
i2c_bus_config.trans_queue_depth = 37;
|
||||
i2c_bus_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_bus_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 400000,
|
||||
.flags.disable_ack_check = true,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 400000;
|
||||
dev_cfg.flags.disable_ack_check = true;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
|
||||
gptimer_handle_t gptimer = NULL;
|
||||
gptimer_config_t timer_config = {
|
||||
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
|
||||
.direction = GPTIMER_COUNT_UP,
|
||||
.resolution_hz = TIMER_RESOLUTION_HZ,
|
||||
};
|
||||
gptimer_config_t timer_config = {};
|
||||
timer_config.clk_src = GPTIMER_CLK_SRC_DEFAULT;
|
||||
timer_config.direction = GPTIMER_COUNT_UP;
|
||||
timer_config.resolution_hz = TIMER_RESOLUTION_HZ;
|
||||
TEST_ESP_OK(gptimer_new_timer(&timer_config, &gptimer));
|
||||
|
||||
gptimer_alarm_config_t alarm_config = {
|
||||
.reload_count = 0,
|
||||
.alarm_count = 1000,
|
||||
.flags.auto_reload_on_alarm = true,
|
||||
};
|
||||
gptimer_alarm_config_t alarm_config = {};
|
||||
alarm_config.reload_count = 0;
|
||||
alarm_config.alarm_count = 1000;
|
||||
alarm_config.flags.auto_reload_on_alarm = true;
|
||||
TEST_ESP_OK(gptimer_set_alarm_action(gptimer, &alarm_config));
|
||||
|
||||
gptimer_event_callbacks_t cbs = {
|
||||
.on_alarm = gptimer_alarm_suspend_cb,
|
||||
};
|
||||
gptimer_event_callbacks_t cbs = {};
|
||||
cbs.on_alarm = gptimer_alarm_suspend_cb;
|
||||
|
||||
TEST_ESP_OK(gptimer_register_event_callbacks(gptimer, &cbs, dev_handle));
|
||||
TEST_ESP_OK(gptimer_enable(gptimer));
|
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
#include "unity_test_utils_cache.h"
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -20,8 +22,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
#include "unity_test_utils_cache.h"
|
||||
|
||||
static QueueHandle_t s_send_queue;
|
||||
static QueueHandle_t event_queue;
|
||||
@@ -64,29 +64,27 @@ static void i2c_master_write_test_iram_safe(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.trans_queue_depth = 200,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_mst_config.trans_queue_depth = 200;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
s_send_queue = xQueueCreate(1, sizeof(i2c_master_event_data_t));
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
i2c_master_event_callbacks_t cbs = {
|
||||
.on_trans_done = test_master_tx_done_callback,
|
||||
};
|
||||
i2c_master_event_callbacks_t cbs = {};
|
||||
cbs.on_trans_done = test_master_tx_done_callback;
|
||||
|
||||
i2c_master_event_data_t evt_data;
|
||||
i2c_master_register_event_callbacks(dev_handle, &cbs, s_send_queue);
|
||||
unity_wait_for_signal("i2c slave init finish");
|
||||
@@ -112,26 +110,24 @@ static void i2c_slave_read_test_iram_safe(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL);
|
@@ -7,6 +7,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -19,7 +20,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
|
||||
void disp_buf(uint8_t *buf, int len)
|
||||
{
|
||||
@@ -61,26 +61,24 @@ static void i2c_slave_read_test(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -110,22 +108,20 @@ static void i2c_master_write_test(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = ESP_SLAVE_ADDR,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = ESP_SLAVE_ADDR;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -157,22 +153,20 @@ TEST_CASE_MULTIPLE_DEVICES("I2C master write slave test", "[i2c][test_env=generi
|
||||
static void master_read_slave_test(void)
|
||||
{
|
||||
uint8_t data_rd[DATA_LENGTH] = {0};
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = ESP_SLAVE_ADDR,
|
||||
.scl_speed_hz = 100000,
|
||||
.scl_wait_us = 20000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = ESP_SLAVE_ADDR;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
dev_cfg.scl_wait_us = 20000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -198,23 +192,21 @@ static void slave_write_buffer_test(void)
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -247,22 +239,21 @@ static void i2c_master_write_test_with_customize_api(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = I2C_DEVICE_ADDRESS_NOT_USED,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = I2C_DEVICE_ADDRESS_NOT_USED;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -281,10 +272,10 @@ static void i2c_master_write_test_with_customize_api(void)
|
||||
uint8_t address = (ESP_SLAVE_ADDR << 1 | 0);
|
||||
|
||||
i2c_operation_job_t i2c_ops[] = {
|
||||
{ .command = I2C_MASTER_CMD_START },
|
||||
{ .command = I2C_MASTER_CMD_START, .write = {}},
|
||||
{ .command = I2C_MASTER_CMD_WRITE, .write = { .ack_check = true, .data = (uint8_t *) &address, .total_bytes = 1 } },
|
||||
{ .command = I2C_MASTER_CMD_WRITE, .write = { .ack_check = true, .data = (uint8_t *) data_wr, .total_bytes = DATA_LENGTH } },
|
||||
{ .command = I2C_MASTER_CMD_STOP },
|
||||
{ .command = I2C_MASTER_CMD_STOP, .write = {}},
|
||||
};
|
||||
|
||||
TEST_ESP_OK(i2c_master_execute_defined_operations(dev_handle, i2c_ops, sizeof(i2c_ops) / sizeof(i2c_operation_job_t), -1));
|
||||
@@ -298,22 +289,21 @@ TEST_CASE_MULTIPLE_DEVICES("I2C master write slave with customize api", "[i2c][t
|
||||
static void master_read_slave_test_single_byte(void)
|
||||
{
|
||||
uint8_t data_rd[DATA_LENGTH] = {0};
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = I2C_DEVICE_ADDRESS_NOT_USED,
|
||||
.scl_speed_hz = 100000,
|
||||
.scl_wait_us = 20000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = I2C_DEVICE_ADDRESS_NOT_USED;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
dev_cfg.scl_wait_us = 20000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -323,10 +313,10 @@ static void master_read_slave_test_single_byte(void)
|
||||
uint8_t read_address = (ESP_SLAVE_ADDR << 1 | 1);
|
||||
|
||||
i2c_operation_job_t i2c_ops[] = {
|
||||
{ .command = I2C_MASTER_CMD_START },
|
||||
{ .command = I2C_MASTER_CMD_START, .write = {}},
|
||||
{ .command = I2C_MASTER_CMD_WRITE, .write = { .ack_check = true, .data = (uint8_t *) &read_address, .total_bytes = 1 } },
|
||||
{ .command = I2C_MASTER_CMD_READ, .read = { .ack_value = I2C_NACK_VAL, .data = data_rd, .total_bytes = 1 }},
|
||||
{ .command = I2C_MASTER_CMD_STOP },
|
||||
{ .command = I2C_MASTER_CMD_STOP, .write = {}},
|
||||
};
|
||||
|
||||
i2c_master_execute_defined_operations(dev_handle, i2c_ops, sizeof(i2c_ops) / sizeof(i2c_operation_job_t), 1000);
|
||||
@@ -345,23 +335,21 @@ static void slave_write_buffer_test_single_byte(void)
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -390,22 +378,20 @@ TEST_CASE_MULTIPLE_DEVICES("I2C master read slave test single byte", "[i2c][test
|
||||
static void master_read_slave_test_with_multi_read_job(void)
|
||||
{
|
||||
uint8_t data_rd[DATA_LENGTH] = {0};
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = I2C_DEVICE_ADDRESS_NOT_USED,
|
||||
.scl_speed_hz = 100000,
|
||||
.scl_wait_us = 20000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = I2C_DEVICE_ADDRESS_NOT_USED;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
dev_cfg.scl_wait_us = 20000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -415,12 +401,12 @@ static void master_read_slave_test_with_multi_read_job(void)
|
||||
uint8_t read_address = (ESP_SLAVE_ADDR << 1 | 1);
|
||||
|
||||
i2c_operation_job_t i2c_ops[] = {
|
||||
{ .command = I2C_MASTER_CMD_START },
|
||||
{ .command = I2C_MASTER_CMD_START, .write = {}},
|
||||
{ .command = I2C_MASTER_CMD_WRITE, .write = { .ack_check = true, .data = (uint8_t *) &read_address, .total_bytes = 1 } },
|
||||
{ .command = I2C_MASTER_CMD_READ, .read = { .ack_value = I2C_ACK_VAL, .data = data_rd, .total_bytes = 1 }},
|
||||
{ .command = I2C_MASTER_CMD_READ, .read = { .ack_value = I2C_ACK_VAL, .data = data_rd + 1, .total_bytes = 1 }},
|
||||
{ .command = I2C_MASTER_CMD_READ, .read = { .ack_value = I2C_NACK_VAL, .data = data_rd + 2, .total_bytes = 1 }},
|
||||
{ .command = I2C_MASTER_CMD_STOP },
|
||||
{ .command = I2C_MASTER_CMD_STOP, .write = {}},
|
||||
};
|
||||
|
||||
i2c_master_execute_defined_operations(dev_handle, i2c_ops, sizeof(i2c_ops) / sizeof(i2c_operation_job_t), 1000);
|
||||
@@ -441,23 +427,21 @@ static void slave_write_buffer_test_single_byte_for_multi_read_job(void)
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -491,27 +475,25 @@ static void i2c_slave_repeat_read(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(5, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH * 3, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH * 3, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
int times = 3;
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH * 3,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH * 3;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -543,22 +525,20 @@ static void i2c_master_repeat_write(void)
|
||||
int i;
|
||||
int times = 3;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = ESP_SLAVE_ADDR,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = ESP_SLAVE_ADDR;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -589,13 +569,13 @@ TEST_CASE_MULTIPLE_DEVICES("I2C repeat write test", "[i2c][test_env=generic_mult
|
||||
|
||||
static void master_probe_slave(void)
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
@@ -619,16 +599,15 @@ static void master_probe_slave(void)
|
||||
|
||||
static void slave_init_for_probe(void)
|
||||
{
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_slave_dev_handle_t slave_handle;
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &slave_handle));
|
||||
@@ -663,22 +642,21 @@ static void i2c_master_write_multi_buffer_test(void)
|
||||
{.write_buffer = data_wr3, .buffer_size = DATA_LENGTH},
|
||||
};
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = ESP_SLAVE_ADDR,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = ESP_SLAVE_ADDR;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -705,26 +683,24 @@ static void i2c_slave_read_multi_buffer_test(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH * 3, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH * 3, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = ESP_SLAVE_ADDR,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH * 3,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH * 3;
|
||||
i2c_slv_config.slave_addr = ESP_SLAVE_ADDR;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
||||
@@ -764,22 +740,21 @@ static void i2c_master_write_test_more_port(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = 1,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = 1;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -804,26 +779,24 @@ static void i2c_slave_read_test_more_port(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = 1,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = 1;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
@@ -15,7 +17,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_private/sleep_cpu.h"
|
||||
#include "esp_pm.h"
|
||||
@@ -49,23 +50,22 @@ static void i2c_master_write_sleep_retention_test(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
.flags.allow_pd = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_mst_config.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_mst_config.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_mst_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
i2c_mst_config.flags.allow_pd = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -111,27 +111,25 @@ static void i2c_slave_read_sleep_retention_test(void)
|
||||
{
|
||||
event_queue = xQueueCreate(5, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = I2C_SLAVE_SCL_IO,
|
||||
.sda_io_num = I2C_SLAVE_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = I2C_SLAVE_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = I2C_SLAVE_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_slave_dev_handle_t slave_handle;
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &slave_handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
ESP_ERROR_CHECK(i2c_slave_register_event_callbacks(slave_handle, &cbs, NULL));
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "test_board.h"
|
||||
|
||||
#include "unity.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -20,7 +22,6 @@
|
||||
#include "driver/i2c_slave.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_board.h"
|
||||
|
||||
#define DATA_LENGTH 100
|
||||
|
||||
@@ -48,15 +49,14 @@ static IRAM_ATTR bool i2c_slave_receive_cb(i2c_slave_dev_handle_t i2c_slave, con
|
||||
|
||||
TEST_CASE("LP I2C initialize on i2c slave", "[i2c]")
|
||||
{
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.addr_bit_len = I2C_ADDR_BIT_LEN_7,
|
||||
.clk_source = LP_I2C_SCLK_DEFAULT,
|
||||
.i2c_port = LP_I2C_NUM_0,
|
||||
.send_buf_depth = 256,
|
||||
.scl_io_num = LP_I2C_SCL_IO,
|
||||
.sda_io_num = LP_I2C_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = LP_I2C_NUM_0;
|
||||
i2c_slv_config.sda_io_num = LP_I2C_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = LP_I2C_SCL_IO;
|
||||
i2c_slv_config.clk_source = static_cast<i2c_clock_source_t>(LP_I2C_SCLK_DEFAULT);
|
||||
i2c_slv_config.send_buf_depth = 256;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.addr_bit_len = I2C_ADDR_BIT_LEN_7;
|
||||
|
||||
i2c_slave_dev_handle_t slave_handle;
|
||||
TEST_ESP_ERR(ESP_ERR_NOT_SUPPORTED, i2c_new_slave_device(&i2c_slv_config, &slave_handle));
|
||||
@@ -66,13 +66,13 @@ TEST_CASE("LP I2C initialize on i2c slave", "[i2c]")
|
||||
|
||||
TEST_CASE("LP I2C initialize with wrong IO", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.lp_source_clk = LP_I2C_SCLK_DEFAULT,
|
||||
.i2c_port = LP_I2C_NUM_0,
|
||||
.scl_io_num = 5,
|
||||
.sda_io_num = 6,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.lp_source_clk = LP_I2C_SCLK_DEFAULT;
|
||||
i2c_mst_config.i2c_port = LP_I2C_NUM_0;
|
||||
i2c_mst_config.scl_io_num = GPIO_NUM_5;
|
||||
i2c_mst_config.sda_io_num = GPIO_NUM_6;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
@@ -82,13 +82,13 @@ TEST_CASE("LP I2C initialize with wrong IO", "[i2c]")
|
||||
|
||||
TEST_CASE("LP I2C initialize with wrong clock source", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.lp_source_clk = I2C_CLK_SRC_DEFAULT,
|
||||
.i2c_port = LP_I2C_NUM_0,
|
||||
.scl_io_num = LP_I2C_SCL_IO,
|
||||
.sda_io_num = LP_I2C_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.lp_source_clk = static_cast<lp_i2c_clock_source_t>(I2C_CLK_SRC_DEFAULT);
|
||||
i2c_mst_config.i2c_port = LP_I2C_NUM_0;
|
||||
i2c_mst_config.scl_io_num = LP_I2C_SCL_IO;
|
||||
i2c_mst_config.sda_io_num = LP_I2C_SDA_IO;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_ERR(ESP_ERR_NOT_SUPPORTED, i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
@@ -99,22 +99,21 @@ static void lp_i2c_master_write_test(void)
|
||||
uint8_t data_wr[DATA_LENGTH] = { 0 };
|
||||
int i;
|
||||
|
||||
i2c_master_bus_config_t i2c_mst_config = {
|
||||
.lp_source_clk = LP_I2C_SCLK_DEFAULT,
|
||||
.i2c_port = LP_I2C_NUM_0,
|
||||
.scl_io_num = LP_I2C_SCL_IO,
|
||||
.sda_io_num = LP_I2C_SDA_IO,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_config_t i2c_mst_config = {};
|
||||
i2c_mst_config.lp_source_clk = LP_I2C_SCLK_DEFAULT;
|
||||
i2c_mst_config.i2c_port = LP_I2C_NUM_0;
|
||||
i2c_mst_config.scl_io_num = LP_I2C_SCL_IO;
|
||||
i2c_mst_config.sda_io_num = LP_I2C_SDA_IO;
|
||||
i2c_mst_config.flags.enable_internal_pullup = true;
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
TEST_ESP_OK(i2c_new_master_bus(&i2c_mst_config, &bus_handle));
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = 0x58,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_device_config_t dev_cfg = {};
|
||||
dev_cfg.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||
dev_cfg.device_address = 0x58;
|
||||
dev_cfg.scl_speed_hz = 100000;
|
||||
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
TEST_ESP_OK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
@@ -139,26 +138,24 @@ static void hp_i2c_slave_read_test(void)
|
||||
i2c_slave_dev_handle_t handle;
|
||||
event_queue = xQueueCreate(2, sizeof(i2c_slave_event_t));
|
||||
assert(event_queue);
|
||||
temp_data = heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT);
|
||||
temp_data = static_cast<uint8_t*>(heap_caps_malloc(DATA_LENGTH, MALLOC_CAP_DEFAULT));
|
||||
assert(temp_data);
|
||||
|
||||
i2c_slave_config_t i2c_slv_config = {
|
||||
.i2c_port = TEST_I2C_PORT,
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = LP_I2C_SCL_IO,
|
||||
.sda_io_num = LP_I2C_SDA_IO,
|
||||
.slave_addr = 0x58,
|
||||
.send_buf_depth = DATA_LENGTH,
|
||||
.receive_buf_depth = DATA_LENGTH,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_slave_config_t i2c_slv_config = {};
|
||||
i2c_slv_config.i2c_port = TEST_I2C_PORT;
|
||||
i2c_slv_config.sda_io_num = LP_I2C_SDA_IO;
|
||||
i2c_slv_config.scl_io_num = LP_I2C_SCL_IO;
|
||||
i2c_slv_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_slv_config.send_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.receive_buf_depth = DATA_LENGTH;
|
||||
i2c_slv_config.slave_addr = 0x58;
|
||||
i2c_slv_config.flags.enable_internal_pullup = true;
|
||||
|
||||
TEST_ESP_OK(i2c_new_slave_device(&i2c_slv_config, &handle));
|
||||
|
||||
i2c_slave_event_callbacks_t cbs = {
|
||||
.on_receive = i2c_slave_receive_cb,
|
||||
.on_request = i2c_slave_request_cb,
|
||||
};
|
||||
i2c_slave_event_callbacks_t cbs = {};
|
||||
cbs.on_request = i2c_slave_request_cb;
|
||||
cbs.on_receive = i2c_slave_receive_cb;
|
||||
|
||||
TEST_ESP_OK(i2c_slave_register_event_callbacks(handle, &cbs, NULL));
|
||||
|
@@ -411,12 +411,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -413,12 +413,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -434,12 +434,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -414,12 +414,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -427,12 +427,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -415,12 +415,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -415,12 +415,12 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof (dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof (dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -413,12 +413,12 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof (dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof (dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -425,12 +425,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -354,12 +354,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
@@ -417,12 +417,11 @@ static inline bool spimem_flash_ll_host_idle(const spi_mem_dev_t *dev)
|
||||
*/
|
||||
static inline void spimem_flash_ll_read_phase(spi_mem_dev_t *dev)
|
||||
{
|
||||
typeof(dev->user) user = {
|
||||
.usr_mosi = 0,
|
||||
.usr_miso = 1,
|
||||
.usr_addr = 1,
|
||||
.usr_command = 1,
|
||||
};
|
||||
typeof(dev->user) user = {};
|
||||
user.usr_mosi = 0;
|
||||
user.usr_miso = 1;
|
||||
user.usr_addr = 1;
|
||||
user.usr_command = 1;
|
||||
dev->user.val = user.val;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user