Исправлены баги с обнулением счётчика стирвний секторов, баг с размером страницы и баг с зацикливанием в ожидании готовности микросхемы
This commit is contained in:
parent
42ed6e9924
commit
87176c5751
@ -230,7 +230,7 @@ void Bl25cm1a_write_data(uint32_t Addr_8bit, uint16_t quant_8bit, uint16_t * wri
|
||||
while( (Addr_8bit&0xFF)+(quant_8bit) > BL25CM1A0_PAGE) //åñëè äàííûå âûõîäÿò çà ãðàíèöó òåêóùåé ñòðàíèöû
|
||||
{
|
||||
page_quant_8bit = BL25CM1A0_PAGE - (Addr_8bit&0xFF); //âû÷èñëÿåì êîë-âî áàéò äàííûõ äî êîíöà òåêóùåé ñòðàíèöû
|
||||
Bl25cm1a_write_1_page(Addr_8bit, page_quant_8bit/2, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
Bl25cm1a_write_1_page(Addr_8bit, page_quant_8bit, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
Addr_8bit += page_quant_8bit; //ïåðåëèñòûâàåì ñòðàíèöó âíåøíåé ïàìÿòè
|
||||
addr_write_data += page_quant_8bit/2; //øàãàåì íà ñëåäóþùèå íåçàïèñàííûå äàííûå â áóôåðå
|
||||
quant_8bit -= page_quant_8bit; //óìåíüøàåì êîë-âî äàííûõ íà âåëè÷èíó êîòîðóþ óæå çàïèñàëè
|
||||
|
@ -76,16 +76,32 @@ uint16_t GD25Q16ETIGR_ReadStatus(void)
|
||||
return empty;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_sector_erase(uint32_t Addr)
|
||||
volatile uint32_t MaxRepeat = 0;
|
||||
|
||||
uint16_t GD25Q16ETIGR_WaitStatus(void)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
uint16_t repeat = 0, ErrRepeat = 0x4000;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
repeat++;
|
||||
if(repeat > ErrRepeat) return 1;
|
||||
}
|
||||
if(repeat > MaxRepeat) MaxRepeat = repeat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t GD25Q16ETIGR_sector_erase(uint32_t Addr)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
|
||||
uint16_t Err = 0;
|
||||
GD25Q16ETIGR_en();
|
||||
Err = GD25Q16ETIGR_WaitStatus();
|
||||
if(Err) return Err;
|
||||
|
||||
GD25Q16ETIGR_en();
|
||||
transmitData(SectorErase);
|
||||
@ -100,18 +116,17 @@ void GD25Q16ETIGR_sector_erase(uint32_t Addr)
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_read_8_bytes(uint32_t Addr, uint16_t * read_data, uint16_t num_byte)//÷òåíèå äî 8 áàéò
|
||||
uint16_t GD25Q16ETIGR_read_8_bytes(uint32_t Addr, uint16_t * read_data, uint16_t num_byte)//÷òåíèå äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
uint16_t Err = 0;
|
||||
|
||||
Err = GD25Q16ETIGR_WaitStatus();
|
||||
if(Err) return Err;
|
||||
|
||||
transmitData(ReadData);
|
||||
transmitData(Addr>>16);
|
||||
@ -130,18 +145,17 @@ void GD25Q16ETIGR_read_8_bytes(uint32_t Addr, uint16_t * read_data, uint16_t num
|
||||
{
|
||||
read_data[j] = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t GD25Q16ETIGR_verify_8_bytes(uint32_t Addr, uint16_t * verify_data, uint16_t num_byte)//÷òåíèå è ïðîâåðêà äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
uint16_t Err = 0;
|
||||
|
||||
Err = GD25Q16ETIGR_WaitStatus();
|
||||
if(Err) return Err;
|
||||
|
||||
transmitData(ReadData);
|
||||
transmitData(Addr>>16);
|
||||
@ -163,16 +177,14 @@ uint16_t GD25Q16ETIGR_verify_8_bytes(uint32_t Addr, uint16_t * verify_data, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_8_bytes(uint32_t Addr, uint16_t * write_data, uint16_t num_byte)//çàïèñü äî 8 áàéò
|
||||
uint16_t GD25Q16ETIGR_write_8_bytes(uint32_t Addr, uint16_t * write_data, uint16_t num_byte)//çàïèñü äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
uint16_t Err = 0;
|
||||
GD25Q16ETIGR_en();
|
||||
Err = GD25Q16ETIGR_WaitStatus();
|
||||
if(Err) return Err;
|
||||
|
||||
GD25Q16ETIGR_en();
|
||||
transmitData(PageProgram);
|
||||
@ -192,28 +204,33 @@ void GD25Q16ETIGR_write_8_bytes(uint32_t Addr, uint16_t * write_data, uint16_t n
|
||||
{
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant8, uint16_t * read_data)
|
||||
uint16_t GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant8, uint16_t * read_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_read_data[8];
|
||||
uint16_t Err = 0;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, 8);
|
||||
Err = GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, 8);
|
||||
if(Err) return Err;
|
||||
copy8_to_16(addr_read_data, read_data, 4);
|
||||
read_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, (quant8 - i));
|
||||
Err = GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, (quant8 - i));
|
||||
if(Err) return Err;
|
||||
if((quant8 - i) & 1) {addr_read_data[quant8] = 0; quant8++; }//åñëè áàéò íå÷¸òíîå ÷èñëî, òî äîïîëíÿåì äî ÷¸òíîãî íóë¸ì
|
||||
copy8_to_16(addr_read_data, read_data, (quant8 - i)/2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -241,18 +258,20 @@ uint16_t GD25Q16ETIGR_verify_data(uint32_t Addr, uint16_t quant8, uint16_t * ver
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_1_page(uint32_t Addr, uint16_t quant8, uint16_t * write_data) // çàïèñü âíóòðè îäíîé ñòðàíèöû
|
||||
uint16_t GD25Q16ETIGR_write_1_page(uint32_t Addr, uint16_t quant8, uint16_t * write_data) // çàïèñü âíóòðè îäíîé ñòðàíèöû
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_write_data[8];
|
||||
uint16_t quant16;
|
||||
uint16_t Err = 0;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{ //â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(write_data, addr_write_data, 4);
|
||||
GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, 8);
|
||||
Err = GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, 8);
|
||||
if(Err) return Err;
|
||||
write_data += 4;
|
||||
}
|
||||
}
|
||||
@ -260,38 +279,44 @@ void GD25Q16ETIGR_write_1_page(uint32_t Addr, uint16_t quant8, uint16_t * write_
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(write_data, addr_write_data, quant16);
|
||||
GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, (quant8 - i));
|
||||
Err = GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, (quant8 - i));
|
||||
if(Err) return Err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_data(uint32_t Addr_8bit, uint16_t quant_8bit, uint16_t * write_data)
|
||||
uint16_t GD25Q16ETIGR_write_data(uint32_t Addr_8bit, uint16_t quant_8bit, uint16_t * write_data)
|
||||
{
|
||||
uint16_t * addr_write_data = write_data;
|
||||
uint16_t page_quant_8bit = 0;
|
||||
uint16_t FlashSektorStart = 0;
|
||||
uint16_t FlashSektorEnd = 0;
|
||||
uint16_t i=0;
|
||||
uint16_t Err = 0;
|
||||
|
||||
FlashSektorStart = GD25Q16ETIGR_Sektor_Addr(Addr_8bit); //ñåêòîð ñ êîòîðîãî íà÷èíàåòñÿ çàïèñü
|
||||
FlashSektorEnd = GD25Q16ETIGR_Sektor_Addr(Addr_8bit + quant_8bit - 1); //ñåêòîð â êîòîðîì êîíåö çàïèñè
|
||||
|
||||
for(i = FlashSektorStart; i <= FlashSektorEnd; i++)
|
||||
{
|
||||
if(!SectorWasErraised[i]) {SectorWasErraised[i] = 1; GD25Q16ETIGR_sector_erase(i*0x1000);}
|
||||
if(!SectorWasErraised[i]) {SectorWasErraised[i] = 1; Err = GD25Q16ETIGR_sector_erase(i*0x1000); if(Err) return Err;}
|
||||
}
|
||||
|
||||
while( (Addr_8bit&0xFF)+(quant_8bit) > GD25Q16E_PAGE) //åñëè äàííûå âûõîäÿò çà ãðàíèöó òåêóùåé ñòðàíèöû
|
||||
{
|
||||
page_quant_8bit = GD25Q16E_PAGE - (Addr_8bit&0xFF); //âû÷èñëÿåì êîë-âî áàéò äàííûõ äî êîíöà òåêóùåé ñòðàíèöû
|
||||
GD25Q16ETIGR_write_1_page(Addr_8bit, page_quant_8bit/2, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
Err = GD25Q16ETIGR_write_1_page(Addr_8bit, page_quant_8bit, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
if(Err) return Err;
|
||||
Addr_8bit += page_quant_8bit; //ïåðåëèñòûâàåì ñòðàíèöó âíåøíåé ïàìÿòè
|
||||
addr_write_data += page_quant_8bit/2; //øàãàåì íà ñëåäóþùèå íåçàïèñàííûå äàííûå â áóôåðå (îíè ó íàñ 16-áèòíûìè ñëîâàìè)
|
||||
quant_8bit -= page_quant_8bit; //óìåíüøàåì êîë-âî äàííûõ íà âåëè÷èíó êîòîðóþ óæå çàïèñàëè
|
||||
}
|
||||
if(quant_8bit > 0)
|
||||
{
|
||||
GD25Q16ETIGR_write_1_page(Addr_8bit, quant_8bit, addr_write_data); //åñëè äàííûå äëÿ çàïèñè îñòàëèñü, òî çàïèñûâàåì èõ
|
||||
Err = GD25Q16ETIGR_write_1_page(Addr_8bit, quant_8bit, addr_write_data); //åñëè äàííûå äëÿ çàïèñè îñòàëèñü, òî çàïèñûâàåì èõ
|
||||
if(Err) return Err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
void GD25Q16ETIGR_en(void);
|
||||
void GD25Q16ETIGR_write(void);
|
||||
void GD25Q16ETIGR_write_data(uint32_t Addr, uint16_t quant, uint16_t * write_data);
|
||||
void GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant, uint16_t * read_data);
|
||||
uint16_t GD25Q16ETIGR_write_data(uint32_t Addr, uint16_t quant, uint16_t * write_data);
|
||||
uint16_t GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant, uint16_t * read_data);
|
||||
uint16_t GD25Q16ETIGR_verify_data(uint32_t Addr, uint16_t quant, uint16_t * verify_data);
|
||||
uint16_t GD25Q16ETIGR_ReadManufacturerDeviceID(void);
|
||||
void GD25Q16ETIGR_clean_SectorWasErraised(void);
|
||||
|
@ -114,11 +114,6 @@ uint16_t ZD24C02A_verify(uint32_t Addr, uint16_t quant8, uint16_t * verify_data)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array)
|
||||
{
|
||||
I2CRead(SlaveAdr, byteCount, true, Array);
|
||||
|
@ -20,7 +20,7 @@ void GpioInit(void)
|
||||
// GpioDataRegs.GPADAT.bit.GPIO21 = 0;
|
||||
|
||||
|
||||
GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 0;
|
||||
/* GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 0;
|
||||
GpioCtrlRegs.GPBGMUX2.bit.GPIO54 = 0;
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO54 = 1;
|
||||
GpioDataRegs.GPBDAT.bit.GPIO54 = 0;
|
||||
@ -33,11 +33,11 @@ void GpioInit(void)
|
||||
GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 0;
|
||||
GpioCtrlRegs.GPBGMUX2.bit.GPIO56 = 0;
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO56 = 1;
|
||||
GpioDataRegs.GPBDAT.bit.GPIO56 = 0;
|
||||
GpioDataRegs.GPBDAT.bit.GPIO56 = 0;*/
|
||||
|
||||
GpioCtrlRegs.GPBMUX2.bit.GPIO57 = 0;
|
||||
GpioCtrlRegs.GPBGMUX2.bit.GPIO57 = 0;
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO57 = 1;
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO57 = 0;
|
||||
GpioDataRegs.GPBDAT.bit.GPIO57 = 0;
|
||||
|
||||
|
||||
@ -70,9 +70,11 @@ void GpioInit(void)
|
||||
GpioCtrlRegs.GPEGMUX2.bit.GPIO147 = 0;
|
||||
GpioCtrlRegs.GPEDIR.bit.GPIO147 = 0;
|
||||
|
||||
GpioCtrlRegs.GPDMUX1.bit.GPIO104 = 0;
|
||||
GpioCtrlRegs.GPDGMUX1.bit.GPIO104 = 0;
|
||||
GpioCtrlRegs.GPDDIR.bit.GPIO104 = 0;
|
||||
GpioCtrlRegs.GPDMUX1.bit.GPIO103 = 0;
|
||||
GpioCtrlRegs.GPDGMUX1.bit.GPIO103 = 0;
|
||||
GpioCtrlRegs.GPDDIR.bit.GPIO103 = 0;
|
||||
GpioDataRegs.GPDDAT.bit.GPIO103 = 0;
|
||||
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
@ -258,12 +258,14 @@ void getMessage_from_Cm_GD25Q16E(void)
|
||||
switch(InCommand >> 16)
|
||||
{
|
||||
case READ:
|
||||
GD25Q16ETIGR_read_data(InAddr, InData, (uint16_t *)CPUXTOCMMSGRAM0_BASE);
|
||||
IPC_sendCommand(IPC_CPU1_L_CM_R, DONE_SUCCESS, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
MemOperationError = GD25Q16ETIGR_read_data(InAddr, InData, (uint16_t *)CPUXTOCMMSGRAM0_BASE);
|
||||
if(MemOperationError) IPC_sendCommand(IPC_CPU1_L_CM_R, FLASH_ERR, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
else IPC_sendCommand(IPC_CPU1_L_CM_R, DONE_SUCCESS, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
break;
|
||||
case WRITE:
|
||||
GD25Q16ETIGR_write_data(InAddr, InData, (uint16_t *)CMTOCPUXMSGRAM0_BASE);
|
||||
IPC_sendCommand(IPC_CPU1_L_CM_R, DONE_SUCCESS, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
MemOperationError = GD25Q16ETIGR_write_data(InAddr, InData, (uint16_t *)CMTOCPUXMSGRAM0_BASE);
|
||||
if(MemOperationError) IPC_sendCommand(IPC_CPU1_L_CM_R, FLASH_ERR, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
else IPC_sendCommand(IPC_CPU1_L_CM_R, DONE_SUCCESS, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
break;
|
||||
case VERIFY:
|
||||
MemOperationError = GD25Q16ETIGR_verify_data(InAddr, InData, (uint16_t *)CMTOCPUXMSGRAM0_BASE);
|
||||
@ -272,10 +274,10 @@ void getMessage_from_Cm_GD25Q16E(void)
|
||||
break;
|
||||
case END:
|
||||
IPC_sendCommand(IPC_CPU1_L_CM_R, COMMAND_ACCEPTED, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
GD25Q16ETIGR_clean_SectorWasErraised();
|
||||
break;
|
||||
default:
|
||||
IPC_sendCommand(IPC_CPU1_L_CM_R, WRONG_COMMAND, GD25Q16E_16M_bit_SPI, 0, 0);
|
||||
GD25Q16ETIGR_clean_SectorWasErraised();
|
||||
break;
|
||||
}
|
||||
spi_TurnOffCS1_GD25Q16E();
|
||||
|
@ -171,9 +171,6 @@ __interrupt void spia_tx_isr(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SpiBInit(void)
|
||||
{
|
||||
|
||||
|
@ -1,35 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<configurations XML_version="1.2" id="configurations_0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<configuration XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0">
|
||||
<instance XML_version="1.2" desc="Texas Instruments XDS2xx USB Debug Probe_0" href="connections/TIXDS2XXUSB_Connection.xml" id="Texas Instruments XDS2xx USB Debug Probe_0" xml="TIXDS2XXUSB_Connection.xml" xmlpath="connections"/>
|
||||
<connection XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0">
|
||||
|
Loading…
Reference in New Issue
Block a user