Subversion Repositories freemyipod

Rev

Rev 841 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 841 Rev 968
Line 29... Line 29...
29
#include "s5l8701.h"
29
#include "s5l8701.h"
30
#include "contextswitch.h"
30
#include "contextswitch.h"
31
 
31
 
32
 
32
 
33
static struct wakeup clickwheel_wakeup IBSS_ATTR;
33
static struct wakeup clickwheel_wakeup IBSS_ATTR;
-
 
34
static struct wakeup clickwheel_init_wakeup INITDATA_ATTR;
34
static volatile uint32_t clickwheel_packet IBSS_ATTR;
35
static volatile uint32_t clickwheel_packet IBSS_ATTR;
35
static struct scheduler_thread clickwheel_thread_handle;
36
static struct scheduler_thread clickwheel_thread_handle;
36
static uint32_t clickwheel_stack[0x100] STACK_ATTR;
37
static uint32_t clickwheel_stack[0x100] STACK_ATTR;
-
 
38
static bool wheel_initialized IBSS_ATTR;
37
static bool oldtouched IBSS_ATTR;
39
static bool oldtouched IBSS_ATTR;
38
static int oldpos IBSS_ATTR;
40
static int oldpos IBSS_ATTR;
39
static int oldbuttons IBSS_ATTR;
41
static int oldbuttons IBSS_ATTR;
40
static uint32_t lastpacket IBSS_ATTR;
42
static int lastpacket IBSS_ATTR;
41
static int packets IBSS_ATTR;
43
static int packets IBSS_ATTR;
42
static int collect IBSS_ATTR;
44
static int collect IBSS_ATTR;
43
static int lastdiff IBSS_ATTR;
45
static int lastdiff IBSS_ATTR;
44
 
46
 
45
 
47
 
Line 122... Line 124...
122
        }
124
        }
123
        else if ((data & 0x8000FFFF) == 0x8000023A)
125
        else if ((data & 0x8000FFFF) == 0x8000023A)
124
        {
126
        {
125
            if (data & 0x1F0000) oldbuttons = (data >> 16) & 0x1F;
127
            if (data & 0x1F0000) oldbuttons = (data >> 16) & 0x1F;
126
            DEBUGF("This is an init packet, button state: %02X", oldbuttons);
128
            DEBUGF("This is an init packet, button state: %02X", oldbuttons);
-
 
129
            if (!wheel_initialized)
-
 
130
            {
-
 
131
                wheel_initialized = true;
-
 
132
                wakeup_signal(&clickwheel_init_wakeup);
-
 
133
            }
127
        }
134
        }
128
    }
135
    }
129
}
136
}
130
 
137
 
131
 
138
 
132
void clickwheel_init()
139
int clickwheel_init()
133
{
140
{
134
    wakeup_init(&clickwheel_wakeup);
141
    wakeup_init(&clickwheel_wakeup);
-
 
142
    wakeup_init(&clickwheel_init_wakeup);
-
 
143
    wheel_initialized = false;
135
    oldtouched = false;
144
    oldtouched = false;
136
    oldbuttons = 0;
145
    oldbuttons = 0;
137
    lastpacket = 0;
146
    lastpacket = 0;
138
    collect = 0;
147
    collect = 0;
139
    lastdiff = 0;
148
    lastdiff = 0;
Line 152... Line 161...
152
    WHEEL04 |= 1;
161
    WHEEL04 |= 1;
153
    PDAT10 &= ~2;
162
    PDAT10 &= ~2;
154
    thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher", clickwheel_thread,
163
    thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher", clickwheel_thread,
155
                  clickwheel_stack, sizeof(clickwheel_stack), OS_THREAD, 200, true,
164
                  clickwheel_stack, sizeof(clickwheel_stack), OS_THREAD, 200, true,
156
                  NULL, NULL, NULL, NULL);
165
                  NULL, NULL, NULL, NULL);
-
 
166
    wakeup_wait(&clickwheel_init_wakeup, 100000);
-
 
167
    if (!wheel_initialized) RET_ERR(0);
-
 
168
    return 0;
157
}
169
}
158
 
170
 
159
void INT_WHEEL(void) ICODE_ATTR;
171
void INT_WHEEL(void) ICODE_ATTR;
160
void INT_WHEEL()
172
void INT_WHEEL()
161
{
173
{