freemyipod r841 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r840‎ | r841 | r842 >
Date:22:22, 26 December 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Fix clickwheel drivers
Modified paths:
  • /emcore/trunk/target/ipodnano2g/clickwheel.c (modified) (history)
  • /emcore/trunk/target/ipodnano3g/clickwheel.c (modified) (history)

Diff [purge]

Index: emcore/trunk/target/ipodnano2g/clickwheel.c
@@ -137,21 +137,22 @@
138138 lastpacket = 0;
139139 collect = 0;
140140 lastdiff = 0;
141 - INTMSK |= 1 << IRQ_WHEEL;
142141 PWRCON(1) &= ~1;
143142 PCON15 = (PCON15 & ~0xFFFF0000) | 0x22220000;
144143 PUNK15 = 0xF0;
 144+ PCON10 = (PCON10 & ~0xFF0) | 0x10;
 145+ WHEELINT = 7;
 146+ WHEEL10 = 1;
 147+ INTMSK |= 1 << IRQ_WHEEL;
145148 WHEEL08 = 0x3A980;
146149 WHEEL00 = 0x280000;
147 - WHEEL10 = 3;
148 - PCON10 = (PCON10 & ~0xFF0) | 0x10;
 150+ while (WHEEL0C & 4) yield();
149151 PDAT10 |= 2;
150152 WHEELTX = 0x8000023A;
151153 WHEEL04 |= 1;
152154 PDAT10 &= ~2;
153 - thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher",
154 - clickwheel_thread, clickwheel_stack,
155 - sizeof(clickwheel_stack), OS_THREAD, 200, true,
 155+ thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher", clickwheel_thread,
 156+ clickwheel_stack, sizeof(clickwheel_stack), OS_THREAD, 200, true,
156157 NULL, NULL, NULL, NULL);
157158 }
158159
@@ -159,14 +160,12 @@
160161 void INT_WHEEL()
161162 {
162163 uint32_t events = WHEELINT;
163 - if (events & 4) WHEELINT = 4;
164 - if (events & 2) WHEELINT = 2;
165164 if (events & 1)
166165 {
167166 clickwheel_packet = WHEELRX;
168167 wakeup_signal(&clickwheel_wakeup);
169 - WHEELINT = 1;
170168 }
 169+ WHEELINT = events;
171170 }
172171
173172 uint32_t clickwheel_get_state()
Index: emcore/trunk/target/ipodnano3g/clickwheel.c
@@ -137,24 +137,18 @@
138138 lastpacket = 0;
139139 collect = 0;
140140 lastdiff = 0;
141 - interrupt_enable(IRQ_WHEEL, true);
 141+ PCON(14) = (PCON(14) & ~0xffff0000) | 0x22220000;
142142 PUNA(2) &= ~2;
143 - PCON(14) = (PCON(14) & ~0xffff0000) | 0x22220000;
144143 WHEELINT = 7;
145 - WHEEL10 = 7;
 144+ WHEEL10 = 1;
 145+ interrupt_enable(IRQ_WHEEL, true);
 146+ WHEEL08 = 0x20000;
146147 WHEEL00 = 0x380000;
147 - WHEEL08 = 0x20000;
148 - do
149 - {
150 - WHEELTX = 0x8001052A;
151 - while (WHEEL0C & 4) yield();
152 - WHEEL04 = 1;
153 - sleep(20000);
154 - }
155 - while (WHEEL0C & 4);
156 - thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher",
157 - clickwheel_thread, clickwheel_stack,
158 - sizeof(clickwheel_stack), OS_THREAD, 200, true,
 148+ while (WHEEL0C & 4) yield();
 149+ WHEELTX = 0x8000023A;
 150+ WHEEL04 |= 1;
 151+ thread_create(&clickwheel_thread_handle, "Clickwheel dispatcher", clickwheel_thread,
 152+ clickwheel_stack, sizeof(clickwheel_stack), OS_THREAD, 200, true,
159153 NULL, NULL, NULL, NULL);
160154 }
161155
@@ -162,14 +156,12 @@
163157 void INT_WHEEL()
164158 {
165159 uint32_t events = WHEELINT;
166 - if (events & 4) WHEELINT = 4;
167 - if (events & 2) WHEELINT = 2;
168160 if (events & 1)
169161 {
170162 clickwheel_packet = WHEELRX;
171163 wakeup_signal(&clickwheel_wakeup);
172 - WHEELINT = 1;
173164 }
 165+ WHEELINT = events;
174166 }
175167
176168 uint32_t clickwheel_get_state()