Добавил ID устройств

This commit is contained in:
Eugene 2023-11-16 14:52:31 +03:00
parent d5563e6fef
commit 42defbbfe6

View File

@ -30,6 +30,11 @@
#define COMMAND_ACCEPTED 0x20
#define DONE_SUCCESS 0x21
#define Flash 0xA0
#define EMIF 0xA1
#define BL25CM1A_1M_bit_SPI 0xA2
#define GD25Q16E_16M_bit_SPI 0xA3
#define ZD24C02A_2K_I2C 0xA4
typedef enum
{
@ -97,7 +102,7 @@ void clear_BlockWasErased(void)
}
}
void getMessage_from_Cm(void)
void getMessage_from_Cm_Flash(void)
{
uint16_t FlashSektorStart = 0;
uint16_t FlashSektorEnd = 0;
@ -105,11 +110,6 @@ void getMessage_from_Cm(void)
uint32_t block1, block2;
uint16_t FlashErr = 0;
IPC_readCommand(IPC_CPU1_L_CM_R, 0, 0, &InCommand, &InAddr, &InData );
if(InData > 2048) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_LENGHT, 0, 0); return;}
if((InAddr+InData) > 0x40000) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_ADDR, 0, 0); return;}
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
FactAddressFlash = InAddr + Bzero_Sector0_start;
@ -167,22 +167,32 @@ void getMessage_from_Cm(void)
__interrupt void IPC_ISR0()
{
IPC_readCommand(IPC_CPU1_L_CM_R, 0, 0, &InCommand, &InAddr, &InData );
if(InData > 2048) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_LENGHT, 0, 0); return;}
if((InAddr+InData) > 0x40000) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_ADDR, 0, 0); return;}
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
getMessage_from_Cm();
if(WriteToCm != 2)
switch(InCommand & 0xFFFF)
{
//putMessage_to_Cm();
//IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, Command, Address, Data);
case Flash:
getMessage_from_Cm_Flash();
break;
case EMIF:
break;
case BL25CM1A_1M_bit_SPI:
break;
case GD25Q16E_16M_bit_SPI:
break;
case ZD24C02A_2K_I2C:
break;
default:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_COMMAND, 0, 0);
break;
}
else WriteToCm = 0;
//
// Acknowledge the flag
//
IPC_ackFlagRtoL(IPC_CPU1_L_CM_R, (1<<0));
PieCtrlRegs.PIEACK.all = PIEACK_GROUP11;
}
@ -235,15 +245,10 @@ void ipc_init(void)
void ipc_run(void)
{
if(WriteToCm == 1)
{
WriteToCm = 2;
//putMessage_to_Cm();
}
if(ReadFromCm == 1)
{
ReadFromCm = 0;
getMessage_from_Cm();
IPC_readCommand(IPC_CPU1_L_CM_R, 0, 0, &InCommand, &InAddr, &InData );
}
}