MT2523 I2S的slave模式,调用hal_i2s_enable_tx()会死机
时间:10-02
整理:3721RD
点击:
MT2523 I2S的GPIO4 gpio5 gpio6 gpio7只能做i2s的salve模式,外接codec,设置pinmux之后,调用i2s_open()函数,运行到hal_i2s_enable_tx()的时候会死机,
i2s_open()函数如下:
i2s_open()函数如下:
static int32_t i2s_open(void)
{
uint32_t memory_size = 0;
uint8_t *memory;
hal_i2s_config_t i2s_config;
hal_i2s_status_t result = HAL_I2S_STATUS_OK;
重新发一下i2s_open()函数
- static int32_t i2s_open(void)
- {
- uint32_t memory_size = 0;
- uint8_t *memory;
- hal_i2s_config_t i2s_config;
- hal_i2s_status_t result = HAL_I2S_STATUS_OK;
- LOG_I(WM8904,"ENTER\r\n");
- i2s_config.clock_mode = HAL_I2S_SLAVE;
- // configure the RX settings
- i2s_config.i2s_in.sample_rate = HAL_I2S_SAMPLE_RATE_8K;
- i2s_config.i2s_in.channel_number = HAL_I2S_MONO;
- // configure the TX settings
- i2s_config.i2s_out.sample_rate = HAL_I2S_SAMPLE_RATE_8K;
- i2s_config.i2s_out.channel_number = HAL_I2S_MONO;
- // set the I2S to an external mode.
- result = hal_i2s_init(HAL_I2S_TYPE_EXTERNAL_MODE);
- if(HAL_I2S_STATUS_OK != result)
- {
- LOG_E(freertos,"error result = %d \r\n",result);
- return -1;
- }
- result = hal_i2s_set_config(&i2s_config);
- if(HAL_I2S_STATUS_OK != result)
- {
- LOG_E(freertos,"error result = %d \r\n",result);
- return -2;
- }
-
- // get the amount of internal-use memory
- hal_i2s_get_memory_size(&memory_size);
- memory = malloc(memory_size * sizeof(uint8_t));
- if(NULL == memory)
- {
- LOG_E(freertos,"error result = %d \r\n",result);
- }
-
- result = hal_i2s_set_memory(memory);
- if(HAL_I2S_STATUS_OK != result)
- {
- LOG_E(freertos,"error result = %d \r\n",result);
- }
- LOG_I(WM8904,"pass\r\n");
- hal_i2s_register_tx_callback(user_i2s_tx_callback, NULL);
- hal_i2s_register_rx_callback(user_i2s_rx_callback, NULL);
- LOG_I(WM8904,"pass\r\n");
- result = hal_i2s_enable_tx();
- if(HAL_I2S_STATUS_OK != result)
- {
- LOG_E(freertos,"there is an error \r\n");
- return result;
- }
-
- result = hal_i2s_enable_rx();
- if(HAL_I2S_STATUS_OK != result)
- {
- LOG_E(freertos,"there is an error \r\n");
- return result;
- }
- LOG_I(WM8904,"EXIT\r\n");
- return 1;
- }
会不会可能 指针方面引起的错误?
不是,现在已经不死机了,就是要 调用一下这个 hal_audio_init()初始化,还是不明所以,并且我现在user_i2s_rx_callback接收到的数据一直有问题
路过帮顶
不懂,看看
路过
帮顶!
帮顶!