tests-mbed_hal-flash: optimieze time_cpu_cycles() function

This function should perform instruction cycles count in critical section.
Additionally remove redundant code.
pull/7009/head
Przemyslaw Stekiel 2018-05-21 10:08:40 +02:00 committed by Bartek Szatkowski
parent be098399a8
commit e7fa5fc599
1 changed files with 8 additions and 6 deletions

View File

@ -98,16 +98,18 @@ MBED_NOINLINE
static int time_cpu_cycles(uint32_t cycles) static int time_cpu_cycles(uint32_t cycles)
{ {
Timer timer; Timer timer;
core_util_critical_section_enter();
timer.start(); timer.start();
int timer_start = timer.read_us(); delay_loop(cycles);
uint32_t delay = cycles;
delay_loop(delay);
int timer_end = timer.read_us();
timer.stop(); timer.stop();
return timer_end - timer_start;
core_util_critical_section_exit();
return timer.read_us();
} }
void flash_init_test() void flash_init_test()