2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-04-08 16:36:15 +00:00
|
|
|
|
2020-04-08 16:45:50 +00:00
|
|
|
void Sleep_Cycles(OSTime cycles) {
|
2020-04-08 16:36:15 +00:00
|
|
|
OSMesgQueue mq;
|
|
|
|
OSMesg msg;
|
|
|
|
OSTimer timer;
|
|
|
|
|
2022-06-13 15:38:20 +00:00
|
|
|
osCreateMesgQueue(&mq, &msg, 1);
|
2020-04-08 16:36:15 +00:00
|
|
|
osSetTimer(&timer, cycles, 0, &mq, NULL);
|
|
|
|
osRecvMesg(&mq, NULL, OS_MESG_BLOCK);
|
|
|
|
}
|
|
|
|
|
2020-04-08 16:45:50 +00:00
|
|
|
void Sleep_Nsec(u32 nsec) {
|
2020-04-08 16:36:15 +00:00
|
|
|
Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec));
|
|
|
|
}
|
|
|
|
|
2020-04-08 16:45:50 +00:00
|
|
|
void Sleep_Usec(u32 usec) {
|
2020-04-08 16:36:15 +00:00
|
|
|
Sleep_Cycles(OS_USEC_TO_CYCLES(usec));
|
|
|
|
}
|
|
|
|
|
|
|
|
// originally "msleep"
|
2020-04-08 16:45:50 +00:00
|
|
|
void Sleep_Msec(u32 ms) {
|
2020-04-08 16:36:15 +00:00
|
|
|
Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ull);
|
|
|
|
}
|
|
|
|
|
2020-04-08 16:45:50 +00:00
|
|
|
void Sleep_Sec(u32 sec) {
|
2020-04-08 18:24:46 +00:00
|
|
|
Sleep_Cycles(sec * OS_CPU_COUNTER);
|
2020-04-08 16:36:15 +00:00
|
|
|
}
|