i2s: fix write failure on ESP32 in 32bit slave mode

This commit is contained in:
laokaiyao
2021-08-18 10:52:16 +08:00
parent 0ff3dd9778
commit c5afd7ce34
14 changed files with 413 additions and 259 deletions

View File

@@ -45,7 +45,7 @@ typedef struct {
uint16_t mclk_div; // I2S module clock devider, Fmclk = Fsclk /(mclk_div+b/a)
uint16_t a;
uint16_t b; // The decimal part of module clock devider, the decimal is: b/a
} i2s_ll_clk_cal_t;
} i2s_ll_mclk_div_t;
/**
* @brief I2S module general init, enable I2S clock.
@@ -57,6 +57,16 @@ static inline void i2s_ll_enable_clock(i2s_dev_t *hw)
hw->tx_clkm_conf.clk_en = 1;
}
/**
* @brief I2S module disable I2S clock.
*
* @param hw Peripheral I2S hardware instance address.
*/
static inline void i2s_ll_disable_clock(i2s_dev_t *hw)
{
hw->tx_clkm_conf.clk_en = 0;
}
/**
* @brief Enable I2S tx module clock
*
@@ -204,7 +214,7 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val)
* @param hw Peripheral I2S hardware instance address.
* @param set Pointer to I2S clock devider configuration paramater
*/
static inline void i2s_ll_tx_set_clk(i2s_dev_t *hw, i2s_ll_clk_cal_t *set)
static inline void i2s_ll_tx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set)
{
if (set->a == 0 || set->b == 0) {
hw->tx_clkm_div_conf.tx_clkm_div_x = 0;
@@ -243,7 +253,7 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val)
* @param hw Peripheral I2S hardware instance address.
* @param set Pointer to I2S clock devider configuration paramater
*/
static inline void i2s_ll_rx_set_clk(i2s_dev_t *hw, i2s_ll_clk_cal_t *set)
static inline void i2s_ll_rx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set)
{
if (set->a == 0 || set->b == 0) {
hw->rx_clkm_div_conf.rx_clkm_div_x = 0;
@@ -808,6 +818,10 @@ static inline void i2s_ll_set_single_data(i2s_dev_t *hw, uint32_t data)
/**
* @brief Enable TX mono mode
* @note MONO in hardware means only one channel got data, but another doesn't
* MONO in software means two channel share same data
* This function aims to use MONO in software meaning
* so 'tx_mono' and 'tx_chan_equal' should be enabled at the same time
*
* @param hw Peripheral I2S hardware instance address.
* @param mono_ena Set true to enable mono mde.
@@ -834,9 +848,9 @@ static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena)
* @brief Enable loopback mode
*
* @param hw Peripheral I2S hardware instance address.
* @param ena Set true to enable loopback mode.
* @param ena Set true to share BCK and WS signal for tx module and rx module.
*/
static inline void i2s_ll_enable_loop_back(i2s_dev_t *hw, bool ena)
static inline void i2s_ll_share_bck_ws(i2s_dev_t *hw, bool ena)
{
hw->tx_conf.sig_loopback = ena;
}