diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/Makefile b/testhal/STM32/STM32F4xx/FSMC_SRAM/Makefile index ec5d18c6..c85f1e91 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/Makefile +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/Makefile @@ -10,7 +10,7 @@ endif # C specific options here (added to USE_OPT). ifeq ($(USE_COPT),) - USE_COPT = + USE_COPT = endif # C++ specific options here (added to USE_OPT). diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/main.c b/testhal/STM32/STM32F4xx/FSMC_SRAM/main.c index 186450ff..03d7f1d9 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/main.c +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/main.c @@ -41,7 +41,7 @@ ****************************************************************************** */ -static void mem_error_cb(memtest_t *memp, testtype_t e, size_t address); +static void mem_error_cb(memtest_t *memp, testtype e, size_t address); /* ****************************************************************************** @@ -110,7 +110,7 @@ static inline void green_led_on(void) {palSetPad(GPIOI, GPIOI_LED_G);} static inline void green_led_off(void) {palClearPad(GPIOI, GPIOI_LED_G);} static inline void green_led_toggle(void) {palTogglePad(GPIOI, GPIOI_LED_G);} -void mem_error_cb(memtest_t *memp, testtype_t e, size_t address) { +void mem_error_cb(memtest_t *memp, testtype e, size_t address) { (void)memp; (void)e; (void)address; diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.h b/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.h index 5f23e1cd..1169145e 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.h +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.h @@ -1,3 +1,19 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef MEMBENCH_H_ #define MEMBENCH_H_ diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/memcpy_dma.h b/testhal/STM32/STM32F4xx/FSMC_SRAM/memcpy_dma.h index ceefee1b..8d6212ca 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/memcpy_dma.h +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/memcpy_dma.h @@ -1,3 +1,19 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef MEMCPY_DMA_H_ #define MEMCPY_DMA_H_ diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp index 1be98a27..6a0630a0 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.cpp @@ -1,3 +1,19 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #include #include #include @@ -12,6 +28,7 @@ class Generator { public: Generator(void) : pattern(0) {;} virtual T get(void) = 0; + virtual testtype get_type(void) = 0; virtual void init(T seed) { pattern = seed; } @@ -33,6 +50,10 @@ class GeneratorWalkingOne : public Generator { return ret; } + + testtype get_type(void) { + return MEMTEST_WALKING_ONE; + } }; /* @@ -49,6 +70,10 @@ class GeneratorWalkingZero : public Generator { return ret; } + + testtype get_type(void) { + return MEMTEST_WALKING_ZERO; + } }; /* @@ -61,6 +86,10 @@ class GeneratorOwnAddress : public Generator { this->pattern++; return ret; } + + testtype get_type(void) { + return MEMTEST_OWN_ADDRESS; + } }; /* @@ -73,6 +102,13 @@ class GeneratorMovingInv : public Generator { this->pattern = ~this->pattern; return ret; } + + testtype get_type(void) { + if ((this->pattern == 0) || ((this->pattern & 0xFF) == 0xFF)) + return MEMTEST_MOVING_INVERSION_ZERO; + else + return MEMTEST_MOVING_INVERSION_55AA; + } }; /* @@ -103,6 +139,10 @@ public: return ret; } + testtype get_type(void) { + return MEMTEST_MOVING_INVERSION_RAND; + } + private: size_t step; T prev; @@ -112,10 +152,10 @@ private: * */ template -static void memtest_sequential(memtest_t *memp, Generator &generator, T seed) { - const size_t steps = memp->size / sizeof(T); +static void memtest_sequential(memtest_t *testp, Generator &generator, T seed) { + const size_t steps = testp->size / sizeof(T); size_t i; - T *mem = static_cast(memp->start); + T *mem = static_cast(testp->start); /* fill ram */ generator.init(seed); @@ -126,72 +166,72 @@ static void memtest_sequential(memtest_t *memp, Generator &generator, T seed) generator.init(seed); for (i=0; iecb(memp, MEMTEST_WALKING_ONE, i*sizeof(T)); + testp->ecb(testp, generator.get_type(), i*sizeof(T)); return; } } } template -static void walking_one(memtest_t *memp) { +static void walking_one(memtest_t *testp) { GeneratorWalkingOne generator; - memtest_sequential(memp, generator, 1); + memtest_sequential(testp, generator, 1); } template -static void walking_zero(memtest_t *memp) { +static void walking_zero(memtest_t *testp) { GeneratorWalkingZero generator; - memtest_sequential(memp, generator, 1); + memtest_sequential(testp, generator, 1); } template -static void own_address(memtest_t *memp) { +static void own_address(memtest_t *testp) { GeneratorOwnAddress generator; - memtest_sequential(memp, generator, 0); + memtest_sequential(testp, generator, 0); } template -static void moving_inversion_zero(memtest_t *memp) { +static void moving_inversion_zero(memtest_t *testp) { GeneratorMovingInv generator; T mask = -1; - memtest_sequential(memp, generator, 0); - memtest_sequential(memp, generator, 0xFFFFFFFF & mask); + memtest_sequential(testp, generator, 0); + memtest_sequential(testp, generator, 0xFFFFFFFF & mask); } template -static void moving_inversion_55aa(memtest_t *memp) { +static void moving_inversion_55aa(memtest_t *testp) { GeneratorMovingInv generator; T mask = -1; - memtest_sequential(memp, generator, 0x55555555 & mask); - memtest_sequential(memp, generator, 0xAAAAAAAA & mask); + memtest_sequential(testp, generator, 0x55555555 & mask); + memtest_sequential(testp, generator, 0xAAAAAAAA & mask); } template -static void moving_inversion_rand(memtest_t *memp) { +static void moving_inversion_rand(memtest_t *testp) { GeneratorMovingInvRand generator; T mask = -1; - memtest_sequential(memp, generator, memp->rand_seed & mask); + memtest_sequential(testp, generator, testp->rand_seed & mask); } /* * */ -static void memtest_wrapper(memtest_t *memp, - void (*p_u8)(memtest_t *memp), - void (*p_u16)(memtest_t *memp), - void (*p_u32)(memtest_t *memp)) { - switch(memp->width){ +static void memtest_wrapper(memtest_t *testp, + void (*p_u8)(memtest_t *testp), + void (*p_u16)(memtest_t *testp), + void (*p_u32)(memtest_t *testp)) { + switch(testp->width){ case MEMTEST_WIDTH_32: - p_u8(memp); - p_u16(memp); - p_u32(memp); + p_u8(testp); + p_u16(testp); + p_u32(testp); break; case MEMTEST_WIDTH_16: - p_u8(memp); - p_u16(memp); + p_u8(testp); + p_u16(testp); break; case MEMTEST_WIDTH_8: - p_u8(memp); + p_u8(testp); break; } } @@ -199,45 +239,45 @@ static void memtest_wrapper(memtest_t *memp, /* * */ -void memtest_run(memtest_t *memp, uint32_t testmask) { +void memtest_run(memtest_t *testp, uint32_t testmask) { - if ((testmask & MEMTEST_WALKING_ONE) == MEMTEST_WALKING_ONE) { - memtest_wrapper(memp, + if (testmask & MEMTEST_WALKING_ONE) { + memtest_wrapper(testp, walking_one, walking_one, walking_one); } - if ((testmask & MEMTEST_WALKING_ZERO) == MEMTEST_WALKING_ZERO) { - memtest_wrapper(memp, + if (testmask & MEMTEST_WALKING_ZERO) { + memtest_wrapper(testp, walking_zero, walking_zero, walking_zero); } - if ((testmask & MEMTEST_OWN_ADDRESS) == MEMTEST_OWN_ADDRESS) { - memtest_wrapper(memp, + if (testmask & MEMTEST_OWN_ADDRESS) { + memtest_wrapper(testp, own_address, own_address, own_address); } - if ((testmask & MEMTEST_MOVING_INVERSION_ZERO) == MEMTEST_MOVING_INVERSION_ZERO) { - memtest_wrapper(memp, + if (testmask & MEMTEST_MOVING_INVERSION_ZERO) { + memtest_wrapper(testp, moving_inversion_zero, moving_inversion_zero, moving_inversion_zero); } - if ((testmask & MEMTEST_MOVING_INVERSION_55AA) == MEMTEST_MOVING_INVERSION_55AA) { - memtest_wrapper(memp, + if (testmask & MEMTEST_MOVING_INVERSION_55AA) { + memtest_wrapper(testp, moving_inversion_55aa, moving_inversion_55aa, moving_inversion_55aa); } - if ((testmask & MEMTEST_MOVING_INVERSION_RAND) == MEMTEST_MOVING_INVERSION_RAND) { - memtest_wrapper(memp, + if (testmask & MEMTEST_MOVING_INVERSION_RAND) { + memtest_wrapper(testp, moving_inversion_rand, moving_inversion_rand, moving_inversion_rand); diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.hpp b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.hpp index 4a9e4e3a..200db1f7 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.hpp +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/memtest.hpp @@ -1,3 +1,19 @@ +/* + ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef MEMTEST_HPP_ #define MEMTEST_HPP_ @@ -8,20 +24,20 @@ #define MEMTEST_MOVING_INVERSION_55AA (1 << 4) #define MEMTEST_MOVING_INVERSION_RAND (1 << 5) -#define MEMTEST_RUN_ALL (MEMTEST_WALKING_ONE | \ - MEMTEST_WALKING_ZERO | \ - MEMTEST_OWN_ADDRESS | \ - MEMTEST_MOVING_INVERSION_ZERO | \ - MEMTEST_MOVING_INVERSION_55AA | \ +#define MEMTEST_RUN_ALL (MEMTEST_WALKING_ONE | \ + MEMTEST_WALKING_ZERO | \ + MEMTEST_OWN_ADDRESS | \ + MEMTEST_MOVING_INVERSION_ZERO | \ + MEMTEST_MOVING_INVERSION_55AA | \ MEMTEST_MOVING_INVERSION_RAND) typedef struct memtest_t memtest_t; -typedef uint32_t testtype_t; +typedef uint32_t testtype; /* * Error call back. */ -typedef void (*memtestecb_t)(memtest_t *memp, testtype_t e, size_t address); +typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t address); /* * @@ -49,7 +65,7 @@ struct memtest_t { #ifdef __cplusplus extern "C" { #endif - void memtest_run(memtest_t *memp, uint32_t testmask); + void memtest_run(memtest_t *testp, uint32_t testmask); #ifdef __cplusplus } #endif