refactor(examples): reformat peripheral examples with astyle_py

This commit is contained in:
morris
2023-09-28 09:43:12 +08:00
parent 1b2484214c
commit b12e250b2c
79 changed files with 677 additions and 703 deletions

View File

@@ -41,7 +41,6 @@ static adc_channel_t channel[2] = {ADC_CHANNEL_2, ADC_CHANNEL_3};
static TaskHandle_t s_task_handle; static TaskHandle_t s_task_handle;
static const char *TAG = "EXAMPLE"; static const char *TAG = "EXAMPLE";
static bool IRAM_ATTR s_conv_done_cb(adc_continuous_handle_t handle, const adc_continuous_evt_data_t *edata, void *user_data) static bool IRAM_ATTR s_conv_done_cb(adc_continuous_handle_t handle, const adc_continuous_evt_data_t *edata, void *user_data)
{ {
BaseType_t mustYield = pdFALSE; BaseType_t mustYield = pdFALSE;

View File

@@ -52,7 +52,6 @@ static int voltage[2][10];
static bool example_adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_atten_t atten, adc_cali_handle_t *out_handle); static bool example_adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_atten_t atten, adc_cali_handle_t *out_handle);
static void example_adc_calibration_deinit(adc_cali_handle_t handle); static void example_adc_calibration_deinit(adc_cali_handle_t handle);
void app_main(void) void app_main(void)
{ {
//-------------ADC1 Init---------------// //-------------ADC1 Init---------------//
@@ -76,7 +75,6 @@ void app_main(void)
bool do_calibration1_chan0 = example_adc_calibration_init(ADC_UNIT_1, EXAMPLE_ADC1_CHAN0, EXAMPLE_ADC_ATTEN, &adc1_cali_chan0_handle); bool do_calibration1_chan0 = example_adc_calibration_init(ADC_UNIT_1, EXAMPLE_ADC1_CHAN0, EXAMPLE_ADC_ATTEN, &adc1_cali_chan0_handle);
bool do_calibration1_chan1 = example_adc_calibration_init(ADC_UNIT_1, EXAMPLE_ADC1_CHAN1, EXAMPLE_ADC_ATTEN, &adc1_cali_chan1_handle); bool do_calibration1_chan1 = example_adc_calibration_init(ADC_UNIT_1, EXAMPLE_ADC1_CHAN1, EXAMPLE_ADC_ATTEN, &adc1_cali_chan1_handle);
#if EXAMPLE_USE_ADC2 #if EXAMPLE_USE_ADC2
//-------------ADC2 Init---------------// //-------------ADC2 Init---------------//
adc_oneshot_unit_handle_t adc2_handle; adc_oneshot_unit_handle_t adc2_handle;
@@ -139,7 +137,6 @@ void app_main(void)
#endif //#if EXAMPLE_USE_ADC2 #endif //#if EXAMPLE_USE_ADC2
} }
/*--------------------------------------------------------------- /*---------------------------------------------------------------
ADC Calibration ADC Calibration
---------------------------------------------------------------*/ ---------------------------------------------------------------*/

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -23,7 +23,6 @@ typedef enum {
SOFT_I2C_FREQ_END SOFT_I2C_FREQ_END
} soft_i2c_master_freq_t; } soft_i2c_master_freq_t;
/** /**
* @brief Structure defining the configuration for the software I2C master bus * @brief Structure defining the configuration for the software I2C master bus
*/ */
@@ -33,13 +32,11 @@ typedef struct {
soft_i2c_master_freq_t freq; soft_i2c_master_freq_t freq;
} soft_i2c_master_config_t; } soft_i2c_master_config_t;
/** /**
* @brief Abstract type representing a software I2C bus. * @brief Abstract type representing a software I2C bus.
*/ */
typedef struct i2c_master_bus_impl_t* soft_i2c_master_bus_t; typedef struct i2c_master_bus_impl_t* soft_i2c_master_bus_t;
/** /**
* @brief Create and configure the software I2C bus. * @brief Create and configure the software I2C bus.
* *
@@ -50,7 +47,6 @@ typedef struct i2c_master_bus_impl_t* soft_i2c_master_bus_t;
*/ */
esp_err_t soft_i2c_master_new(soft_i2c_master_config_t *config, soft_i2c_master_bus_t *bus); esp_err_t soft_i2c_master_new(soft_i2c_master_config_t *config, soft_i2c_master_bus_t *bus);
/** /**
* @brief Delete a previously initialized I2C software bus. * @brief Delete a previously initialized I2C software bus.
* *
@@ -60,7 +56,6 @@ esp_err_t soft_i2c_master_new(soft_i2c_master_config_t *config, soft_i2c_master_
*/ */
esp_err_t soft_i2c_master_del(soft_i2c_master_bus_t bus); esp_err_t soft_i2c_master_del(soft_i2c_master_bus_t bus);
/** /**
* @brief Perform a write to the given device on the software I2C bus. * @brief Perform a write to the given device on the software I2C bus.
* *
@@ -75,7 +70,6 @@ esp_err_t soft_i2c_master_write(soft_i2c_master_bus_t bus,
uint8_t device_address, uint8_t device_address,
const uint8_t* write_buffer, size_t write_size); const uint8_t* write_buffer, size_t write_size);
/** /**
* @brief Perform a read from the given device on the software I2C bus. * @brief Perform a read from the given device on the software I2C bus.
* *
@@ -90,7 +84,6 @@ esp_err_t soft_i2c_master_read(soft_i2c_master_bus_t bus,
uint8_t device_address, uint8_t device_address,
uint8_t* read_buffer, size_t read_size); uint8_t* read_buffer, size_t read_size);
/** /**
* @brief Perform a write followed by a read to the given device on the software I2C bus. * @brief Perform a write followed by a read to the given device on the software I2C bus.
* *

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -28,7 +28,6 @@ static esp_err_t emulate_i2c_transfer(uint8_t device_address,
uint8_t* read_buffer, uint32_t read_size, uint8_t* read_buffer, uint32_t read_size,
soft_i2c_master_bus_t bus); soft_i2c_master_bus_t bus);
/* Mutex required to enter critical sections */ /* Mutex required to enter critical sections */
static portMUX_TYPE g_lock = portMUX_INITIALIZER_UNLOCKED; static portMUX_TYPE g_lock = portMUX_INITIALIZER_UNLOCKED;
@@ -42,7 +41,6 @@ struct i2c_master_bus_impl_t {
dedic_gpio_bundle_handle_t bundle; dedic_gpio_bundle_handle_t bundle;
}; };
esp_err_t soft_i2c_master_new(soft_i2c_master_config_t *config, soft_i2c_master_bus_t *bus) esp_err_t soft_i2c_master_new(soft_i2c_master_config_t *config, soft_i2c_master_bus_t *bus)
{ {
esp_err_t ret; esp_err_t ret;
@@ -103,7 +101,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_i2c_master_del(soft_i2c_master_bus_t bus) esp_err_t soft_i2c_master_del(soft_i2c_master_bus_t bus)
{ {
esp_err_t ret; esp_err_t ret;
@@ -117,7 +114,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_i2c_master_write(soft_i2c_master_bus_t bus, esp_err_t soft_i2c_master_write(soft_i2c_master_bus_t bus,
uint8_t device_address, uint8_t device_address,
const uint8_t* write_buffer, size_t write_size) const uint8_t* write_buffer, size_t write_size)
@@ -159,7 +155,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_i2c_master_write_read(soft_i2c_master_bus_t bus, esp_err_t soft_i2c_master_write_read(soft_i2c_master_bus_t bus,
uint8_t device_address, uint8_t device_address,
const uint8_t* write_buffer, size_t write_size, const uint8_t* write_buffer, size_t write_size,
@@ -184,7 +179,6 @@ error:
return ret; return ret;
} }
/***** Private implementation *****/ /***** Private implementation *****/
static uint32_t freq_to_delay(soft_i2c_master_freq_t freq) static uint32_t freq_to_delay(soft_i2c_master_freq_t freq)
@@ -232,7 +226,6 @@ static inline void emulate_start(soft_i2c_master_bus_t bus)
set_sda(bidir_bundle, 0, delay); set_sda(bidir_bundle, 0, delay);
} }
static inline void emulate_stop(soft_i2c_master_bus_t bus) static inline void emulate_stop(soft_i2c_master_bus_t bus)
{ {
dedic_gpio_bundle_handle_t bidir_bundle = bus->bundle; dedic_gpio_bundle_handle_t bidir_bundle = bus->bundle;
@@ -287,8 +280,7 @@ static inline uint8_t emulate_read_byte(soft_i2c_master_bus_t bus, int send_ack)
set_scl(bidir_bundle, 0, delay); set_scl(bidir_bundle, 0, delay);
set_sda(bidir_bundle, 1, delay); set_sda(bidir_bundle, 1, delay);
for (int i = 7; i >= 0; i--) for (int i = 7; i >= 0; i--) {
{
/* Set SCL to low */ /* Set SCL to low */
set_scl(bidir_bundle, 0, delay); set_scl(bidir_bundle, 0, delay);
/* Get SDA value now and store it in the final result */ /* Get SDA value now and store it in the final result */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -23,13 +23,11 @@ typedef struct {
uint32_t cs_pin; uint32_t cs_pin;
} soft_spi_config_t; } soft_spi_config_t;
/** /**
* @brief Abstract type representing a software SPI bus. * @brief Abstract type representing a software SPI bus.
*/ */
typedef struct soft_spi_bus_impl_t* soft_spi_bus_t; typedef struct soft_spi_bus_impl_t* soft_spi_bus_t;
/** /**
* @brief Create and configure the software SPI bus. * @brief Create and configure the software SPI bus.
* *
@@ -40,7 +38,6 @@ typedef struct soft_spi_bus_impl_t* soft_spi_bus_t;
*/ */
esp_err_t soft_spi_new(soft_spi_config_t *config, soft_spi_bus_t *bus); esp_err_t soft_spi_new(soft_spi_config_t *config, soft_spi_bus_t *bus);
/** /**
* @brief Delete a previously initialized software SPI bus. * @brief Delete a previously initialized software SPI bus.
* *
@@ -50,7 +47,6 @@ esp_err_t soft_spi_new(soft_spi_config_t *config, soft_spi_bus_t *bus);
*/ */
esp_err_t soft_spi_del(soft_spi_bus_t bus); esp_err_t soft_spi_del(soft_spi_bus_t bus);
/** /**
* @brief Send the given bytes on the software SPI bus. * @brief Send the given bytes on the software SPI bus.
* *
@@ -65,7 +61,6 @@ esp_err_t soft_spi_transfer(soft_spi_bus_t bus,
const uint8_t* write_buffer, uint8_t* read_buffer, const uint8_t* write_buffer, uint8_t* read_buffer,
size_t buf_size); size_t buf_size);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -31,7 +31,6 @@ static portMUX_TYPE g_lock = portMUX_INITIALIZER_UNLOCKED;
const char* __attribute__((used)) SOFT_SPI_TAG = "soft_spi"; const char* __attribute__((used)) SOFT_SPI_TAG = "soft_spi";
struct soft_spi_bus_impl_t { struct soft_spi_bus_impl_t {
uint32_t clk_bit; uint32_t clk_bit;
uint32_t mosi_bit; uint32_t mosi_bit;
@@ -41,7 +40,6 @@ struct soft_spi_bus_impl_t {
dedic_gpio_bundle_handle_t in_bundle; dedic_gpio_bundle_handle_t in_bundle;
}; };
esp_err_t soft_spi_new(soft_spi_config_t *config, soft_spi_bus_t *bus) esp_err_t soft_spi_new(soft_spi_config_t *config, soft_spi_bus_t *bus)
{ {
esp_err_t ret; esp_err_t ret;
@@ -121,7 +119,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_spi_del(soft_spi_bus_t bus) esp_err_t soft_spi_del(soft_spi_bus_t bus)
{ {
esp_err_t ret; esp_err_t ret;
@@ -135,7 +132,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_spi_transfer(soft_spi_bus_t bus, const uint8_t* write_buffer, uint8_t* read_buffer, size_t buf_size) esp_err_t soft_spi_transfer(soft_spi_bus_t bus, const uint8_t* write_buffer, uint8_t* read_buffer, size_t buf_size)
{ {
esp_err_t ret = ESP_OK; esp_err_t ret = ESP_OK;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -24,7 +24,6 @@ typedef enum {
SOFT_UART_BAUD_END SOFT_UART_BAUD_END
} soft_uart_baudrate_t; } soft_uart_baudrate_t;
/** /**
* @brief Structure defining the configuration for the software UART port * @brief Structure defining the configuration for the software UART port
*/ */
@@ -34,13 +33,11 @@ typedef struct {
soft_uart_baudrate_t baudrate; soft_uart_baudrate_t baudrate;
} soft_uart_config_t; } soft_uart_config_t;
/** /**
* @brief Abstract type representing a software UART port. * @brief Abstract type representing a software UART port.
*/ */
typedef struct soft_uart_port_impl_t* soft_uart_port_t; typedef struct soft_uart_port_impl_t* soft_uart_port_t;
/** /**
* @brief Create and configure the software UART port. * @brief Create and configure the software UART port.
* *
@@ -51,7 +48,6 @@ typedef struct soft_uart_port_impl_t* soft_uart_port_t;
*/ */
esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port); esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port);
/** /**
* @brief Delete a previously initialized software UART port. * @brief Delete a previously initialized software UART port.
* *
@@ -61,7 +57,6 @@ esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port);
*/ */
esp_err_t soft_uart_del(soft_uart_port_t port); esp_err_t soft_uart_del(soft_uart_port_t port);
/** /**
* @brief Send the given bytes on the software UART port. * @brief Send the given bytes on the software UART port.
* *

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -33,7 +33,6 @@ struct soft_uart_port_impl_t {
dedic_gpio_bundle_handle_t rx_bundle; dedic_gpio_bundle_handle_t rx_bundle;
}; };
esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port) esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port)
{ {
esp_err_t ret; esp_err_t ret;
@@ -82,7 +81,6 @@ esp_err_t soft_uart_new(soft_uart_config_t *config, soft_uart_port_t *port)
} }
}; };
/* Allocate the master port structure now that we need it */ /* Allocate the master port structure now that we need it */
port_impl = malloc(sizeof(struct soft_uart_port_impl_t)); port_impl = malloc(sizeof(struct soft_uart_port_impl_t));
ESP_GOTO_ON_FALSE(port_impl != NULL, ESP_ERR_NO_MEM, error, SOFT_UART_TAG, "No more memory available in the system"); ESP_GOTO_ON_FALSE(port_impl != NULL, ESP_ERR_NO_MEM, error, SOFT_UART_TAG, "No more memory available in the system");
@@ -118,7 +116,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_uart_del(soft_uart_port_t port) esp_err_t soft_uart_del(soft_uart_port_t port)
{ {
esp_err_t ret; esp_err_t ret;
@@ -132,7 +129,6 @@ error:
return ret; return ret;
} }
esp_err_t soft_uart_send(soft_uart_port_t port, const uint8_t* write_buffer, size_t write_size) esp_err_t soft_uart_send(soft_uart_port_t port, const uint8_t* write_buffer, size_t write_size)
{ {
esp_err_t ret = ESP_OK; esp_err_t ret = ESP_OK;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -78,7 +78,6 @@ static esp_err_t i2c_master_init(void)
return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0); return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
} }
void app_main(void) void app_main(void)
{ {
uint8_t data[2]; uint8_t data[2];

View File

@@ -24,7 +24,6 @@
#define EXAMPLE_PDM_RX_FREQ_HZ 16000 // I2S PDM RX frequency #define EXAMPLE_PDM_RX_FREQ_HZ 16000 // I2S PDM RX frequency
static i2s_chan_handle_t i2s_example_init_pdm_rx(void) static i2s_chan_handle_t i2s_example_init_pdm_rx(void)
{ {
i2s_chan_handle_t rx_chan; // I2S rx channel handler i2s_chan_handle_t rx_chan; // I2S rx channel handler
@@ -72,7 +71,6 @@ static i2s_chan_handle_t i2s_example_init_pdm_rx(void)
return rx_chan; return rx_chan;
} }
void i2s_example_pdm_rx_task(void *args) void i2s_example_pdm_rx_task(void *args)
{ {
int16_t *r_buf = (int16_t *)calloc(1, EXAMPLE_BUFF_SIZE); int16_t *r_buf = (int16_t *)calloc(1, EXAMPLE_BUFF_SIZE);

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -25,14 +25,17 @@
#define EXAMPLE_BYTE_NUM_EVERY_TONE (EXAMPLE_TONE_LAST_TIME_MS * EXAMPLE_PDM_TX_FREQ_HZ / 1000) #define EXAMPLE_BYTE_NUM_EVERY_TONE (EXAMPLE_TONE_LAST_TIME_MS * EXAMPLE_PDM_TX_FREQ_HZ / 1000)
/* The frequency of tones: do, re, mi, fa, so, la, si, in Hz. */ /* The frequency of tones: do, re, mi, fa, so, la, si, in Hz. */
static const uint32_t tone[3][7] = {{262, 294, 330, 349, 392, 440, 494}, // bass static const uint32_t tone[3][7] = {
{262, 294, 330, 349, 392, 440, 494}, // bass
{523, 587, 659, 698, 784, 880, 988}, // alto {523, 587, 659, 698, 784, 880, 988}, // alto
{1046, 1175, 1318, 1397, 1568, 1760, 1976}}; // treble {1046, 1175, 1318, 1397, 1568, 1760, 1976}, // treble
};
/* Numbered musical notation of 'twinkle twinkle little star' */ /* Numbered musical notation of 'twinkle twinkle little star' */
static const uint8_t song[28] = {1, 1, 5, 5, 6, 6, 5, static const uint8_t song[28] = {1, 1, 5, 5, 6, 6, 5,
4, 4, 3, 3, 2, 2, 1, 4, 4, 3, 3, 2, 2, 1,
5, 5, 4, 4, 3, 3, 2, 5, 5, 4, 4, 3, 3, 2,
5, 5, 4, 4, 3, 3, 2}; 5, 5, 4, 4, 3, 3, 2
};
/* Rhythm of 'twinkle twinkle little star', it's repeated in four sections */ /* Rhythm of 'twinkle twinkle little star', it's repeated in four sections */
static const uint8_t rhythm[7] = {1, 1, 1, 1, 1, 1, 2}; static const uint8_t rhythm[7] = {1, 1, 1, 1, 1, 1, 2};

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -71,7 +71,6 @@
static const char *TAG = "example"; static const char *TAG = "example";
static i2s_chan_handle_t es7210_i2s_init(void) static i2s_chan_handle_t es7210_i2s_init(void)
{ {
i2s_chan_handle_t i2s_rx_chan = NULL; i2s_chan_handle_t i2s_rx_chan = NULL;

View File

@@ -18,7 +18,6 @@
#define EXAMPLE_MIC_GAIN CONFIG_EXAMPLE_MIC_GAIN #define EXAMPLE_MIC_GAIN CONFIG_EXAMPLE_MIC_GAIN
#endif #endif
#if !defined(CONFIG_EXAMPLE_BSP) #if !defined(CONFIG_EXAMPLE_BSP)
/* I2C port and GPIOs */ /* I2C port and GPIOs */
@@ -47,7 +46,6 @@
#define I2S_DI_IO (GPIO_NUM_3) #define I2S_DI_IO (GPIO_NUM_3)
#endif #endif
#else // CONFIG_EXAMPLE_BSP #else // CONFIG_EXAMPLE_BSP
#include "bsp/esp-bsp.h" #include "bsp/esp-bsp.h"
#define I2C_NUM BSP_I2C_NUM #define I2C_NUM BSP_I2C_NUM

View File

@@ -15,7 +15,6 @@
#include "es8311.h" #include "es8311.h"
#include "example_config.h" #include "example_config.h"
static const char *TAG = "i2s_es8311"; static const char *TAG = "i2s_es8311";
static const char err_reason[][30] = {"input param is invalid", static const char err_reason[][30] = {"input param is invalid",
"operation timeout" "operation timeout"

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -34,10 +34,18 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect)
if (frame != prev_frame) { if (frame != prev_frame) {
//We need to calculate a new set of offset coefficients. Take some random sines as offsets to make everything //We need to calculate a new set of offset coefficients. Take some random sines as offsets to make everything
//look pretty and fluid-y. //look pretty and fluid-y.
for (int x=0; x<320; x++) xofs[x]=sin(frame*0.15+x*0.06)*4; for (int x = 0; x < 320; x++) {
for (int y=0; y<240; y++) yofs[y]=sin(frame*0.1+y*0.05)*4; xofs[x] = sin(frame * 0.15 + x * 0.06) * 4;
for (int x=0; x<320; x++) xcomp[x]=sin(frame*0.11+x*0.12)*4; }
for (int y=0; y<240; y++) ycomp[y]=sin(frame*0.07+y*0.15)*4; for (int y = 0; y < 240; y++) {
yofs[y] = sin(frame * 0.1 + y * 0.05) * 4;
}
for (int x = 0; x < 320; x++) {
xcomp[x] = sin(frame * 0.11 + x * 0.12) * 4;
}
for (int y = 0; y < 240; y++) {
ycomp[y] = sin(frame * 0.07 + y * 0.15) * 4;
}
prev_frame = frame; prev_frame = frame;
} }
for (int y = line; y < line + linect; y++) { for (int y = line; y < line + linect; y++) {
@@ -47,7 +55,6 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect)
} }
} }
esp_err_t pretty_effect_init(void) esp_err_t pretty_effect_init(void)
{ {
return decode_image(&pixels); return decode_image(&pixels);

View File

@@ -8,7 +8,6 @@
#include <stdint.h> #include <stdint.h>
#include "esp_err.h" #include "esp_err.h"
/** /**
* @brief Calculate the effect for a bunch of lines. * @brief Calculate the effect for a bunch of lines.
* *
@@ -19,7 +18,6 @@
*/ */
void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect); void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect);
/** /**
* @brief Initialize the effect * @brief Initialize the effect
* *

View File

@@ -64,7 +64,6 @@ static rgb_channel_config_t rgb_led_2_channels = {
.blue_channel = LEDC_CHANNEL_GAMMA_BLUE, .blue_channel = LEDC_CHANNEL_GAMMA_BLUE,
}; };
// Define some colors R, G, B channel PWM duty cycles // Define some colors R, G, B channel PWM duty cycles
#define RGB_TO_DUTY(x) (x * (1 << LEDC_DUTY_RES) / 255) #define RGB_TO_DUTY(x) (x * (1 << LEDC_DUTY_RES) / 255)
@@ -126,7 +125,6 @@ static rgb_channel_config_t rgb_led_2_channels = {
#define BLUEISH_PURPLE_G RGB_TO_DUTY(102) #define BLUEISH_PURPLE_G RGB_TO_DUTY(102)
#define BLUEISH_PURPLE_B RGB_TO_DUTY(255) #define BLUEISH_PURPLE_B RGB_TO_DUTY(255)
#if CONFIG_GAMMA_CORRECTION_WITH_LUT #if CONFIG_GAMMA_CORRECTION_WITH_LUT
// Brightness 0 - 100% gamma correction look up table (gamma = 2.6) // Brightness 0 - 100% gamma correction look up table (gamma = 2.6)
// Y = B ^ 2.6 // Y = B ^ 2.6
@@ -158,7 +156,6 @@ static uint32_t gamma_correction_calculator(uint32_t duty)
} }
#endif // CONFIG_GAMMA_CORRECTION_WITH_LUT #endif // CONFIG_GAMMA_CORRECTION_WITH_LUT
static void rgb_set_duty_and_update(rgb_channel_config_t rgb_channels, static void rgb_set_duty_and_update(rgb_channel_config_t rgb_channels,
uint32_t target_r_duty, uint32_t target_g_duty, uint32_t target_b_duty) uint32_t target_r_duty, uint32_t target_g_duty, uint32_t target_b_duty)
{ {

View File

@@ -1,6 +1,6 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@@ -51,12 +51,11 @@ static const char *TAG = "example_foc";
#define EXAMPLE_FOC_WAVE_FREQ 10 // 50Hz 3 phase AC wave #define EXAMPLE_FOC_WAVE_FREQ 10 // 50Hz 3 phase AC wave
#define EXAMPLE_FOC_WAVE_AMPL 100 // Wave amplitude, Use up-down timer mode, max value should be (EXAMPLE_FOC_MCPWM_PERIOD/2) #define EXAMPLE_FOC_WAVE_AMPL 100 // Wave amplitude, Use up-down timer mode, max value should be (EXAMPLE_FOC_MCPWM_PERIOD/2)
void bsp_bridge_driver_init(void) void bsp_bridge_driver_init(void)
{ {
gpio_config_t drv_en_config = { gpio_config_t drv_en_config = {
.pin_bit_mask = 1ULL << EXAMPLE_FOC_DRV_EN_GPIO,
.mode = GPIO_MODE_OUTPUT, .mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << EXAMPLE_FOC_DRV_EN_GPIO,
}; };
ESP_ERROR_CHECK(gpio_config(&drv_en_config)); ESP_ERROR_CHECK(gpio_config(&drv_en_config));
} }

View File

@@ -5,7 +5,6 @@
*/ */
#include "esp_foc.h" #include "esp_foc.h"
/** /**
* alpha = u - (v + w)sin(30) * (2/3), (2/3): Equal amplitude transformation const * alpha = u - (v + w)sin(30) * (2/3), (2/3): Equal amplitude transformation const
* beta = (v - w)cos(30) * (2/3) * beta = (v - w)cos(30) * (2/3)

View File

@@ -10,7 +10,6 @@
#define GLOBAL_IQ 18 #define GLOBAL_IQ 18
#include "IQmathLib.h" #include "IQmathLib.h"
// 3-phase uvw coord data type // 3-phase uvw coord data type
typedef struct foc_uvw_coord { typedef struct foc_uvw_coord {
_iq u; // U phase data in IQ type _iq u; // U phase data in IQ type

View File

@@ -18,7 +18,6 @@ typedef struct mcpwm_svpwm_ctx {
mcpwm_gen_handle_t generators[3][2]; mcpwm_gen_handle_t generators[3][2];
} mcpwm_svpwm_ctx_t; } mcpwm_svpwm_ctx_t;
esp_err_t svpwm_new_inverter(const inverter_config_t *config, inverter_handle_t *ret_inverter) esp_err_t svpwm_new_inverter(const inverter_config_t *config, inverter_handle_t *ret_inverter)
{ {
esp_err_t ret; esp_err_t ret;

View File

@@ -10,7 +10,6 @@
#include "driver/rmt_tx.h" #include "driver/rmt_tx.h"
#include "led_strip_encoder.h" #include "led_strip_encoder.h"
#define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution) #define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define RMT_LED_STRIP_GPIO_NUM 0 #define RMT_LED_STRIP_GPIO_NUM 0

View File

@@ -28,7 +28,6 @@
#include "sdkconfig.h" #include "sdkconfig.h"
#include "sdmmc_cmd.h" #include "sdmmc_cmd.h"
#define TIMEOUT_MAX UINT32_MAX #define TIMEOUT_MAX UINT32_MAX
#define GPIO_B1 21 #define GPIO_B1 21
@@ -55,7 +54,6 @@
#define PIN_D3 SDMMC_SLOT1_IOMUX_PIN_NUM_D3 #define PIN_D3 SDMMC_SLOT1_IOMUX_PIN_NUM_D3
#endif #endif
/* /*
sdio host example. sdio host example.
@@ -298,7 +296,6 @@ esp_err_t slave_init(essl_handle_t* handle)
return ret; return ret;
} }
void slave_power_on(void) void slave_power_on(void)
{ {
#ifdef SLAVE_PWR_GPIO #ifdef SLAVE_PWR_GPIO
@@ -338,9 +335,13 @@ static esp_err_t get_intr(essl_handle_t handle, uint32_t* out_raw, uint32_t* out
#endif #endif
ret = essl_get_intr(handle, out_raw, out_st, TIMEOUT_MAX); ret = essl_get_intr(handle, out_raw, out_st, TIMEOUT_MAX);
if (ret != ESP_OK) return ret; if (ret != ESP_OK) {
return ret;
}
ret = essl_clear_intr(handle, *out_raw, TIMEOUT_MAX); ret = essl_clear_intr(handle, *out_raw, TIMEOUT_MAX);
if (ret != ESP_OK) return ret; if (ret != ESP_OK) {
return ret;
}
ESP_LOGD(TAG, "intr: %08"PRIX32, *out_raw); ESP_LOGD(TAG, "intr: %08"PRIX32, *out_raw);
return ESP_OK; return ESP_OK;
} }

View File

@@ -85,22 +85,27 @@ static const char job_desc[][32] = {
"JOB_WRITE_REG", "JOB_WRITE_REG",
}; };
//reset counters of the slave hardware, and clean the receive buffer (normally they should be sent back to the host) //reset counters of the slave hardware, and clean the receive buffer (normally they should be sent back to the host)
static esp_err_t slave_reset(void) static esp_err_t slave_reset(void)
{ {
esp_err_t ret; esp_err_t ret;
sdio_slave_stop(); sdio_slave_stop();
ret = sdio_slave_reset(); ret = sdio_slave_reset();
if (ret != ESP_OK) return ret; if (ret != ESP_OK) {
return ret;
}
ret = sdio_slave_start(); ret = sdio_slave_start();
if (ret != ESP_OK) return ret; if (ret != ESP_OK) {
return ret;
}
//Since the buffer will not be sent any more, we return them back to receving driver //Since the buffer will not be sent any more, we return them back to receving driver
while (1) { while (1) {
sdio_slave_buf_handle_t handle; sdio_slave_buf_handle_t handle;
ret = sdio_slave_send_get_finished(&handle, 0); ret = sdio_slave_send_get_finished(&handle, 0);
if (ret != ESP_OK) break; if (ret != ESP_OK) {
break;
}
ret = sdio_slave_recv_load_buf(handle); ret = sdio_slave_recv_load_buf(handle);
ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(ret);
} }
@@ -114,7 +119,9 @@ static esp_err_t task_hostint(void)
ESP_LOGV(TAG, "send intr: %d", i); ESP_LOGV(TAG, "send intr: %d", i);
sdio_slave_send_host_int(i); sdio_slave_send_host_int(i);
//check reset for quick response to RESET signal //check reset for quick response to RESET signal
if (s_job & JOB_RESET) break; if (s_job & JOB_RESET) {
break;
}
vTaskDelay(500 / portTICK_PERIOD_MS); vTaskDelay(500 / portTICK_PERIOD_MS);
} }
return ESP_OK; return ESP_OK;

View File

@@ -5,7 +5,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2015-2023 Espressif Systems (Shanghai) CO LTD
*/ */
/* This is mbedtls boilerplate for library configuration */ /* This is mbedtls boilerplate for library configuration */

View File

@@ -19,7 +19,6 @@
#include <sys/param.h> #include <sys/param.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#define EEPROM_BUSY_TIMEOUT_MS 5 #define EEPROM_BUSY_TIMEOUT_MS 5
#define EEPROM_CLK_FREQ (1*1000*1000) //When powered by 3.3V, EEPROM max freq is 1MHz #define EEPROM_CLK_FREQ (1*1000*1000) //When powered by 3.3V, EEPROM max freq is 1MHz
@@ -52,7 +51,6 @@ typedef struct eeprom_context_t eeprom_context_t;
static const char TAG[] = "eeprom"; static const char TAG[] = "eeprom";
// Workaround: The driver depends on some data in the flash and cannot be placed to DRAM easily for // Workaround: The driver depends on some data in the flash and cannot be placed to DRAM easily for
// now. Using the version in LL instead. // now. Using the version in LL instead.
#define gpio_set_level gpio_set_level_patch #define gpio_set_level gpio_set_level_patch
@@ -63,7 +61,6 @@ static inline esp_err_t gpio_set_level_patch(gpio_num_t gpio_num, uint32_t level
return ESP_OK; return ESP_OK;
} }
static esp_err_t eeprom_simple_cmd(eeprom_context_t *ctx, uint16_t cmd) static esp_err_t eeprom_simple_cmd(eeprom_context_t *ctx, uint16_t cmd)
{ {
spi_transaction_t t = { spi_transaction_t t = {
@@ -89,7 +86,9 @@ static esp_err_t eeprom_wait_done(eeprom_context_t* ctx)
gpio_intr_disable(ctx->cfg.miso_io); gpio_intr_disable(ctx->cfg.miso_io);
gpio_set_level(ctx->cfg.cs_io, 0); gpio_set_level(ctx->cfg.cs_io, 0);
if (ret != pdTRUE) return ESP_ERR_TIMEOUT; if (ret != pdTRUE) {
return ESP_ERR_TIMEOUT;
}
} else { } else {
bool timeout = true; bool timeout = true;
gpio_set_level(ctx->cfg.cs_io, 1); gpio_set_level(ctx->cfg.cs_io, 1);
@@ -101,7 +100,9 @@ static esp_err_t eeprom_wait_done(eeprom_context_t* ctx)
usleep(1); usleep(1);
} }
gpio_set_level(ctx->cfg.cs_io, 0); gpio_set_level(ctx->cfg.cs_io, 0);
if (timeout) return ESP_ERR_TIMEOUT; if (timeout) {
return ESP_ERR_TIMEOUT;
}
} }
return ESP_OK; return ESP_OK;
} }
@@ -144,7 +145,9 @@ esp_err_t spi_eeprom_init(const eeprom_config_t *cfg, eeprom_context_t** out_ctx
} }
eeprom_context_t* ctx = (eeprom_context_t*)malloc(sizeof(eeprom_context_t)); eeprom_context_t* ctx = (eeprom_context_t*)malloc(sizeof(eeprom_context_t));
if (!ctx) return ESP_ERR_NO_MEM; if (!ctx) {
return ESP_ERR_NO_MEM;
}
*ctx = (eeprom_context_t) { *ctx = (eeprom_context_t) {
.cfg = *cfg, .cfg = *cfg,
@@ -217,7 +220,9 @@ esp_err_t spi_eeprom_read(eeprom_context_t* ctx, uint8_t addr, uint8_t* out_data
.user = ctx, .user = ctx,
}; };
esp_err_t err = spi_device_polling_transmit(ctx->spi, &t); esp_err_t err = spi_device_polling_transmit(ctx->spi, &t);
if (err!= ESP_OK) return err; if (err != ESP_OK) {
return err;
}
*out_data = t.rx_data[0]; *out_data = t.rx_data[0];
return ESP_OK; return ESP_OK;
@@ -227,7 +232,9 @@ esp_err_t spi_eeprom_erase(eeprom_context_t* ctx, uint8_t addr)
{ {
esp_err_t err; esp_err_t err;
err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY); err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY);
if (err != ESP_OK) return err; if (err != ESP_OK) {
return err;
}
err = eeprom_simple_cmd(ctx, CMD_ERASE | (addr & ADDR_MASK)); err = eeprom_simple_cmd(ctx, CMD_ERASE | (addr & ADDR_MASK));
@@ -243,7 +250,9 @@ esp_err_t spi_eeprom_write(eeprom_context_t* ctx, uint8_t addr, uint8_t data)
{ {
esp_err_t err; esp_err_t err;
err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY); err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY);
if (err != ESP_OK) return err; if (err != ESP_OK) {
return err;
}
spi_transaction_t t = { spi_transaction_t t = {
.cmd = CMD_WRITE | (addr & ADDR_MASK), .cmd = CMD_WRITE | (addr & ADDR_MASK),
@@ -282,7 +291,9 @@ esp_err_t spi_eeprom_erase_all(eeprom_context_t* ctx)
esp_err_t err; esp_err_t err;
err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY); err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY);
if (err != ESP_OK) return err; if (err != ESP_OK) {
return err;
}
err = eeprom_simple_cmd(ctx, CMD_ERAL | ADD_ERAL); err = eeprom_simple_cmd(ctx, CMD_ERAL | ADD_ERAL);
@@ -304,7 +315,9 @@ esp_err_t spi_eeprom_write_all(eeprom_context_t* ctx, uint8_t data)
esp_err_t err; esp_err_t err;
err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY); err = spi_device_acquire_bus(ctx->spi, portMAX_DELAY);
if (err != ESP_OK) return err; if (err != ESP_OK) {
return err;
}
spi_transaction_t t = { spi_transaction_t t = {
.cmd = CMD_WRAL | ADD_WRAL, .cmd = CMD_WRAL | ADD_WRAL,

View File

@@ -18,7 +18,6 @@
#include "esp_log.h" #include "esp_log.h"
#include "spi_eeprom.h" #include "spi_eeprom.h"
/* /*
This code demonstrates how to use the SPI master half duplex mode to read/write a AT932C46D EEPROM (8-bit mode). This code demonstrates how to use the SPI master half duplex mode to read/write a AT932C46D EEPROM (8-bit mode).
*/ */
@@ -70,7 +69,6 @@
# define PIN_NUM_CS 1 # define PIN_NUM_CS 1
#endif #endif
static const char TAG[] = "main"; static const char TAG[] = "main";
void app_main(void) void app_main(void)

View File

@@ -39,10 +39,18 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect)
if (frame != prev_frame) { if (frame != prev_frame) {
//We need to calculate a new set of offset coefficients. Take some random sines as offsets to make everything //We need to calculate a new set of offset coefficients. Take some random sines as offsets to make everything
//look pretty and fluid-y. //look pretty and fluid-y.
for (int x=0; x<320; x++) xofs[x]=sin(frame*0.15+x*0.06)*4; for (int x = 0; x < 320; x++) {
for (int y=0; y<240; y++) yofs[y]=sin(frame*0.1+y*0.05)*4; xofs[x] = sin(frame * 0.15 + x * 0.06) * 4;
for (int x=0; x<320; x++) xcomp[x]=sin(frame*0.11+x*0.12)*4; }
for (int y=0; y<240; y++) ycomp[y]=sin(frame*0.07+y*0.15)*4; for (int y = 0; y < 240; y++) {
yofs[y] = sin(frame * 0.1 + y * 0.05) * 4;
}
for (int x = 0; x < 320; x++) {
xcomp[x] = sin(frame * 0.11 + x * 0.12) * 4;
}
for (int y = 0; y < 240; y++) {
ycomp[y] = sin(frame * 0.07 + y * 0.15) * 4;
}
prev_frame = frame; prev_frame = frame;
} }
for (int y = line; y < line + linect; y++) { for (int y = line; y < line + linect; y++) {
@@ -52,7 +60,6 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect)
} }
} }
esp_err_t pretty_effect_init(void) esp_err_t pretty_effect_init(void)
{ {
return decode_image(&pixels); return decode_image(&pixels);

View File

@@ -14,7 +14,6 @@
extern "C" { extern "C" {
#endif #endif
/** /**
* @brief Calculate the effect for a bunch of lines. * @brief Calculate the effect for a bunch of lines.
* *
@@ -25,7 +24,6 @@ extern "C" {
*/ */
void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect); void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect);
/** /**
* @brief Initialize the effect * @brief Initialize the effect
* *

View File

@@ -223,7 +223,9 @@ void lcd_data(spi_device_handle_t spi, const uint8_t *data, int len)
{ {
esp_err_t ret; esp_err_t ret;
spi_transaction_t t; spi_transaction_t t;
if (len==0) return; //no need to send anything if (len == 0) {
return; //no need to send anything
}
memset(&t, 0, sizeof(t)); //Zero out the transaction memset(&t, 0, sizeof(t)); //Zero out the transaction
t.length = len * 8; //Len is in bytes, transaction length is in bits. t.length = len * 8; //Len is in bytes, transaction length is in bits.
t.tx_buffer = data; //Data t.tx_buffer = data; //Data
@@ -329,7 +331,6 @@ void lcd_init(spi_device_handle_t spi)
gpio_set_level(PIN_NUM_BCKL, 0); gpio_set_level(PIN_NUM_BCKL, 0);
} }
/* To send a set of lines we have to send a command, 2 data bytes, another command, 2 more data bytes and another command /* To send a set of lines we have to send a command, 2 data bytes, another command, 2 more data bytes and another command
* before sending the line data itself; a total of 6 transactions. (We can't put all of this in just one transaction * before sending the line data itself; a total of 6 transactions. (We can't put all of this in just one transaction
* because the D/C line needs to be toggled in the middle.) * because the D/C line needs to be toggled in the middle.)
@@ -387,7 +388,6 @@ static void send_lines(spi_device_handle_t spi, int ypos, uint16_t *linedata)
//send_line_finish, which will wait for the transfers to be done and check their status. //send_line_finish, which will wait for the transfers to be done and check their status.
} }
static void send_line_finish(spi_device_handle_t spi) static void send_line_finish(spi_device_handle_t spi)
{ {
spi_transaction_t *rtrans; spi_transaction_t *rtrans;
@@ -400,7 +400,6 @@ static void send_line_finish(spi_device_handle_t spi)
} }
} }
//Simple routine to generate some patterns and send them to the LCD. Don't expect anything too //Simple routine to generate some patterns and send them to the LCD. Don't expect anything too
//impressive. Because the SPI driver handles transactions in the background, we can calculate the next line //impressive. Because the SPI driver handles transactions in the background, we can calculate the next line
//while the previous one is being sent. //while the previous one is being sent.
@@ -423,7 +422,9 @@ static void display_pretty_colors(spi_device_handle_t spi)
//Calculate a line. //Calculate a line.
pretty_effect_calc_lines(lines[calc_line], y, frame, PARALLEL_LINES); pretty_effect_calc_lines(lines[calc_line], y, frame, PARALLEL_LINES);
//Finish up the sending process of the previous line, if any //Finish up the sending process of the previous line, if any
if (sending_line!=-1) send_line_finish(spi); if (sending_line != -1) {
send_line_finish(spi);
}
//Swap sending_line and calc_line //Swap sending_line and calc_line
sending_line = calc_line; sending_line = calc_line;
calc_line = (calc_line == 1) ? 0 : 1; calc_line = (calc_line == 1) ? 0 : 1;

View File

@@ -18,7 +18,6 @@
#include "driver/spi_slave.h" #include "driver/spi_slave.h"
#include "driver/gpio.h" #include "driver/gpio.h"
/* /*
SPI receiver (slave) example. SPI receiver (slave) example.
@@ -71,7 +70,6 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
#endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_IDF_TARGET_ESP32 #ifdef CONFIG_IDF_TARGET_ESP32
#define RCV_HOST HSPI_HOST #define RCV_HOST HSPI_HOST
@@ -80,15 +78,15 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
#endif #endif
//Called after a transaction is queued and ready for pickup by master. We use this to set the handshake line high. //Called after a transaction is queued and ready for pickup by master. We use this to set the handshake line high.
void my_post_setup_cb(spi_slave_transaction_t *trans) { void my_post_setup_cb(spi_slave_transaction_t *trans)
{
gpio_set_level(GPIO_HANDSHAKE, 1); gpio_set_level(GPIO_HANDSHAKE, 1);
} }
//Called after transaction is sent/received. We use this to set the handshake line low. //Called after transaction is sent/received. We use this to set the handshake line low.
void my_post_trans_cb(spi_slave_transaction_t *trans) { void my_post_trans_cb(spi_slave_transaction_t *trans)
{
gpio_set_level(GPIO_HANDSHAKE, 0); gpio_set_level(GPIO_HANDSHAKE, 0);
} }

View File

@@ -31,7 +31,6 @@ ready to receive/send data. This code connects this line to a GPIO interrupt whi
task waits for this semaphore to be given before queueing a transmission. task waits for this semaphore to be given before queueing a transmission.
*/ */
/* /*
Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed. Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed.
*/ */
@@ -72,7 +71,6 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
#endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_IDF_TARGET_ESP32 #ifdef CONFIG_IDF_TARGET_ESP32
#define SENDER_HOST HSPI_HOST #define SENDER_HOST HSPI_HOST
@@ -81,7 +79,6 @@ Pins in use. The SPI Master can use the GPIO mux, so feel free to change these i
#endif #endif
//The semaphore indicating the slave is ready to receive stuff. //The semaphore indicating the slave is ready to receive stuff.
static QueueHandle_t rdySem; static QueueHandle_t rdySem;

View File

@@ -29,7 +29,6 @@
#define SLAVE_READY_FLAG 0x88 #define SLAVE_READY_FLAG 0x88
#define READY_FLAG_REG 0 #define READY_FLAG_REG 0
struct trans_link_s { struct trans_link_s {
spi_slave_hd_data_t trans; spi_slave_hd_data_t trans;
struct trans_link_s *next; struct trans_link_s *next;
@@ -41,7 +40,6 @@ typedef struct trans_link_s trans_link_t;
trans_link_t *tx_curr_trans; trans_link_t *tx_curr_trans;
trans_link_t *rx_curr_trans; trans_link_t *rx_curr_trans;
static void init_slave_hd(void) static void init_slave_hd(void)
{ {
spi_bus_config_t bus_cfg = {}; spi_bus_config_t bus_cfg = {};

View File

@@ -68,7 +68,6 @@
static const char TAG[] = "SEG_MASTER"; static const char TAG[] = "SEG_MASTER";
static void get_spi_bus_default_config(spi_bus_config_t *bus_cfg) static void get_spi_bus_default_config(spi_bus_config_t *bus_cfg)
{ {
memset(bus_cfg, 0x0, sizeof(spi_bus_config_t)); memset(bus_cfg, 0x0, sizeof(spi_bus_config_t));
@@ -114,7 +113,6 @@ static void init_master_hd(spi_device_handle_t* out_spi)
ESP_ERROR_CHECK(spi_bus_add_device(MASTER_HOST, &dev_cfg, out_spi)); ESP_ERROR_CHECK(spi_bus_add_device(MASTER_HOST, &dev_cfg, out_spi));
} }
//-------------------------------Function used for Master-Slave Synchronization---------------------------// //-------------------------------Function used for Master-Slave Synchronization---------------------------//
//Wait for Slave to init the shared registers for its configurations, see the Helper Macros above //Wait for Slave to init the shared registers for its configurations, see the Helper Macros above
static esp_err_t wait_for_slave_ready(spi_device_handle_t spi) static esp_err_t wait_for_slave_ready(spi_device_handle_t spi)

View File

@@ -66,7 +66,6 @@
//Value in these 4 registers indicates number of the RX buffer that Slave has loaded to the DMA //Value in these 4 registers indicates number of the RX buffer that Slave has loaded to the DMA
#define SLAVE_RX_READY_BUF_NUM_REG 16 #define SLAVE_RX_READY_BUF_NUM_REG 16
static const char TAG[] = "SEG_SLAVE"; static const char TAG[] = "SEG_SLAVE";
/* Used for Master-Slave synchronization */ /* Used for Master-Slave synchronization */
@@ -75,7 +74,6 @@ static uint32_t s_rx_ready_buf_num; //See ``cb_set_rx_ready_buf_num()``
static uint32_t s_tx_data_id; static uint32_t s_tx_data_id;
//-------------------------------Function used for Master-Slave Synchronization---------------------------// //-------------------------------Function used for Master-Slave Synchronization---------------------------//
/** /**
* NOTE: Only if all the counters are in same size (here uint32_t), the calculation is safe (when the shared register overflows). * NOTE: Only if all the counters are in same size (here uint32_t), the calculation is safe (when the shared register overflows).

View File

@@ -25,7 +25,6 @@ void app_main(void)
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(10, 50); temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(10, 50);
ESP_ERROR_CHECK(temperature_sensor_install(&temp_sensor_config, &temp_sensor)); ESP_ERROR_CHECK(temperature_sensor_install(&temp_sensor_config, &temp_sensor));
temperature_sensor_event_callbacks_t cbs = { temperature_sensor_event_callbacks_t cbs = {
.on_threshold = temp_sensor_monitor_cbs, .on_threshold = temp_sensor_monitor_cbs,
}; };

View File

@@ -102,7 +102,6 @@ void app_main(void)
user_data->timer_idx = 0; user_data->timer_idx = 0;
user_data->alarm_value = TIMER_ALARM_PERIOD_S * TIMER_RESOLUTION_HZ; user_data->alarm_value = TIMER_ALARM_PERIOD_S * TIMER_RESOLUTION_HZ;
ESP_LOGI(TAG, "Init timer with auto-reload"); ESP_LOGI(TAG, "Init timer with auto-reload");
user_data->auto_reload = true; user_data->auto_reload = true;
example_tg_timer_init(user_data); example_tg_timer_init(user_data);

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -47,7 +47,8 @@ static const twai_general_config_t g_config = {.mode = TWAI_MODE_LISTEN_ONLY,
.clkout_io = TWAI_IO_UNUSED, .bus_off_io = TWAI_IO_UNUSED, .clkout_io = TWAI_IO_UNUSED, .bus_off_io = TWAI_IO_UNUSED,
.tx_queue_len = 0, .rx_queue_len = 5, .tx_queue_len = 0, .rx_queue_len = 5,
.alerts_enabled = TWAI_ALERT_NONE, .alerts_enabled = TWAI_ALERT_NONE,
.clkout_divider = 0}; .clkout_divider = 0
};
static SemaphoreHandle_t rx_sem; static SemaphoreHandle_t rx_sem;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -64,11 +64,14 @@ static const twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
static const twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NORMAL); static const twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NORMAL);
static const twai_message_t ping_message = {.identifier = ID_MASTER_PING, .data_length_code = 0, static const twai_message_t ping_message = {.identifier = ID_MASTER_PING, .data_length_code = 0,
.ss = 1, .data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .ss = 1, .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
static const twai_message_t start_message = {.identifier = ID_MASTER_START_CMD, .data_length_code = 0, static const twai_message_t start_message = {.identifier = ID_MASTER_START_CMD, .data_length_code = 0,
.data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
static const twai_message_t stop_message = {.identifier = ID_MASTER_STOP_CMD, .data_length_code = 0, static const twai_message_t stop_message = {.identifier = ID_MASTER_STOP_CMD, .data_length_code = 0,
.data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
static QueueHandle_t tx_task_queue; static QueueHandle_t tx_task_queue;
static QueueHandle_t rx_task_queue; static QueueHandle_t rx_task_queue;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
@@ -64,12 +64,15 @@ static const twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPI
static const twai_timing_config_t t_config = TWAI_TIMING_CONFIG_25KBITS(); static const twai_timing_config_t t_config = TWAI_TIMING_CONFIG_25KBITS();
static const twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); static const twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
static const twai_message_t ping_resp = {.identifier = ID_SLAVE_PING_RESP, .data_length_code = 0, static const twai_message_t ping_resp = {.identifier = ID_SLAVE_PING_RESP, .data_length_code = 0,
.data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
static const twai_message_t stop_resp = {.identifier = ID_SLAVE_STOP_RESP, .data_length_code = 0, static const twai_message_t stop_resp = {.identifier = ID_SLAVE_STOP_RESP, .data_length_code = 0,
.data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
//Data bytes of data message will be initialized in the transmit task //Data bytes of data message will be initialized in the transmit task
static twai_message_t data_message = {.identifier = ID_SLAVE_DATA, .data_length_code = 4, static twai_message_t data_message = {.identifier = ID_SLAVE_DATA, .data_length_code = 4,
.data = {0, 0 , 0 , 0 ,0 ,0 ,0 ,0}}; .data = {0, 0, 0, 0, 0, 0, 0, 0}
};
static QueueHandle_t tx_task_queue; static QueueHandle_t tx_task_queue;
static QueueHandle_t rx_task_queue; static QueueHandle_t rx_task_queue;
@@ -230,7 +233,6 @@ void app_main(void)
vTaskDelay(pdMS_TO_TICKS(1000)); vTaskDelay(pdMS_TO_TICKS(1000));
} }
//Create semaphores and tasks //Create semaphores and tasks
tx_task_queue = xQueueCreate(1, sizeof(tx_task_action_t)); tx_task_queue = xQueueCreate(1, sizeof(tx_task_action_t));
rx_task_queue = xQueueCreate(1, sizeof(rx_task_action_t)); rx_task_queue = xQueueCreate(1, sizeof(rx_task_action_t));

View File

@@ -19,7 +19,8 @@ static const int RX_BUF_SIZE = 1024;
#define TXD_PIN (GPIO_NUM_4) #define TXD_PIN (GPIO_NUM_4)
#define RXD_PIN (GPIO_NUM_5) #define RXD_PIN (GPIO_NUM_5)
void init(void) { void init(void)
{
const uart_config_t uart_config = { const uart_config_t uart_config = {
.baud_rate = 115200, .baud_rate = 115200,
.data_bits = UART_DATA_8_BITS, .data_bits = UART_DATA_8_BITS,

View File

@@ -84,7 +84,6 @@ static void configure_uarts(void)
ESP_ERROR_CHECK(uart_set_pin(DEFAULT_UART_CHANNEL, DEFAULT_UART_TX_PIN, DEFAULT_UART_RX_PIN, ESP_ERROR_CHECK(uart_set_pin(DEFAULT_UART_CHANNEL, DEFAULT_UART_TX_PIN, DEFAULT_UART_RX_PIN,
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
connect_uarts(); connect_uarts();
} }
@@ -92,7 +91,8 @@ static void configure_uarts(void)
* @brief Function called when command `consoletest` will be invoked. * @brief Function called when command `consoletest` will be invoked.
* It will simply print `test_message` defined above. * It will simply print `test_message` defined above.
*/ */
static int console_test(int argc, char **argv) { static int console_test(int argc, char **argv)
{
printf("%s\n", test_message); printf("%s\n", test_message);
return 0; return 0;
} }
@@ -104,7 +104,8 @@ static int console_test(int argc, char **argv) {
* the response on RX. * the response on RX.
* The response shall contain the test_message string. * The response shall contain the test_message string.
*/ */
static void send_commands(void* arg) { static void send_commands(void* arg)
{
static char data[READ_BUF_SIZE]; static char data[READ_BUF_SIZE];
char command[] = "consoletest\n"; char command[] = "consoletest\n";
int len = 0; int len = 0;

View File

@@ -131,7 +131,6 @@ static void _mount(void)
ESP_LOGI(TAG, "Mount storage..."); ESP_LOGI(TAG, "Mount storage...");
ESP_ERROR_CHECK(tinyusb_msc_storage_mount(BASE_PATH)); ESP_ERROR_CHECK(tinyusb_msc_storage_mount(BASE_PATH));
// List all the files in this directory // List all the files in this directory
ESP_LOGI(TAG, "\nls command output:"); ESP_LOGI(TAG, "\nls command output:");
struct dirent *d; struct dirent *d;

View File

@@ -24,7 +24,6 @@
#include "tinyusb.h" #include "tinyusb.h"
#include "tinyusb_net.h" #include "tinyusb_net.h"
static const char *TAG = "USB_NCM"; static const char *TAG = "USB_NCM";
static esp_err_t usb_recv_callback(void *buffer, uint16_t len, void *ctx) static esp_err_t usb_recv_callback(void *buffer, uint16_t len, void *ctx)

View File

@@ -342,7 +342,6 @@ static void hid_host_generic_report_callback(const uint8_t *const data, const in
putchar('\r'); putchar('\r');
} }
/** /**
* @brief USB HID Host interface callback * @brief USB HID Host interface callback
* *

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -190,7 +190,6 @@ esp_err_t tcp_server_wait_for_connection(void)
return ESP_FAIL; return ESP_FAIL;
} }
BaseType_t task_created = xTaskCreate(sender_task, "sender_task", 4096, server, 10, &task_handle); BaseType_t task_created = xTaskCreate(sender_task, "sender_task", 4096, server, 10, &task_handle);
if (!task_created) { if (!task_created) {
socket_close(server); socket_close(server);

View File

@@ -127,7 +127,6 @@ components_not_formatted_temporary:
- "/examples/mesh/" - "/examples/mesh/"
- "/examples/network/" - "/examples/network/"
- "/examples/openthread/" - "/examples/openthread/"
- "/examples/peripherals/"
- "/examples/phy/" - "/examples/phy/"
- "/examples/protocols/" - "/examples/protocols/"
- "/examples/provisioning/" - "/examples/provisioning/"
@@ -174,6 +173,9 @@ components_not_formatted_permanent:
- "/components/app_trace/sys_view/SEGGER/" - "/components/app_trace/sys_view/SEGGER/"
# SoC header files (generated) # SoC header files (generated)
- "/components/soc/*/include/soc/" - "/components/soc/*/include/soc/"
# Example resource files (generated)
- "/examples/peripherals/lcd/i80_controller/main/images/"
- "/examples/peripherals/dac/dac_continuous/dac_audio/main/audio_example_file.h"
docs: docs:
# Docs directory contains some .inc files, which are not C include files # Docs directory contains some .inc files, which are not C include files