微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > MT2523 I2S的slave模式,调用hal_i2s_enable_tx()会死机

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()函数如下:

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 settingsi2s_config.i2s_in.sample_rate = HAL_I2S_SAMPLE_RATE_8K;i2s_config.i2s_in.channel_number = HAL_I2S_MONO;// configure the TX settingsi2s_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) {

重新发一下i2s_open()函数

  1. static int32_t i2s_open(void)

  2. {
  3.         uint32_t memory_size = 0;
  4.         uint8_t  *memory;
  5.         hal_i2s_config_t i2s_config;
  6.         hal_i2s_status_t result = HAL_I2S_STATUS_OK;

  7.     LOG_I(WM8904,"ENTER\r\n");
  8.         i2s_config.clock_mode = HAL_I2S_SLAVE;
  9.         // configure the RX settings
  10.         i2s_config.i2s_in.sample_rate = HAL_I2S_SAMPLE_RATE_8K;
  11.         i2s_config.i2s_in.channel_number = HAL_I2S_MONO;

  12.         // configure the TX settings
  13.         i2s_config.i2s_out.sample_rate = HAL_I2S_SAMPLE_RATE_8K;
  14.         i2s_config.i2s_out.channel_number = HAL_I2S_MONO;

  15.         // set the I2S to an external mode.
  16.         result = hal_i2s_init(HAL_I2S_TYPE_EXTERNAL_MODE);
  17.         if(HAL_I2S_STATUS_OK != result)
  18.         {       
  19.                 LOG_E(freertos,"error result = %d \r\n",result);        
  20.         return -1;
  21.         }

  22.         result = hal_i2s_set_config(&i2s_config);
  23.         if(HAL_I2S_STATUS_OK != result)
  24.         {
  25.                 LOG_E(freertos,"error result = %d \r\n",result);        
  26.         return -2;
  27.         }
  28.        
  29.     // get the amount of internal-use memory   
  30.     hal_i2s_get_memory_size(&memory_size);   
  31.         memory = malloc(memory_size * sizeof(uint8_t));   
  32.         if(NULL == memory)
  33.         {      
  34.                 LOG_E(freertos,"error result = %d \r\n",result);
  35.         }   
  36.        
  37.         result = hal_i2s_set_memory(memory);   
  38.         if(HAL_I2S_STATUS_OK != result)
  39.         {      
  40.                 LOG_E(freertos,"error result = %d \r\n",result);  
  41.         }

  42.     LOG_I(WM8904,"pass\r\n");

  43.     hal_i2s_register_tx_callback(user_i2s_tx_callback, NULL);   
  44.         hal_i2s_register_rx_callback(user_i2s_rx_callback, NULL);

  45.     LOG_I(WM8904,"pass\r\n");

  46.         result = hal_i2s_enable_tx();
  47.         if(HAL_I2S_STATUS_OK != result)
  48.         {
  49.                 LOG_E(freertos,"there is an  error \r\n");
  50.         return result;
  51.         }
  52.        
  53.         result = hal_i2s_enable_rx();       
  54.         if(HAL_I2S_STATUS_OK != result)
  55.         {
  56.                 LOG_E(freertos,"there is an  error \r\n");
  57.         return result;
  58.         }

  59.     LOG_I(WM8904,"EXIT\r\n");

  60.     return 1;
  61. }

复制代码


会不会可能 指针方面引起的错误?

不是,现在已经不死机了,就是要 调用一下这个 hal_audio_init()初始化,还是不明所以,并且我现在user_i2s_rx_callback接收到的数据一直有问题

路过帮顶

不懂,看看

路过   

帮顶!

帮顶!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top