diff options
-rw-r--r-- | flash/bootloader/bootloader.c | 21 | ||||
-rw-r--r-- | flash/bootloader/bootloader.h | 24 |
2 files changed, 32 insertions, 13 deletions
diff --git a/flash/bootloader/bootloader.c b/flash/bootloader/bootloader.c index a6fe91d283..e5bab34abd 100644 --- a/flash/bootloader/bootloader.c +++ b/flash/bootloader/bootloader.c | |||
@@ -122,9 +122,10 @@ void PlatformInit(void) | |||
122 | 122 | ||
123 | #if defined PLATFORM_PLAYER | 123 | #if defined PLATFORM_PLAYER |
124 | BRR1 = 0x0019; // 14400 Baud for monitor | 124 | BRR1 = 0x0019; // 14400 Baud for monitor |
125 | if (FW_VERSION > 451) // "new" Player? | 125 | PACR2 &= 0xFFFC; // GPIO for PA0 (charger detection, input by default) |
126 | { | 126 | if (FW_VERSION > 451 && (PADRL & 0x01)) |
127 | PBDR &= ~0x10; // set PB4 to 0 to power-up the harddisk early | 127 | { // "new" Player and charger not plugged? |
128 | PBDR |= 0x10; // set PB4 to 1 to power-up the harddisk early | ||
128 | PBIOR |= 0x10; // make PB4 an output | 129 | PBIOR |= 0x10; // make PB4 an output |
129 | } | 130 | } |
130 | #elif defined PLATFORM_RECORDER | 131 | #elif defined PLATFORM_RECORDER |
@@ -255,7 +256,7 @@ void DecompressStart(tImage* pImage) | |||
255 | pImage->pExecute(); | 256 | pImage->pExecute(); |
256 | } | 257 | } |
257 | 258 | ||
258 | 259 | #ifdef USE_ADC | |
259 | int ReadADC(int channel) | 260 | int ReadADC(int channel) |
260 | { | 261 | { |
261 | // after channel 3, the ports wrap and get re-used | 262 | // after channel 3, the ports wrap and get re-used |
@@ -267,12 +268,14 @@ int ReadADC(int channel) | |||
267 | 268 | ||
268 | return (timeout == 0) ? -1 : *pResult>>6; | 269 | return (timeout == 0) ? -1 : *pResult>>6; |
269 | } | 270 | } |
271 | #endif | ||
270 | 272 | ||
271 | 273 | ||
272 | // This function is platform-dependent, | 274 | // This function is platform-dependent, |
273 | // until I figure out how to distinguish at runtime. | 275 | // until I figure out how to distinguish at runtime. |
274 | int ButtonPressed(void) // return 1,2,3 for F1,F2,F3, 0 if none pressed | 276 | int ButtonPressed(void) // return 1,2,3 for F1,F2,F3, 0 if none pressed |
275 | { | 277 | { |
278 | #ifdef USE_ADC | ||
276 | int value = ReadADC(CHANNEL); | 279 | int value = ReadADC(CHANNEL); |
277 | 280 | ||
278 | if (value >= F1_LOWER && value <= F1_UPPER) // in range | 281 | if (value >= F1_LOWER && value <= F1_UPPER) // in range |
@@ -281,6 +284,16 @@ int ButtonPressed(void) // return 1,2,3 for F1,F2,F3, 0 if none pressed | |||
281 | return 2; | 284 | return 2; |
282 | else if (value >= F3_LOWER && value <= F3_UPPER) // in range | 285 | else if (value >= F3_LOWER && value <= F3_UPPER) // in range |
283 | return 3; | 286 | return 3; |
287 | #else | ||
288 | int value = PCDR; | ||
289 | |||
290 | if (!(value & F1_MASK)) | ||
291 | return 1; | ||
292 | else if (!(value & F2_MASK)) | ||
293 | return 2; | ||
294 | else if (!(value & F3_MASK)) | ||
295 | return 3; | ||
296 | #endif | ||
284 | 297 | ||
285 | return 0; | 298 | return 0; |
286 | } | 299 | } |
diff --git a/flash/bootloader/bootloader.h b/flash/bootloader/bootloader.h index 342ebb4991..fc6bcb1eed 100644 --- a/flash/bootloader/bootloader.h +++ b/flash/bootloader/bootloader.h | |||
@@ -34,14 +34,12 @@ typedef struct | |||
34 | 34 | ||
35 | // resolve platform dependency of F1 button check | 35 | // resolve platform dependency of F1 button check |
36 | #if defined PLATFORM_PLAYER | 36 | #if defined PLATFORM_PLAYER |
37 | #define CHANNEL 1 | 37 | #define F1_MASK 0x0001 // Player has no F1 button, so we use "-" |
38 | #define F1_LOWER 0 // this is the "Menu" key | 38 | #define F2_MASK 0x0008 // Player has no F2 button, so we use "Play" |
39 | #define F1_UPPER 384 | 39 | #define F3_MASK 0x0004 // Player has no F3 button, so we use "+" |
40 | #define F2_LOWER 1024 // not present | 40 | |
41 | #define F2_UPPER 1024 | ||
42 | #define F3_LOWER 1024 | ||
43 | #define F3_UPPER 1024 | ||
44 | #elif defined PLATFORM_RECORDER | 41 | #elif defined PLATFORM_RECORDER |
42 | #define USE_ADC | ||
45 | #define CHANNEL 4 | 43 | #define CHANNEL 4 |
46 | #define F1_LOWER 250 | 44 | #define F1_LOWER 250 |
47 | #define F1_UPPER 499 | 45 | #define F1_UPPER 499 |
@@ -49,7 +47,9 @@ typedef struct | |||
49 | #define F2_UPPER 699 | 47 | #define F2_UPPER 699 |
50 | #define F3_LOWER 900 | 48 | #define F3_LOWER 900 |
51 | #define F3_UPPER 1023 | 49 | #define F3_UPPER 1023 |
50 | |||
52 | #elif defined PLATFORM_FM | 51 | #elif defined PLATFORM_FM |
52 | #define USE_ADC | ||
53 | #define CHANNEL 4 | 53 | #define CHANNEL 4 |
54 | #define F1_LOWER 150 | 54 | #define F1_LOWER 150 |
55 | #define F1_UPPER 384 | 55 | #define F1_UPPER 384 |
@@ -57,18 +57,22 @@ typedef struct | |||
57 | #define F2_UPPER 544 | 57 | #define F2_UPPER 544 |
58 | #define F3_LOWER 700 | 58 | #define F3_LOWER 700 |
59 | #define F3_UPPER 1023 | 59 | #define F3_UPPER 1023 |
60 | |||
60 | #elif defined PLATFORM_ONDIO | 61 | #elif defined PLATFORM_ONDIO |
62 | #define USE_ADC | ||
61 | #define CHANNEL 4 | 63 | #define CHANNEL 4 |
62 | #define F1_LOWER 0x2EF // Ondio has no F1 button, | 64 | #define F1_LOWER 0x2EF // Ondio has no F1 button, |
63 | #define F1_UPPER 0x3FF // so we use "Right". | 65 | #define F1_UPPER 0x3FF // so we use "Left". |
64 | #define F2_LOWER 0x19D // Ondio has no F2 button, | 66 | #define F2_LOWER 0x19D // Ondio has no F2 button, |
65 | #define F2_UPPER 0x245 // so we use "Up". | 67 | #define F2_UPPER 0x245 // so we use "Up". |
66 | #define F3_LOWER 0x246 // Ondio has no F3 button, | 68 | #define F3_LOWER 0x246 // Ondio has no F3 button, |
67 | #define F3_UPPER 0x2EE // so we use "Left". | 69 | #define F3_UPPER 0x2EE // so we use "Right". |
70 | |||
68 | #else | 71 | #else |
69 | #error ("No platform given!") | 72 | #error ("No platform given!") |
70 | #endif | 73 | #endif |
71 | 74 | ||
75 | |||
72 | #define FLASH_BASE 0x02000000 // start of the flash memory | 76 | #define FLASH_BASE 0x02000000 // start of the flash memory |
73 | #define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version | 77 | #define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version |
74 | 78 | ||
@@ -80,7 +84,9 @@ void PlatformInit(void); | |||
80 | void DramInit(void); | 84 | void DramInit(void); |
81 | int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); | 85 | int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); |
82 | void DecompressStart(tImage* pImage); | 86 | void DecompressStart(tImage* pImage); |
87 | #ifdef USE_ADC | ||
83 | int ReadADC(int channel); | 88 | int ReadADC(int channel); |
89 | #endif | ||
84 | int ButtonPressed(void); | 90 | int ButtonPressed(void); |
85 | tImage* GetStartImage(int nPreferred); | 91 | tImage* GetStartImage(int nPreferred); |
86 | // test functions | 92 | // test functions |