diff options
author | barthess <barthess@yandex.ru> | 2015-02-24 17:43:53 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2015-02-24 17:43:53 +0300 |
commit | 900963482d2589fd752f0c7501c99b98ef4e8b82 (patch) | |
tree | 90789f6c07c6871491b26a95f1655e9ee17778a9 /testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp | |
parent | 33f1b2541ef3a15b4ed5875f741d71a19e773217 (diff) | |
download | ChibiOS-Contrib-900963482d2589fd752f0c7501c99b98ef4e8b82.tar.gz ChibiOS-Contrib-900963482d2589fd752f0c7501c99b98ef4e8b82.tar.bz2 ChibiOS-Contrib-900963482d2589fd752f0c7501c99b98ef4e8b82.zip |
Finished memtest code
Diffstat (limited to 'testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp')
-rw-r--r-- | testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp | 64 |
1 files changed, 42 insertions, 22 deletions
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 <typename T> class GeneratorMovingInvRand : public Generator<T> { 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<T> &generator, T seed) /* fill ram */ generator.init(seed); - for (i=0; i<steps; i++) { + for (i=0; i<steps; i++) mem[i] = generator.get(); - } /* read back and compare */ generator.init(seed); @@ -149,15 +151,26 @@ static void own_address(memtest_t *memp) { } template <typename T> -static void moving_inversion(memtest_t *memp) { +static void moving_inversion_zero(memtest_t *memp) { GeneratorMovingInv<T> generator; + T mask = -1; memtest_sequential<T>(memp, generator, 0); + memtest_sequential<T>(memp, generator, 0xFFFFFFFF & mask); +} + +template <typename T> +static void moving_inversion_55aa(memtest_t *memp) { + GeneratorMovingInv<T> generator; + T mask = -1; + memtest_sequential<T>(memp, generator, 0x55555555 & mask); + memtest_sequential<T>(memp, generator, 0xAAAAAAAA & mask); } template <typename T> static void moving_inversion_rand(memtest_t *memp) { GeneratorMovingInvRand<T> generator; - memtest_sequential<T>(memp, generator, memp->rand_seed); + T mask = -1; + memtest_sequential<T>(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<uint32_t>, + walking_one<uint8_t>, walking_one<uint16_t>, - walking_one<uint8_t>); + walking_one<uint32_t>); } if ((testmask & MEMTEST_WALKING_ZERO) == MEMTEST_WALKING_ZERO) { memtest_wrapper(memp, - walking_zero<uint32_t>, + walking_zero<uint8_t>, walking_zero<uint16_t>, - walking_zero<uint8_t>); + walking_zero<uint32_t>); } if ((testmask & MEMTEST_OWN_ADDRESS) == MEMTEST_OWN_ADDRESS) { memtest_wrapper(memp, - own_address<uint32_t>, + own_address<uint8_t>, own_address<uint16_t>, - own_address<uint8_t>); + own_address<uint32_t>); + } + + if ((testmask & MEMTEST_MOVING_INVERSION_ZERO) == MEMTEST_MOVING_INVERSION_ZERO) { + memtest_wrapper(memp, + moving_inversion_zero<uint8_t>, + moving_inversion_zero<uint16_t>, + moving_inversion_zero<uint32_t>); } - if ((testmask & MEMTEST_MOVING_INVERSION) == MEMTEST_MOVING_INVERSION) { + if ((testmask & MEMTEST_MOVING_INVERSION_55AA) == MEMTEST_MOVING_INVERSION_55AA) { memtest_wrapper(memp, - moving_inversion<uint32_t>, - moving_inversion<uint16_t>, - moving_inversion<uint8_t>); + moving_inversion_55aa<uint8_t>, + moving_inversion_55aa<uint16_t>, + moving_inversion_55aa<uint32_t>); } if ((testmask & MEMTEST_MOVING_INVERSION_RAND) == MEMTEST_MOVING_INVERSION_RAND) { memtest_wrapper(memp, - moving_inversion_rand<uint32_t>, + moving_inversion_rand<uint8_t>, moving_inversion_rand<uint16_t>, - moving_inversion_rand<uint8_t>); + moving_inversion_rand<uint32_t>); } } |