-
Notifications
You must be signed in to change notification settings - Fork 8
/
devicePalmTungstenT.c
executable file
·167 lines (124 loc) · 3.69 KB
/
devicePalmTungstenT.c
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//(c) uARM project https://github.com/uARM-Palm/uARM [email protected]
#include "uwiredev_ADS7846.h"
#include "SDL2/SDL.h"
#include "device.h"
#include "util.h"
#include "RAM.h"
/*
oslo/T|T button map (3 lowest outputs driven, only 3 used, all 5 inputs used):
btn output input
H1 0 0
H2 0 1
H3 0 2
H4 0 3
center 0 4
left 1 0
down 1 1
up 1 2
right 1 3
pwr 2 0
voicRec 2 4
*/
struct Device {
struct Ads7846 *ads7846;
};
bool deviceHasGrafArea(void)
{
return true;
}
enum RomChipType deviceGetRomMemType(void)
{
return RomStrataFlash16x;
}
uint32_t deviceGetRamSize(void)
{
return 32UL << 20;
}
enum RamTermination deviceGetRamTerminationStyle(void)
{
return RamTerminationMirror;
}
uint_fast8_t deviceGetSocRev(void)
{
return 1; //omap with DSP
}
struct Device* deviceSetup(struct SocPeriphs *sp, struct Keypad *kp, struct VSD *vsd, FILE* nandFile)
{
struct ArmRam *weirdBusAccess;
struct Device *dev;
uint_fast8_t i;
dev = (struct Device*)malloc(sizeof(*dev));
if (!dev)
ERR("cannot alloc device");
weirdBusAccess = ramInit(sp->mem, 0x08000000ul, 0x280, (uint32_t*)malloc(0x280));
if (!weirdBusAccess)
ERR("Cannot init RAM4");
for (i = 0; i < 3; i++) {
if (!keypadDefineCol(kp, i, 32 + i))
ERR("Cannot init keypad col %u as gpio %u", i, 32 + i);
}
for (i = 0; i < 5; i++) {
if (!keypadDefineRow(kp, i, 40 + i))
ERR("Cannot init keypad row %u as gpio %u", i, 40 + i);
}
//shared 0 is pen detect
dev->ads7846 = ads7846init(sp->uw, 0, sp->gpio, 6);
if (!dev->ads7846)
ERR("Cannot init ADS7846");
//shared 0: Vusb active high
socGpioSetState(sp->gpio, 0, false);
//xxx: these are from oslo:
//shared 8 is sd card write protect (high when protected)
socGpioSetState(sp->gpio, 8, false);
//mpuio 12 is sd card detect (active low)
socGpioSetState(sp->gpio, 16 + 12, !vsd);
//shared 14 is headphone detect (active high)
socGpioSetState(sp->gpio, 14, false);
//mpuio 1 is hot sync button (Active high)
socGpioSetState(sp->gpio, 16 + 1, false);
//mpuio 2 is AC-power detect (active low)
socGpioSetState(sp->gpio, 16 + 2, false);
//mpuio 3 is slider detect (high when open)
socGpioSetState(sp->gpio, 16 + 3, true);
//battery is full
ads7846setAdc(dev->ads7846, Ads7846auxTypeBatt, 4100);
//keys
if (!keypadAddMatrixKey(kp, SDLK_F1, 0, 0))
ERR("Cannot init hardkey1\n");
if (!keypadAddMatrixKey(kp, SDLK_F2, 1, 0))
ERR("Cannot init hardkey2\n");
if (!keypadAddMatrixKey(kp, SDLK_F3, 2, 0))
ERR("Cannot init hardkey3\n");
if (!keypadAddMatrixKey(kp, SDLK_F4, 3, 0))
ERR("Cannot init hardkey4\n");
if (!keypadAddMatrixKey(kp, SDLK_F5, 4, 2))
ERR("Cannot init hardkey5\n");
if (!keypadAddMatrixKey(kp, SDLK_ESCAPE, 0, 2))
ERR("Cannot init power key\n");
if (!keypadAddMatrixKey(kp, SDLK_DOWN, 1, 1))
ERR("Cannot init down key\n");
if (!keypadAddMatrixKey(kp, SDLK_UP, 2, 1))
ERR("Cannot init up key\n");
if (!keypadAddMatrixKey(kp, SDLK_LEFT, 0, 1))
ERR("Cannot init left key\n");
if (!keypadAddMatrixKey(kp, SDLK_RIGHT, 3, 1))
ERR("Cannot init right key\n");
if (!keypadAddMatrixKey(kp, SDLK_RETURN, 4, 0))
ERR("Cannot init select key\n");
return dev;
}
void devicePeriodic(struct Device *dev, uint32_t cycles)
{
}
void deviceTouch(struct Device *dev, int x, int y)
{
uint16_t z = (x >= 0 && y >= 0) ? 2048 : 0;
uint16_t adcX, adcY;
adcX = 3570 - x * 175 / 20;
adcY = 3750 - y * 158 / 20;
ads7846penInput(dev->ads7846, adcX, adcY, z);
}
void deviceKey(struct Device *dev, uint32_t key, bool down)
{
//nothing
}