mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-15 19:34:03 +00:00
change(driver): reformat driver component with astyle_py
This commit is contained in:
@@ -202,7 +202,7 @@ static bool IRAM_ATTR i2s_dma_rx_callback(gdma_channel_handle_t dma_chan, gdma_e
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_RX_Q_OVF;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ static bool IRAM_ATTR i2s_dma_rx_callback(gdma_channel_handle_t dma_chan, gdma_e
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_RX_DONE;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -234,7 +234,7 @@ static bool IRAM_ATTR i2s_dma_tx_callback(gdma_channel_handle_t dma_chan, gdma_e
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_TX_Q_OVF;
|
||||
i2s_event.size = p_i2s->tx->buf_size;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static bool IRAM_ATTR i2s_dma_tx_callback(gdma_channel_handle_t dma_chan, gdma_e
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_TX_DONE;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg)
|
||||
xQueueReceiveFromISR(p_i2s->i2s_queue, &dummy, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg)
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_TX_Q_OVF;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg)
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_TX_DONE;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg)
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_RX_Q_OVF;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg)
|
||||
need_awoke |= tmp;
|
||||
if (p_i2s->i2s_queue) {
|
||||
i2s_event.type = I2S_EVENT_RX_DONE;
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void * )&i2s_event, &tmp);
|
||||
xQueueSendFromISR(p_i2s->i2s_queue, (void *)&i2s_event, &tmp);
|
||||
need_awoke |= tmp;
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ static esp_err_t i2s_dma_intr_init(i2s_port_t i2s_num, int intr_flag)
|
||||
|
||||
/* Set GDMA config */
|
||||
gdma_channel_alloc_config_t dma_cfg = {};
|
||||
if ( p_i2s[i2s_num]->dir & I2S_DIR_TX) {
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_TX) {
|
||||
dma_cfg.direction = GDMA_CHANNEL_DIRECTION_TX;
|
||||
/* Register a new GDMA tx channel */
|
||||
ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &p_i2s[i2s_num]->tx_dma_chan), TAG, "Register tx dma channel error");
|
||||
@@ -369,7 +369,7 @@ static esp_err_t i2s_dma_intr_init(i2s_port_t i2s_num, int intr_flag)
|
||||
/* Set callback function for GDMA, the interrupt is triggered by GDMA, then the GDMA ISR will call the callback function */
|
||||
gdma_register_tx_event_callbacks(p_i2s[i2s_num]->tx_dma_chan, &cb, p_i2s[i2s_num]);
|
||||
}
|
||||
if ( p_i2s[i2s_num]->dir & I2S_DIR_RX) {
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_RX) {
|
||||
dma_cfg.direction = GDMA_CHANNEL_DIRECTION_RX;
|
||||
/* Register a new GDMA rx channel */
|
||||
ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &p_i2s[i2s_num]->rx_dma_chan), TAG, "Register rx dma channel error");
|
||||
@@ -693,7 +693,7 @@ err:
|
||||
/*-------------------------------------------------------------
|
||||
I2S clock operation
|
||||
-------------------------------------------------------------*/
|
||||
// [clk_tree] TODO: replace the following switch table by clk_tree API
|
||||
// [clk_tree] TODO: replace the following switch table by clk_tree API
|
||||
static uint32_t i2s_config_source_clock(i2s_port_t i2s_num, bool use_apll, uint32_t mclk)
|
||||
{
|
||||
#if SOC_I2S_SUPPORTS_APLL
|
||||
@@ -844,7 +844,6 @@ static esp_err_t i2s_calculate_common_clock(int i2s_num, i2s_hal_clock_info_t *c
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t i2s_calculate_clock(i2s_port_t i2s_num, i2s_hal_clock_info_t *clk_info)
|
||||
{
|
||||
/* Calculate clock for ADC/DAC mode */
|
||||
@@ -996,7 +995,6 @@ static esp_err_t i2s_check_cfg_validity(i2s_port_t i2s_num, const i2s_config_t *
|
||||
ESP_RETURN_ON_FALSE((cfg->dma_desc_num >= 2 && cfg->dma_desc_num <= 128), ESP_ERR_INVALID_ARG, TAG, "I2S buffer count less than 128 and more than 2");
|
||||
ESP_RETURN_ON_FALSE((cfg->dma_frame_num >= 8 && cfg->dma_frame_num <= 1024), ESP_ERR_INVALID_ARG, TAG, "I2S buffer length at most 1024 and more than 8");
|
||||
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM_TX || SOC_I2S_SUPPORTS_PDM_RX
|
||||
/* Check PDM mode */
|
||||
if (cfg->mode & I2S_MODE_PDM) {
|
||||
@@ -1041,22 +1039,22 @@ static void i2s_set_slot_legacy(i2s_port_t i2s_num)
|
||||
}
|
||||
if (p_i2s[i2s_num]->mode == I2S_COMM_MODE_STD) {
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_TX) {
|
||||
i2s_hal_std_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_std_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_RX) {
|
||||
i2s_hal_std_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_std_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
}
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
else if (p_i2s[i2s_num]->mode == I2S_COMM_MODE_PDM) {
|
||||
#if SOC_I2S_SUPPORTS_PDM_TX
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_TX) {
|
||||
i2s_hal_pdm_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_pdm_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
#endif
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_RX) {
|
||||
i2s_hal_pdm_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_pdm_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1064,10 +1062,10 @@ static void i2s_set_slot_legacy(i2s_port_t i2s_num)
|
||||
#if SOC_I2S_SUPPORTS_TDM
|
||||
else if (p_i2s[i2s_num]->mode == I2S_COMM_MODE_TDM) {
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_TX) {
|
||||
i2s_hal_tdm_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_tdm_set_tx_slot(&(p_i2s[i2s_num]->hal), is_tx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
if (p_i2s[i2s_num]->dir & I2S_DIR_RX) {
|
||||
i2s_hal_tdm_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg) );
|
||||
i2s_hal_tdm_set_rx_slot(&(p_i2s[i2s_num]->hal), is_rx_slave, (i2s_hal_slot_config_t *)(&p_i2s[i2s_num]->slot_cfg));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1324,7 +1322,7 @@ static void i2s_mode_identify(i2s_port_t i2s_num, const i2s_config_t *i2s_config
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
if ((i2s_config->mode & I2S_MODE_DAC_BUILT_IN) ||
|
||||
(i2s_config->mode & I2S_MODE_ADC_BUILT_IN)) {
|
||||
(i2s_config->mode & I2S_MODE_ADC_BUILT_IN)) {
|
||||
p_i2s[i2s_num]->mode = (i2s_comm_mode_t)I2S_COMM_MODE_ADC_DAC;
|
||||
}
|
||||
#endif // SOC_I2S_SUPPORTS_ADC_DAC
|
||||
@@ -1337,7 +1335,7 @@ static esp_err_t i2s_config_transfer(i2s_port_t i2s_num, const i2s_config_t *i2s
|
||||
/* Convert legacy configuration into general part of slot and clock configuration */
|
||||
p_i2s[i2s_num]->slot_cfg.data_bit_width = i2s_config->bits_per_sample;
|
||||
p_i2s[i2s_num]->slot_cfg.slot_bit_width = (int)i2s_config->bits_per_chan < (int)i2s_config->bits_per_sample ?
|
||||
i2s_config->bits_per_sample : i2s_config->bits_per_chan;
|
||||
i2s_config->bits_per_sample : i2s_config->bits_per_chan;
|
||||
|
||||
p_i2s[i2s_num]->slot_cfg.slot_mode = i2s_config->channel_format < I2S_CHANNEL_FMT_ONLY_RIGHT ?
|
||||
I2S_SLOT_MODE_STEREO : I2S_SLOT_MODE_MONO;
|
||||
@@ -1637,7 +1635,6 @@ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue)
|
||||
{
|
||||
#if CONFIG_I2S_ENABLE_DEBUG_LOG
|
||||
|
||||
Reference in New Issue
Block a user