Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /** 00002 * Program an AVR with an mbed. 00003 */ 00004 00005 // ATMega328 Datasheet: 00006 // 00007 // http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf 00008 00009 #include "AVR910.h" 00010 00011 #define DELETE_BINARY 1 00012 00013 DigitalOut led1(LED1); 00014 DigitalOut led2(LED2); 00015 00016 LocalFileSystem local("local"); 00017 Serial pc(USBTX, USBRX); 00018 00019 AVR910 mbedISP(p5, p6, p7, p8); //mosi, miso, sclk, nreset. 00020 00021 int main() { 00022 00023 00024 int success = -1; 00025 00026 printf("\nAVR Programmer\nLooking for /local/program.avr\n"); 00027 00028 FILE *fp = fopen("/local/program.avr", "rb"); 00029 00030 if (fp == NULL) { 00031 pc.printf("Failed to open binary\n"); 00032 } else { 00033 pc.printf("Binary file opened successfully\n"); 00034 led1 = 1; // in progress 00035 success = mbedISP.program(fp); 00036 fclose(fp); 00037 #ifdef DELETE_BINARY 00038 remove("/local/program.avr"); // remove the file when we're done 00039 #endif 00040 led2 = 1; // finished 00041 } 00042 00043 if (success < 0) { 00044 printf("Programming failed.\n"); 00045 } else { 00046 printf("Programming was successful!\n"); 00047 } 00048 00049 fclose(fp); 00050 00051 00052 while (1) { 00053 } 00054 00055 }
Generated on Wed Jul 20 2022 19:55:29 by
1.7.2