de Levak » 13 Mai 2014, 18:27
The most elegant way is to use Nucleus tasks/timers (which is on what the Nspire is based on) which are made for that.
Obviously, those syscalls have to be found by yourself which is not an easy solution. I have the addresses for CX CAS 3.1 but not for others such as 3.6.
I was wondering Ndless integrating those syscalls but it appears it only includes file management one (or hackspire is not up to date).
Below is an old test I found on my HDD :
- Code: Tout sélectionner
#include <os.h>
#include <libndls.h>
typedef void (*Timer_Callback)(void);
static unsigned TMS_Reset_Timer_addrs[] = {0x0, 0x0, 0x0, 0x10277740};
#define TMS_Reset_Timer SYSCALL_CUSTOM(TMS_Reset_Timer_addrs, void, void * /* timer */, Timer_Callback, int /* initial_time */, int /* reschedule_time */, int /* 4 = disable, 5 = enable */)
static unsigned TMS_Control_Timer_addrs[] = {0x0, 0x0, 0x0, 0x102776AC};
#define TMS_Control_Timer SYSCALL_CUSTOM(TMS_Control_Timer_addrs, void, void * /* timer */, int /* 4 = disable, 5 = enable */)
static unsigned TMS_Create_Timer_addrs[] = {0x0, 0x0, 0x0, 0x10277830};
#define TMS_Create_Timer SYSCALL_CUSTOM(TMS_Create_Timer_addrs, void, void * /* timer */, char * /* name */, Timer_Callback, int /* id */, int /* initial_timer */, int /* reschedule_time */, int /* 4 = disable, 5 = enable */)
static unsigned TMS_Delete_Timer_addrs[] = {0x0, 0x0, 0x0, 0x102777BC};
#define TMS_Delete_Timer SYSCALL_CUSTOM(TMS_Delete_Timer_addrs, void, void * /* timer */)
static unsigned NU_printf_addrs[] = {0x0, 0x0, 0x0, 0x10101FF8};
#define NU_printf SYSCALL_CUSTOM(NU_printf_addrs, int, char * /* format */, ...)
static int mtimer[0x64];
void timer_handler()
{
NU_printf("Hello World\n");
TMS_Reset_Timer(&mtimer, timer_handler, 100, 0, 5);
// TMS_Control_Timer(&mtimer, 5);
// TMS_Delete_Timer(&mtimer);
}
int main(int argc, char* argv[]) {
if(argc < 1) return 0;
TMS_Create_Timer(&mtimer, "1s", timer_handler, 0, 100, 0, 5);
nl_set_resident();
return;
}
Responsable design/graphique de TI-PlanetI do not get mad at people, I just want them to learn the way I learnt.