Chris Styles
/
m3pi_AVRprogrammer
main.cpp
- Committer:
- chris
- Date:
- 2010-11-01
- Revision:
- 0:20fc0ecfb510
- Child:
- 1:ce6a12e62219
File content as of revision 0:20fc0ecfb510:
/** * Program an AVR with an mbed. */ // ATMega328 Datasheet: // // http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf #include "AVR910.h" DigitalOut led1(LED1); DigitalOut led2(LED2); LocalFileSystem local("local"); Serial pc(USBTX, USBRX); AVR910 mbedISP(p5, p6, p7, p8); //mosi, miso, sclk, nreset. int main() { int success = -1; printf("\nAVR Programmer\nLooking for /local/program.avr\n"); FILE *fp = fopen("/local/program.avr", "rb"); if (fp == NULL) { pc.printf("Failed to open binary\n"); } else { pc.printf("Binary file opened successfully\n"); led1 = 1; // in progress success = mbedISP.program(fp); fclose(fp); remove("/local/program.avr"); // remove the file when we're done led2 = 1; // finished } if (success < 0) { printf("Programming failed.\n"); } else { printf("Programming was successful!\n"); } fclose(fp); while (1) { } }