Demo entry 6685625

1

   

Submitted by 1 on Dec 20, 2017 at 11:44
Language: C. Code size: 924 Bytes.

uint8_t NewDevice_Sign=0;
uint8_t KeyWords[6]={0,0,0,0,0,0};
uint8_t EEBuffer[8]={0,0,0,0,0,0,0,0};
uint8_t PassWords[8]={0x55,1,5,1,1,2,2,0xAA};

void EEReadPassword(void)
{
	uint8_t	i;
	for(i=0;i<8;i++)
	{
		EEBuffer[i]= AT24CXX_ReadOneByte(i);
	}
	/*The flag of valid password*/
	if(EEBuffer[0]==0x55 && EEBuffer[7]==0xAA)
	{
		NewDevice_Sign=0;
		for(i=0;i<8;i++)
		{
			PassWords[i]= EEBuffer[i];
		}			
	}
	else
	{
		NewDevice_Sign=1;	
	}
}

void EEWritePassword(void)
{
	uint8_t	i;
	for(i=0;i<8;i++)
	{
    	AT24CXX_WriteOneByte( i, PassWords[i]);
	}
}

        //main
        AT24CXX_Init();
	if(AT24CXX_Check() != 0)
	{
		OLED_DrawString1608(0,4,(const uint8_t *)"AT24CXX is NG");
		OLED_DrawString1608(0,2,(const uint8_t *)"Please check!");
		return;
	}
	else
	{
		EEReadPassword();
		if(NewDevice_Sign==1)
		{
			EEWritePassword();
			EEReadPassword();
		}
	}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).