Skip to content

Instantly share code, notes, and snippets.

@pancurster
Created December 11, 2012 22:00
Show Gist options
  • Save pancurster/4262654 to your computer and use it in GitHub Desktop.
Save pancurster/4262654 to your computer and use it in GitHub Desktop.
/*
* My MEM-TEST-SUITE based on Michael Barr code
*/
/* badanie zwarc miedzy nogami */
int mem_short_test(U8* saddr, int size)
{
char buf[256];
U8 pattern = 0xAA;
int addr_mask = size-1;
int offset, testoffset;
for (offset=1; (offset & addr_mask)!=0; offset<<=1) {
saddr[offset] = pattern;
for (testoffset=1; testoffset !=0; testoffset<<=1) {
if (offset == testoffset) continue;
if (saddr[offset | testoffset] == pattern) {
sprintf(buf, "Prawdopodobne zwarcie pinow %d i %d\n",
ff_bit_num(offset), ff_bit_num(testoffset));
print_wrap(0, buf);
while(1);
}
}
}
}
/* badanie zwarcia do plusa */
int mem_h_pin_test(U8* saddr, int size)
{
char buf[256];
U8 pattern = 0xAA;
U8 antipattern = 0x55;
int addr_mask = size-1;
int offset, testoffset;
/* jesli ktorys z testowanych pinow jest zwarty do '+'
* to pod adresem 1111...itd zapisze sie 'pattern'*/
saddr[addr_mask] = antipattern;
for (offset=1; (offset & addr_mask)!=0; offset<<=1) {
testoffset = ~offset;
testoffset = testoffset & addr_mask;
saddr[testoffset] = pattern;
if (saddr[addr_mask] != antipattern) {
sprintf(buf, "Prawdopodobne zwarcie do '+' pinu %d\n",
ff_bit_num(offset));
print_wrap(0, buf);
while(1);
}
}
}
/* badanie zwarcia do masy */
int mem_l_pin_test(U8* saddr, int size)
{
char buf[256];
U8 pattern = 0xAA;
U8 antipattern = 0x55;
int addr_mask = size-1;
int offset, testoffset;
/* w razie zwarcia ktorejs z testowanych nog 'pattern' zapisze
* sie wlasnie w saddr[0] */
saddr[0] = antipattern;
for (offset=1; (offset & addr_mask)!=0; offset<<=1) {
saddr[offset] = pattern;
if (saddr[0] != antipattern) {
sprintf(buf, "Prawdopodobne zwarcie do '0' pinu %d\n",
ff_bit_num(offset));
print_wrap(0, buf);
while(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment