From 900963482d2589fd752f0c7501c99b98ef4e8b82 Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 24 Feb 2015 17:43:53 +0300 Subject: Finished memtest code --- testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp | 64 ++++++++++++++++++--------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp') diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp index c12e952..1be98a2 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp @@ -82,18 +82,21 @@ template class GeneratorMovingInvRand : public Generator { public: GeneratorMovingInvRand(void) : step(0), prev(0){;} - void init(size_t seed) { + void init(T seed) { srand(seed); + step = 0; + prev = 0; } T get(void) { T ret; + T mask = -1; if ((step & 1) == 0) { - ret = rand(); + ret = rand() & mask; prev = ret; } else { - ret = ~prev; + ret = ~prev & mask; } step++; @@ -116,9 +119,8 @@ static void memtest_sequential(memtest_t *memp, Generator &generator, T seed) /* fill ram */ generator.init(seed); - for (i=0; i -static void moving_inversion(memtest_t *memp) { +static void moving_inversion_zero(memtest_t *memp) { GeneratorMovingInv generator; + T mask = -1; memtest_sequential(memp, generator, 0); + memtest_sequential(memp, generator, 0xFFFFFFFF & mask); +} + +template +static void moving_inversion_55aa(memtest_t *memp) { + GeneratorMovingInv generator; + T mask = -1; + memtest_sequential(memp, generator, 0x55555555 & mask); + memtest_sequential(memp, generator, 0xAAAAAAAA & mask); } template static void moving_inversion_rand(memtest_t *memp) { GeneratorMovingInvRand generator; - memtest_sequential(memp, generator, memp->rand_seed); + T mask = -1; + memtest_sequential(memp, generator, memp->rand_seed & mask); } /* @@ -169,13 +182,13 @@ static void memtest_wrapper(memtest_t *memp, void (*p_u32)(memtest_t *memp)) { switch(memp->width){ case MEMTEST_WIDTH_32: - p_u32(memp); - p_u16(memp); p_u8(memp); + p_u16(memp); + p_u32(memp); break; case MEMTEST_WIDTH_16: - p_u16(memp); p_u8(memp); + p_u16(memp); break; case MEMTEST_WIDTH_8: p_u8(memp); @@ -190,37 +203,44 @@ void memtest_run(memtest_t *memp, uint32_t testmask) { if ((testmask & MEMTEST_WALKING_ONE) == MEMTEST_WALKING_ONE) { memtest_wrapper(memp, - walking_one, + walking_one, walking_one, - walking_one); + walking_one); } if ((testmask & MEMTEST_WALKING_ZERO) == MEMTEST_WALKING_ZERO) { memtest_wrapper(memp, - walking_zero, + walking_zero, walking_zero, - walking_zero); + walking_zero); } if ((testmask & MEMTEST_OWN_ADDRESS) == MEMTEST_OWN_ADDRESS) { memtest_wrapper(memp, - own_address, + own_address, own_address, - own_address); + own_address); + } + + if ((testmask & MEMTEST_MOVING_INVERSION_ZERO) == MEMTEST_MOVING_INVERSION_ZERO) { + memtest_wrapper(memp, + moving_inversion_zero, + moving_inversion_zero, + moving_inversion_zero); } - if ((testmask & MEMTEST_MOVING_INVERSION) == MEMTEST_MOVING_INVERSION) { + if ((testmask & MEMTEST_MOVING_INVERSION_55AA) == MEMTEST_MOVING_INVERSION_55AA) { memtest_wrapper(memp, - moving_inversion, - moving_inversion, - moving_inversion); + moving_inversion_55aa, + moving_inversion_55aa, + moving_inversion_55aa); } if ((testmask & MEMTEST_MOVING_INVERSION_RAND) == MEMTEST_MOVING_INVERSION_RAND) { memtest_wrapper(memp, - moving_inversion_rand, + moving_inversion_rand, moving_inversion_rand, - moving_inversion_rand); + moving_inversion_rand); } } -- cgit v1.2.3