Обновление тестовой версии CM для EFC_IPC_Server_C28

This commit is contained in:
seklyuts 2024-05-21 10:39:19 +03:00
parent 6d997d7233
commit 9bcf133617
2 changed files with 297 additions and 77 deletions

View File

@ -10,6 +10,6 @@
<rts value="libc.a"/>
<createSlaveProjects value=""/>
<templateProperties value="id=ipc_ex2_msgqueue.projectspec.ipc_ex2_msgqueue_cm"/>
<origin value="D:/MotorControlModuleSDFM_TMS320F28388D/export/ipc_ex2_msgqueue_cm"/>
<origin value="D:/MotorControlModuleSDFM_TMS320F28388D/backup/ipc_ex2_msgqueue_cm"/>
<filesToOpen value=""/>
</projectOptions>

View File

@ -67,28 +67,139 @@
#define TEST_PASS 0x5555
#define TEST_FAIL 0xAAAA
#define WRONG_COMMAND 0x10
#define ERROR_VERIFY 0x11
#define FLASH_ERR 0x12
#define FLASH_FAIL 0x13
#define FLASH_ECC_FAIL 0x14
#define WRONG_LENGHT 0x15
#define WRONG_ADDR 0x16
#define WRONG_ID 0x17
#define BUSY 0x18
#define COMMAND_ACCEPTED 0x20
#define DONE_SUCCESS 0x21
IPC_MessageQueue_t messageQueue;
uint16_t WriteToCpu1, ReadFromCpu1;
uint16_t WriteToCpu2, ReadFromCpu2;
uint16_t copyBuf1,copyBuf2,fillBuf1;
uint16_t copyBuf1,copyBuf2,fillBuf1,ErraseBuff,Fiil0Buff,TheEndGD25Q16E;
IPC_Message_t TxMsg, RxMsg;
//uint16_t IntNum = 1;
uint16_t GetMes[16];
uint16_t PutMes[16];
uint16_t offset;
uint16_t TempConst = 2;
uint16_t CounterCPU1Blocks = 0;
//uint16_t CounterCPU1Blocks = 0;
uint32_t Command,StartAddr,Data;
uint32_t Command=0x0100A3,StartAddr=0x1E7040,Data=160;
uint32_t InCommand,InAddr,InData;
uint16_t Fill_num = 0x0;
uint16_t Array[256]=
{
0x27, 0x17, 0x00, 0x02, 0x00, 0x07, 0x00, 0x0A,
0x27, 0x18, 0x00, 0x02, 0x00, 0x08, 0x00, 0x0A,
0x27, 0x19, 0x00, 0x02, 0x00, 0x09, 0x00, 0x0A,
0x27, 0x1A, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x0A,
0x27, 0x1B, 0x00, 0x02, 0x00, 0x0B, 0x00, 0x0A,
0x27, 0x1C, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x0A,
0x27, 0x1D, 0x00, 0x02, 0x00, 0x0D, 0x00, 0x0A,
0x27, 0x1E, 0x00, 0x02, 0x00, 0x0E, 0x00, 0x0A,
0x27, 0x1F, 0x00, 0x02, 0x00, 0x0F, 0x00, 0x0A,
0x27, 0x20, 0x00, 0x02, 0x00, 0x10, 0x00, 0x0A,
0x27, 0x21, 0x00, 0x02, 0x27, 0x22, 0x00, 0x02,
0x00, 0x11, 0x00, 0x0A, 0x27, 0x23, 0x00, 0x02,
0x00, 0x12, 0x00, 0x0A, 0x27, 0x24, 0x00, 0x02,
0x00, 0x13, 0x00, 0x0A, 0x27, 0x25, 0x00, 0x02,
0x00, 0x14, 0x00, 0x0A, 0x27, 0x26, 0x00, 0x02,
0x00, 0x15, 0x00, 0x0A, 0x27, 0x27, 0x00, 0x02,
0x00, 0x16, 0x00, 0x0A, 0x27, 0x28, 0x00, 0x02,
0x00, 0x17, 0x00, 0x0A, 0x27, 0x29, 0x00, 0x02,
0x00, 0x18, 0x00, 0x0A, 0x27, 0x2A, 0x00, 0x02,
0x00, 0x19, 0x00, 0x0A, 0x27, 0x2B, 0x00, 0x02,
0x27, 0x1F, 0x00, 0x02, 0x00, 0x0F, 0x00, 0x0A,
0x27, 0x20, 0x00, 0x02, 0x00, 0x10, 0x00, 0x0A,
0x27, 0x21, 0x00, 0x02, 0x27, 0x22, 0x00, 0x02,
0x00, 0x11, 0x00, 0x0A, 0x27, 0x23, 0x00, 0x02,
0x00, 0x12, 0x00, 0x0A, 0x27, 0x24, 0x00, 0x02,
0x00, 0x13, 0x00, 0x0A, 0x27, 0x25, 0x00, 0x02,
0x00, 0x14, 0x00, 0x0A, 0x27, 0x26, 0x00, 0x02,
0x00, 0x15, 0x00, 0x0A, 0x27, 0x27, 0x00, 0x02,
0x00, 0x16, 0x00, 0x0A, 0x27, 0x28, 0x00, 0x02,
0x00, 0x17, 0x00, 0x0A, 0x27, 0x29, 0x00, 0x02,
0x00, 0x18, 0x00, 0x0A, 0x27, 0x2A, 0x00, 0x02,
0x00, 0x19, 0x00, 0x0A, 0x27, 0x2B, 0x00, 0x02
};
// IPC ISR for Flag 1
// C28x core sends data with message queue using Flag 0
//
uint16_t offset;
void FillBuff1_num(uint16_t num)
{
uint16_t i;
uint16_t * Buffer = (uint16_t *)CMTOCPU1MSGRAM0_BASE;
for(i=0; i < 2048; i++)
{
Buffer[i] = num;
}
}
void FillBuff1Array(void)
{
uint16_t i,j,a,b;
uint16_t * Buffer = (uint16_t *)CMTOCPU1MSGRAM0_BASE;
for(j=0; j< 16; j++)
{
for(i=0; i < 256; i++)
{
a = Array[i*2];
b = Array[i*2+1];
Buffer[i+256*j] = b+(a<<8);
}
}
}
uint16_t ErrVerify;
void verifyArray(void)
{
uint16_t i,j,a,b,r1,r2;
uint16_t * Buffer = (uint16_t *)CPU1TOCMMSGRAM0_BASE;
for(j=0; j< 16; j++)
{
for(i=0; i < 256; i++)
{
a = Array[i*2];
b = Array[i*2+1];
r1 = Buffer[i+80*j];
r2 = b+(a<<8);
if(r1 != r2)
{
ErrVerify++;
}
}
}
}
void FillBuff1(void)
{
@ -130,24 +241,24 @@ void buffCopy2(void)
void putMessage_to_CPU1(uint16_t IntNum)
{
uint16_t i;
uint16_t * Buffer = (uint16_t *)CMTOCPU1MSGRAM0_BASE;
for(i=0; i < 2048; i++)
{
// uint16_t i;
// uint16_t * Buffer = (uint16_t *)CMTOCPU1MSGRAM0_BASE;
// for(i=0; i < 2048; i++)
// {
// Buffer[i] = i*TempConst;
}
// IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<IntNum));
// }
IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<IntNum));
}
void putMessage_to_CPU2(uint16_t IntNum)
{
uint16_t i;
uint16_t * Buffer = (uint16_t *)CMTOCPU2MSGRAM0_BASE;
for(i=0; i < 2048; i++)
{
// uint16_t i;
// uint16_t * Buffer = (uint16_t *)CMTOCPU2MSGRAM0_BASE;
// for(i=0; i < 2048; i++)
// {
// Buffer[i] = i*TempConst;
}
// IPC_setFlagLtoR(IPC_CM_L_CPU2_R, (1<<IntNum));
// }
IPC_setFlagLtoR(IPC_CM_L_CPU2_R, (1<<IntNum));
}
@ -198,29 +309,15 @@ __interrupt void IPC1_ISR1()
}
__interrupt void IPC1_ISR0()
{
IPC_readCommand(IPC_CM_L_CPU1_R, 0, 0, &InCommand, &InAddr, &InData );
getMessage_from_CPU1(GetMes,16);
if(CounterCPU1Blocks > 0)
{
StartAddr += Data;
offset += Data;
FillBuff1();
CounterCPU1Blocks--;
WriteToCpu1 = 1;
}
else WriteToCpu1 = 0;
//
// Acknowledge the flag
//
CounterISR[1]++;
IPC_ackFlagRtoL(IPC_CM_L_CPU1_R, IPC_FLAG0);
}
uint16_t ErrStage = 0, TestErrCommand = 0;
uint16_t stage=0, read_now = 1;
uint16_t CountErr[257];
__interrupt void IPC2_ISR1()
{
@ -265,6 +362,160 @@ __interrupt void IPC2_ISR0()
//
void DoItCPU1(void)
{
if(WriteToCpu1 == 1)
{
WriteToCpu1 = 2;
IPC_sendCommand(IPC_CM_L_CPU1_R, 0, 0, Command, StartAddr, Data);
IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<0));
}
// if(ReadFromCpu1 == 1)
// {
// ReadFromCpu1 = 0;
// getMessage_from_CPU1(GetMes,16);
// IPC_readCommand(IPC_CM_L_CPU1_R, 0, 0, &InCommand, &InAddr, &InData );
// }
// if(TheEndGD25Q16E == 1)
// {
// TheEndGD25Q16E = 0;
// IPC_sendCommand(IPC_CM_L_CPU1_R, 0, 0, 0xFF00A3, 0, 0);
// IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<0));
// }
}
//void SendStopToGD25Q16E(void)
//{
// IPC_sendCommand(IPC_CM_L_CPU1_R, 0, 0, 0xFF00A3, 0, 0);
// IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<0));
//}
void DoItCPU2(void)
{
if(WriteToCpu2 == 1)
{
WriteToCpu2 = 2;
IPC_sendCommand(IPC_CM_L_CPU2_R, 0, 0, Command, StartAddr, Data);
IPC_setFlagLtoR(IPC_CM_L_CPU2_R, (1<<0));
}
// if(ReadFromCpu2 == 1)
// {
// ReadFromCpu2 = 0;
// getMessage_from_CPU2(GetMes,16);
// IPC_readCommand(IPC_CM_L_CPU2_R, 0, 0, &InCommand, &InAddr, &InData );
// }
}
void DoItBoof(void)
{
if(copyBuf1 == 1)
{
copyBuf1 = 0;
buffCopy1();
}
if(copyBuf2 == 1)
{
copyBuf2 = 0;
buffCopy2();
}
if(fillBuf1 == 1)
{
fillBuf1 = 0;
FillBuff1Array();
}
if(Fiil0Buff == 1)
{
Fiil0Buff = 0;
FillBuff1_num(Fill_num);
}
}
uint16_t stageStart = 145;
uint16_t stageEnd = 145;
uint16_t Size = 0x1000;
uint16_t OffsetAdr = 0;
void writeAndVerifyAllGD25Q16E(void)
{
if(stage == 0)
{
Command = 0xFF00A3;
StartAddr = 0;
WriteToCpu1 = 1;
}
else
{
if(stage <= 256 )
{
if(stageStart == 0) stageStart++;
if(stage <= 1)stage = stageStart;
if(read_now) Command = 0x0000A3;
else Command = 0x0100A3;
StartAddr = (stage - 1)*0x1000 + OffsetAdr;
Data = Size;
WriteToCpu1 = 1;
if(stage == stageEnd) stage = 256;
}
}
}
uint16_t AdrErr[2048];
void verify_num(uint16_t num)
{
uint16_t i,r1,r2;
uint16_t * Buffer = (uint16_t *)CPU1TOCMMSGRAM0_BASE;
for(i=0; i < (Size/2); i++)
{
r1 = Buffer[i];
r2 = num;
if(r1 != r2)
{
AdrErr[ErrVerify] = i*2;
ErrVerify++;
}
}
}
__interrupt void IPC1_ISR0()
{
IPC_readCommand(IPC_CM_L_CPU1_R, 0, 0, &InCommand, &InAddr, &InData );
getMessage_from_CPU1(GetMes,16);
WriteToCpu1 = 0;
TestErrCommand = InCommand>>16;
if((TestErrCommand != COMMAND_ACCEPTED) && (TestErrCommand != DONE_SUCCESS) )
{
ErrStage++;
}
if(Command == 0x0000A3)
{
verify_num(Fill_num);
}
CountErr[stage] = ErrVerify;
ErrVerify = 0;
stage++;
//
// Acknowledge the flag
//
CounterISR[1]++;
IPC_ackFlagRtoL(IPC_CM_L_CPU1_R, IPC_FLAG0);
}
void main(void)
{
//
@ -298,49 +549,18 @@ void main(void)
//
// Loop forever. Wait for IPC interrupt
//
//FillBuff1Array();
FillBuff1_num(Fill_num);
stage = 257;
while(1)
{
if(WriteToCpu1 == 1)
{
WriteToCpu1 = 2;
IPC_sendCommand(IPC_CM_L_CPU1_R, 0, 0, Command, StartAddr, Data);
IPC_setFlagLtoR(IPC_CM_L_CPU1_R, (1<<0));
}
if(WriteToCpu2 == 1)
{
WriteToCpu2 = 2;
IPC_sendCommand(IPC_CM_L_CPU2_R, 0, 0, Command, StartAddr, Data);
IPC_setFlagLtoR(IPC_CM_L_CPU2_R, (1<<0));
}
if(ReadFromCpu1 == 1)
{
ReadFromCpu1 = 0;
getMessage_from_CPU1(GetMes,16);
IPC_readCommand(IPC_CM_L_CPU1_R, 0, 0, &InCommand, &InAddr, &InData );
}
if(copyBuf1 == 1)
{
copyBuf1 = 0;
buffCopy1();
}
if(ReadFromCpu2 == 1)
{
ReadFromCpu2 = 0;
getMessage_from_CPU2(GetMes,16);
IPC_readCommand(IPC_CM_L_CPU2_R, 0, 0, &InCommand, &InAddr, &InData );
}
if(copyBuf2 == 1)
{
copyBuf2 = 0;
buffCopy2();
}
if(fillBuf1 == 1)
{
fillBuf1 = 0;
FillBuff1();
}
DoItCPU1();
DoItCPU2();
DoItBoof();
if(WriteToCpu1 == 0) writeAndVerifyAllGD25Q16E();
}
}