Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. #include "compatibility.h"
  2. static uint32_t mtime, seconds, useconds;
  3. //static struct timeval start, end;
  4. struct timespec start, end;
  5. /**********************************************************************/
  6. /**
  7. * This function is added in order to simulate arduino delay() function
  8. * @param milisec
  9. */
  10. void __msleep(int milisec)
  11. {
  12. struct timespec req;// = {0};
  13. req.tv_sec = (time_t) milisec / 1000;
  14. req.tv_nsec = (milisec % 1000 ) * 1000000L;
  15. //nanosleep(&req, (struct timespec *)NULL);
  16. clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
  17. }
  18. void __usleep(int microsec)
  19. {
  20. struct timespec req;// = {0};
  21. req.tv_sec = (time_t) microsec/ 1000000;
  22. req.tv_nsec = (microsec / 1000000) * 1000;
  23. //nanosleep(&req, (struct timespec *)NULL);
  24. clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
  25. }
  26. /**
  27. * This function is added in order to simulate arduino millis() function
  28. */
  29. void __start_timer()
  30. {
  31. //gettimeofday(&start, NULL);
  32. clock_gettime(CLOCK_MONOTONIC_RAW, &start);
  33. }
  34. uint32_t __millis()
  35. {
  36. //gettimeofday(&end, NULL);
  37. clock_gettime(CLOCK_MONOTONIC_RAW,&end);
  38. seconds = end.tv_sec - start.tv_sec;
  39. useconds = (end.tv_nsec - start.tv_nsec)/1000;
  40. mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
  41. return mtime;
  42. }