main.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include "nuclei_sdk_soc.h"
  4. #if defined(__ECLIC_PRESENT) && (__ECLIC_PRESENT == 1)
  5. #else
  6. #error "This example require CPU ECLIC feature"
  7. #endif
  8. #if defined(__SYSTIMER_PRESENT) && (__SYSTIMER_PRESENT == 1)
  9. #else
  10. #error "This example require CPU System Timer feature"
  11. #endif
  12. #if defined(SIMULATION_MODE) && (SIMULATION_MODE == SIMULATION_MODE_XLSPIKE)
  13. #define RECORD_START() UART0->RXFIFO = 1
  14. #define RECORD_END() UART0->RXFIFO = 2
  15. #else
  16. #define RECORD_START()
  17. #define RECORD_END()
  18. #endif
  19. int main(void)
  20. {
  21. volatile uint64_t start, end;
  22. __disable_irq();
  23. // need to adapt the tick according to your SoC
  24. SysTick_Config(1);
  25. SysTimer_Start();
  26. start = __get_rv_cycle();
  27. RECORD_START();
  28. // Should not enter interrupt handler due to irq disabled
  29. __WFI();
  30. RECORD_END();
  31. end = __get_rv_cycle();
  32. printf("CSV, WFI Start/End, %lu/%lu\n", (unsigned long)start, (unsigned long)end);
  33. printf("CSV, WFI Cost, %lu\n", (unsigned long)(end - start));
  34. return 0;
  35. }