Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
daugihao
Date:
Fri Sep 30 14:55:11 2011 +0000
Parent:
6:fab999f0e93b
Commit message:
Some slight alterations and comment addition

Changed in this revision

ID.cpp Show annotated file Show diff for this revision Revisions of this file
ISP.cpp Show annotated file Show diff for this revision Revisions of this file
SerialBuffered.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ID.cpp	Fri Sep 30 12:03:31 2011 +0000
+++ b/ID.cpp	Fri Sep 30 14:55:11 2011 +0000
@@ -5,29 +5,33 @@
     switch (idcode) {
     
         //Cortex M3 - LPC17xx
-        case 637615927:                                 //Works
+        case 637615927://Works                           //ID code
             strcpy(strChipType, "LPC1768 - Cortex M3");  //Chip name
+            //MAX 230400 baud                            //Maximum baud rate
             lastSector = 29;                             //Last available sector in Flash
-            RAM = 268435968;                             //First RAM address
+            RAM = 0x10000200;                            //First RAM address
             strcpy(speed, "4000");                       //Chip speed
             break;
             
-        case 1023410219:
-            strcpy(strChipType, "LPC1343 - Cortex M3");  //Can run up to 115200 baud (working on compatability)
+        case 1023410219://Looking at the user manual to solve problems
+            strcpy(strChipType, "LPC1343 - Cortex M3");  
+            //MAX 115200 baud
             lastSector = 7;
             RAM = 0x10000000;
-            strcpy(speed, "4000");                      
+            strcpy(speed, "60000");                      
             break;
             
-        case 71569451:
-            strcpy(strChipType, "LPC1114 - Cortex M3");  //Can run up to 115200 baud (working on compatability)
+        case 71569451://Looking at the user manual to solve problems
+            strcpy(strChipType, "LPC1114 - Cortex M3");
+            //MAX 115200 baud
             lastSector = 7;
             RAM = 0x10000000;
             strcpy(speed, "4000");                      
             break;
             
         //ARM7
-        case 117702437:                                 //Works
+        case 117702437://Works
+            //MAX 230400
             strcpy(strChipType, "LPC2387 - ARM7");
             lastSector = 27;
             RAM = 0x40000200;
--- a/ISP.cpp	Fri Sep 30 12:03:31 2011 +0000
+++ b/ISP.cpp	Fri Sep 30 14:55:11 2011 +0000
@@ -13,19 +13,17 @@
     int sector[30] = {4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768};
     int startadd[30] = {0x0, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000, 0x8000, 0x9000, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000, 0x10000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000, 0x40000, 0x48000, 0x50000, 0x58000, 0x60000, 0x68000, 0x70000, 0x78000};
     
-    pc.printf("**** LPCxxxx Flash Bootloader ****\n\n\r");
+    pc.printf("\n\r**** LPCxxxx Flash Bootloader ****\n\r");
     if(CheckTargetPresent()==0) {
         pc.printf("ERROR: Communication failed with board. Ensure board reset and P2.10 pulled low before running mbed program! If the setup is correct, try lowering the baud rate, set in main.cpp.\r\n\n");  
         exit(0);
     }
     
-    sprintf(strRAM, "W %d 1024", RAM);
-    
-    DIR *d = opendir("/fs");               // Opens the root directory of the local file system
+    DIR *d = opendir("/fs"); //Opens the root directory of the local file system
     struct dirent *p;
     
     fname[0] = 0;
-    while((p = readdir(d)) != NULL) {         // Print the names of the files in the local file system
+    while((p = readdir(d)) != NULL) { //Print the names of the files in the local file system
         if ( strcmp(p->d_name+strlen(p->d_name)-3,"LPC") == 0 )
         {
             strcpy(fname,"/fs/");
@@ -41,6 +39,7 @@
     } 
     else pc.printf("%s opened successfully\n\n\r", fname);
     
+    sprintf(strRAM, "W %d 1024", RAM);
     TargetSendStringAndCR(strRAM);
     readBytes(buf, 3);
     if ( strncmp(buf,str0, 1) != 0 )
@@ -171,17 +170,13 @@
     readBytes(buf, 3);
     if (strncmp(buf,str0,1) != 0 )
         return 0;
-    readBytes(buf, 12);
     
-    int length;
-    for (length=0; length<12; length++) {
-        if (buf[length]==0x0D)
-            break; 
+    readBytes(buf,1);    
+    while(buf[0]!=0x0D) {
+        id = (id*10)+buf[0]-'0';
+        readBytes(buf,1);
     }
-    
-    for (int i=0; i<length; i++)
-        id = (id*10)+buf[i]-'0';
-    //pc.printf("%d\n\r", id);
+    readBytes(buf,1);
     
     int finish = IDCheck(id);
     pc.printf("Chip to bootload: %s\n\r", strChipType);
@@ -204,6 +199,6 @@
     if ( strncmp(buf,str0,1) != 0 )
         return 0;
 
-    pc.printf("Ready to write to chip...\n\r");
+    pc.printf("Ready to write to chip\n\r");
     return 1;
 }
\ No newline at end of file
--- a/SerialBuffered.cpp	Fri Sep 30 12:03:31 2011 +0000
+++ b/SerialBuffered.cpp	Fri Sep 30 14:55:11 2011 +0000
@@ -11,7 +11,7 @@
     target.attach( this, &SerialBuffered::handleInterrupt );
     m_buff = (uint8_t *) malloc( bufferSize );
     if ( m_buff == NULL ) {
-        pc2.printf("SerialBuffered - failed to alloc buffer size %d\r\n", (int) bufferSize );
+        pc2.printf("\n\rERROR: Failed to alloc serial buffer size of %d\r\n", (int) bufferSize );
     } else {
         m_buffSize = bufferSize;
     }
@@ -78,7 +78,7 @@
 void SerialBuffered::handleInterrupt() {
     while (target.readable()) {
         if (m_contentStart == (m_contentEnd +1) % m_buffSize) {
-            pc2.printf("SerialBuffered - buffer overrun, data lost!\r\n" );
+            pc2.printf("\n\rERROR: Serial buffer overrun, data lost!\r\n" );
             exit(0);
         } else {
             m_buff[m_contentEnd++] = target.getc();
--- a/main.cpp	Fri Sep 30 12:03:31 2011 +0000
+++ b/main.cpp	Fri Sep 30 14:55:11 2011 +0000
@@ -5,7 +5,7 @@
 
 int main() {
     //RESET CHIP TO LOAD TO BEFORE RUNNING PROGRAM!!!
-    lpc.InitUART(230400);                   //Specified limit of 230400 baud
+    lpc.InitUART(115200);                   //Specified limit of 230400 baud
     lpc.ProgramFile();
 }
 //To add new chips to load to, add a case to the switch function in ID.cpp, using the ID code and last sector number information
\ No newline at end of file