Skip to content

Commit c2b77a3

Browse files
Merge pull request #12 from TimerOverflow/20200417
20200417
2 parents c3b0b8a + 916a44c commit c2b77a3

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

SysEeprom.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <string.h>
88
#include "SysEeprom.h"
99
/*********************************************************************************/
10-
#if(SYS_EEPROM_REVISION_DATE != 20200115)
10+
#if(SYS_EEPROM_REVISION_DATE != 20200417)
1111
#error wrong include file. (SysEeprom.h)
1212
#endif
1313
/*********************************************************************************/
@@ -74,12 +74,7 @@ tU8 InitEepCommonConfig(tag_EepCommonConfig *EepConfig, tU16 LastAddr, tU8 (*Hal
7474
DoEepReadControl(&EepSignature);
7575
if((StrSignature[0] != 'J') || (StrSignature[1] != 'H') || (StrSignature[2] != 'G'))
7676
{
77-
StrSignature[0] = 'J'; StrSignature[1] = 'H'; StrSignature[2] = 'G';
78-
SetEepWriteEnable(&EepSignature);
79-
while(DoEepWriteControl(&EepSignature) == true)
80-
{
81-
EepConfig->Bit.FirstExecute = true;
82-
}
77+
EepConfig->Bit.FirstExecute = true;
8378
}
8479
}
8580

@@ -166,6 +161,7 @@ void DoEepReadControl(tag_EepControl *Eep)
166161
tU8 DoEepWriteControl(tag_EepControl *Eep)
167162
{
168163
tU16 *pIndex = (tU16 *) &Eep->Index;
164+
tag_EepCommonConfig *Config = (tag_EepCommonConfig *) Eep->Config;
169165
tag_EepBitField *pBit;
170166
tU8 Data = 0;
171167

@@ -184,30 +180,41 @@ tU8 DoEepWriteControl(tag_EepControl *Eep)
184180
- 값이 유효하여 쓰기를 진행하거나 해당영역의 마지막에 도달할 경우에만 while loop를 탈출한다.
185181
*/
186182

187-
if((Eep->Bit.InitComplete == false) || (Eep->Config->Bit.ReadFail == true) || (Eep->Config->Bit.WriteFail == true) || (Eep->Bit.Write == false))
183+
if((Eep->Bit.InitComplete == false) || (Config->Bit.ReadFail == true) || (Config->Bit.WriteFail == true))
188184
{
189185
return false;
190186
/* error or disabled */
191187
}
192-
193-
while(true)
188+
189+
if(Eep->Bit.Write == true)
194190
{
195-
EepRead((tag_EepCommonConfig *) Eep->Config, Eep->EepBase + (*pIndex), &Data);
196-
if(Data != Eep->DataBase[*pIndex])
191+
Config->SignatureWriteDelay = 5;
192+
while(true)
197193
{
198-
EepWrite((tag_EepCommonConfig *) Eep->Config, Eep->EepBase + (*pIndex), Eep->DataBase[*pIndex]);
199-
return true;
200-
/* check valid data */
201-
}
202-
203-
if(++(*pIndex) >= Eep->Length)
204-
{
205-
pBit = (tag_EepBitField *) &Eep->Bit;
206-
pBit->Write = false;
207-
return false;
208-
/* end of sector */
194+
EepRead(Config, Eep->EepBase + (*pIndex), &Data);
195+
if(Data != Eep->DataBase[*pIndex])
196+
{
197+
EepWrite(Config, Eep->EepBase + (*pIndex), Eep->DataBase[*pIndex]);
198+
return true;
199+
/* check valid data */
200+
}
201+
202+
if(++(*pIndex) >= Eep->Length)
203+
{
204+
pBit = (tag_EepBitField *) &Eep->Bit;
205+
pBit->Write = false;
206+
return false;
207+
/* end of sector */
208+
}
209209
}
210210
}
211+
else if(Config->Bit.FirstExecute)
212+
{
213+
if(Config->SignatureWriteDelay == 0){ EepWrite(Config, 0, 'J'); EepWrite(Config, 1, 'H'); EepWrite(Config, 2, 'G'); Config->Bit.FirstExecute = false; }
214+
else{ Config->SignatureWriteDelay--; }
215+
}
216+
217+
return false;
211218
}
212219
/*********************************************************************************/
213220
void SetEepWriteEnable(tag_EepControl *Eep)

SysEeprom.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
/*********************************************************************************/
1010
#include "SysTypedef.h"
1111
/*********************************************************************************/
12-
#define SYS_EEPROM_REVISION_DATE 20200115
12+
#define SYS_EEPROM_REVISION_DATE 20200417
1313
/*********************************************************************************/
1414
/** REVISION HISTORY **/
1515
/*
16+
2020. 04. 17. - tag_EepCommonConfig의 시그니처는 연결된 모든 tag_EepControl 인스턴스들이
17+
Jeong Hyun Gu write동작을 끝냈을 때 write하도록 변경.
18+
1619
2020. 01. 15. - 실제 Eeprom과의 정상 동작 여부 확인 기능 추가.
1720
Jeong Hyun Gu - CheckEepromError() 함수 추가. 'tag_EepCommonConfig'에서 관리 하는 실제
1821
Eeprom의 정상 동작 여부 확인.
@@ -80,6 +83,7 @@ typedef struct
8083

8184
const tU16 LastAddr; // eeprom마지막 주소(크기)
8285
tU16 AllocEepAddr;
86+
tU8 SignatureWriteDelay;
8387

8488
tU8 (*HalEepromWrite)(tU16 Addr, tU8 Data);
8589
tU8 (*HalEepromRead)(tU16 Addr, tU8 *pData);

0 commit comments

Comments
 (0)