summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flash/uart_boot/uart_boot.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/flash/uart_boot/uart_boot.c b/flash/uart_boot/uart_boot.c
index 8110e9b678..acfbb8e9c5 100644
--- a/flash/uart_boot/uart_boot.c
+++ b/flash/uart_boot/uart_boot.c
@@ -21,6 +21,7 @@ struct
21 char* szDumpfile; // file to dump into 21 char* szDumpfile; // file to dump into
22 char* szExecfile; // file with the executable 22 char* szExecfile; // file with the executable
23 bool bTest; // debug action 23 bool bTest; // debug action
24 bool bHold; // hold power (for FMs & V2s)
24 bool bBlink; // blink red LED 25 bool bBlink; // blink red LED
25 bool bNoDownload; 26 bool bNoDownload;
26} gCmd; 27} gCmd;
@@ -43,6 +44,7 @@ int ProcessCmdLine(int argc, char* argv[])
43 printf("-recorder (this is a recorder/FM, default is player if not specified)\n"); 44 printf("-recorder (this is a recorder/FM, default is player if not specified)\n");
44 printf("-archos (use Archos bootloader, this one needs powerup while program waits)\n"); 45 printf("-archos (use Archos bootloader, this one needs powerup while program waits)\n");
45 printf("-nodownload (no MiniMon download, it's already active)\n"); 46 printf("-nodownload (no MiniMon download, it's already active)\n");
47 printf("-hold (hold the power, useful for FMs and V2s, so you can release ON)\n");
46 printf("-spindown (spindown the harddisk, else it stays on by default)\n"); 48 printf("-spindown (spindown the harddisk, else it stays on by default)\n");
47 printf("-id (read manufacturer and device ID of flash, no checks)\n"); 49 printf("-id (read manufacturer and device ID of flash, no checks)\n");
48 printf("-flash <filename of binary to program into flash>\n"); 50 printf("-flash <filename of binary to program into flash>\n");
@@ -122,6 +124,10 @@ int ProcessCmdLine(int argc, char* argv[])
122 { 124 {
123 gCmd.bTest = true; 125 gCmd.bTest = true;
124 } 126 }
127 else if (!strncmp("-hold", *argv, 2))
128 {
129 gCmd.bHold = true;
130 }
125 else if (!strncmp("-blink", *argv, 2)) 131 else if (!strncmp("-blink", *argv, 2))
126 { 132 {
127 gCmd.bBlink = true; 133 gCmd.bBlink = true;
@@ -194,21 +200,37 @@ int main(int argc, char* argv[])
194 } 200 }
195 } 201 }
196 202
203
197 // do the action 204 // do the action
205 if (gCmd.bHold)
206 {
207 // hold power for FM
208 reg = ReadHalfword(serial_handle, 0x05FFFFC2); // PBDR
209 reg |= 0x0020; // set PB5 to keep power
210 WriteHalfword(serial_handle, 0x05FFFFC2, reg);
211
212 reg = ReadHalfword(serial_handle, 0x05FFFFC6); // PBIOR
213 reg |= 0x0020; // make PB5 an output
214 WriteHalfword(serial_handle, 0x05FFFFC6, reg);
215 printf("Power hold, you can release ON button now.\n");
216 }
217
198 218
199 if (gCmd.bSpindown) 219 if (gCmd.bSpindown)
200 { 220 {
201 // spindown the disk (works only for master) 221 // power down the disk
202 UINT32 ata; // address of ATA_ALT_STATUS 222 reg = ReadHalfword(serial_handle, 0x05FFFFCA); // PACR2
203 printf("Harddisk spindown..."); 223 reg &= ~0x0400; // clear bit 10: GPIO
204 ata = (gCmd.bRecorder && (ReadHalfword(serial_handle, 0x020000FC) & 0x0100)) ? 0x06200206 : 0x06200306; 224 WriteHalfword(serial_handle, 0x05FFFFCA, reg);
205 WriteHalfword(serial_handle, 0x05FFFFCA, 0xBF99); // PACR2 (was 0xFF99) 225
206 WriteHalfword(serial_handle, 0x05FFFFC4, 0x0280); // PAIOR (was 0x0000) 226 reg = ReadHalfword(serial_handle, 0x05FFFFC4); // PAIOR
207 WriteHalfword(serial_handle, 0x05FFFFC0, 0xA27F); // PADR (was 0xA0FF) 227 reg |= 0x0020; // set bit 5: output
208 while (ReadByte(serial_handle, ata) & 0x80); // ATA_ALT_STATUS & STATUS_BSY 228 WriteHalfword(serial_handle, 0x05FFFFC4, reg);
209 WriteByte(serial_handle, 0x06100107, 0xE0); // ATA_COMMAND = CMD_STANDBY_IMMEDIATE; 229
210 //while (ReadByte(serial_handle, ata) & 0x80); // ATA_ALT_STATUS & STATUS_BSY 230 reg = ReadHalfword(serial_handle, 0x05FFFFC0); // PADR
211 printf("\b\b\b done.\n"); 231 reg &= ~0x0020; // clear PA5 to power down
232 WriteHalfword(serial_handle, 0x05FFFFC0, reg);
233 printf("Harddisk powered down.\n");
212 } 234 }
213 235
214 236
@@ -307,13 +329,22 @@ int main(int argc, char* argv[])
307 329
308 if (gCmd.bTest) 330 if (gCmd.bTest)
309 { 331 {
310 // test code: query keypad 332 // test code: toggle PA5 to test FM IDE power
333 reg = ReadHalfword(serial_handle, 0x05FFFFCA); // PACR2
334 reg &= ~0x0400; // clear bit 10: GPIO
335 WriteHalfword(serial_handle, 0x05FFFFCA, reg);
336
337 reg = ReadHalfword(serial_handle, 0x05FFFFC4); // PAIOR
338 reg |= 0x0020; // set bit 5: output
339 WriteHalfword(serial_handle, 0x05FFFFC4, reg);
340
341 printf("Toggling PA5 forever... (stop with Ctrl-C)\n");
342 reg = ReadHalfword(serial_handle, 0x05FFFFC0); // PADR
311 while (1) 343 while (1)
312 { 344 {
313 WriteByte(serial_handle, 0x05FFFEE8, 0x24); // ADCSR 345 reg ^= 0x0020;
314 while (!(ReadByte(serial_handle, 0x05FFFEE8) & 0x80)); 346 WriteHalfword(serial_handle, 0x05FFFFC0, reg); // PADR
315 reg = ReadHalfword(serial_handle, 0x05FFFEE0); // ADDRA 347 Sleep(1000);
316 printf("ADC(4): %d\n", reg>>6);
317 } 348 }
318 } 349 }
319 350