-
Notifications
You must be signed in to change notification settings - Fork 8
/
devicePalmZire71.c
executable file
·131 lines (95 loc) · 2.77 KB
/
devicePalmZire71.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
//(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"
/*
*/
struct Device {
struct Ads7846 *ads7846;
};
bool deviceHasGrafArea(void)
{
return true;
}
enum RomChipType deviceGetRomMemType(void)
{
return RomStrataFlash16x;
}
uint32_t deviceGetRamSize(void)
{
return 16UL << 20;
}
enum RamTermination deviceGetRamTerminationStyle(void)
{
return RamTerminationMirror;
}
uint_fast8_t deviceGetSocRev(void)
{
return 0;
}
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 < 2; 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);
}
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);
//shared 1: VCC_in (Vusb or Vac) active low
socGpioSetState(sp->gpio, 1, false);
//shared 14 is headphone detect (active high)
socGpioSetState(sp->gpio, 14, false);
//shared 8 is SD write protect (high if protected)
socGpioSetState(sp->gpio, 8, false);
//mpuio 4 is sd card detect (active low)
socGpioSetState(sp->gpio, 16 + 4, !vsd);
//mpuio 2 is AC-power detect (active low)
socGpioSetState(sp->gpio, 16 + 2, false);
//keys
if (!keypadAddMatrixKey(kp, SDLK_F1, 1, 0))
ERR("Cannot init hardkey1\n");
if (!keypadAddMatrixKey(kp, SDLK_F2, 2, 0))
ERR("Cannot init hardkey1\n");
if (!keypadAddMatrixKey(kp, SDLK_ESCAPE, 4, 0))
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");
//battery is full
ads7846setAdc(dev->ads7846, Ads7846auxTypeBatt, 4100);
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 = 274 + y * 158 / 20;
ads7846penInput(dev->ads7846, adcX, adcY, z);
}
void deviceKey(struct Device *dev, uint32_t key, bool down)
{
//nothing
}