-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.c
More file actions
113 lines (101 loc) · 3.08 KB
/
Copy pathtemplate.c
File metadata and controls
113 lines (101 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <ti/screen.h>
#include <ti/getcsc.h>
#include <sys/power.h>
#include <stdlib.h>
#include <stdarg.h>
#include "elk.h"
#include <debug.h>
#include <string.h>
#include <sys/basicusb.h>
/* native elk stuff */
jsval_t dump(struct js *js, jsval_t *args, int nargs)
{
js_dump(js);
return js_mkundef();
}
/* screen.h */
jsval_t js_os_ClrHome(struct js *js, jsval_t *args, int nargs)
{
os_ClrHome();
return js_mkundef();
}
/* sys/power.h */
jsval_t js_boot_TurnOff(struct js *js, jsval_t *args, int nargs)
{
boot_TurnOff();
return js_mkundef();
}
jsval_t js_boot_TurnOn(struct js *js, jsval_t *args, int nargs)
{
boot_TurnOn();
return js_mkundef();
}
jsval_t js_boot_GetBatteryStatus(struct js *js, jsval_t *args, int nargs)
{
uint8_t *battery = boot_GetBatteryStatus();
return js_mknum((double)(*battery / 2));
}
/* sys/basicusb.h */
jsval_t js_boot_USBBusPowered(struct js *js, jsval_t *args, int nargs)
{
bool *powered = boot_USBBusPowered();
return powered ? js_mktrue() : js_mkfalse();
}
jsval_t js_boot_USBSelfPowered(struct js *js, jsval_t *args, int nargs)
{
bool *powered = boot_USBSelfPowered();
return powered ? js_mktrue() : js_mkfalse();
}
jsval_t js_boot_USBResetChip(struct js *js, jsval_t *args, int nargs)
{
boot_USBResetChip();
return js_mkundef();
}
jsval_t js_boot_USBDisableTimers(struct js *js, jsval_t *args, int nargs)
{
boot_USBDisableTimers();
return js_mkundef();
}
jsval_t js_boot_USBEnableTimers(struct js *js, jsval_t *args, int nargs)
{
boot_USBEnableTimers();
return js_mkundef();
}
jsval_t js_boot_USBResetTimers(struct js *js, jsval_t *args, int nargs)
{
boot_USBResetTimers();
return js_mkundef();
}
jsval_t js_os_USBGetRequestStatus(struct js *js, jsval_t *args, int nargs)
{
return js_mknum(os_USBGetRequestStatus());
}
int main(void)
{
os_ClrHome();
uint8_t var_type;
char *var_name;
void *vat_ptr = NULL;
char mem[2000];
struct js *js = js_create(mem, sizeof(mem));
/* native elk stuff */
js_set(js, js_glob(js), "dump", js_mkfun(dump));
/* screen.h */
js_set(js, js_glob(js), "ClrHome", js_mkfun(js_os_ClrHome));
/* sys/power.h */
js_set(js, js_glob(js), "boot_TurnOff", js_mkfun(js_boot_TurnOff));
js_set(js, js_glob(js), "boot_TurnOn", js_mkfun(js_boot_TurnOn));
js_set(js, js_glob(js), "boot_GetBatteryStatus", js_mkfun(js_boot_GetBatteryStatus));
/* sys/basicusb.h */
js_set(js, js_glob(js), "boot_USBBusPowered", js_mkfun(js_boot_USBBusPowered));
js_set(js, js_glob(js), "boot_USBSelfPowered", js_mkfun(js_boot_USBSelfPowered));
js_set(js, js_glob(js), "boot_USBResetChip", js_mkfun(js_boot_USBResetChip));
js_set(js, js_glob(js), "boot_USBDisableTimers", js_mkfun(js_boot_USBDisableTimers));
js_set(js, js_glob(js), "boot_USBEnableTimers", js_mkfun(js_boot_USBEnableTimers));
js_set(js, js_glob(js), "boot_USBResetTimers", js_mkfun(js_boot_USBResetTimers));
js_set(js, js_glob(js), "os_USBGetRequestStatus", js_mkfun(js_os_USBGetRequestStatus));
// evaluator
while (!os_GetCSC())
;
return 0;
}