예제 #1
0
bool superTest() {
	int i, j;
	uint16_t a1;
	uint8_t numb, datas[9];
	a1 = EE241_Test();
	if (a1 != ERR_OK)
		return FALSE;

	//faz o teste da escrita de string
	a1 = EE241_WriteBlock(0x076, (uint8_t*) "076 Ting", sizeof("076 Ting"));
	if (a1 != ERR_OK)
		return FALSE;
	a1 = EE241_ReadBlock(0x076, datas, sizeof(datas));
	if (a1 != ERR_OK)
		return FALSE;
	if (strcmp((char*) "076 Ting", (char*) datas) != 0)
		return FALSE;

	//faz o teste de todos os 1's em todos as posições da memória
	for (i = 0; i < 2048; i++) { //todas as posições da memória
		for (j = 1; j <= 128; j *= 2) { //todos os valores do walking 1's test
			a1 = EE241_WriteByte(i, j); //(1,2,4,8,32,64,128,256...)
			if (a1 != ERR_OK)
				return FALSE;
			a1 = EE241_ReadByte(i, &numb);
			if (numb != j)
				return FALSE;
		}
	}

	return TRUE;
}
예제 #2
0
파일: main.c 프로젝트: gciotto/workspace
int test_memory() {

	int address;
	byte data_byte = 0, data_read;
	//for (address = 0; address < 2048; address++) {
	for (address = 0; address < 2; address++) {

		for (data_byte = 1; data_byte != 0; data_byte = data_byte << 1) {

			EE241_WriteByte(address, data_byte);
			EE241_ReadByte(address, &data_read);

			if (data_byte != data_read)
				return 0;
		}

	}

	return 1;

}