Изменение размерности массивов работы с внешней памятью

This commit is contained in:
Eugene 2023-11-17 10:34:40 +03:00
parent fe71486eae
commit 90f626ebb1
8 changed files with 45 additions and 23 deletions

View File

@ -8,6 +8,8 @@
#ifndef SRC_BL25CM1A_H_
#define SRC_BL25CM1A_H_
#define BL25CM1A0_SIZE 0x10000 //16 bit lenght
void Bl25cm1a_en(void);
void Bl25cm1a_write(void);
void Bl25cm1a_write_data(uint32_t Addr);

View File

@ -20,8 +20,8 @@ uint16_t WriteI2C = 0;
uint16_t Adr = 0x0;
uint32_t SpiAdr = 0;
uint16_t ArrayForTests[MAX_BUFFER_SIZE+1] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x51, 0x52};
uint16_t ArrayMax[256];
char ArrayForTests[MAX_BUFFER_SIZE+1] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x51, 0x52};
char ArrayMax[256];
void ExtEEPROM_run(void)
{

View File

@ -8,6 +8,8 @@
#ifndef SRC_GD25Q16ETIGR_H_
#define SRC_GD25Q16ETIGR_H_
#define GD25Q16E_SIZE 0x100000 // 16 bit lenght
void GD25Q16ETIGR_en(void);
void GD25Q16ETIGR_write(void);
void GD25Q16ETIGR_write_data(uint32_t Addr);

View File

@ -10,12 +10,12 @@
volatile uint16_t SlaveAdr = I2C_SLAVE_ADDRESS;
void ZD24C02A_write(uint16_t byteCount, uint16_t * Array)
void ZD24C02A_write(uint16_t byteCount, char * Array)// ìîæåò ïèñàòü î÷åðåäÿìè ïî 16 áàéò
{
I2CWrite(SlaveAdr, (byteCount + 1), true, Array);
}
void ZD24C02A_read(uint16_t byteCount, uint16_t * Array)
void ZD24C02A_read(uint16_t byteCount, char * Array)
{
I2CWrite(SlaveAdr, 1, false, Array);
I2CRead(SlaveAdr, byteCount, true, Array);
@ -23,7 +23,15 @@ void ZD24C02A_read(uint16_t byteCount, uint16_t * Array)
// I2CWriteReadOnes(I2C_SLAVE_ADDRESS);
}
void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array)
void ZD24C02A_verify(uint16_t byteCount, char * Array)
{
}
void ZD24C02A_read_all(uint16_t byteCount, char * Array)
{
I2CRead(SlaveAdr, byteCount, true, Array);
// I2CWriteRead(I2C_SLAVE_ADDRESS, byteCount, true, Array);
@ -31,7 +39,7 @@ void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array)
}
void ZD24C02A_test(uint16_t * Array)
void ZD24C02A_test(char * Array)
{
uint16_t i=0;
for(i=0;i<=255;i+=15)

View File

@ -11,10 +11,13 @@
#define I2C_SLAVE_ADDRESS 0x51U
#define I2C_OWN_ADDRESS 0x30U
#define ZD24C02A_SIZE 0x80
void ZD24C02A_write(uint16_t byteCount, uint16_t * Array);
void ZD24C02A_read(uint16_t byteCount, uint16_t * Array);
void ZD24C02A_test(uint16_t * Array);
void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array);
void ZD24C02A_write(uint16_t byteCount, char * Array);
void ZD24C02A_read(uint16_t byteCount, char * Array);
void ZD24C02A_test(char * Array);
void ZD24C02A_read_all(uint16_t byteCount, char * Array);
void ZD24C02A_verify(uint16_t byteCount, char * Array);
#endif /* SRC_ZD24C02A_H_ */

View File

@ -184,7 +184,7 @@ void I2CWrite(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, ch
// Function to read data over I2C. Returns the number of bytes read
//
uint16_t ttest=0;
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, uint16_t * I2C_RXdata)
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, char * I2C_RXdata)
{
I2caRegs.I2CMDR.bit.NACKMOD = 0x0;
//

View File

@ -18,8 +18,8 @@
void I2CMasterInit(uint16_t I2CSlave_OwnAddress, uint16_t I2CSlave_Address);
void I2CWrite(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, char * I2C_TXdata);
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, uint16_t * I2C_RXdata);
uint16_t I2CWriteRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, uint16_t * I2C_RXdata);
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, char * I2C_RXdata);
uint16_t I2CWriteRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition, char * I2C_RXdata);
void I2CMasterGpioInit(void);
void TimerBaseTimeoutInc(void);
void I2CWriteReadOnes(uint16_t slaveAddr);

View File

@ -189,7 +189,7 @@ void getMessage_from_Cm_EMIF(void)
case VERIFY:
case END:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
break;
default:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_COMMAND, 0, 0);
@ -200,21 +200,24 @@ void getMessage_from_Cm_EMIF(void)
void getMessage_from_Cm_BL25CM1A(void)
{
if(InData > 2048) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_LENGHT, 0, 0); return;}
if((InAddr+InData) > 0x10000) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_ADDR, 0, 0); return;}
if((InAddr+InData) > BL25CM1A0_SIZE) {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);
switch(InCommand >> 16)
{
case READ:
Bl25cm1a_en();
break;
case WRITE:
Bl25cm1a_en();
break;
case VERIFY:
Bl25cm1a_en();
case END:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
break;
default:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_COMMAND, 0, 0);
@ -225,21 +228,24 @@ void getMessage_from_Cm_BL25CM1A(void)
void getMessage_from_Cm_GD25Q16E(void)
{
if(InData > 2048) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_LENGHT, 0, 0); return;}
if((InAddr+InData) > 0x100000) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_ADDR, 0, 0); return;}
if((InAddr+InData) > GD25Q16E_SIZE) {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);
switch(InCommand >> 16)
{
case READ:
GD25Q16ETIGR_en();
break;
case WRITE:
GD25Q16ETIGR_en();
break;
case VERIFY:
GD25Q16ETIGR_en();
case END:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
break;
default:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_COMMAND, 0, 0);
@ -250,21 +256,21 @@ void getMessage_from_Cm_GD25Q16E(void)
void getMessage_from_Cm_ZD24C02A(void)
{
if(InData > 2048) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_LENGHT, 0, 0); return;}
if((InAddr+InData) > 0x80) {IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_ADDR, 0, 0); return;}
if((InAddr+InData) > ZD24C02A_SIZE) {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);
switch(InCommand >> 16)
{
case READ:
ZD24C02A_read(InData, (char *)CPUXTOCMMSGRAM0_BASE);
ZD24C02A_read(InData*2, (char *)CPUXTOCMMSGRAM0_BASE);
break;
case WRITE:
ZD24C02A_write(InData, (char *)CMTOCPUXMSGRAM0_BASE);
ZD24C02A_write(InData*2, (char *)CMTOCPUXMSGRAM0_BASE);
break;
case VERIFY:
ZD24C02A_verify(InData*2, (char *)CMTOCPUXMSGRAM0_BASE);
case END:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, COMMAND_ACCEPTED, 0, 0);
break;
default:
IPC_sendCommand(IPC_CPU1_L_CM_R, 0, 0, WRONG_COMMAND, 0, 0);
@ -304,6 +310,7 @@ __interrupt void IPC_ISR0()
IPC_ackFlagRtoL(IPC_CPU1_L_CM_R, (1<<0));
PieCtrlRegs.PIEACK.all = PIEACK_GROUP11;
IPC_setFlagLtoR(IPC_CPU1_L_CM_R,(1<<0));
}