/* ========================================================================== */
/* INCLUDE FILES */
/* ========================================================================== */
#include <xdc/std.h>
#include <ti/sysbios/io/iom.h>
#include <xdc/runtime/log.h>
#include <ti/sysbios/knl/task.h>
#include <string.h>
#include <mcbsp/include/mcbsp.h>
#include <ti/sysbios/io/GIO.h>
#include <xdc/runtime/Memory.h>
#include <ti/sysbios/heaps/HeapMem.h>
#include <xdc/runtime/IHeap.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sdo/edma3/drv/edma3_drv.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/runtime/Timestamp.h>
#include <include/McbspLocal.h>
#include <ti/sdo/edma3/drv/src/edma3.h>
#include <ti/sysbios/hal/Cache.h>
#include <cslr/cslr_syscfg0_C6748.h>
#include <include/McbspLocal.h>
#include <assert.h>
#include <cslr/cslr_edma3cc.h>
/* ========================================================================== */
/* IMPORTED VARIABLES */
/* ========================================================================== */
extern Semaphore_Handle adc_finish_sem;
/* ========================================================================== */
/* EXTERNAL FUNCTIONS */
/* ========================================================================== */
extern EDMA3_DRV_Handle edma3init(unsigned int edma3Id, EDMA3_DRV_Result *);
/* ========================================================================== */
/* MACRO DEFINITIONS */
/* ========================================================================== */
/*EDMA WORK AT CIRCLE MODE*/
#define MOVE_DATA_CIRCLE 1
/*EDMA WORK AT PING-PONG MODE*/
//#define MOVE_DATA_PING_PONG 1
/*EDMA WORK AT NORMAL MODE*/
//#define MOVE_DATA_NORMAL 1
#define move_data_edmaEventQ 0
#define BUFALIGN 128 /* align buffers to 128 bytes */
#define BUFSIZE 10 /* 1 of data transceive */
/**
* \brief Block Interface Driver: Direction for EDMA copy
*/
typedef enum Move_DataDir
{
Move_Data_Write = 0,
/**< Data Write */
Move_Data_Read
/**< Data Read */
}Move_DataDir;
/* ========================================================================== */
/* LOCAL VARIABLES */
/* ========================================================================== */
/* Handle to the EDMA driver instance */
EDMA3_DRV_Handle moveData_hEdma;
static Uint32 moveDataTcc = EDMA3_DRV_TCC_ANY;
static UInt32 moveDataChId = EDMA3_DRV_DMA_CHANNEL_ANY;
static Uint32 moveDataTcc_circle = EDMA3_DRV_TCC_ANY;
static UInt32 moveDataChId_circle = EDMA3_DRV_LINK_CHANNEL;
static Uint32 moveDataTcc_ping = EDMA3_DRV_TCC_ANY;
static UInt32 moveDataChId_ping = EDMA3_DRV_LINK_CHANNEL;
static Uint32 moveDataTcc_pong = EDMA3_DRV_TCC_ANY;
static UInt32 moveDataChId_pong = EDMA3_DRV_LINK_CHANNEL;
#pragma DATA_ALIGN(moveData_write, 128);
Uint8 moveData_write[BUFSIZE];
//#pragma DATA_SECTION (adc_data_read, "l2ramdata");
#pragma DATA_ALIGN(moveData_read, 128);
Uint8 moveData_read[BUFSIZE];
#pragma DATA_ALIGN(moveData_write1, 128);
Uint8 moveData_write1[BUFSIZE];
//#pragma DATA_SECTION (adc_data_read, "l2ramdata");
#pragma DATA_ALIGN(moveData_read1, 128);
Uint8 moveData_read1[BUFSIZE];
Uint32 g_move_data_cnt=0;
#define CIRCLE_TX_BUF ((Uint32)&moveData_write[0])
#define CIRCLE_RX_BUF ((Uint32)&moveData_read[0])
#define PING_TX_BUF ((Uint32)&moveData_write[0])
#define PING_RX_BUF ((Uint32)&moveData_read[0])
#define PONG_TX_BUF ((Uint32)&moveData_write1[0])
#define PONG_RX_BUF ((Uint32)&moveData_read1[0])
/* ========================================================================== */
/* LOCAL FUNCTIONS */
/* ========================================================================== */
/* ========================================================================== */
/* FUNCTION DEFINTIONS */
/* ========================================================================== */
/*
* \brief EDMA callback for the TX event.
*
* This function is the EDMA callback for the move data event handling.
*
* \param tcc [IN] tcc number of EDMA
* \param status [IN] status of EDMA
* \param data [IN] paramaters send to EDMA ISR (chan handler)
*
* \return None
*/
static Void moveDataEdmaTxCallback(Uint32 tcc,
EDMA3_RM_TccStatus status,
Ptr data)
{
Uint32 i;
EDMA3_DRV_PaRAMRegs paramSet = {0};
// Cache_inv(&moveData_read[0], BUFSIZE, Cache_Type_ALL, TRUE);
// moveData_write[0] = g_move_data_cnt%255;
for(i=0;i<BUFSIZE;i++)
{
// if(moveData_read[i] != moveData_read[i-1])
{
// System_printf(("\r\move data: Edma move data failed"));
}
// moveData_write1[i] = g_move_data_cnt%255;
moveData_write[i] = g_move_data_cnt%255;
// moveData_read1[i] = 0;
}
EDMA3_DRV_getPaRAM(
moveData_hEdma,
moveDataChId,
¶mSet);
/* clean the D Cache in MVA way */
// Cache_wb(&moveData_write[0], BUFSIZE, Cache_Type_ALL, TRUE);
/* To remove warning, kept for future usage */
tcc = tcc;
status = status;
g_move_data_cnt++;
// timee=Timestamp_get32()-timep;
if (NULL != data)
{
data = data;
}
}
Uint32 g_move_data_cnt_ping=0;
static Void moveDataEdmaTxCallback_ping(Uint32 tcc,
EDMA3_RM_TccStatus status,
Ptr data)
{
Uint32 i;
EDMA3_DRV_PaRAMRegs paramSet = {0};
for(i=0;i<BUFSIZE;i++)
{
// moveData_write1[i] = g_move_data_cnt%255;
moveData_write[i] = g_move_data_cnt_ping%255;
moveData_read1[i] = 0;
}
EDMA3_DRV_getPaRAM(
moveData_hEdma,
moveDataChId_ping,
¶mSet);
/* clean the D Cache in MVA way */
// Cache_wb(&moveData_write[0], 128, Cache_Type_ALL, TRUE);
/* To remove warning, kept for future usage */
tcc = tcc;
status = status;
g_move_data_cnt_ping++;
// timee=Timestamp_get32()-timep;
if (NULL != data)
{
data = data;
}
}
Uint32 g_move_data_cnt_pong=0;
static Void moveDataEdmaTxCallback_pong(Uint32 tcc,
EDMA3_RM_TccStatus status,
Ptr data)
{
Uint32 i;
EDMA3_DRV_PaRAMRegs paramSet = {0};
for(i=0;i<BUFSIZE;i++)
{
moveData_write1[i] = g_move_data_cnt_pong%255;
// moveData_write[i] = g_move_data_cnt%255;
moveData_read1[i] = 0;
}
EDMA3_DRV_getPaRAM(
moveData_hEdma,
moveDataChId_pong,
¶mSet);
/* clean the D Cache in MVA way */
// Cache_wb(&moveData_write[0], 128, Cache_Type_ALL, TRUE);
/* To remove warning, kept for future usage */
tcc = tcc;
status = status;
g_move_data_cnt_pong++;
// t