setup-loop.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "all-headers.h"
  2. static volatile uint32_t gCount1 = 0 ;
  3. static volatile uint32_t gCount2 = 0 ;
  4. static volatile uint32_t gCount3 = 0 ;
  5. static volatile uint32_t gCount4 = 0 ;
  6. static volatile bool gPerformCount = true ;
  7. static void rtISR (SECTION_MODE_ const uint32_t inUptime) {
  8. if (gPerformCount) {
  9. gCount1 += 1 ;
  10. gCount2 += 1 ;
  11. gCount3 += 1 ;
  12. gCount4 += 1 ;
  13. }
  14. }
  15. MACRO_REAL_TIME_ISR (rtISR) ;
  16. void setup (USER_MODE) {
  17. }
  18. void loop (USER_MODE) {
  19. if (gPerformCount) {
  20. __atomic_fetch_add (& gCount1, 1, __ATOMIC_ACQ_REL);
  21. __atomic_fetch_add (& gCount2, 1, __ATOMIC_ACQ_REL);
  22. __atomic_fetch_add (& gCount3, 1, __ATOMIC_ACQ_REL);
  23. __atomic_fetch_add (& gCount4, 1, __ATOMIC_ACQ_REL);
  24. if (5000 <= millis (MODE)) {
  25. gPerformCount = false ;
  26. gotoLineColumn (MODE_ 0, 0) ;
  27. printUnsigned (MODE_ gCount1) ;
  28. gotoLineColumn (MODE_ 1, 0) ;
  29. printUnsigned (MODE_ gCount2) ;
  30. gotoLineColumn (MODE_ 2, 0) ;
  31. printUnsigned (MODE_ gCount3) ;
  32. gotoLineColumn (MODE_ 3, 0) ;
  33. printUnsigned (MODE_ gCount4) ;
  34. }
  35. }
  36. }