A fork of mAVRISP by Aaron Berk. This version does not use a local file system to hold the AVR program. Instead it uses a serial connection to a PC and a python script to send the AVR program to the mbed.

Dependencies:   mbed

Fork of mAVRISP by Aaron Berk

Revision:
1:276f6df4be7a
Parent:
0:3066745764a5
Child:
3:df6782d01720
--- a/main.cpp	Tue Aug 31 14:09:53 2010 +0000
+++ b/main.cpp	Wed Sep 01 10:22:51 2010 +0000
@@ -12,7 +12,7 @@
 
     int success  = -1;
     int response =  0;
-    
+
     //Read the vendor code [0x1E == Atmel].
     response = mAVRISP.readVendorCode();
 
@@ -25,7 +25,7 @@
         pc.printf("Microcontroller is not an Atmel\n");
         return -1;
     }
-    
+
     //Read part family and flash size - see datasheet for code meaning.
     response = mAVRISP.readPartFamilyAndFlashSize();
 
@@ -43,33 +43,32 @@
 
     if (response == 0xFF) {
         pc.printf("Device code erased or target missing\n");
-        return -1;
     } else if (response == 0x02) {
         pc.printf("Device locked\n");
         return -1;
     } else {
         pc.printf("Part number code is: 0x%02x\n", response);
     }
-    
+
     //Open binary file to write to AVR.
     FILE *fp = fopen(PATH_TO_BINARY, "rb");
-    
-    if(fp == NULL){
+
+    if (fp == NULL) {
         pc.printf("Failed to open binary. Please check the file path\n");
         return -1;
-    }
-    else{
+    } else {
         //Program it!
         pc.printf("Binary file opened successfully\n");
-        success = mAVRISP.program(fp);
+        success = mAVRISP.program(fp,
+                                  ATMEGA328P_PAGESIZE,
+                                  ATMEGA328P_NUM_PAGES);
         fclose(fp);
     }
-    
-    if(success < 0){
+
+    if (success < 0) {
         printf("Programming failed.\n");
-    }
-    else{
+    } else {
         printf("Programming was successful!\n");
     }
-    
+
 }