diff options
author | barthess <barthess@yandex.ru> | 2015-02-25 23:02:05 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2015-02-25 23:02:05 +0300 |
commit | 7ac7d41b203681068a8ccd076a7f99bfac0e13f0 (patch) | |
tree | abf771897170ac5d5814622244eb6abe42ba6c66 /testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c | |
parent | 900963482d2589fd752f0c7501c99b98ef4e8b82 (diff) | |
download | ChibiOS-Contrib-7ac7d41b203681068a8ccd076a7f99bfac0e13f0.tar.gz ChibiOS-Contrib-7ac7d41b203681068a8ccd076a7f99bfac0e13f0.tar.bz2 ChibiOS-Contrib-7ac7d41b203681068a8ccd076a7f99bfac0e13f0.zip |
FSMC_SRAM haltest. Added memcpy over DMA speed test
Diffstat (limited to 'testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c')
-rw-r--r-- | testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c b/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c index 4e9dfcb..91b9aee 100644 --- a/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c +++ b/testhal/STM32/STM32F4xx/FSMC_SRAM/membench.c @@ -20,6 +20,7 @@ #include "hal.h" #include "membench.h" +#include "memcpy_dma.h" /* ****************************************************************************** @@ -54,9 +55,9 @@ volatile int warning_suppressor; ****************************************************************************** */ /* - * Calculates memory access time in MiB. + * Calculates memory access time in MiB/s. */ -double speed(const time_measurement_t *tmu, size_t len) { +double speed_mibps(const time_measurement_t *tmu, size_t len) { double size; // MiB double time; // sec @@ -70,6 +71,17 @@ double speed(const time_measurement_t *tmu, size_t len) { } /* + * Calculates memory access time in B/s. + */ +uint32_t speed_bps(const time_measurement_t *tmu, size_t len) { + + uint64_t tmp = len; + tmp *= STM32_SYSCLK; + + return tmp / tmu->last; +} + +/* ****************************************************************************** * EXPORTED FUNCTIONS ****************************************************************************** @@ -93,20 +105,29 @@ void membench_run(membench_t *dest, const membench_t *src, chTMStartMeasurementX(&mem_tmu); memset(dest->start, 0x55, dest->size); chTMStopMeasurementX(&mem_tmu); - result->memset_spd = speed(&mem_tmu, dest->size); + result->memset = speed_bps(&mem_tmu, dest->size); /* memcpy */ chTMObjectInit(&mem_tmu); chTMStartMeasurementX(&mem_tmu); memcpy(dest->start, src->start, len); chTMStopMeasurementX(&mem_tmu); - result->memcpy_spd = speed(&mem_tmu, len); + result->memcpy = speed_bps(&mem_tmu, len); /* memcmp */ chTMObjectInit(&mem_tmu); chTMStartMeasurementX(&mem_tmu); warning_suppressor = memcmp(dest->start, src->start, len); chTMStopMeasurementX(&mem_tmu); - result->memcmp_spd = speed(&mem_tmu, len); + result->memcmp = speed_bps(&mem_tmu, len); + + /* memcpy DMA */ + memcpy_dma_start(); + chTMObjectInit(&mem_tmu); + chTMStartMeasurementX(&mem_tmu); + memcpy_dma(dest->start, src->start, len); + chTMStopMeasurementX(&mem_tmu); + result->memcpy_dma = speed_bps(&mem_tmu, len); + memcpy_dma_stop(); } |