mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-21 23:08:53 -05:00
Add a delay API (for cross-platform sleeps)
This commit is contained in:
parent
04f3bd8d08
commit
01c4c23125
@ -8,7 +8,7 @@ PREFIX=/usr/local
|
||||
|
||||
PROG=gcn64ctl
|
||||
|
||||
OBJS=main.o gcn64.o mempak.o gcn64lib.o hexdump.o gc2n64_adapter.o ihex.o
|
||||
OBJS=main.o gcn64.o mempak.o gcn64lib.o hexdump.o gc2n64_adapter.o ihex.o delay.o
|
||||
|
||||
.PHONY : clean install
|
||||
|
||||
|
27
tool/delay.c
Normal file
27
tool/delay.c
Normal file
@ -0,0 +1,27 @@
|
||||
#ifdef LIBDRAGON
|
||||
#include <libdragon.h>
|
||||
|
||||
void _delay_us(unsigned long us)
|
||||
{
|
||||
wait_ms(us/1000);
|
||||
}
|
||||
|
||||
void _delay_s(unsigned long s)
|
||||
{
|
||||
wait_ms(s*1000);
|
||||
}
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
void _delay_us(unsigned long us)
|
||||
{
|
||||
usleep(us);
|
||||
}
|
||||
|
||||
void _delay_s(unsigned long s)
|
||||
{
|
||||
sleep(s);
|
||||
}
|
||||
|
||||
#endif
|
2
tool/delay.h
Normal file
2
tool/delay.h
Normal file
@ -0,0 +1,2 @@
|
||||
void _delay_us(unsigned long us);
|
||||
void _delay_s(unsigned long s);
|
@ -1,11 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "gcn64lib.h"
|
||||
#include "gc2n64_adapter.h"
|
||||
#include "hexdump.h"
|
||||
#include "ihex.h"
|
||||
#include "delay.h"
|
||||
|
||||
int gc2n64_adapter_echotest(gcn64_hdl_t hdl, int verbose)
|
||||
{
|
||||
@ -184,7 +184,7 @@ int gc2n64_adapter_boot_waitNotBusy(gcn64_hdl_t hdl, int verbose)
|
||||
}
|
||||
printf("%c\b", spinner[c%4]); fflush(stdout);
|
||||
c++;
|
||||
usleep(50000);
|
||||
_delay_us(50000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -267,7 +267,7 @@ int gc2n64_adapter_enterBootloader(gcn64_hdl_t hdl)
|
||||
return n;
|
||||
|
||||
// No answer since the effect is immediate.
|
||||
usleep(100000);
|
||||
_delay_us(100000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -390,7 +390,7 @@ int gc2n64_adapter_waitForBootloader(gcn64_hdl_t hdl, int timeout_s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
_delay_s(1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user