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)
166161tU8 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/*********************************************************************************/
213220void SetEepWriteEnable (tag_EepControl * Eep )
0 commit comments