mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-23 01:05:14 +00:00
change(driver): reformat driver component with astyle_py
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
|
||||
#define TIME_REMAIN(start, end, timeout) TIME_REMAIN_CORE(start, end, timeout, UINT32_MAX)
|
||||
|
||||
|
||||
#define ESSL_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
__attribute__((unused)) static const char TAG[] = "esp_serial_slave_link";
|
||||
@@ -43,7 +42,6 @@ __attribute__((unused)) static const char TAG[] = "esp_serial_slave_link";
|
||||
|
||||
#define CHECK_EXECUTE_CMD(DEV, CMD, ...) _CHECK_EXECUTE_CMD(DEV, CMD, #CMD" not supported for the current device.",##__VA_ARGS__)
|
||||
|
||||
|
||||
esp_err_t essl_init(essl_handle_t handle, uint32_t wait_ms)
|
||||
{
|
||||
CHECK_EXECUTE_CMD(handle, init, wait_ms);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,7 +28,6 @@ static const char TAG[] = "essl_sdio";
|
||||
#define HOST_SLC0HOST_INT_CLR_REG (DR_REG_SLCHOST_BASE + 0xD4)
|
||||
#define HOST_SLC0HOST_FUNC1_INT_ENA_REG (DR_REG_SLCHOST_BASE + 0xDC)
|
||||
|
||||
|
||||
#define HOST_SLCHOST_CONF_W_REG(pos) (HOST_SLCHOST_CONF_W0_REG+pos+(pos>23?4:0)+(pos>31?12:0))
|
||||
|
||||
#define ESSL_CMD53_END_ADDR 0x1f800
|
||||
@@ -79,7 +78,6 @@ typedef struct {
|
||||
///< Block size of the SDIO function 1. After the initialization this will hold the value the slave really do. Valid value is 1-2048.
|
||||
} essl_sdio_context_t;
|
||||
|
||||
|
||||
esp_err_t essl_sdio_update_tx_buffer_num(void *arg, uint32_t wait_ms);
|
||||
esp_err_t essl_sdio_update_rx_data_size(void *arg, uint32_t wait_ms);
|
||||
|
||||
@@ -139,7 +137,7 @@ cleanup:
|
||||
esp_err_t essl_sdio_deinit_dev(essl_handle_t handle)
|
||||
{
|
||||
if (handle) {
|
||||
free (handle->args);
|
||||
free(handle->args);
|
||||
}
|
||||
free(handle);
|
||||
return ESP_OK;
|
||||
@@ -412,7 +410,6 @@ esp_err_t essl_sdio_update_rx_data_size(void *arg, uint32_t wait_ms)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t essl_sdio_write_reg(void *arg, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms)
|
||||
{
|
||||
ESP_LOGV(TAG, "write_reg: 0x%02"PRIX8, value);
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
// Definitions of Espressif SDIO Slave hardware
|
||||
|
||||
|
||||
#include "essl_sdio.h"
|
||||
|
||||
essl_sdio_def_t ESSL_SDIO_DEF_ESP32 = {
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -67,7 +66,6 @@ esp_err_t essl_get_tx_buffer_num(essl_handle_t handle, uint32_t *out_tx_num, uin
|
||||
*/
|
||||
esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uint32_t wait_ms);
|
||||
|
||||
|
||||
/** Reset the counters of this component. Usually you don't need to do this unless you know the slave is reset.
|
||||
*
|
||||
* @param handle Handle of an ESSL device.
|
||||
|
@@ -25,7 +25,6 @@ extern essl_sdio_def_t ESSL_SDIO_DEF_ESP32;
|
||||
/// Definitions of ESP32C6 SDIO Slave hardware
|
||||
extern essl_sdio_def_t ESSL_SDIO_DEF_ESP32C6;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: From the view of master
|
||||
|
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
void test_fill_random_to_buffers_dualboard(uint32_t seed, uint8_t *dut0_buffer, uint8_t *dut1_buffer, size_t buffer_size);
|
||||
|
||||
|
||||
/**
|
||||
* Fill tx buffer with random numbers
|
||||
*
|
||||
@@ -33,7 +32,6 @@ void test_fill_random_to_buffers_dualboard(uint32_t seed, uint8_t *dut0_buffer,
|
||||
*/
|
||||
void test_fill_random_to_buffer(uint32_t seed, uint8_t *buffer, size_t buffer_size);
|
||||
|
||||
|
||||
/**
|
||||
* Calloc a pool, filled with random numbers
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#define TEST_SPI_PERIPH_NUM (SOC_SPI_PERIPH_NUM - 1)
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C6 // cs_pin conflict with uart pin
|
||||
#define PIN_NUM_MISO SPI2_IOMUX_PIN_NUM_MISO
|
||||
#define PIN_NUM_MOSI SPI2_IOMUX_PIN_NUM_MOSI
|
||||
@@ -46,7 +45,6 @@
|
||||
#define PIN_NUM_HD SPI2_IOMUX_PIN_NUM_HD
|
||||
#endif
|
||||
|
||||
|
||||
#if (TEST_SPI_PERIPH_NUM >= 2) // esp32, s2, s3
|
||||
#define TEST_SPI_HOST SPI2_HOST
|
||||
#define TEST_SLAVE_HOST SPI3_HOST
|
||||
@@ -62,7 +60,6 @@
|
||||
#define TEST_SLAVE_HOST SPI2_HOST
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 // spi3 have iomux pin only on esp32
|
||||
#define SLAVE_IOMUX_PIN_MISO SPI3_IOMUX_PIN_NUM_MISO
|
||||
#define SLAVE_IOMUX_PIN_MOSI SPI3_IOMUX_PIN_NUM_MOSI
|
||||
@@ -97,13 +94,11 @@
|
||||
#define WIRE_DELAY 12.5
|
||||
#endif //CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
|
||||
#define GET_DMA_CHAN(HOST) (HOST)
|
||||
|
||||
#define TEST_DMA_CHAN_MASTER GET_DMA_CHAN(TEST_SPI_HOST)
|
||||
#define TEST_DMA_CHAN_SLAVE GET_DMA_CHAN(TEST_SLAVE_HOST)
|
||||
|
||||
|
||||
#define FUNC_SPI 1
|
||||
#define FUNC_GPIO PIN_FUNC_GPIO
|
||||
|
||||
@@ -274,7 +269,7 @@ esp_err_t spitest_check_data(int len, spi_transaction_t *master_t, slave_rxdata_
|
||||
|
||||
static inline int get_trans_len(spi_dup_t dup, spi_transaction_t *master_t)
|
||||
{
|
||||
if (dup!=HALF_DUPLEX_MISO) {
|
||||
if (dup != HALF_DUPLEX_MISO) {
|
||||
return master_t->length;
|
||||
} else {
|
||||
return master_t->rxlength;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -16,10 +16,12 @@ void test_serializer(const param_group_t *param_group, const ptest_func_t* test_
|
||||
test_func->pre_test(&context);
|
||||
|
||||
void *pset = param_group->param_group;
|
||||
for (int i = param_group->pset_num; i >0; i--) {
|
||||
if (test_func->def_param) test_func->def_param(pset);
|
||||
for (int i = param_group->pset_num; i > 0; i--) {
|
||||
if (test_func->def_param) {
|
||||
test_func->def_param(pset);
|
||||
}
|
||||
test_func->loop(pset, context);
|
||||
pset+=param_group->pset_size;
|
||||
pset += param_group->pset_size;
|
||||
}
|
||||
|
||||
test_func->post_test(context);
|
||||
|
@@ -29,7 +29,6 @@ void test_fill_random_to_buffer(uint32_t seed, uint8_t *buffer, size_t buffer_si
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Create a pool with random numbers, get buffer from pool
|
||||
---------------------------------------------------------------*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,8 +10,7 @@
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
|
||||
|
||||
int test_freq_default[]=TEST_FREQ_DEFAULT();
|
||||
int test_freq_default[] = TEST_FREQ_DEFAULT();
|
||||
|
||||
const char MASTER_TAG[] = "test_master";
|
||||
const char SLAVE_TAG[] = "test_slave";
|
||||
@@ -23,7 +22,7 @@ DRAM_ATTR uint8_t spitest_master_send[] = {
|
||||
0x74,
|
||||
0x93, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0xaa, 0xcc, 0xff, 0xee, 0x55, 0x77, 0x88, 0x43,
|
||||
0x74,
|
||||
};
|
||||
};
|
||||
DRAM_ATTR uint8_t spitest_slave_send[] = {
|
||||
0xaa, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x13, 0x57, 0x9b, 0xdf, 0x24, 0x68, 0xac, 0xe0,
|
||||
0xda,
|
||||
@@ -31,13 +30,15 @@ DRAM_ATTR uint8_t spitest_slave_send[] = {
|
||||
0xda,
|
||||
0xaa, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x13, 0x57, 0x9b, 0xdf, 0x24, 0x68, 0xac, 0xe0,
|
||||
0xda,
|
||||
};
|
||||
};
|
||||
|
||||
void spitest_def_param(void* arg)
|
||||
{
|
||||
spitest_param_set_t *param_set=(spitest_param_set_t*)arg;
|
||||
spitest_param_set_t *param_set = (spitest_param_set_t*)arg;
|
||||
param_set->test_size = 8;
|
||||
if (param_set->freq_list==NULL) param_set->freq_list = test_freq_default;
|
||||
if (param_set->freq_list == NULL) {
|
||||
param_set->freq_list = test_freq_default;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************
|
||||
@@ -45,25 +46,25 @@ void spitest_def_param(void* arg)
|
||||
*********************************************************************************/
|
||||
esp_err_t init_slave_context(spi_slave_task_context_t *context, spi_host_device_t host)
|
||||
{
|
||||
context->data_to_send = xQueueCreate( 16, sizeof( slave_txdata_t ));
|
||||
if ( context->data_to_send == NULL ) {
|
||||
context->data_to_send = xQueueCreate(16, sizeof(slave_txdata_t));
|
||||
if (context->data_to_send == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
context->data_received = xRingbufferCreate( 1024, RINGBUF_TYPE_NOSPLIT );
|
||||
if ( context->data_received == NULL ) {
|
||||
context->data_received = xRingbufferCreate(1024, RINGBUF_TYPE_NOSPLIT);
|
||||
if (context->data_received == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
context->spi=host;
|
||||
context->spi = host;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void deinit_slave_context(spi_slave_task_context_t *context)
|
||||
{
|
||||
TEST_ASSERT( context->data_to_send != NULL );
|
||||
vQueueDelete( context->data_to_send );
|
||||
TEST_ASSERT(context->data_to_send != NULL);
|
||||
vQueueDelete(context->data_to_send);
|
||||
context->data_to_send = NULL;
|
||||
TEST_ASSERT( context->data_received != NULL );
|
||||
vRingbufferDelete( context->data_received );
|
||||
TEST_ASSERT(context->data_received != NULL);
|
||||
vRingbufferDelete(context->data_received);
|
||||
context->data_received = NULL;
|
||||
}
|
||||
|
||||
@@ -76,27 +77,27 @@ void spitest_slave_task(void* arg)
|
||||
spi_slave_task_context_t* context = (spi_slave_task_context_t*) arg;
|
||||
QueueHandle_t queue = context->data_to_send;
|
||||
RingbufHandle_t ringbuf = context->data_received;
|
||||
uint8_t recvbuf[320+8];
|
||||
uint8_t recvbuf[320 + 8];
|
||||
slave_txdata_t txdata;
|
||||
|
||||
ESP_LOGI( SLAVE_TAG, "slave up" );
|
||||
ESP_LOGI(SLAVE_TAG, "slave up");
|
||||
//never quit, but blocked by the queue, waiting to be killed, when no more send from main task.
|
||||
while( 1 ) {
|
||||
BaseType_t ret = xQueueReceive( queue, &txdata, portMAX_DELAY );
|
||||
while (1) {
|
||||
BaseType_t ret = xQueueReceive(queue, &txdata, portMAX_DELAY);
|
||||
assert(ret);
|
||||
|
||||
spi_slave_transaction_t t = {};
|
||||
t.length = txdata.len;
|
||||
t.tx_buffer = txdata.start;
|
||||
t.rx_buffer = recvbuf+8;
|
||||
t.rx_buffer = recvbuf + 8;
|
||||
//loop until trans_len != 0 to skip glitches
|
||||
do {
|
||||
TEST_ESP_OK( spi_slave_transmit( context->spi, &t, portMAX_DELAY ) );
|
||||
} while ( t.trans_len <= 2 );
|
||||
TEST_ESP_OK(spi_slave_transmit(context->spi, &t, portMAX_DELAY));
|
||||
} while (t.trans_len <= 2);
|
||||
memcpy(recvbuf, &t.trans_len, sizeof(uint32_t));
|
||||
*(uint8_t**)(recvbuf+4) = (uint8_t*)txdata.start;
|
||||
ESP_LOGD( SLAVE_TAG, "received: %" PRIu32, (uint32_t)t.trans_len );
|
||||
xRingbufferSend( ringbuf, recvbuf, 8+(t.trans_len+7)/8, portMAX_DELAY );
|
||||
*(uint8_t**)(recvbuf + 4) = (uint8_t*)txdata.start;
|
||||
ESP_LOGD(SLAVE_TAG, "received: %" PRIu32, (uint32_t)t.trans_len);
|
||||
xRingbufferSend(ringbuf, recvbuf, 8 + (t.trans_len + 7) / 8, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +121,11 @@ void spitest_init_transactions(const spitest_param_set_t *cfg, spitest_context_t
|
||||
const spi_dup_t dup = cfg->dup;
|
||||
|
||||
for (int i = 0; i < cfg->test_size; i++) {
|
||||
const void* tx_buffer = spitest_master_send + i%8;
|
||||
int length = 8*test_len[i];
|
||||
if (cfg->length_aligned) length = (length+31)&(~31);
|
||||
const void* tx_buffer = spitest_master_send + i % 8;
|
||||
int length = 8 * test_len[i];
|
||||
if (cfg->length_aligned) {
|
||||
length = (length + 31) & (~31);
|
||||
}
|
||||
|
||||
if (dup == HALF_DUPLEX_MISO) {
|
||||
trans[i] = (spi_transaction_t) {
|
||||
@@ -141,30 +144,38 @@ void spitest_init_transactions(const spitest_param_set_t *cfg, spitest_context_t
|
||||
.rx_buffer = rx_buf_ptr,
|
||||
};
|
||||
}
|
||||
rx_buf_ptr = (uint8_t*)( (uint32_t)(rx_buf_ptr + (length+7)/8 + 3) & (~3));
|
||||
rx_buf_ptr = (uint8_t*)((uint32_t)(rx_buf_ptr + (length + 7) / 8 + 3) & (~3));
|
||||
|
||||
const void* slave_tx = spitest_slave_send + (cfg->slave_unaligned_addr? i%3: (i%3)*4);
|
||||
const void* slave_tx = spitest_slave_send + (cfg->slave_unaligned_addr ? i % 3 : (i % 3) * 4);
|
||||
//prepare slave tx data
|
||||
context->slave_trans[i] = (slave_txdata_t) {
|
||||
.start = slave_tx,
|
||||
.len = 512,
|
||||
};
|
||||
if (cfg->slave_dma_chan != 0) context->slave_trans[i].len = 1024;
|
||||
if (cfg->slave_dma_chan != 0) {
|
||||
context->slave_trans[i].len = 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void spitest_master_print_data(spi_transaction_t *t, int rxlength)
|
||||
{
|
||||
if (t->tx_buffer) ESP_LOG_BUFFER_HEX( "master tx", t->tx_buffer, t->length/8 );
|
||||
if (t->rx_buffer) ESP_LOG_BUFFER_HEX( "master rx", t->rx_buffer, rxlength/8 );
|
||||
if (t->tx_buffer) {
|
||||
ESP_LOG_BUFFER_HEX("master tx", t->tx_buffer, t->length / 8);
|
||||
}
|
||||
if (t->rx_buffer) {
|
||||
ESP_LOG_BUFFER_HEX("master rx", t->rx_buffer, rxlength / 8);
|
||||
}
|
||||
}
|
||||
|
||||
void spitest_slave_print_data(slave_rxdata_t *t, bool print_rxdata)
|
||||
{
|
||||
int rcv_len = (t->len+7)/8;
|
||||
int rcv_len = (t->len + 7) / 8;
|
||||
ESP_LOGI(SLAVE_TAG, "trans_len: %" PRIu32, t->len);
|
||||
ESP_LOG_BUFFER_HEX("slave tx", t->tx_start, rcv_len);
|
||||
if (print_rxdata) ESP_LOG_BUFFER_HEX("slave rx", t->data, rcv_len);
|
||||
if (print_rxdata) {
|
||||
ESP_LOG_BUFFER_HEX("slave rx", t->data, rcv_len);
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t spitest_check_data(int len, spi_transaction_t *master_t, slave_rxdata_t *slave_t, bool check_master_data, bool check_slave_len, bool check_slave_data)
|
||||
@@ -173,18 +184,18 @@ esp_err_t spitest_check_data(int len, spi_transaction_t *master_t, slave_rxdata_
|
||||
uint32_t rcv_len = slave_t->len;
|
||||
//currently the rcv_len can be in range of [t->length-1, t->length+3]
|
||||
if (check_slave_len &&
|
||||
(rcv_len < len - 1 || rcv_len > len + 4)) {
|
||||
ret = ESP_FAIL;
|
||||
(rcv_len < len - 1 || rcv_len > len + 4)) {
|
||||
ret = ESP_FAIL;
|
||||
}
|
||||
|
||||
if (check_master_data &&
|
||||
memcmp(slave_t->tx_start, master_t->rx_buffer, (len + 7) / 8) != 0 ) {
|
||||
ret = ESP_FAIL;
|
||||
memcmp(slave_t->tx_start, master_t->rx_buffer, (len + 7) / 8) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
}
|
||||
|
||||
if (check_slave_data &&
|
||||
memcmp(master_t->tx_buffer, slave_t->data, (len + 7) / 8) != 0 ) {
|
||||
ret = ESP_FAIL;
|
||||
memcmp(master_t->tx_buffer, slave_t->data, (len + 7) / 8) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
}
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGI(SLAVE_TAG, "slave_recv_len: %" PRIu32, rcv_len);
|
||||
@@ -201,11 +212,10 @@ esp_err_t spitest_check_data(int len, spi_transaction_t *master_t, slave_rxdata_
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
void master_free_device_bus(spi_device_handle_t spi)
|
||||
{
|
||||
TEST_ESP_OK( spi_bus_remove_device(spi) );
|
||||
TEST_ESP_OK( spi_bus_free(TEST_SPI_HOST) );
|
||||
TEST_ESP_OK(spi_bus_remove_device(spi));
|
||||
TEST_ESP_OK(spi_bus_free(TEST_SPI_HOST));
|
||||
}
|
||||
|
||||
void spitest_gpio_output_sel(uint32_t gpio_num, int func, uint32_t signal_idx)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -48,17 +48,17 @@ TEST_CASE("DAC_output(RTC)_check_by_adc", "[dac_legacy]")
|
||||
{
|
||||
gpio_num_t adc_gpio_num, dac_gpio_num;
|
||||
|
||||
TEST_ESP_OK( adc2_pad_get_io_num( ADC_TEST_CHANNEL_NUM, &adc_gpio_num ) );
|
||||
TEST_ESP_OK( dac_pad_get_io_num( DAC_TEST_CHANNEL_NUM, &dac_gpio_num ) );
|
||||
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
|
||||
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
|
||||
|
||||
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num );
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
|
||||
|
||||
TEST_ESP_OK( dac_output_enable( DAC_TEST_CHANNEL_NUM ) );
|
||||
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
|
||||
|
||||
//be sure to do the init before using adc2.
|
||||
printf("adc2_init...\n");
|
||||
TEST_ESP_OK( adc2_config_channel_atten( ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN ) );
|
||||
TEST_ESP_OK(adc2_config_channel_atten(ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN));
|
||||
|
||||
vTaskDelay(2 * portTICK_PERIOD_MS);
|
||||
|
||||
@@ -66,28 +66,28 @@ TEST_CASE("DAC_output(RTC)_check_by_adc", "[dac_legacy]")
|
||||
int output_data = 0;
|
||||
int read_raw = 0, read_old = 0;
|
||||
for (int i = 0; i < DAC_OUT_TIMES; i++) {
|
||||
TEST_ESP_OK( dac_output_voltage( DAC_TEST_CHANNEL_NUM, output_data ) );
|
||||
TEST_ESP_OK(dac_output_voltage(DAC_TEST_CHANNEL_NUM, output_data));
|
||||
output_data += DAC_OUT_STEP;
|
||||
vTaskDelay(2 * portTICK_PERIOD_MS);
|
||||
TEST_ESP_OK( adc2_get_raw( ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw) );
|
||||
TEST_ESP_OK(adc2_get_raw(ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw));
|
||||
ESP_LOGI(TAG, "DAC: %d - ADC: %d", output_data, read_raw);
|
||||
if (read_old != 0) {
|
||||
TEST_ASSERT_GREATER_THAN(read_old, read_raw);
|
||||
}
|
||||
read_old = read_raw;
|
||||
}
|
||||
TEST_ESP_OK( dac_output_disable( DAC_TEST_CHANNEL_NUM ) );
|
||||
TEST_ESP_OK(dac_output_disable(DAC_TEST_CHANNEL_NUM));
|
||||
}
|
||||
|
||||
TEST_CASE("DAC_cw_generator_output(RTC)_check_by_adc", "[dac_legacy]")
|
||||
{
|
||||
gpio_num_t adc_gpio_num, dac_gpio_num;
|
||||
|
||||
TEST_ESP_OK( adc2_pad_get_io_num( ADC_TEST_CHANNEL_NUM, &adc_gpio_num ) );
|
||||
TEST_ESP_OK( dac_pad_get_io_num( DAC_TEST_CHANNEL_NUM, &dac_gpio_num ) );
|
||||
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
|
||||
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
|
||||
|
||||
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num );
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
|
||||
|
||||
dac_cw_config_t cw = {
|
||||
.en_ch = DAC_TEST_CHANNEL_NUM,
|
||||
@@ -100,13 +100,13 @@ TEST_CASE("DAC_cw_generator_output(RTC)_check_by_adc", "[dac_legacy]")
|
||||
.offset = 16,
|
||||
#endif
|
||||
};
|
||||
TEST_ESP_OK( dac_cw_generator_config(&cw) );
|
||||
TEST_ESP_OK( dac_cw_generator_enable() );
|
||||
TEST_ESP_OK( dac_output_enable( DAC_TEST_CHANNEL_NUM ) );
|
||||
TEST_ESP_OK(dac_cw_generator_config(&cw));
|
||||
TEST_ESP_OK(dac_cw_generator_enable());
|
||||
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
|
||||
|
||||
//be sure to do the init before using adc2.
|
||||
printf("adc2_init...\n");
|
||||
TEST_ESP_OK( adc2_config_channel_atten( ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN ) );
|
||||
TEST_ESP_OK(adc2_config_channel_atten(ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN));
|
||||
|
||||
vTaskDelay(2 * portTICK_PERIOD_MS);
|
||||
|
||||
@@ -114,14 +114,14 @@ TEST_CASE("DAC_cw_generator_output(RTC)_check_by_adc", "[dac_legacy]")
|
||||
int read_raw[3] = {0};
|
||||
for (int i = 0; i < DAC_TEST_TIMES; i++) {
|
||||
vTaskDelay(10 * portTICK_PERIOD_MS);
|
||||
TEST_ESP_OK( adc2_get_raw( ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw[0]) );
|
||||
TEST_ESP_OK(adc2_get_raw(ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw[0]));
|
||||
ESP_LOGI(TAG, "ADC: %d", read_raw[0]);
|
||||
read_raw[2] = read_raw[1];
|
||||
read_raw[1] = read_raw[0];
|
||||
}
|
||||
|
||||
TEST_ESP_OK( dac_cw_generator_disable() );
|
||||
TEST_ESP_OK( dac_output_disable( DAC_TEST_CHANNEL_NUM ) );
|
||||
TEST_ESP_OK(dac_cw_generator_disable());
|
||||
TEST_ESP_OK(dac_output_disable(DAC_TEST_CHANNEL_NUM));
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
@@ -136,7 +136,7 @@ static bool subtest_adc_dac(int mV_ref, esp_adc_cal_characteristics_t * chars)
|
||||
int raw;
|
||||
adc2_get_raw((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_WIDTH_BIT_13, &raw);
|
||||
uint32_t voltage = esp_adc_cal_raw_to_voltage(raw, chars);
|
||||
TEST_ASSERT_INT_WITHIN( 200, mV_ref, voltage ); // 200 mV error allowance, because both DAC and ADC have error
|
||||
TEST_ASSERT_INT_WITHIN(200, mV_ref, voltage); // 200 mV error allowance, because both DAC and ADC have error
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ TEST_CASE("esp32s2_adc2-dac_with_adc2_calibration", "[dac_legacy]")
|
||||
if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP) != ESP_OK) {
|
||||
TEST_IGNORE_MESSAGE("Warning: This esp32s2 board does not support calibration. This test will be skipped.\n");
|
||||
}
|
||||
TEST_ESP_OK( adc2_pad_get_io_num( ADC_TEST_CHANNEL_NUM, &adc_gpio_num ) );
|
||||
TEST_ESP_OK( dac_pad_get_io_num( DAC_TEST_CHANNEL_NUM, &dac_gpio_num ) );
|
||||
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
|
||||
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
|
||||
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num );
|
||||
TEST_ESP_OK( dac_output_enable( DAC_TEST_CHANNEL_NUM ) );
|
||||
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
|
||||
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
|
||||
|
||||
esp_adc_cal_characteristics_t chars;
|
||||
|
||||
|
@@ -85,14 +85,13 @@
|
||||
|
||||
const __attribute__((unused)) static char *TAG = "TEST_ADC_LEGACY";
|
||||
|
||||
|
||||
void test_adc_set_io_level(adc_unit_t unit, adc_channel_t channel, bool level)
|
||||
{
|
||||
TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel");
|
||||
|
||||
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
|
||||
uint32_t io_num = ADC_GET_IO_NUM(unit, channel);
|
||||
TEST_ESP_OK(gpio_set_pull_mode(io_num, (level ? GPIO_PULLUP_ONLY: GPIO_PULLDOWN_ONLY)));
|
||||
TEST_ESP_OK(gpio_set_pull_mode(io_num, (level ? GPIO_PULLUP_ONLY : GPIO_PULLDOWN_ONLY)));
|
||||
#else
|
||||
gpio_num_t io_num = ADC_GET_IO_NUM(unit, channel);
|
||||
if (level) {
|
||||
|
@@ -50,17 +50,16 @@ static DRAM_ATTR i2c_dev_t *const I2C[SOC_I2C_NUM] = { &I2C0,
|
||||
#if SOC_I2C_NUM > 1
|
||||
&I2C1,
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#define ACK_VAL 0
|
||||
#define NACK_VAL 1
|
||||
|
||||
|
||||
static esp_err_t i2c_master_write_slave(i2c_port_t i2c_num, uint8_t *data_wr, size_t size)
|
||||
{
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
TEST_ESP_OK(i2c_master_write_byte(cmd, ( ESP_SLAVE_ADDR << 1 ) | WRITE_BIT, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | WRITE_BIT, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_write(cmd, data_wr, size, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_stop(cmd));
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 5000 / portTICK_PERIOD_MS);
|
||||
@@ -82,7 +81,6 @@ static i2c_config_t i2c_master_init(void)
|
||||
return conf_master;
|
||||
}
|
||||
|
||||
|
||||
#if SOC_I2C_SUPPORT_SLAVE // i2c test can't work without slave
|
||||
|
||||
static i2c_config_t i2c_slave_init(void)
|
||||
@@ -103,7 +101,7 @@ static i2c_config_t i2c_slave_init(void)
|
||||
|
||||
TEST_CASE("I2C i2c_set_pin() fails if sda and scl gpios are same", "[i2c]")
|
||||
{
|
||||
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, i2c_set_pin(0, 0, 0, true, true , I2C_MODE_MASTER));
|
||||
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, i2c_set_pin(0, 0, 0, true, true, I2C_MODE_MASTER));
|
||||
}
|
||||
|
||||
TEST_CASE("I2C config test", "[i2c]")
|
||||
@@ -137,7 +135,7 @@ TEST_CASE("I2C config test", "[i2c]")
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ASSERT_EQUAL_INT32(I2C[I2C_SLAVE_NUM] -> ctr.ms_mode, 0);
|
||||
TEST_ESP_OK(i2c_driver_delete(I2C_SLAVE_NUM));
|
||||
}
|
||||
@@ -169,16 +167,15 @@ TEST_CASE("I2C set and get period test", "[i2c]")
|
||||
TEST_ESP_OK(i2c_driver_delete(I2C_MASTER_NUM));
|
||||
}
|
||||
|
||||
|
||||
#if SOC_I2C_SUPPORT_SLAVE // i2c test can't work without slave
|
||||
|
||||
TEST_CASE("I2C config FIFO test", "[i2c]")
|
||||
{
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ASSERT_BIT_LOW(1, I2C[I2C_SLAVE_NUM]->fifo_conf.tx_fifo_rst);
|
||||
TEST_ESP_OK(i2c_reset_tx_fifo(I2C_SLAVE_NUM));
|
||||
TEST_ASSERT_BIT_LOW(0, I2C[I2C_SLAVE_NUM]->fifo_conf.tx_fifo_rst);
|
||||
@@ -245,7 +242,7 @@ static void disp_buf(uint8_t *buf, int len)
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("%02x ", buf[i]);
|
||||
if (( i + 1 ) % 16 == 0) {
|
||||
if ((i + 1) % 16 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@@ -283,7 +280,7 @@ static void i2c_slave_read_test(void)
|
||||
int len = 0;
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -291,7 +288,7 @@ static void i2c_slave_read_test(void)
|
||||
|
||||
unity_wait_for_signal("master write");
|
||||
while (1) {
|
||||
len = i2c_slave_read_buffer( I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
len = i2c_slave_read_buffer(I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -321,19 +318,19 @@ static void master_read_slave_test(void)
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, ( ESP_SLAVE_ADDR << 1 ) | READ_BIT, ACK_CHECK_EN);
|
||||
i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | READ_BIT, ACK_CHECK_EN);
|
||||
|
||||
unity_send_signal("slave write");
|
||||
unity_wait_for_signal("master read");
|
||||
i2c_master_read(cmd, data_rd, RW_TEST_LENGTH-1, ACK_VAL);
|
||||
i2c_master_read_byte(cmd, data_rd + RW_TEST_LENGTH-1, NACK_VAL);
|
||||
i2c_master_read(cmd, data_rd, RW_TEST_LENGTH - 1, ACK_VAL);
|
||||
i2c_master_read_byte(cmd, data_rd + RW_TEST_LENGTH - 1, NACK_VAL);
|
||||
i2c_master_stop(cmd);
|
||||
i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 5000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
for (int i = 0; i < RW_TEST_LENGTH; i++) {
|
||||
printf("%d\n", data_rd[i]);
|
||||
TEST_ASSERT(data_rd[i]==i);
|
||||
TEST_ASSERT(data_rd[i] == i);
|
||||
}
|
||||
free(data_rd);
|
||||
unity_send_signal("ready to delete");
|
||||
@@ -346,7 +343,7 @@ static void slave_write_buffer_test(void)
|
||||
int size_rd;
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -364,10 +361,8 @@ static void slave_write_buffer_test(void)
|
||||
i2c_driver_delete(I2C_SLAVE_NUM);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE_MULTIPLE_DEVICES("I2C master read slave test", "[i2c][test_env=generic_multi_device][timeout=150]", master_read_slave_test, slave_write_buffer_test);
|
||||
|
||||
|
||||
static void i2c_master_write_read_test(void)
|
||||
{
|
||||
uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH);
|
||||
@@ -382,7 +377,7 @@ static void i2c_master_write_read_test(void)
|
||||
unity_wait_for_signal("i2c slave init finish");
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, ( ESP_SLAVE_ADDR << 1 ) | READ_BIT, ACK_CHECK_EN);
|
||||
i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | READ_BIT, ACK_CHECK_EN);
|
||||
|
||||
unity_send_signal("slave write");
|
||||
unity_wait_for_signal("master read and write");
|
||||
@@ -394,7 +389,7 @@ static void i2c_master_write_read_test(void)
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
disp_buf(data_rd, RW_TEST_LENGTH);
|
||||
for (int i = 0; i < RW_TEST_LENGTH; i++) {
|
||||
TEST_ASSERT(data_rd[i] == i/2);
|
||||
TEST_ASSERT(data_rd[i] == i / 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < DATA_LENGTH; i++) {
|
||||
@@ -418,7 +413,7 @@ static void i2c_slave_read_write_test(void)
|
||||
int size_rd;
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -426,13 +421,13 @@ static void i2c_slave_read_write_test(void)
|
||||
unity_wait_for_signal("slave write");
|
||||
|
||||
for (int i = 0; i < DATA_LENGTH / 2; i++) {
|
||||
data_wr[i] = i/2;
|
||||
data_wr[i] = i / 2;
|
||||
}
|
||||
size_rd = i2c_slave_write_buffer(I2C_SLAVE_NUM, data_wr, RW_TEST_LENGTH, 2000 / portTICK_PERIOD_MS);
|
||||
disp_buf(data_wr, size_rd);
|
||||
unity_send_signal("master read and write");
|
||||
unity_wait_for_signal("slave read");
|
||||
size_rd = i2c_slave_read_buffer( I2C_SLAVE_NUM, data_rd, RW_TEST_LENGTH, 1000 / portTICK_PERIOD_MS);
|
||||
size_rd = i2c_slave_read_buffer(I2C_SLAVE_NUM, data_rd, RW_TEST_LENGTH, 1000 / portTICK_PERIOD_MS);
|
||||
printf("slave read data is:\n");
|
||||
disp_buf(data_rd, size_rd);
|
||||
for (int i = 0; i < RW_TEST_LENGTH; i++) {
|
||||
@@ -446,7 +441,6 @@ static void i2c_slave_read_write_test(void)
|
||||
|
||||
TEST_CASE_MULTIPLE_DEVICES("I2C read and write test", "[i2c][test_env=generic_multi_device][timeout=150]", i2c_master_write_read_test, i2c_slave_read_write_test);
|
||||
|
||||
|
||||
static void i2c_master_repeat_write(void)
|
||||
{
|
||||
uint8_t *data_wr = (uint8_t *) malloc(DATA_LENGTH);
|
||||
@@ -480,7 +474,7 @@ static void i2c_slave_repeat_read(void)
|
||||
uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH * 3);
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -488,7 +482,7 @@ static void i2c_slave_repeat_read(void)
|
||||
unity_wait_for_signal("master write");
|
||||
|
||||
while (1) {
|
||||
int len = i2c_slave_read_buffer( I2C_SLAVE_NUM, data_rd + size_rd, RW_TEST_LENGTH * 3, 10000 / portTICK_PERIOD_MS);
|
||||
int len = i2c_slave_read_buffer(I2C_SLAVE_NUM, data_rd + size_rd, RW_TEST_LENGTH * 3, 10000 / portTICK_PERIOD_MS);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -541,7 +535,7 @@ static void i2c_slave_read_test_more_ports(void)
|
||||
int len = 0;
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_NUM_1, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_NUM_1, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_NUM_1, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -549,7 +543,7 @@ static void i2c_slave_read_test_more_ports(void)
|
||||
|
||||
unity_wait_for_signal("master write");
|
||||
while (1) {
|
||||
len = i2c_slave_read_buffer( I2C_NUM_1, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
len = i2c_slave_read_buffer(I2C_NUM_1, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -580,14 +574,14 @@ static void test_task(void *pvParameters)
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
while (exit_flag == false) {
|
||||
if (test_read_func) {
|
||||
i2c_slave_read_buffer(I2C_SLAVE_NUM, data, DATA_LENGTH, 0);
|
||||
} else {
|
||||
i2c_slave_write_buffer(I2C_SLAVE_NUM, data, DATA_LENGTH, 0);
|
||||
}
|
||||
vTaskDelay(10/portTICK_PERIOD_MS);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
free(data);
|
||||
@@ -651,9 +645,9 @@ TEST_CASE("I2C general API test", "[i2c]")
|
||||
.sda_io_num = I2C_MASTER_SDA_IO,
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
};
|
||||
TEST_ESP_OK(i2c_param_config( i2c_num, &conf_master));
|
||||
TEST_ESP_OK(i2c_param_config(i2c_num, &conf_master));
|
||||
int time_get0, time_get1;
|
||||
for(int i = 10; i < I2C_TEST_TIME; i++) {
|
||||
for (int i = 10; i < I2C_TEST_TIME; i++) {
|
||||
//set period test
|
||||
TEST_ESP_OK(i2c_set_period(i2c_num, i, i));
|
||||
TEST_ESP_OK(i2c_get_period(i2c_num, &time_get0, &time_get1));
|
||||
@@ -708,11 +702,11 @@ static void i2c_scl_freq_cal(void)
|
||||
int negpulse_cnt = uart_ll_get_neg_pulse_cnt(&UART1);
|
||||
int high_period_cnt = uart_ll_get_high_pulse_cnt(&UART1);
|
||||
int low_period_cnt = uart_ll_get_low_pulse_cnt(&UART1);
|
||||
if(edg_cnt != expt_cnt) {
|
||||
if (edg_cnt != expt_cnt) {
|
||||
printf("\nedg_cnt != %d, test fail\n", expt_cnt);
|
||||
return;
|
||||
}
|
||||
printf("\nDetected SCL frequency: %d Hz\n", i2c_source_clk_freq / ((pospulse_cnt + negpulse_cnt) / 2) );
|
||||
printf("\nDetected SCL frequency: %d Hz\n", i2c_source_clk_freq / ((pospulse_cnt + negpulse_cnt) / 2));
|
||||
|
||||
printf("\nSCL high period %.3f (us), SCL low_period %.3f (us)\n\n", (float)(i2c_cource_clk_period * high_period_cnt), (float)(i2c_cource_clk_period * low_period_cnt));
|
||||
uart_ll_set_autobaud_en(&UART1, false);
|
||||
@@ -733,7 +727,7 @@ TEST_CASE("I2C SCL freq test (local test)", "[i2c][ignore]")
|
||||
.scl_io_num = I2C_MASTER_SCL_IO,
|
||||
};
|
||||
uint8_t *data = (uint8_t *)malloc(30);
|
||||
TEST_ESP_OK(i2c_param_config( i2c_num, &conf_master));
|
||||
TEST_ESP_OK(i2c_param_config(i2c_num, &conf_master));
|
||||
TEST_ESP_OK(i2c_driver_install(i2c_num, I2C_MODE_MASTER, 0, 0, 0));
|
||||
memset(data, 0, 0);
|
||||
uart_aut_baud_det_init(uart1_rxd_io);
|
||||
|
@@ -40,12 +40,11 @@
|
||||
#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
|
||||
#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
|
||||
|
||||
|
||||
static esp_err_t i2c_master_write_slave(i2c_port_t i2c_num, uint8_t *data_wr, size_t size)
|
||||
{
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
TEST_ESP_OK(i2c_master_write_byte(cmd, ( ESP_SLAVE_ADDR << 1 ) | WRITE_BIT, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | WRITE_BIT, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_write(cmd, data_wr, size, ACK_CHECK_EN));
|
||||
TEST_ESP_OK(i2c_master_stop(cmd));
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 5000 / portTICK_PERIOD_MS);
|
||||
@@ -87,7 +86,7 @@ static void disp_buf(uint8_t *buf, int len)
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("%02x ", buf[i]);
|
||||
if (( i + 1 ) % 16 == 0) {
|
||||
if ((i + 1) % 16 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@@ -143,7 +142,7 @@ static void i2c_slave_read_sleep_test(void)
|
||||
int len = 0;
|
||||
|
||||
i2c_config_t conf_slave = i2c_slave_init();
|
||||
TEST_ESP_OK(i2c_param_config( I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_param_config(I2C_SLAVE_NUM, &conf_slave));
|
||||
TEST_ESP_OK(i2c_driver_install(I2C_SLAVE_NUM, I2C_MODE_SLAVE,
|
||||
I2C_SLAVE_RX_BUF_LEN,
|
||||
I2C_SLAVE_TX_BUF_LEN, 0));
|
||||
@@ -151,7 +150,7 @@ static void i2c_slave_read_sleep_test(void)
|
||||
|
||||
unity_wait_for_signal("master write and sleep");
|
||||
while (1) {
|
||||
len = i2c_slave_read_buffer( I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
len = i2c_slave_read_buffer(I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -173,7 +172,7 @@ static void i2c_slave_read_sleep_test(void)
|
||||
memset(data_rd, 0, DATA_LENGTH);
|
||||
size_rd = 0;
|
||||
while (1) {
|
||||
len = i2c_slave_read_buffer( I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
len = i2c_slave_read_buffer(I2C_SLAVE_NUM, data_rd + size_rd, DATA_LENGTH, 10000 / portTICK_PERIOD_MS);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -89,11 +89,11 @@ static esp_err_t test_touch_sw_read_test_runner(void)
|
||||
ESP_LOGI(TAG, "%s", __func__);
|
||||
uint16_t touch_value;
|
||||
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW));
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL));
|
||||
}
|
||||
|
||||
// Start task to read values sensed by pads
|
||||
@@ -104,7 +104,7 @@ static esp_err_t test_touch_sw_read_test_runner(void)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -114,23 +114,23 @@ static esp_err_t test_touch_sw_read(void)
|
||||
ESP_LOGI(TAG, "%s", __func__);
|
||||
uint16_t touch_value;
|
||||
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW));
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL));
|
||||
}
|
||||
|
||||
// Start task to read values sensed by pads
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
printf("test T%d\n", touch_list[i]);
|
||||
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read(touch_list[i], &touch_value));
|
||||
printf("T%d:[%4d] ", touch_list[i], touch_value);
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -141,29 +141,29 @@ static esp_err_t test_touch_timer_read(void)
|
||||
uint16_t touch_value[TEST_TOUCH_CHANNEL], touch_temp[TEST_TOUCH_CHANNEL];
|
||||
int t_cnt = TEST_TOUCH_COUNT_NUM;
|
||||
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER));
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL));
|
||||
}
|
||||
// Start task to read values sensed by pads
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value[i]) );
|
||||
TEST_ESP_OK(touch_pad_read(touch_list[i], &touch_value[i]));
|
||||
printf("T%d:[%4d] ", touch_list[i], touch_value[i]);
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
||||
}
|
||||
while (t_cnt--) {
|
||||
// Start task to read values sensed by pads
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_temp[i]) );
|
||||
TEST_ESP_OK(touch_pad_read(touch_list[i], &touch_temp[i]));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
||||
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||
}
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -174,11 +174,11 @@ static esp_err_t test_touch_filtered_read(void)
|
||||
uint16_t touch_value, touch_temp;
|
||||
int t_cnt = TEST_TOUCH_COUNT_NUM;
|
||||
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER));
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL));
|
||||
}
|
||||
// Initialize and start a software filter to detect slight change of capacitance.
|
||||
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
|
||||
@@ -186,20 +186,20 @@ static esp_err_t test_touch_filtered_read(void)
|
||||
|
||||
while (t_cnt--) {
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read(touch_list[i], &touch_value));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read_raw_data(touch_list[i], &touch_value));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_temp) );
|
||||
TEST_ESP_OK(touch_pad_read_filtered(touch_list[i], &touch_temp));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp);
|
||||
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp * TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||
printf("T%d:[%4d] ", touch_list[i], touch_value);
|
||||
}
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -214,9 +214,9 @@ TEST_CASE("Touch Sensor all channel read test", "[touch]")
|
||||
#endif
|
||||
TOUCH_REG_BASE_TEST();
|
||||
test_touch_sw_read_test_runner();
|
||||
TEST_ESP_OK( test_touch_sw_read() );
|
||||
TEST_ESP_OK( test_touch_timer_read() );
|
||||
TEST_ESP_OK( test_touch_filtered_read() );
|
||||
TEST_ESP_OK(test_touch_sw_read());
|
||||
TEST_ESP_OK(test_touch_timer_read());
|
||||
TEST_ESP_OK(test_touch_filtered_read());
|
||||
#if CONFIG_PM_ENABLE
|
||||
TEST_ESP_OK(esp_pm_lock_release(pm_lock));
|
||||
TEST_ESP_OK(esp_pm_lock_delete(pm_lock));
|
||||
@@ -227,9 +227,9 @@ static int test_touch_parameter(touch_pad_t pad_num, int meas_time, int slp_time
|
||||
{
|
||||
ESP_LOGI(TAG, "%s", __func__);
|
||||
uint16_t touch_value;
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
|
||||
TEST_ESP_OK( touch_pad_config(pad_num, TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER));
|
||||
TEST_ESP_OK(touch_pad_config(pad_num, TOUCH_READ_INVALID_VAL));
|
||||
|
||||
touch_pad_set_measurement_interval(slp_time);
|
||||
touch_pad_set_measurement_clock_cycles(meas_time);
|
||||
@@ -241,17 +241,17 @@ static int test_touch_parameter(touch_pad_t pad_num, int meas_time, int slp_time
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
|
||||
// Start task to read values sensed by pads
|
||||
TEST_ESP_OK( touch_pad_read(pad_num, &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read(pad_num, &touch_value));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
printf("T%d:[%4d] ", pad_num, touch_value);
|
||||
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read_raw_data(pad_num, &touch_value));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
printf("T%d:[%4d] ", pad_num, touch_value);
|
||||
TEST_ESP_OK( touch_pad_read_filtered(pad_num, &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read_filtered(pad_num, &touch_value));
|
||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||
printf("T%d:[%4d] \n", pad_num, touch_value);
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return touch_value;
|
||||
}
|
||||
@@ -316,12 +316,12 @@ static esp_err_t test_touch_interrupt(void)
|
||||
ESP_LOGI(TAG, "%s", __func__);
|
||||
uint16_t touch_value;
|
||||
|
||||
TEST_ESP_OK( touch_pad_init() );
|
||||
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
|
||||
TEST_ESP_OK(touch_pad_init());
|
||||
TEST_ESP_OK(touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER));
|
||||
touch_pad_set_voltage(TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
|
||||
TEST_ESP_OK(touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL));
|
||||
}
|
||||
// Initialize and start a software filter to detect slight change of capacitance.
|
||||
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
|
||||
@@ -329,16 +329,16 @@ static esp_err_t test_touch_interrupt(void)
|
||||
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
//read filtered value
|
||||
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_value) );
|
||||
TEST_ESP_OK(touch_pad_read_filtered(touch_list[i], &touch_value));
|
||||
ESP_LOGI(TAG, "test init: touch pad [%d] val is %d", touch_list[i], touch_value);
|
||||
//set interrupt threshold.
|
||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * 2 / 3) );
|
||||
TEST_ESP_OK(touch_pad_set_thresh(touch_list[i], touch_value * 2 / 3));
|
||||
}
|
||||
|
||||
// Register touch interrupt ISR
|
||||
TEST_ESP_OK( touch_pad_isr_register(test_touch_intr_cb, NULL) );
|
||||
TEST_ESP_OK( touch_pad_clear_status() );
|
||||
TEST_ESP_OK( touch_pad_intr_enable() );
|
||||
TEST_ESP_OK(touch_pad_isr_register(test_touch_intr_cb, NULL));
|
||||
TEST_ESP_OK(touch_pad_clear_status());
|
||||
TEST_ESP_OK(touch_pad_intr_enable());
|
||||
|
||||
int test_cnt = TEST_TOUCH_COUNT_NUM;
|
||||
while (test_cnt--) {
|
||||
@@ -366,12 +366,12 @@ static esp_err_t test_touch_interrupt(void)
|
||||
printf_touch_hw_read("release");
|
||||
}
|
||||
|
||||
TEST_ESP_OK( touch_pad_deinit() );
|
||||
TEST_ESP_OK(touch_pad_deinit());
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
TEST_CASE("Touch Sensor interrupt test", "[touch]")
|
||||
{
|
||||
TEST_ESP_OK( test_touch_interrupt() );
|
||||
TEST_ESP_OK(test_touch_interrupt());
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -45,20 +45,20 @@ static void float_to_byte(float *target, unsigned char *buf, unsigned char offse
|
||||
*/
|
||||
static void datascope_get_channel_data(float data, unsigned char channel)
|
||||
{
|
||||
if ( (channel > 10) || (channel == 0) ) {
|
||||
if ((channel > 10) || (channel == 0)) {
|
||||
return;
|
||||
} else {
|
||||
switch (channel) {
|
||||
case 1: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 2: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 3: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 4: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 5: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 6: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 7: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 8: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 9: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 10: float_to_byte(&data,datascope_output_buffer, channel*4-3); break;
|
||||
case 1: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 2: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 3: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 4: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 5: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 6: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 7: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 8: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 9: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
case 10: float_to_byte(&data, datascope_output_buffer, channel * 4 - 3); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,21 +71,21 @@ static void datascope_get_channel_data(float data, unsigned char channel)
|
||||
*/
|
||||
static unsigned char datascope_data_generate(unsigned char channel_num)
|
||||
{
|
||||
if ( (channel_num > 10) || (channel_num == 0) ) {
|
||||
if ((channel_num > 10) || (channel_num == 0)) {
|
||||
return 0;
|
||||
} else {
|
||||
datascope_output_buffer[0] = '$'; //frame header
|
||||
switch(channel_num) {
|
||||
case 1: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 2: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 3: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 4: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 5: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 6: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 7: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 8: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 9: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
case 10: datascope_output_buffer[channel_num*4+1] = channel_num*4+1; return channel_num*4+2; break;
|
||||
switch (channel_num) {
|
||||
case 1: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 2: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 3: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 4: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 5: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 6: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 7: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 8: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 9: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
case 10: datascope_output_buffer[channel_num * 4 + 1] = channel_num * 4 + 1; return channel_num * 4 + 2; break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -107,21 +107,21 @@ int test_tp_print_to_scope(float *data, unsigned char channel_num)
|
||||
if (uart_num >= UART_NUM_MAX) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if ( (channel_num > 10) || (channel_num == 0) || (NULL == data) ) {
|
||||
if ((channel_num > 10) || (channel_num == 0) || (NULL == data)) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
for(uint8_t i = 0 ; i < channel_num; i++) {
|
||||
datascope_get_channel_data(data[i] , i+1); // write data x into channel 1~10.
|
||||
for (uint8_t i = 0 ; i < channel_num; i++) {
|
||||
datascope_get_channel_data(data[i], i + 1); // write data x into channel 1~10.
|
||||
}
|
||||
unsigned char out_len = datascope_data_generate(channel_num); // Generate n number data.
|
||||
unsigned char *out_data = datascope_output_buffer;
|
||||
// Init uart.
|
||||
if(uart_num != uart_used) {
|
||||
if (uart_num != uart_used) {
|
||||
return 0;
|
||||
} else {
|
||||
#if ROM_UART_DRIVER_ENABLE
|
||||
esp_rom_output_tx_wait_idle(uart_num); // Default print uart mumber is 0.
|
||||
for(int i=0; i<out_len; i++) {
|
||||
for (int i = 0; i < out_len; i++) {
|
||||
esp_rom_output_tx_one_char(out_data[i]);
|
||||
}
|
||||
return out_len;
|
||||
@@ -155,11 +155,11 @@ esp_err_t test_tp_scope_debug_init(uint8_t uart_num, int tx_io_num, int rx_io_nu
|
||||
{
|
||||
#if ROM_UART_DRIVER_ENABLE
|
||||
esp_rom_output_tx_wait_idle(0); // Default print uart mumber is 0.
|
||||
if(uart_num != 0) {
|
||||
if (uart_num != 0) {
|
||||
esp_rom_output_set_as_console(uart_num);
|
||||
}
|
||||
#else
|
||||
if(uart_used == uart_num) {
|
||||
if (uart_used == uart_num) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (uart_num >= UART_NUM_MAX) {
|
||||
@@ -179,7 +179,7 @@ esp_err_t test_tp_scope_debug_init(uint8_t uart_num, int tx_io_num, int rx_io_nu
|
||||
uart_param_config(uart_num, &uart_config);
|
||||
// Set UART pins using UART0 default pins i.e. no changes
|
||||
uart_set_pin(uart_num, scope_tx_io_num, scope_rx_io_num,
|
||||
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
uart_driver_install(uart_num, 1024, 2048, 0, NULL, 0);
|
||||
uart_used = uart_num;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user