Add to 11U68 11E68

Dependencies:   DirectoryList MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Committer:
Hapi_Tech
Date:
Sat Jul 04 05:29:32 2015 +0000
Revision:
50:57ad8e04f063
Parent:
48:99cfe3a929ea
Adding LPC11U68,11E68.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 11:8dfc3217d1ca 1 /**
okano 11:8dfc3217d1ca 2 * Sample of ISP operation for NXP MCUs
okano 11:8dfc3217d1ca 3 *
okano 14:a7b9f74fb856 4 * @author Tedd OKANO
okano 48:99cfe3a929ea 5 * @version 1.1.2
okano 47:e7d395119a63 6 * @date Jan-2015
okano 26:a63e73885b21 7 *
okano 26:a63e73885b21 8 * This program programs MCU flash memory through UART. It uses
okano 14:a7b9f74fb856 9 * "In-System Programming (ISP)" interface in target MCU (NXP LPC micro-
okano 14:a7b9f74fb856 10 * controllers).
okano 26:a63e73885b21 11 *
okano 26:a63e73885b21 12 * The ISP is done by PC and serial cable normally. The ISP protocol is
okano 14:a7b9f74fb856 13 * executed software on a PC. The software reads a data file and transfers
okano 26:a63e73885b21 14 * the data with the ISP protocol.
okano 26:a63e73885b21 15 * This program does same process of that. The mbed perform the function like
okano 14:a7b9f74fb856 16 * "FlashMagic" and "lpc21isp".
okano 26:a63e73885b21 17 * (This program not just copies the binary but also insert 4 byte checksum at
okano 14:a7b9f74fb856 18 * address 0x1C.)
okano 26:a63e73885b21 19 *
okano 46:fe8ca451abcb 20 * This program supports LPC1114, LPC81x, LPC82x and LPC1768/1769.
okano 11:8dfc3217d1ca 21 */
okano 11:8dfc3217d1ca 22
okano 5:ff30f5b58617 23 #include "mbed.h"
okano 30:e0d7524661ca 24 #include "isp.h"
okano 22:bd98a782fba6 25 #include "serial_utilities.h"
okano 25:33cb5ad8ae24 26 #include "_user_settings.h"
okano 48:99cfe3a929ea 27 #include "dir_handling.h"
okano 21:e149d0bdbf4a 28
okano 30:e0d7524661ca 29
okano 2:8d75eb0ecd20 30 LocalFileSystem local( "local" );
okano 7:815366f003ee 31
okano 19:7a7381e78025 32
okano 35:0b434ef4af49 33 #define SUMMARY_MESSAGE_FAIL "** The data could not be " WHAT_WAS_DONE " :("
okano 35:0b434ef4af49 34 #define SUMMARY_MESSAGE_SUCCESS "** The data has been " WHAT_WAS_DONE " successflly :)"
okano 35:0b434ef4af49 35
okano 7:815366f003ee 36 int main()
okano 7:815366f003ee 37 {
okano 28:689c3880e0e4 38 int err;
okano 30:e0d7524661ca 39
okano 48:99cfe3a929ea 40 printf( "\r\n\r\n\r\nmbed ISP program : programming LPC device from mbed (v1.1.2)\r\n" );
okano 30:e0d7524661ca 41
okano 48:99cfe3a929ea 42 #ifndef ENABLE_FILE_SELECTOR
okano 28:689c3880e0e4 43 err = isp_flash_write( SOURCE_FILE );
okano 48:99cfe3a929ea 44 #else
okano 48:99cfe3a929ea 45 std::string str( SOURCE_FILE );
okano 48:99cfe3a929ea 46 if ( "" == get_file_name( str, SUFFIX_FILTER_STR ) )
okano 48:99cfe3a929ea 47 goto skip_ISP;
okano 48:99cfe3a929ea 48 err = isp_flash_write( str.c_str() );
okano 48:99cfe3a929ea 49 #endif
okano 30:e0d7524661ca 50
k4zuki 42:2b40666d8177 51 printf( "\r\n %d: %s\r\n\r\n",err,
okano 28:689c3880e0e4 52 err ?
okano 35:0b434ef4af49 53 SUMMARY_MESSAGE_FAIL :
okano 35:0b434ef4af49 54 SUMMARY_MESSAGE_SUCCESS
okano 8:b220fadbb3d8 55 );
okano 26:a63e73885b21 56
okano 28:689c3880e0e4 57 if ( err )
okano 19:7a7381e78025 58 error( " ** ISP failed\r\n" );
okano 26:a63e73885b21 59
okano 48:99cfe3a929ea 60 skip_ISP:
okano 48:99cfe3a929ea 61
okano 14:a7b9f74fb856 62 #ifdef AUTO_PROGRAM_START
okano 31:1a4d59d7bd72 63
okano 30:e0d7524661ca 64 start_target_in_normal_mode( TARGET_OPERATION_BAUD_RATE );
okano 16:cac2348cfcfb 65
okano 41:74b9ff21098f 66 printf( " ** The program programmed in flash has been started!!\r\n" );
okano 35:0b434ef4af49 67
okano 14:a7b9f74fb856 68 #endif
okano 14:a7b9f74fb856 69
okano 16:cac2348cfcfb 70 printf( " (now the mbed is working in \"serial through mode\")\r\n\r\n" );
okano 35:0b434ef4af49 71
okano 30:e0d7524661ca 72 start_success_indicator();
okano 21:e149d0bdbf4a 73 usb_serial_bridge_operation(); // doesn't return. infinite loop in this function
okano 20:98d7b5878e3e 74 }
okano 16:cac2348cfcfb 75