Skip to content

Commit

Permalink
Fix for SPIDEV & MRAA: delayMicroseconds() (#952)
Browse files Browse the repository at this point in the history
* Update MRAA timer functions
- Found MRAA timer functions not working properly
- Copy timing functions from SPIDEV
* Change / to % in micros function
* Corrects timing problems with SPIDEV and MRAA drivers
  • Loading branch information
TMRh20 authored Mar 2, 2024
1 parent 7b315e1 commit bcc7a7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion utility/MRAA/compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void __usleep(int microsec)
{
struct timespec req; // = {0};
req.tv_sec = (time_t)microsec / 1000000;
req.tv_nsec = (microsec / 1000000) * 1000;
req.tv_nsec = (microsec % 1000000) * 1000;
clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion utility/SPIDEV/compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void __usleep(int microsec)
{
struct timespec req; // = {0};
req.tv_sec = (time_t)microsec / 1000000;
req.tv_nsec = (microsec / 1000000) * 1000;
req.tv_nsec = (microsec % 1000000) * 1000;
//nanosleep(&req, (struct timespec *)NULL);
clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
}
Expand Down

0 comments on commit bcc7a7c

Please sign in to comment.