Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. void busyWait(long ms) {
  2.     TickType_t currentTick = xTaskGetTickCount();
  3.     TickType_t goalTick = currentTick + pdMS_TO_TICKS(ms);
  4.     while (currentTick < goalTick) {
  5.         currentTick = xTaskGetTickCount();
  6.     }
  7. }
  8.  
  9. void testTask(void *args) {
  10.     for (;;) {
  11.         printf("test\n");
  12.         busyWait(500);
  13.     }
  14. }
  15.  
  16. extern int setup(void);
  17. int main() {
  18.     setup();
  19.     xTaskCreate(testTask, "busyWait", 100, NULL, 1, NULL);
  20.  
  21.  
  22.  
  23.     vTaskStartScheduler();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement