已回答假定已回答

关于ADSP-SC589 EZ-Board问题

amu340 在 2017-3-30 詢問的問題
最後回覆由HenryL於2017-4-8提供

在支持包ADC_DAC_Playback(SHARC)例子中,想在里面添加访问UART的程序,为什么只添加了UART初始化代码,程序运行时就出错。

代码如下:

/*

* Main function

*/

int main()

{

  /**

  * Initialize managed drivers and/or services that have been added to

  * the project.

  * @return zero on success

  */

  uint32_t Result = 0u;

  uint32_t i;

 

 

  /* configure System Event Controller SEC and Signal Routing Unit SRU */

  adi_initComponents();

  /* Software Switch Configuration for the EZ-Board */

  ConfigSoftSwitches();

  /* Initialize power service */

  Result = PowerServiceInit();

  /* Initialize GPIO for ADC/DAC reset control, PB1 Button reset */

  if(Result == 0u)

  {

  Result = GpioInit();

  }

   /* ADSP-SC589 Processor family */

    /* Initialize SPU Service */

    if(adi_spu_Init(0u, SpuMemory, NULL, NULL, &hSpu) != ADI_SPU_SUCCESS)

    {

        DBG_MSG("Failed to initialize SPU service\n");

        return (ADI_SPU_FAILURE);

    }

    /* Make SPORT 4A to generate secure transactions */

    if(adi_spu_EnableMasterSecure(hSpu, SPORT_4A_SPU_PID, true) != ADI_SPU_SUCCESS)

    {

        DBG_MSG("Failed to enable Master secure for SPORT 4A\n");

        return (ADI_SPU_FAILURE);

    }

 

    /* Make SPORT 4B to generate secure transactions */

    if(adi_spu_EnableMasterSecure(hSpu, SPORT_4B_SPU_PID, true) != ADI_SPU_SUCCESS)

    {

        DBG_MSG("Failed to enable Master secure for SPORT 4B\n");

        return (ADI_SPU_FAILURE);

    }

 

    /* Make SPORT 4A DMA to generate secure transactions */

    if(adi_spu_EnableMasterSecure(hSpu, SPORT_4A_DMA10_SPU_PID, true) != ADI_SPU_SUCCESS)

    {

        DBG_MSG("Failed to enable Master secure for SPORT 4A DMA\n");

        return (ADI_SPU_FAILURE);

    }

 

 

    /* Make SPORT 4B DMA to generate secure transactions */

    if(adi_spu_EnableMasterSecure(hSpu, SPORT_4B_DMA11_SPU_PID, true) != ADI_SPU_SUCCESS)

    {

        DBG_MSG("Failed to enable Master secure for SPORT 4B DMA\n");

        return (ADI_SPU_FAILURE);

    }

 

  /* Initialize ADAU1979 */

  if(Result == 0u)

  {

  Result = Adau1979Init();

  }

  /* Initialize ADAU1962A */

  if(Result == 0u)

  {

  Result = Adau1962aInit();

  }

 

 

/***********************************UART CODE INIT*************************/

  /*init UART*/

  if (UartInit() != 0u)

  {

  printf("UartInit error!\n");

  }

/****************************************************************************/

 

  /* Submit ADC buffers */

  if(Result == 0u)

  {

  Result = Adau1979SubmitBuffers();

  }

 

 

  /* Submit DAC buffers */

  if(Result == 0u)

  {

  Result = Adau1962aSubmitBuffers();

  }

 

  /* Enable data flow for only the ADC and DAC */

 

 

  if((uint32_t)adi_adau1962a_Enable(phAdau1962a, true) != 0u)

  {

  /* return error */

  return 1u;

  }

 

  if((uint32_t)adi_adau1979_Enable(phAdau1979, true) != 0u)

  {

  /* return error */

  return 1u;

  }

if(Result == 0u)

  {

     /* Audio loopback */

  while(1)

  {

     /* Process audio buffers */

  Result = ProcessBuffers();

  /* IF (Error) */

  if(Result != 0u)

  {

     /* exit loopback */

  break;

  }

 

 

  /* check if an error has been detected in callback */

            if(bEventError)

  {

     /* there has been an error returned in the callback */

  Result =1u;

  break;

            }

  }

 

 

    }

 

 

  if (Result == 0u)

  {

  printf("All done\n");

  }

  else

  {

  printf(" Error\n");

  }

}

 

/*****************************UART**************************/

uint32_t UartInit(void)

{

  uint32_t result = 0u;

  ADI_UART_RESULT    eResult;

 

 

#if 0

  /* Make UART to generate secure transactions */

  if(adi_spu_EnableMasterSecure(hSpu, UART_SPU_PID, true) != ADI_SPU_SUCCESS)

  {

  printf("Failed to enable Master secure for UART\n");

  return 1u;

  }

 

 

  /* Make UART Tx DMA to generate secure transactions */

  if(adi_spu_EnableMasterSecure(hSpu, UART_TX_DMA_SPU_PID, true) != ADI_SPU_SUCCESS)

  {

 

 

  printf("Failed to enable Master secure for UART Tx DMA\n");

  return 1u;

  }

 

 

  /* Make UART to generate secure transactions */

  if(adi_spu_EnableMasterSecure(hSpu, UART_RX_DMA_SPU_PID, true) != ADI_SPU_SUCCESS)

  {

  printf("Failed to enable Master secure for UART Rx DMA\n");

  return 1u;

  }

#endif

 

 

  /*

  * Initialize UART

  */

  /* Open UART driver */

  eResult = adi_uart_Open(UART_DEVICE_NUM,

                 ADI_UART_DIR_RECEIVE,

  gUARTMemory,

  ADI_UART_BIDIR_INT_MEMORY_SIZE,

  &ghUART);

  if (eResult != ADI_UART_SUCCESS)

  {

  printf("Could not open UART Device 0x%08X\n", eResult);

  return 1;

  }

 

 

 

 

  /* Set the UART Mode */

  eResult = adi_uart_SetMode(ghUART, ADI_UART_MODE_UART);

  if (eResult != ADI_UART_SUCCESS)

  {

  printf("Could not set the Mode 0x%08X\n", eResult);

  return 1;

  }

 

 

 

 

  /* Set UART Baud Rate */

  eResult = adi_uart_SetBaudRate(ghUART, BAUD_RATE);

  if (eResult != ADI_UART_SUCCESS)

  {

  printf("Could not set the Baud Rate 0x%08X\n", eResult);

  return 1;

  }

 

 

  /* Set number of stop bits */

  eResult = adi_uart_SetNumStopBits(ghUART, ADI_UART_ONE_STOPBIT);

  if (eResult != ADI_UART_SUCCESS)

  {

  printf("Could not set the stop bits 0x%08X\n", eResult);

  return 1;

  }

 

 

 

 

  /* Set number of stop bits */

  eResult = adi_uart_SetWordLen(ghUART, ADI_UART_WORDLEN_8BITS);

  if (eResult != ADI_UART_SUCCESS)

  {

  printf("Could not set word length 0x%08X\n", eResult);

  return 1;

  }

 

 

  /*Set callback function*/

  //eResult = adi_uart_RegisterCallback(ghUART, UartCallBack, NULL);

  return 0u;

}

結果