fork download
  1.  
  2. cli();
  3. uint32_t offset1 = offset;
  4. uint16_t tcnt = TCNT1;
  5. __sync_synchronize();
  6. if (TIFR1 & (1 << TOV1)) {
  7. // overflow happened, deal with it here and relieve the ISR from it
  8. offset += UINT32_C(0x10000);
  9. TIFR1 |= (1 << TOV1); // writing the flag clears it
  10. offset1 = offset;
  11. tcnt = TCNT1;
  12. }
  13. sei();
  14. return (offset1 + tcnt);
  15.  
  16.  
  17.  
  18.  
  19. cli();
  20. uint32_t offset1 = offset;
  21. uint16_t tcnt = TCNT1;
  22. __sync_synchronize();
  23. if (TIFR1 & (1 << TOV1)) {
  24. // overflow happened, let the interrupt handle it
  25. sei();
  26. cli();
  27. offset1 = offset;
  28. tcnt = TCNT1;
  29. }
  30. sei();
  31. return (offset1 + tcnt);
  32.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty