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 #include "mbed.h" 00002 #include "AVRISP.h" 00003 00004 #define FUSE_LOW 0xD0 00005 #define FUSE_HIGH 0xD9 00006 #define FUSE_EXTENDED 0xFF 00007 #define LOCK_BYTE 0xFF 00008 00009 LocalFileSystem local("local"); 00010 AVRISP avrisp(p11,p12,p13,p14); 00011 Serial pc(USBTX, USBRX); 00012 00013 int main() 00014 { 00015 bool ifSuccessful; 00016 00017 pc.printf("Press any button to program the AVR.\n"); 00018 char c = pc.getc(); 00019 00020 ifSuccessful = avrisp.EnableProgrammingMode(); 00021 if(ifSuccessful) 00022 { 00023 pc.printf("Enter Programming Mode: Successful.\n"); 00024 } 00025 else 00026 { 00027 pc.printf("Enter Programming Mode: Failed.\n"); 00028 } 00029 00030 int signatureByte1 = avrisp.ReadChipSignatureByte1(); 00031 int signatureByte2 = avrisp.ReadChipSignatureByte2(); 00032 int signatureByte3 = avrisp.ReadChipSignatureByte3(); 00033 pc.printf("Chip signature is %x %x %x\n",signatureByte1,signatureByte2,signatureByte3); 00034 00035 pc.printf("Erase Chip.\n"); 00036 avrisp.ChipErase(); 00037 00038 pc.printf("Write Fuse Low Byte.\n"); 00039 avrisp.WriteFuseLow(FUSE_LOW); 00040 pc.printf("Fuse Low Byte Readback = %x.\n",avrisp.ReadFuseLow()); 00041 00042 pc.printf("Write Fuse High Byte.\n"); 00043 avrisp.WriteFuseLow(FUSE_HIGH); 00044 pc.printf("Fuse High Byte Readback = %x.\n",avrisp.ReadFuseHigh()); 00045 00046 pc.printf("Write Fuse Extended Byte.\n"); 00047 avrisp.WriteFuseLow(FUSE_EXTENDED); 00048 pc.printf("Fuse Extended Byte Readback = %x.\n",avrisp.ReadFuseExtended()); 00049 00050 pc.printf("Write Lock Byte.\n"); 00051 avrisp.WriteLockByte(LOCK_BYTE); 00052 pc.printf("Lock Byte Readback = %x.\n",avrisp.ReadLockByte()); 00053 00054 ifSuccessful = avrisp.ProgramFlash("/local/avr1"); 00055 if(ifSuccessful) 00056 { 00057 pc.printf("Program Flash: Successful.\n"); 00058 } 00059 else 00060 { 00061 pc.printf("Program Flash: Failed.\n"); 00062 } 00063 00064 avrisp.LeaveProgrammingMode(); 00065 }
Generated on Fri Jul 15 2022 13:15:25 by
1.7.2