this transfers data (which is stored in "bin" file in mbed storage) into LPC1114, LPC1115, LPC81x, LPC82x, LPC1768/LPC1769 and LPC11U68/LPC11E68 internal flash memory through ISP.
Dependencies: mbed MODSERIAL DirectoryList
main.cpp
00001 /** 00002 * Sample of ISP operation for NXP MCUs 00003 * 00004 * @author Tedd OKANO 00005 * @version 1.2.1 00006 * @date Aug-2015 00007 * 00008 * This program programs MCU flash memory through UART. It uses 00009 * "In-System Programming (ISP)" interface in target MCU (NXP LPC micro- 00010 * controllers). 00011 * 00012 * The ISP is done by PC and serial cable normally. The ISP protocol is 00013 * executed software on a PC. The software reads a data file and transfers 00014 * the data with the ISP protocol. 00015 * This program does same process of that. The mbed perform the function like 00016 * "FlashMagic" and "lpc21isp". 00017 * (This program not just copies the binary but also insert 4 byte checksum at 00018 * address 0x1C.) 00019 * 00020 * This program supports 00021 * LPC1114, LPC1115, LPC81x, LPC82x, LPC1768/1769 and LPC11U68/LPC11E68. 00022 * 00023 * All detailed history is available in code publishing page. 00024 * Please find it on 00025 * https://developer.mbed.org/users/okano/code/ika_shouyu_poppoyaki/shortlog 00026 * Thank you for all feedbacks and controbutes! 00027 */ 00028 00029 #include "mbed.h" 00030 #include "isp.h" 00031 #include "serial_utilities.h" 00032 #include "_user_settings.h" 00033 #include "dir_handling.h" 00034 00035 00036 LocalFileSystem local( "local" ); 00037 00038 00039 #define SUMMARY_MESSAGE_FAIL "** The data could not be " WHAT_WAS_DONE " :(" 00040 #define SUMMARY_MESSAGE_SUCCESS "** The data has been " WHAT_WAS_DONE " successflly :)" 00041 00042 int main() 00043 { 00044 int err; 00045 00046 printf( "\r\n\r\n\r\nmbed ISP program : programming LPC device from mbed (v1.2.1)\r\n" ); 00047 00048 #ifndef ENABLE_FILE_SELECTOR 00049 err = isp_flash_write( SOURCE_FILE ); 00050 #else 00051 std::string str( SOURCE_FILE ); 00052 if ( "" == get_file_name( str, SUFFIX_FILTER_STR ) ) 00053 goto skip_ISP; 00054 err = isp_flash_write( str.c_str() ); 00055 #endif 00056 00057 printf( "\r\n %d: %s\r\n\r\n",err, 00058 err ? 00059 SUMMARY_MESSAGE_FAIL : 00060 SUMMARY_MESSAGE_SUCCESS 00061 ); 00062 00063 if ( err ) 00064 error( " ** ISP failed\r\n" ); 00065 00066 skip_ISP: 00067 00068 #ifdef AUTO_PROGRAM_START 00069 00070 start_target_in_normal_mode( TARGET_OPERATION_BAUD_RATE ); 00071 00072 printf( " ** The program programmed in flash has been started!!\r\n" ); 00073 00074 #endif 00075 00076 printf( " (now the mbed is working in \"serial through mode\")\r\n\r\n" ); 00077 00078 start_success_indicator(); 00079 usb_serial_bridge_operation(); // doesn't return. infinite loop in this function 00080 } 00081
Generated on Sat Jul 16 2022 08:56:48 by 1.7.2