#include "cmsis_os.h"
#include "ImC/imc_kernel.h"
#include "ImC/imc_extension.h"

#include <stdio.h>

void vBenchmarkDriver(void *_benchmark)
{
    void (*benchmark)(void) = _benchmark;
    #if (imcBENCH_INFINITE_LOOP)
    while(1) {
    #endif
    portDISABLE_INTERRUPTS();
    printf("Start benchmark\r\n");
    portENABLE_INTERRUPTS();

    benchmark();

    portDISABLE_INTERRUPTS();
    printf("End benchmark\r\n");
    portENABLE_INTERRUPTS();
    imcREQUEST_CHECKPOINT();
    #if (imcBENCH_INFINITE_LOOP)
    osDelay(10);
    }
    #endif

    #if (imcUSE_IMC_KERNEL == 1)
        vImcInvalidateRecovery();
    #endif
}