/************************************************************************************ * accessSlave.c * * synopsis: Functions which are used to read and write the SDSP HPI registers * * writeSlvHPIx: Writes "dataValue" to the HPIx register of slave DSP "slaveNum". * readSlvHPIx: Reads the HPIx register of slave DSP "slaveNum". * writeSlvHPID_I: Writes "dataValue" to the HPID register and increments by 4 * (bytes) the HPIA register of slave DSP "slaveNum". * readSlvHPID_I: Reads the HPID register and increments by 4 (bytes) the HPIA * register of slave DSP "slaveNum". * * notes: The calling routine is responsible to ensure that slave DSP "slaveNum" * exists and is active. This is done with the function slaveIsOn(slaveNum). * * arguments: * * IN: slaveNum = index of the slave DSP which is being accessed * dataValue = 32 bit value to be written to the HPI register. * * return value: (readSlvHPIx routines only) = value read from the HPI register * * related files: * accessSlave.c - Prototype declarations for the functions defined here * * modifications/bugs: * - changed code for 32 bit access to slave RCJ 2/26/02 * - added temporary pre-processor flag ACCESS32 to select the * board type (32/16 bit) dpsf 20.03.02 * - removed ACCESS32 flag (well tested now); added in a polling loop * for the ARDY bit in the EMIF global control register. This prevents * the inter-DSP routines from executing too quickly if they've been put * in IPRAM & botching writes. dpsf 13.11.02 * - added functions writeSlvBlock & readSlvBlock to read & write a block * of data to/from a SDSP dpsf 06.08.03 ************************************************************************************/ #include "resources.h" #include "memoryPartitions.h" #include "accessSlave.h" #pragma CODE_SECTION(writeSlvHPIC, "icode"); #pragma CODE_SECTION(writeSlvHPIA, "icode"); #pragma CODE_SECTION(writeSlvHPID, "icode"); #pragma CODE_SECTION(writeSlvHPID_I, "icode"); #pragma CODE_SECTION(readSlvHPIC, "icode"); #pragma CODE_SECTION(readSlvHPIA, "icode"); #pragma CODE_SECTION(readSlvHPID, "icode"); #pragma CODE_SECTION(readSlvHPID_I, "icode"); #pragma CODE_SECTION(writeSlvBlock, "icode"); #pragma CODE_SECTION(readSlvBlock, "icode"); extern TIMER_Handle timer1; /* general purpose timer, started in main() */ /* when fully satisfied with the ARDY poll, the struct & ER bit can go */ #include "comRegDfns.h" UINT32 *emifGCR= (UINT32 *) 0x01800000; //dpsf: ? UINT32 slvData; //dpsf: ? UINT32 *mcbsp_pcr0= (UINT32 *) 0x018c0024; struct IDspTest { UINT32 header, rwCnt[8], trailer; }; #pragma DATA_SECTION(iDspTest, "idata"); struct IDspTest iDspTest= {0xabdcef12, 0,0,0,0, 0,0,0,0, 0xabcdef12}; /* -------- write to the HPI control register -------- */ void writeSlvHPIC(UINT32 slaveNum, UINT32 dataValue) { iDspTest.rwCnt[0]= 0; *((UINT32 *)(SDSP_HPIC(slaveNum)))= dataValue; while (!(*emifGCR & 0x00000400)) ++iDspTest.rwCnt[0]; /* wait for ARDY */ return; } /* -------- write to the HPI address register -------- */ void writeSlvHPIA(UINT32 slaveNum, UINT32 dataValue) { if ((dataValue >= 0x60000000) & (dataValue < 0x80000000)) { //scream. WRITE_REG(RESERVED_REG_2, dataValue); yellowLed_on; } iDspTest.rwCnt[1]= 0; *((UINT32 *)(SDSP_HPIA(slaveNum)))= dataValue; while (!(*emifGCR & 0x00000400)) ++iDspTest.rwCnt[1]; /* wait for ARDY */ *((UINT32 *)(SDSP_HPIA(slaveNum))) = dataValue; while (!(*emifGCR & 0x00000400)) ++iDspTest.rwCnt[1]; /* wait for ARDY */ return; } /* -------- write to the HPI data register -------- */ void writeSlvHPID(UINT32 slaveNum, UINT32 dataValue) { iDspTest.rwCnt[2]= 0; *((UINT32 *)(SDSP_HPID(slaveNum)))= dataValue; while (!(*emifGCR & 0x00000400)) ++iDspTest.rwCnt[2]; /* wait for ARDY */ return; } /* -------- write to the HPI data register with auto increment -------- */ void writeSlvHPID_I(UINT32 slaveNum, UINT32 dataValue) { iDspTest.rwCnt[3]= 0; *((UINT32 *)(SDSP_HPID_I(slaveNum)))= dataValue; while (!(*emifGCR & 0x00000400)) ++iDspTest.rwCnt[3]; /* wait for ARDY */ return; } /* -------- read from the HPI control register -------- */ UINT32 readSlvHPIC(UINT32 slaveNum) { return *((UINT32 *)(SDSP_HPIC(slaveNum))); } /* -------- read from the HPI address register -------- */ UINT32 readSlvHPIA(UINT32 slaveNum) { return *((UINT32 *)(SDSP_HPIA(slaveNum))); } /* -------- read from the HPI data register -------- */ UINT32 readSlvHPID(UINT32 slaveNum) { return *((UINT32 *) (SDSP_HPID(slaveNum))); } /* -------- read from the HPI data register with auto increment -------- */ UINT32 readSlvHPID_I(UINT32 slaveNum) { return *((UINT32 *) (SDSP_HPID_I(slaveNum))); } /* Write a block of data to the desired SDSP's memory. On Rev. E RODs, the transfer must be finished with a HPID and not an HPID_I; this is required due to a bug in the silicon (on other revisions this has no effect). */ #if ((!defined(SIM)) && (!defined(TI_EVM))) void writeSlvBlock(UINT8 slv, UINT32 *slvPtr, UINT32 *ptr, UINT32 len) { UINT32 i; greenLed_on; writeSlvHPIA(slv, (UINT32) slvPtr); for (i=0; i<(len-1); ++i) writeSlvHPID_I(slv, *(ptr +i)); writeSlvHPID(slv, *(ptr +i)); greenLed_off; } /* Read a block of data from the desired SDSP's memory. On Rev. E RODs, the transfer is finished with a HPID and not an HPID_I; this is required due to a bug in the silicon. */ void readSlvBlock(UINT8 slv, UINT32 *slvPtr, UINT32 *ptr, UINT32 len) { UINT32 i; greenLed_on; writeSlvHPIA(slv, (UINT32) slvPtr); for (i=0; i<(len-1); ++i) *(ptr +i)= readSlvHPID_I(slv); *(ptr +i)= readSlvHPID(slv); greenLed_off; } #else /************************************************************************************* * The SDSP memory is simulated, using a re-mapping function. ************************************************************************************/ void writeSlvBlock(UINT8 sdsp, UINT32 *sdspPtr, UINT32 *ptr, UINT32 len) { UINT32 *sdspAddr; copySdspRegs(sdsp, TRUE); //Current SDSP comm. regs => IDRAM //re-map the SDSP address into the simulated SDSP memory space sdspAddr= remapSdspPtr(sdsp, sdspPtr); copyMem(ptr, sdspAddr, len); copySdspRegs(sdsp, FALSE); //Copy SDSP comm. regs back (they might be modified). } void readSlvBlock(UINT8 sdsp, UINT32 *sdspPtr, UINT32 *ptr, UINT32 len) { UINT32 *sdspAddr; copySdspRegs(sdsp, TRUE); //re-map the SDSP address into the simulated SDSP memory space sdspAddr= remapSdspPtr(sdsp, sdspPtr); copyMem(sdspAddr, ptr, len); } #endif