diff options
-rw-r--r-- | firmware/config-fmrecorder.h | 23 | ||||
-rw-r--r-- | firmware/drivers/adc.h | 4 | ||||
-rw-r--r-- | firmware/drivers/button.c | 36 | ||||
-rw-r--r-- | firmware/drivers/power.c | 6 | ||||
-rw-r--r-- | firmware/usb.c | 4 |
5 files changed, 69 insertions, 4 deletions
diff --git a/firmware/config-fmrecorder.h b/firmware/config-fmrecorder.h new file mode 100644 index 0000000000..ed3454ff7e --- /dev/null +++ b/firmware/config-fmrecorder.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* define this if you have recording possibility */ | ||
2 | #define HAVE_RECORDING 1 | ||
3 | |||
4 | /* define this if you have a bitmap LCD display */ | ||
5 | #define HAVE_LCD_BITMAP 1 | ||
6 | |||
7 | /* define this if you have a Recorder style 10-key keyboard */ | ||
8 | #define HAVE_RECORDER_KEYPAD 1 | ||
9 | |||
10 | /* define this if you have a real-time clock */ | ||
11 | #define HAVE_RTC 1 | ||
12 | |||
13 | /* Define this if you have a MAS3587F */ | ||
14 | #define HAVE_MAS3587F | ||
15 | |||
16 | /* Define this if you have charging control */ | ||
17 | #define HAVE_CHARGE_CTRL | ||
18 | |||
19 | /* Define this if you have ATA power-off control */ | ||
20 | #define HAVE_ATA_POWER_OFF | ||
21 | |||
22 | /* Define this if you have a FM Recorder key system */ | ||
23 | #define HAVE_FMADC 1 | ||
diff --git a/firmware/drivers/adc.h b/firmware/drivers/adc.h index 0c05f4d0f8..9c90cb08a7 100644 --- a/firmware/drivers/adc.h +++ b/firmware/drivers/adc.h | |||
@@ -23,8 +23,12 @@ | |||
23 | 23 | ||
24 | #define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to | 24 | #define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to |
25 | silly scaling */ | 25 | silly scaling */ |
26 | #ifdef HAVE_FMADC | ||
27 | #define ADC_CHARGE_REGULATOR 0 /* Uh, we read the battery voltage? */ | ||
28 | #else | ||
26 | #define ADC_CHARGE_REGULATOR 1 /* Regulator reference voltage, should read | 29 | #define ADC_CHARGE_REGULATOR 1 /* Regulator reference voltage, should read |
27 | about 0x1c0 when charging, else 0x3FF */ | 30 | about 0x1c0 when charging, else 0x3FF */ |
31 | #endif | ||
28 | #define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */ | 32 | #define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */ |
29 | 33 | ||
30 | #define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different | 34 | #define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index ea3ffadffd..ebf606ac25 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -191,10 +191,19 @@ int button_get_w_tmo(int ticks) | |||
191 | * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ | 191 | * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ |
192 | 192 | ||
193 | /* Button analog voltage levels */ | 193 | /* Button analog voltage levels */ |
194 | #ifdef HAVE_FMADC | ||
195 | /* FM Recorder super-special levels */ | ||
196 | #define LEVEL1 150 | ||
197 | #define LEVEL2 385 | ||
198 | #define LEVEL3 545 | ||
199 | #define LEVEL4 700 | ||
200 | #else | ||
201 | /* plain bog standard Recorder levels */ | ||
194 | #define LEVEL1 250 | 202 | #define LEVEL1 250 |
195 | #define LEVEL2 500 | 203 | #define LEVEL2 500 |
196 | #define LEVEL3 700 | 204 | #define LEVEL3 700 |
197 | #define LEVEL4 900 | 205 | #define LEVEL4 900 |
206 | #endif | ||
198 | 207 | ||
199 | /* | 208 | /* |
200 | *Initialize buttons | 209 | *Initialize buttons |
@@ -219,11 +228,22 @@ static int button_read(void) | |||
219 | int btn = BUTTON_NONE; | 228 | int btn = BUTTON_NONE; |
220 | 229 | ||
221 | /* Check port B pins for ON and OFF */ | 230 | /* Check port B pins for ON and OFF */ |
222 | int data = PBDR; | 231 | int data; |
232 | |||
233 | #ifdef HAVE_FMADC | ||
234 | /* TODO: use proper defines here, and not the numerics in the | ||
235 | function argument */ | ||
236 | if ( adc_read(3) < 512 ) | ||
237 | btn |= BUTTON_ON; | ||
238 | if ( adc_read(2) > 512 ) | ||
239 | btn |= BUTTON_OFF; | ||
240 | #else | ||
241 | data = PBDR; | ||
223 | if ((data & PBDR_BTN_ON) == 0) | 242 | if ((data & PBDR_BTN_ON) == 0) |
224 | btn |= BUTTON_ON; | 243 | btn |= BUTTON_ON; |
225 | else if ((data & PBDR_BTN_OFF) == 0) | 244 | else if ((data & PBDR_BTN_OFF) == 0) |
226 | btn |= BUTTON_OFF; | 245 | btn |= BUTTON_OFF; |
246 | #endif | ||
227 | 247 | ||
228 | /* Check F1-3 and UP */ | 248 | /* Check F1-3 and UP */ |
229 | data = adc_read(ADC_BUTTON_ROW1); | 249 | data = adc_read(ADC_BUTTON_ROW1); |
@@ -245,12 +265,22 @@ static int button_read(void) | |||
245 | data = adc_read(ADC_BUTTON_ROW2); | 265 | data = adc_read(ADC_BUTTON_ROW2); |
246 | if (data >= LEVEL4) | 266 | if (data >= LEVEL4) |
247 | btn |= BUTTON_DOWN; | 267 | btn |= BUTTON_DOWN; |
248 | else if (data >= LEVEL3) | 268 | else if (data >= LEVEL3) { |
269 | #ifdef HAVE_FMADC | ||
270 | btn |= BUTTON_RIGHT; | ||
271 | #else | ||
249 | btn |= BUTTON_PLAY; | 272 | btn |= BUTTON_PLAY; |
273 | #endif | ||
274 | } | ||
250 | else if (data >= LEVEL2) | 275 | else if (data >= LEVEL2) |
251 | btn |= BUTTON_LEFT; | 276 | btn |= BUTTON_LEFT; |
252 | else if (data >= LEVEL1) | 277 | else if (data >= LEVEL1) { |
278 | #ifdef HAVE_FMADC | ||
279 | btn |= BUTTON_PLAY; | ||
280 | #else | ||
253 | btn |= BUTTON_RIGHT; | 281 | btn |= BUTTON_RIGHT; |
282 | #endif | ||
283 | } | ||
254 | } | 284 | } |
255 | 285 | ||
256 | return btn; | 286 | return btn; |
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index b61090ff26..bb0ec80942 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c | |||
@@ -31,8 +31,12 @@ bool charger_enabled = 0; | |||
31 | 31 | ||
32 | bool charger_inserted(void) | 32 | bool charger_inserted(void) |
33 | { | 33 | { |
34 | #ifdef ARCHOS_RECORDER | 34 | #ifdef HAVE_CHARGE_CTRL |
35 | #ifdef HAVE_FMADC | ||
36 | return adc_read(ADC_CHARGE_REGULATOR) < 0x1FF; | ||
37 | #else | ||
35 | return adc_read(ADC_EXT_POWER) > 0x100; | 38 | return adc_read(ADC_EXT_POWER) > 0x100; |
39 | #endif | ||
36 | #else | 40 | #else |
37 | return (PADR & 1) == 0; | 41 | return (PADR & 1) == 0; |
38 | #endif | 42 | #endif |
diff --git a/firmware/usb.c b/firmware/usb.c index 64474c7b66..fcc06c2f6e 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -218,8 +218,12 @@ static void usb_tick(void) | |||
218 | #ifdef ARCHOS_RECORDER | 218 | #ifdef ARCHOS_RECORDER |
219 | current_status = (adc_read(ADC_USB_POWER) > 500)?true:false; | 219 | current_status = (adc_read(ADC_USB_POWER) > 500)?true:false; |
220 | #else | 220 | #else |
221 | #ifdef ARCHOS_FMRECORDER | ||
222 | current_status = (adc_read(ADC_USB_POWER) < 512)?true:false; | ||
223 | #else | ||
221 | current_status = (PADR & 0x8000)?false:true; | 224 | current_status = (PADR & 0x8000)?false:true; |
222 | #endif | 225 | #endif |
226 | #endif | ||
223 | 227 | ||
224 | /* Only report when the status has changed */ | 228 | /* Only report when the status has changed */ |
225 | if(current_status != last_usb_status) | 229 | if(current_status != last_usb_status) |