fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. #define TAB_TIMER_FREQUENCY ((int) 500e6)
  5. #define TIMEOUT_STOPPED_IN_TAB_TIMER_CLOCKS (TAB_TIMER_FREQUENCY / 2) /* 1/2 second to detect stop */
  6.  
  7. int main(void) {
  8. // your code goes here
  9. int stoppedFlag = 6;
  10. uint32_t period = 187400000;
  11. if (stoppedFlag && TIMEOUT_STOPPED_IN_TAB_TIMER_CLOCKS * 3 / 4 > period)
  12. {
  13. stoppedFlag--; /* We may be turning again */
  14. }
  15. printf("Stopped Flag=%d", stoppedFlag);
  16. printf("\nTIMEOUT time=%u", TIMEOUT_STOPPED_IN_TAB_TIMER_CLOCKS * 3 / 4);
  17. printf("\bTIMEOUT time full=%u", TIMEOUT_STOPPED_IN_TAB_TIMER_CLOCKS);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Stopped Flag=5
TIMEOUT time=187500000TIMEOUT time full=250000000