]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/mcbsp-lld.git/blobdiff - example/k2g/MCBSPDigLpbk/mcbspMasterDigLpbk.c
PRSDK-4301 Add UART print console support
[keystone-rtos/mcbsp-lld.git] / example / k2g / MCBSPDigLpbk / mcbspMasterDigLpbk.c
index 888acbeb5269dbdafef05dda79bfa1c7c8eabcbc..03a52bc0c92cd200562e49b88bc8aec770d0dd0f 100644 (file)
@@ -51,6 +51,7 @@
 
 #include <xdc/cfg/global.h>
 #include <board.h>
+#include <MCBSP_log.h>
 
 /* Include EDMA3 Driver */
 #include <ti/sdo/edma3/drv/edma3_drv.h>
@@ -379,7 +380,7 @@ void mcbspAppCallback(void* arg, Mcbsp_IOBuf *ioBuf)
  */
 void mcbsp_GblErrCallback(uint32_t chanHandle,uint32_t spcr_read,uint32_t Arg3)
 {
-    System_printf ("Debug(Core %d): ERROR callback called SPCR: %x", coreNum, spcr_read);
+    MCBSP_log ("Debug(Core %d): ERROR callback called SPCR: %x", coreNum, spcr_read);
 }
 
 /*
@@ -415,7 +416,7 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
     /* Initialize the OSAL */
     if (Osal_dataBufferInitMemory(BUFSIZE) < 0)
     {
-        System_printf ("Debug(Core %d): Error: Unable to initialize the OSAL. \n", coreNum);
+        MCBSP_log ("Debug(Core %d): Error: Unable to initialize the OSAL. \n", coreNum);
         return;
     }
 
@@ -444,7 +445,7 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
 
     if (status != MCBSP_STATUS_COMPLETED)
     {
-        System_printf ("Debug(Core %d): MCBSP LLD Bind Device Failed\n", coreNum);
+        MCBSP_log ("Debug(Core %d): MCBSP LLD Bind Device Failed\n", coreNum);
         return;
     }
 
@@ -456,7 +457,7 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
     status = mcbspCreateChan(&hMcbspRxChan, hMcbspDev, MCBSP_MODE_INPUT, &mcbspChanparamRx, mcbspAppCallback, &rxChanMode);
     if (MCBSP_STATUS_COMPLETED != status)
     {
-        System_printf ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
+        MCBSP_log ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
         return;
     }
 
@@ -468,7 +469,7 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
     status = mcbspCreateChan(&hMcbspTxChan, hMcbspDev, MCBSP_MODE_OUTPUT, &mcbspChanparamTx, mcbspAppCallback, &txChanMode);
     if (MCBSP_STATUS_COMPLETED != status)
     {
-        System_printf ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
+        MCBSP_log ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
         return;
     }
 
@@ -484,12 +485,12 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
 
         if (bufTx[count] == NULL)
         {
-            System_printf ("Debug(Core %d): Error: Tx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): Error: Tx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
             return;
         }
         if (bufRx[count] == NULL)
         {
-            System_printf ("Debug(Core %d): Error: Rx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): Error: Rx Buffer (%d) Memory Allocation Failed\n", coreNum, count);
             return;
         }
     }
@@ -502,12 +503,12 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
 
         if (bufTxPingPong[count] == NULL)
         {
-            System_printf ("Debug(Core %d): Error: Tx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): Error: Tx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
             return;
         }
         if (bufRxPingPong[count] == NULL)
         {
-            System_printf ("Debug(Core %d): Error: Rx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): Error: Rx Ping pong Buffer (%d) Memory Allocation Failed\n", coreNum, count);
             return;
         }
     }
@@ -522,7 +523,7 @@ void mcbspDigLpbkApp(UArg arg0, UArg arg1)
             ((uint8_t *)bufTx[count])[tempCount] = (tempCount % 0x100);
         }
     }
-    System_printf ("Debug(Core %d): If required to restart set debugCommand variable to %d\n", coreNum, DEBUG_COMMAND_RESTART_CHANNELS);
+    MCBSP_log ("Debug(Core %d): If required to restart set debugCommand variable to %d\n", coreNum, DEBUG_COMMAND_RESTART_CHANNELS);
 
 restart_mcbsp_point:
     txFrameIndex=0;
@@ -555,13 +556,13 @@ restart_mcbsp_point:
         status = mcbspSubmitChan(hMcbspRxChan, (void *)&rxFrame[rxFrameIndex]);
         if (status != MCBSP_STATUS_PENDING)
         {
-            System_printf ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, init_count);
+            MCBSP_log ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, init_count);
             retval = 1;
         }
         else
         {
 #ifdef MCBSP_APP_VERBOSE
-            System_printf ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, init_count);
+            MCBSP_log ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, init_count);
 #endif
         }
         rxFrameIndex++;
@@ -584,13 +585,13 @@ restart_mcbsp_point:
         status = mcbspSubmitChan(hMcbspTxChan, (void *)&txFrame[txFrameIndex]);
         if (status != MCBSP_STATUS_PENDING)
         {
-            System_printf ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, init_count);
+            MCBSP_log ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, init_count);
             retval = 1;
         }
         else
         {
 #ifdef MCBSP_APP_VERBOSE
-            System_printf ("Debug(Core %d): TX buffer  #%d submission is submitted to MCBSP driver\n", coreNum, init_count);
+            MCBSP_log ("Debug(Core %d): TX buffer  #%d submission is submitted to MCBSP driver\n", coreNum, init_count);
 #endif
         }
         txFrameIndex++;
@@ -605,7 +606,7 @@ restart_mcbsp_point:
         if (edmaTxDone == 1)
         {
 #ifdef MCBSP_APP_VERBOSE
-            System_printf ("Debug(Core %d): EDMA -> Iteration-%d frames are transmitted to TX path\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): EDMA -> Iteration-%d frames are transmitted to TX path\n", coreNum, count);
 #endif
             edmaTxDone = 0; /* Reset for next iteration */
             mcbspTxDone = 1;
@@ -613,7 +614,7 @@ restart_mcbsp_point:
         if (edmaRxDone == 1)
         {
 #ifdef MCBSP_APP_VERBOSE
-            System_printf ("Debug(Core %d): EDMA -> Iteration-%d frames are received from RX path\n", coreNum, count);
+            MCBSP_log ("Debug(Core %d): EDMA -> Iteration-%d frames are received from RX path\n", coreNum, count);
 #endif
             edmaRxDone = 0;  /* Reset for next iteration */
             mcbspRxDone = 1;
@@ -656,13 +657,13 @@ restart_mcbsp_point:
             status = mcbspSubmitChan(hMcbspRxChan, (void *)&rxFrame[rxFrameIndex]);
             if (status != MCBSP_STATUS_PENDING)
             {
-                System_printf ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, count);
+                MCBSP_log ("Debug(Core %d): Error: RX buffer #%d submission FAILED\n", coreNum, count);
                 retval = 1;
             }
             else
             {
 #ifdef MCBSP_APP_VERBOSE
-                System_printf ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, count);
+                MCBSP_log ("Debug(Core %d): RX buffer #%d is submitted to MCBSP driver\n", coreNum, count);
 #endif
             }
             rxFrameIndex++;
@@ -684,13 +685,13 @@ restart_mcbsp_point:
             status = mcbspSubmitChan(hMcbspTxChan, (void *)&txFrame[txFrameIndex]);
             if (status != MCBSP_STATUS_PENDING)
             {
-                System_printf ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, count);
+                MCBSP_log ("Debug(Core %d): Error: TX buffer  #%d submission FAILED\n", coreNum, count);
                 retval = 1;
             }
             else
             {
 #ifdef MCBSP_APP_VERBOSE
-                System_printf ("Debug(Core %d): TX buffer  #%d is submitted to MCBSP driver\n", coreNum, count);
+                MCBSP_log ("Debug(Core %d): TX buffer  #%d is submitted to MCBSP driver\n", coreNum, count);
 #endif
             }
             txFrameIndex++;
@@ -704,7 +705,7 @@ restart_mcbsp_point:
                 if (edmaTxDone == 1)
                 {
 #ifdef MCBSP_APP_VERBOSE
-                    System_printf ("Debug(Core %d): EDMA -> Buffer #-%d is transmitted to TX path\n", coreNum, count);
+                    MCBSP_log ("Debug(Core %d): EDMA -> Buffer #-%d is transmitted to TX path\n", coreNum, count);
 #endif
                     edmaTxDone = 0; /* Reset for next iteration */
                     mcbspTxDone = 1;
@@ -712,7 +713,7 @@ restart_mcbsp_point:
                 if (edmaRxDone == 1)
                 {
 #ifdef MCBSP_APP_VERBOSE
-                    System_printf ("Debug(Core %d): EDMA -> Buffer #-%d is received from RX path\n", coreNum, count);
+                    MCBSP_log ("Debug(Core %d): EDMA -> Buffer #-%d is received from RX path\n", coreNum, count);
 #endif
                     edmaRxDone = 0;  /* Reset for next iteration */
                     mcbspRxDone = 1;
@@ -737,9 +738,9 @@ restart_mcbsp_point:
                 if (((char *)bufTx[count])[tempCount] != ((char *)bufRx[count])[tempCount])
                 {
 #ifdef MCBSP_APP_VERBOSE
-                    System_printf("Debug(Core %d): Error: TX and RX frame data DOES NOT match in Buffer #-%d\n",
+                    MCBSP_log("Debug(Core %d): Error: TX and RX frame data DOES NOT match in Buffer #-%d\n",
                         coreNum, count);
-                    System_printf("Debug(Core %d): Error: Buffer index = %d, Tx data = %d, Rx data = %d\n", coreNum,
+                    MCBSP_log("Debug(Core %d): Error: Buffer index = %d, Tx data = %d, Rx data = %d\n", coreNum,
                         tempCount, ((char *)bufTx[count])[tempCount], ((char *)bufRx[count])[tempCount]);
 #endif
                     errBuffCount++;
@@ -749,7 +750,7 @@ restart_mcbsp_point:
             if (tempCount >= BUFSIZE)
             {
 #ifdef MCBSP_APP_VERBOSE
-                System_printf("Debug(Core %d): TX and RX frames data match in iteration-%d !!!\n", coreNum, count);
+                MCBSP_log("Debug(Core %d): TX and RX frames data match in iteration-%d !!!\n", coreNum, count);
 #endif
             }
         }
@@ -768,7 +769,7 @@ restart_mcbsp_point:
             status = mcbspDeleteChan(hMcbspRxChan);
             if (MCBSP_STATUS_COMPLETED != status)
             {
-                System_printf ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
+                MCBSP_log ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
                 return;
             }
 
@@ -776,14 +777,14 @@ restart_mcbsp_point:
             status = mcbspDeleteChan(hMcbspTxChan);
             if (MCBSP_STATUS_COMPLETED != status)
             {
-                System_printf ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
+                MCBSP_log ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
                 return;
             }
             /* Create a RX channel for receiving */
             status = mcbspCreateChan(&hMcbspRxChan, hMcbspDev, MCBSP_MODE_INPUT, &mcbspChanparamRx, mcbspAppCallback, &rxChanMode);
             if (MCBSP_STATUS_COMPLETED != status)
             {
-                System_printf ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
+                MCBSP_log ("Debug(Core %d): Error: Create Channel (RX) failed\n", coreNum);
                 return;
             }
 
@@ -791,7 +792,7 @@ restart_mcbsp_point:
             status = mcbspCreateChan(&hMcbspTxChan, hMcbspDev, MCBSP_MODE_OUTPUT, &mcbspChanparamTx, mcbspAppCallback, &txChanMode);
             if (MCBSP_STATUS_COMPLETED != status)
             {
-                System_printf ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
+                MCBSP_log ("Debug(Core %d): Error: Create Channel (TX) failed\n", coreNum);
                 return;
             }
             edmaTxDone = 0;   /* Reset for next iteration */
@@ -810,13 +811,14 @@ restart_mcbsp_point:
 
     if ((errBuffCount == 0 ) & (retval ==0))
     {
-        System_printf("Debug(Core %d): MCBSP Digital Loopback Application completed successfully : "\
+        MCBSP_log("Debug(Core %d): MCBSP Digital Loopback Application completed successfully : "\
             "Num iterations %d  Num buffers per iteration %d!!!\n",
             coreNum, num_iterations, NUM_BUFS);
+        MCBSP_log("\n All tests have passed \n");
     }
     else
     {
-        System_printf("Debug(Core %d): MCBSP Digital Loopback application FAILED :  "\
+        MCBSP_log("Debug(Core %d): MCBSP Digital Loopback application FAILED :  "\
             "Num iterations %d  Num buffers per iteration %d Failed buffers %d!!!\n",
             coreNum, num_iterations, NUM_BUFS, errBuffCount);
     }
@@ -825,7 +827,7 @@ restart_mcbsp_point:
     status = mcbspDeleteChan(hMcbspRxChan);
     if (MCBSP_STATUS_COMPLETED != status)
     {
-        System_printf ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
+        MCBSP_log ("Debug(Core %d): Error: Delete Channel (RX) failed\n", coreNum);
         return;
     }
 
@@ -833,7 +835,7 @@ restart_mcbsp_point:
     status = mcbspDeleteChan(hMcbspTxChan);
     if (MCBSP_STATUS_COMPLETED != status)
     {
-        System_printf ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
+        MCBSP_log ("Debug(Core %d): Error: Delete Channel (TX) failed\n", coreNum);
         return;
     }
     return;
@@ -867,21 +869,21 @@ Void main(Void)
 
 #ifdef SIMULATOR_SUPPORT
 #warn MCBSP Digital Loopback example is not supported on SIMULATOR !!!
-    System_printf ("MCBSP Digital Loopback example is not supported on SIMULATOR. Exiting!\n");
+    MCBSP_log ("MCBSP Digital Loopback example is not supported on SIMULATOR. Exiting!\n");
     return;
 #else
-    System_printf ("Debug(Core %d): Running MCBSP Digital Loopback example on the DEVICE\n", coreNum);
+    MCBSP_log ("Debug(Core %d): Running MCBSP Digital Loopback example on the DEVICE\n", coreNum);
 #endif
 
     /* Initialize the system only if the core was configured to do so. */
     if (coreNum == CORE_SYS_INIT)
     {
 #if 0
-        System_printf ("Debug(Core %d): System Initialization for MCBSP\n", coreNum);
+        MCBSP_log ("Debug(Core %d): System Initialization for MCBSP\n", coreNum);
         /* Read FPGA register */
         if (0 != (platform_fpgaReadConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, &uchReadValue)))
         {
-            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
+            MCBSP_log ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
             return;
         }
         /* Clear field for configuration */
@@ -893,25 +895,25 @@ Void main(Void)
          * These clocks and syncs are tri-stated and McBSP is accessed over 80-pin header */
         if (0 != (platform_fpgaWriteConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, (uchValue))))
         {
-            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register WRITE failed \n", coreNum);
+            MCBSP_log ("Debug(Core %d): FPGA McBSP_AMC_EN# register WRITE failed \n", coreNum);
             return;
         }
 
         /* DEBUG: Verify if FPGA register is configured correctly */
         if (0 != (platform_fpgaReadConfigReg(MCBSP_FPGA_MISC_REG_OFFSET, &uchReadValue)))
         {
-            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
+            MCBSP_log ("Debug(Core %d): FPGA McBSP_AMC_EN# register READ failed \n", coreNum);
             return;
         }
 
         if (uchValue != uchReadValue)
         {
-            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register setting failed \n", coreNum);
+            MCBSP_log ("Debug(Core %d): FPGA McBSP_AMC_EN# register setting failed \n", coreNum);
             return;
         }
         else
         {
-            System_printf ("Debug(Core %d): FPGA McBSP_AMC_EN# register is set to %d \n", coreNum, uchValue);
+            MCBSP_log ("Debug(Core %d): FPGA McBSP_AMC_EN# register is set to %d \n", coreNum, uchValue);
         }
 #endif
         /* MCBSP Driver Initialization: This should always be called before
@@ -922,7 +924,7 @@ Void main(Void)
         McbspDevice_init();
         
         /* MCBSP Driver is operational at this time. */
-        System_printf ("Debug(Core %d): MCBSP Driver Initialization Done\n", coreNum);
+        MCBSP_log ("Debug(Core %d): MCBSP Driver Initialization Done\n", coreNum);
 
         /* Write to the SHARED memory location at this point in time. The other cores cannot execute
          * till the MCBSP Driver is up and running. */
@@ -937,7 +939,7 @@ Void main(Void)
     else
     {
         /* All other cores need to wait for the MCBSP to be initialized before they proceed with the test. */ 
-        System_printf ("Debug(Core %d): Waiting for MCBSP to be initialized.\n", coreNum);
+        MCBSP_log ("Debug(Core %d): Waiting for MCBSP to be initialized.\n", coreNum);
 
         /* All other cores loop around forever till the MCBSP is up and running. 
          * We need to invalidate the cache so that we always read this from the memory. */
@@ -946,7 +948,7 @@ Void main(Void)
                Cache_inv ((void *) &isMCBSPInitialized[0], MCBSP_CACHE_LENGTH, 0x7fff, 1);
 
 
-        System_printf ("Debug(Core %d): MCBSP can now be used.\n", coreNum);
+        MCBSP_log ("Debug(Core %d): MCBSP can now be used.\n", coreNum);
     }
 
     /* Initialize EDMA3 library */
@@ -955,11 +957,11 @@ Void main(Void)
     if (edmaResult != EDMA3_DRV_SOK)
     {
         /* Report EDMA Error */
-        System_printf("Debug(Core %d): EDMA Driver Initialization FAILED\n", coreNum);
+        MCBSP_log("Debug(Core %d): EDMA Driver Initialization FAILED\n", coreNum);
     }
     else
     {
-        System_printf("Debug(Core %d): EDMA Driver Initialization Done\n", coreNum);
+        MCBSP_log("Debug(Core %d): EDMA Driver Initialization Done\n", coreNum);
     }
 
     /* Create the Digital Loopback Application Task */