1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-07-02 21:34:32 +03:00
This commit is contained in:
Bas Wijnen 2009-06-10 23:20:33 +02:00
parent 159e576174
commit 42f0f365b3
2 changed files with 19 additions and 19 deletions

View File

@ -161,7 +161,7 @@ void Memory::free_obj (Object_base *obj):
self->prev->next = self->next self->prev->next = self->next
else: else:
frees = self->next frees = self->next
pfree ((unsigned)(self - SIZE)) pfree ((unsigned)self - SIZE)
Page *Memory::alloc_page (): Page *Memory::alloc_page ():
Page *ret = (Page *)search_free (sizeof (Page), (void **)&pages) Page *ret = (Page *)search_free (sizeof (Page), (void **)&pages)

View File

@ -20,22 +20,23 @@
#include "devices.hh" #include "devices.hh"
#include "jz4730.hh" #include "jz4730.hh"
// GPIO pins for the keyboard:// // GPIO pins for the keyboard: (port.pin)
// Rows = 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 125 // Cols = 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.29
// Cols = 0, 1, 2, 3, 4, 5, 6, 7 // Rows = 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7
// For some reason, it only works if the rows are input and the columns are output.
static void event (bool release, unsigned row, unsigned col): static void event (bool release, unsigned row, unsigned col):
kdebug (col * 2 + (release ? 1 : 0)) kdebug ((release ? 0x10000 : 0) | (row << 8) | col)
#define ROW_MASK 0x2000ffff #define COL_MASK 0x2000ffff
#define COL_MASK 0x000000ff #define ROW_MASK 0x000000ff
int main (): int main ():
map_gpio () map_gpio ()
// Disable all interrupts. // Disable all interrupts.
GPIO_GPIER (3) &= ~ROW_MASK GPIO_GPIER (3) &= ~COL_MASK
GPIO_GPIER (0) &= ~COL_MASK GPIO_GPIER (0) &= ~ROW_MASK
// Set all to GPIO. // Set all to GPIO.
GPIO_GPALR (3) = 0 GPIO_GPALR (3) = 0
@ -43,28 +44,27 @@ int main ():
GPIO_GPALR (0) &= ~0x0003ffff GPIO_GPALR (0) &= ~0x0003ffff
// Set all rows to input and enable the pull-ups. // Set all rows to input and enable the pull-ups.
GPIO_GPDIR (0) &= ~COL_MASK GPIO_GPDIR (0) &= ~ROW_MASK
GPIO_GPPUR (0) |= COL_MASK GPIO_GPPUR (0) |= ROW_MASK
// Set all columns to input and enable the pull-ups; set to 0 when output. // Set all columns to input and disable the pull-ups; set to 0 when output.
GPIO_GPDIR (3) &= ROW_MASK GPIO_GPDIR (3) &= ~COL_MASK
GPIO_GPPUR (3) |= ROW_MASK GPIO_GPPUR (3) &= ~COL_MASK
GPIO_GPDR (3) &= ~ROW_MASK GPIO_GPDR (3) &= ~COL_MASK
#define NUM_COLS 17 #define NUM_COLS 17
unsigned keys[NUM_COLS] unsigned keys[NUM_COLS]
for unsigned i = 0; i < NUM_COLS; ++i: for unsigned i = 0; i < NUM_COLS; ++i:
keys[i] = 0 keys[i] = 0xff
// Pin numbers for the cols, relative to the start of the port (so minus 0x60). // Pin numbers for the cols, relative to the start of the port (so minus 0x60).
int const cols[NUM_COLS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 29 } int const cols[NUM_COLS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 29 }
while true: while true:
// read keyboard // read keyboard
unsigned data[NUM_COLS]
for unsigned col = 0; col < NUM_COLS; ++col: for unsigned col = 0; col < NUM_COLS; ++col:
GPIO_GPDIR (3) = (GPIO_GPDIR (3) & ~ROW_MASK) | 1 << cols[col] GPIO_GPDIR (3) = (GPIO_GPDIR (3) & ~COL_MASK) | (1 << cols[col])
udelay (100) udelay (100)
unsigned data = GPIO_GPDR (0) & COL_MASK unsigned data = GPIO_GPDR (0) & ROW_MASK
// Generate events. // Generate events.
for unsigned row = 0; row < 8; ++row: for unsigned row = 0; row < 8; ++row:
if (data ^ keys[col]) & (1 << row): if (data ^ keys[col]) & (1 << row):