bench.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #if !defined(HOST)
  2. #if !defined(NORTE)
  3. #include "RTE_Components.h"
  4. #include CMSIS_device_header
  5. #endif
  6. #endif
  7. #ifdef __cplusplus
  8. #include <cstdint>
  9. #else
  10. #include <stdint.h>
  11. #endif
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. extern uint32_t start_time;
  17. extern uint32_t stop_time;
  18. extern uint32_t cycle_count;
  19. #if defined(HOST)
  20. #define INIT_SYSTICK
  21. #define START_CYCLE_MEASUREMENT
  22. #define STOP_CYCLE_MEASUREMENT
  23. #else
  24. #define INIT_SYSTICK \
  25. SysTick->CTRL=0; \
  26. SysTick->LOAD=0xFFFFFFUL;\
  27. SysTick->VAL=0; \
  28. SysTick->CTRL=5; \
  29. while (SysTick->VAL==0)\
  30. ;
  31. #define START_CYCLE_MEASUREMENT \
  32. start_time= SysTick->VAL;
  33. #define STOP_CYCLE_MEASUREMENT \
  34. stop_time= SysTick->VAL; \
  35. SysTick->CTRL=0; \
  36. cycle_count = start_time - stop_time; \
  37. printf ("Cycle count = %d\r\n",(int)cycle_count);
  38. #endif
  39. #if !defined(HOST) && (__ARM_ARCH > 6)
  40. #define dbgInst(imm) __asm volatile("DBG %0\n\t" : :"Ir" ((imm)) )
  41. #define startSectionNB(num) dbgInst(((num) & 0x7) | 0x0)
  42. #define stopSectionNB(num) dbgInst(((num) & 0x7) | 0x8)
  43. #else
  44. #define startSectionNB(num)
  45. #define stopSectionNB(num)
  46. #endif
  47. #ifdef __cplusplus
  48. }
  49. #endif