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

Information

日本語版がこのページ下半分にあります!

Japanese version is available lower half of this page.

Caution!

このプログラムでイカを焼くことはできません (^ ^;

"Ika-shouyu-poppoyaki" is a name of Japanese local food.
If I try to do a direct translation, it will be something like "Choo-choo grilled calamari with soy-sauce".
However, you may noticed already, it cannot be grilled by this program ;-)

ISP programming application on mbed

ISP program writes data into flash memory of target MCU.

This mbed program programs target MCU flash memory through UART. It uses "In-System Programming (ISP)" interface in target MCU (NXP LPC micro-controllers).

The ISP is done by PC with serial cable normally. The ISP protocol is executed software on a PC. The software reads a data file and transfers the data with the ISP protocol.
This program does same process of that. The mbed performs a function like "FlashMagic" or "lpc21isp".
(This program does not just copy the binary but also insert 4 byte checksum at address 0x1C.)

This program currently supports LPC1114, LPC1115, LPC81x, LPC82x, LPC1768/LPC1769 and LPC11U68/LPC11E68.

Information

For the LPC1768 and LPC1769, this program supports writing only. It cannot perform verifying.

Modification for targeting LPC82x series has been done by Mr. k4zuki. Thank you very much!
Modification for targeting LPC11U68/LPC11E68 has been done by HAPI- Tech. Thank you very much!!

/media/uploads/okano/copying_bin_e.png

How to execute

With this program, all you need to do is..

  1. Connect the mbed and the target (/RESET and /ISP_enable signals in are option. Those are not necessary if you set the target ISP mode manually)
  2. Rename your (binary) file to "bin" and copy into the mbed storage.
  3. Press reset button of mbed.
  • When the program completed successfully, you will find the LEDs on mbed blinks sequentially (LED1→LED2→LED3→LED4).
  • If it failed, the mbed reports it "Runtime error" by LEDs.
  • You can also monitor the progress and result on a terminal screen (mbed reports those by printf).
  • if you enabled "AUTO_PROGRAM_START", the program in the target will be started automatically.
  • from version 0.7, this program works as "USB-serial bridge" after the ISP writing done. The serial enabled target program (and if "AUTO_PROGRAM_START" is enabled, ) the UART will come up on the terminal screen after ISP completion. Please set "TARGET_OPERATION_BAUD_RATE" as baud rate of target program. The ISP speed can be set by "ISP_BAUD_RATE" separately.

/media/uploads/okano/files_in_storage_e.png

Information

If you don't have a file named "bin", the program will ask you which file you want to choose.
You will find a list of files on PC terminal and that interface let you select a file as source.
(The file names will appear in 8.3 format like old DOS.)

There are some options to bypassing the ISP to execute USB-serial through mode or erasing flash.

If there is a "bin" file, the program may work as usual.
(updated on 29-Jan-2015)

Sample of operation

Next picture is sample of the operation.

  1. The target (LPC1114) goes into ISP mode after first reset.
  2. mbed writes binary into flash in the target (binary size is 12668 bytes in this sample).
  3. when the writing completed, mbed starts reading the flash. the data is verified by comparing with original file.
  4. Asserting reset again with "ISP_enable pin" HIGH.
  5. The target starts to work with written binary (program). In this sample, the target sending character data on UART and toggling LED (GPIO) pin periodically.

/media/uploads/okano/isp_operation_sample_1114_e2.png

Recipe for adding chip support

Information

This section had been written by At_Zamasu_Zansu.
Thank you!

Describing how to add a target device.
Register new Device ID in target_table.cpp.

Targets defined in target_table.cpp.

target_table.cpp

target_param    target_table[]  = {
    { "unknown ttarget",        0xFFFFFFFF, 1024,    4096, 4096, UUENCODE, 0x10000200 },
    { "LPC1114FN28(FDH28)/102", 0x0A40902B, 4096,   32768, 4096, UUENCODE, 0x10000200 },
    { "LPC1114FN28(FDH28)/102", 0x1A40902B, 4096,   32768, 4096, UUENCODE, 0x10000200 },
    { "LPC810M021FN8",          0x00008100, 1024,    4096, 1024, BINARY,   0x10000300 },
    { "LPC811M001JDH16",        0x00008110, 2048,    8192, 1024, BINARY,   0x10000300 },
    { "LPC812M101JDH16",        0x00008120, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC812M101JD20",         0x00008121, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC812M101JDH20",        0x00008122, 4096,   16384, 1024, BINARY,   0x10000300 },
///added for LPC82x series
    { "LPC824M201JHI33",        0x00008241, 8192,   32768, 1024, BINARY,   0x10000300 },
    { "LPC822M101JHI33",        0x00008221, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC824M201JDH20",        0x00008242, 8192,   32768, 1024, BINARY,   0x10000300 },
    { "LPC822M101JDH20",        0x00008222, 4096,   16384, 1024, BINARY,   0x10000300 },
 
};

Structure of the table is defined in target_table.h.

target_table.h

typedef struct  taget_param_st {
    char            *type_name;
    int             id;
    int             ram_size;
    int             flash_size;
    int             sector_size;
    int             write_type;
    unsigned int    ram_start_address;
}

Items are defined in order of next sample in target_table.cpp

 {type_name, id, ram_size, flash_size, sector_size, write_type, ram_start_address}

Sample of how to do this

Data can be found in usermanual(UM) and datasheet. An example following.

In case of LPC82xx
UM10800 LPC82x User manual http://www.nxp.com/documents/user_manual/UM10800.pdf
LPC82x Product data sheet http://www.nxp.com/documents/data_sheet/LPC82X.pdf

  • type_name:
    • Table 322. Part identification numbers can be found by searching in UM. Pick up a device from the Table 322.
  • id:
    • Put a Hex coding value in Table 322.
  • ram_size:
    • Put target RAM size which can be found in datasheet by searching "Ordering options". Find the RAM size in Table2 (in bytes)
  • flash_size:
    • Put target flash size from the Table 2.
      The size should be calculated as "1KB = 1024" bytes.
  • sector_size:
    • A description of "The size of a sector is 1 KB and the size of a page is 64 Byte. One sector contains 16 pages" can be found in 25.5 General description, UM. Pick up taeget sector size and put it into the table in bytes. In this case, it will be 1024.
    • In case of LPC176x, the secotr size is 4KB for first 16 sectors and rest are 32K. So it cannot be defined by single value. For this type of targets, prepare a special value for the sector size. The program calculates the size when this value is detected.
  • ram_start_address:
    • Put an address of example which can be found by searching "UART ISP Write to RAM command" or "Write to RAM" in UM

Reference




イカ醤油ポッポ焼き

mbed用ISPプログラム

NXP製のマイコンは,内部フラッシュメモリへのプログラムの書き込みをUART経由で行うことができます.
通常,この作業はPC上のソフトウェア(たとえば"FlashMagic""lpc21isp"など)を用いて,PC上のファイルのデータを,UARTで接続したマイコンの内蔵フラッシュに書き込みます.

「イカ醤油ポッポ焼き」はmbedでそれらのソフトの代わりをさせるものです.mbedストレージ内に置いた「bin」と名付けられたファイルを読み,フラッシュへ書き込みます.
この書き込みを行う際には,アドレス0x1Cに置いておく必要のある4バイトのチェックサムも自動で追加されます.

現在サポートしているターゲットはLPC1114LPC1115LPC81xLPC82xLPC1768/LPC1769LPC11U68/LPC11E68です.

Information

LPC1768 and LPC1769 では書き込みのみがサポートされます.読み出し検証は実行されません.

LPC82xシリーズをターゲットとするための変更k4zukiさんがしてくださいました.ありがとうございます!
LPC11U68/LPC11E68をターゲットとするための変更HAPI- Techさんがしてくださいました.ありがとうございます!

/media/uploads/okano/copying_bin_j.png

美味しい料理法

このプログラムの動かし方は次の通り

  1. mbedとターゲット(書き込み対象のマイコン)を接続する (ターゲットを手動でISPモードに入れる場合には,/RESET と /ISP_enable は接続する必要はありません)
  2. 書き込みたいファイル(バイナリフォーマット)の名前を「bin」に変更して,mbed内にコピー
  3. mbedのリセットボタンを押す
  • 書き込みが無事に終了するとmbed上のLEDが順番に点滅を繰り返します(LED1→LED2→LED3→LED4).
  • もし何らかのエラーが発生して失敗した場合には"Runtime error"が発生した時のLED点灯となります.
  • またコンピュータのターミナルで状況や結果を確認することもできます(mbedがprintfで状況を出力しています)
  • "AUTO_PROGRAM_START"を有効にしてあれば,書き込み終了後,ターゲットのプログラムは自動的にスタートします.
  • バージョン0.7以降,このプログラムはISP書き込みの終了後にUSB-Serialブリッジとして動作するようにしてあります.ターゲットのプログラムがシリアルを使うもので(かつ"AUTO_PROGRAM_START"が有効で)あれば,入出力はそのままISP完了後のターミナルに現れます."TARGET_OPERATION_BAUD_RATE"はターゲットのプログラムが使うボーレートに合わせてください.ISPの書き込みに使うボーレートは "これとは別に"ISP_BAUD_RATE"で指定することができます.

/media/uploads/okano/files_in_storage_j2.png

Information

もし「bin」と名付けられたファイルが見つからなければ,(PCターミナル上で)どのファイルを選択するかが訊ねられます.
その表示を確認して,どのファイルを書き込むのかを選択してください.
「bin」ファイルが有れば,これまでと同じように動作します.(ファイル名はDOSのような8.3フォーマットで表示されます)

この他,ISPをバイパスしてシリアススルー・モードに行ったり,フラッシュを消すだけという操作も可能になっています.

(2015年1月29日にアップデートされました)

動作の例

次の図は動作の例です

  1. 最初のリセットによってターゲット(LPC1114)がISPモードに入ります
  2. mbedがターゲットのフラッシュにバイナリを書き込みます(この例では12668バイトのバイナリを書いています)
  3. 書き込みが終わるとフラッシュの読み出しを始めます.このデータを元のファイルとの比較し,検証を行います
  4. ISPイネーブル・ピンをHIGHにして再度リセットを行います
  5. ターゲットは書き込まれたプログラムの実行を開始します.この例ではターゲットは周期的にUARTへ文字データを送り,LEDを(GPIOピン)を点滅させます
  6. The target starts to work with written binary (program). The target sending character data on UART and toggling LED (GPIO) pin periodically.

/media/uploads/okano/isp_operation_sample_1114_j2.png


イカ醤油ポッポ焼き味付けレシピ

Information

この節はざますざんすさんが作成してくれました.
ありがとうございます!

これは,イカ醤油ポッポ焼きに新しいターゲットデバイスを追加する場合のレシピを纏めたものです.

必要事項:target_table.cpp へ新しいDevice ID register を追加する.

target_table.cppに記載されているターゲット一覧.

target_table.cpp

target_param    target_table[]  = {
    { "unknown ttarget",        0xFFFFFFFF, 1024,    4096, 4096, UUENCODE, 0x10000200 },
    { "LPC1114FN28(FDH28)/102", 0x0A40902B, 4096,   32768, 4096, UUENCODE, 0x10000200 },
    { "LPC1114FN28(FDH28)/102", 0x1A40902B, 4096,   32768, 4096, UUENCODE, 0x10000200 },
    { "LPC810M021FN8",          0x00008100, 1024,    4096, 1024, BINARY,   0x10000300 },
    { "LPC811M001JDH16",        0x00008110, 2048,    8192, 1024, BINARY,   0x10000300 },
    { "LPC812M101JDH16",        0x00008120, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC812M101JD20",         0x00008121, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC812M101JDH20",        0x00008122, 4096,   16384, 1024, BINARY,   0x10000300 },
///added for LPC82x series
    { "LPC824M201JHI33",        0x00008241, 8192,   32768, 1024, BINARY,   0x10000300 },
    { "LPC822M101JHI33",        0x00008221, 4096,   16384, 1024, BINARY,   0x10000300 },
    { "LPC824M201JDH20",        0x00008242, 8192,   32768, 1024, BINARY,   0x10000300 },
    { "LPC822M101JDH20",        0x00008222, 4096,   16384, 1024, BINARY,   0x10000300 },
 
};

上記コードは以下の構造を取っている.target_table.h に以下のコードがある.

target_table.h

typedef struct  taget_param_st {
    char            *type_name;
    int             id;
    int             ram_size;
    int             flash_size;
    int             sector_size;
    int             write_type;
    unsigned int    ram_start_address;
}

以下の順番にtarget_table.cppにコーディングする.

 {type_name, id, ram_size, flash_size, sector_size, write_type, ram_start_address}

作業の手順例

データはユーザマニュアル(UM)と Data sheet から検索する.以下に例を上げる.

LPC82xxの場合
UM10800 LPC82x User manual http://www.nxp.com/documents/user_manual/UM10800.pdf
LPC82x Product data sheet http://www.nxp.com/documents/data_sheet/LPC82X.pdf

  • type_name:
    • UMから Part identification numbers を検索すると,Table 322. Part identification numbersが現れる.Table 322より Table記載のDeviceを入力.
  • id:
    • UMから Part identification numbers を検索,Table 322. よりHex codingを入力.
  • ram_size:
    • Product data sheet よりOrdering options を検索しTable2より上記Deviceと同じターゲットのRAMサイズを記載(byte)
  • flash_size:
    • Product data sheet よりOrdering options を検索しTable2より上記Deviceと同じターゲットのFlashサイズを記載(byte)
      尚,1KBは1024byteにて計算
  • sector_size:
    • UMから Flash configuration を検索し25.5 General description に「The size of a sector is 1 KB and the size of a page is 64 Byte. One sector contains 16 pages.」と記載があるので,ターゲットのSectorサイズを記載(byte単位).今回の場合は1KBなので1024byte.
    • LPC176xシリーズのセクタサイズは,最初の16セクタが4KB,残りを32KBとしているため一定の値では表せません.これに対応するため特別な値を用意して,プログラム内でその値を検出した際には実際の構成に則した計算を行うようにしています.
  • ram_start_address:
    • UMからUART ISP Write to RAM command もしくは Write to RAM を検索.Example に書いてあるアドレスを記載する.

参考

日本語版だけの(何の役にも立たない)参考情報

Information

何故このプログラムが作られたか.そして何故こんな名前なのか.
こちらを御覧ください →→ イカ醤油ポッポ焼きはイカにして生まれたか(´(ェ)`;

このプログラムを作ってみるきっかけになったツイート.

(´(ェ)`)

Committer:
okano
Date:
Wed Aug 12 08:34:47 2015 +0000
Revision:
52:4b1a0488e0e3
Parent:
49:380e7be429ef
LPC1115 support added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 48:99cfe3a929ea 1 #include "mbed.h"
okano 48:99cfe3a929ea 2 #include "dir_handling.h"
okano 48:99cfe3a929ea 3 #include "_user_settings.h"
okano 48:99cfe3a929ea 4 #include "DirectoryList.h"
okano 48:99cfe3a929ea 5 #include "isp.h"
okano 48:99cfe3a929ea 6
okano 48:99cfe3a929ea 7 #include <iostream>
okano 48:99cfe3a929ea 8 #include <string>
okano 48:99cfe3a929ea 9 #include <cctype>
okano 48:99cfe3a929ea 10 #include <algorithm>
okano 48:99cfe3a929ea 11
okano 48:99cfe3a929ea 12 extern Serial pc;
okano 48:99cfe3a929ea 13 extern BusOut leds;
okano 48:99cfe3a929ea 14
okano 48:99cfe3a929ea 15 void show_file_list( std::vector<std::string> list );
okano 48:99cfe3a929ea 16 void user_action_waiting_indicator();
okano 48:99cfe3a929ea 17
okano 48:99cfe3a929ea 18
okano 48:99cfe3a929ea 19 std::string get_file_name( std::string &default_path, const char *suffix )
okano 48:99cfe3a929ea 20 {
okano 48:99cfe3a929ea 21 Ticker led_blink;
okano 48:99cfe3a929ea 22 int last_slash;
okano 48:99cfe3a929ea 23
okano 48:99cfe3a929ea 24 last_slash = (int)default_path.rfind( "/" );
okano 48:99cfe3a929ea 25
okano 48:99cfe3a929ea 26 if ( last_slash == std::string::npos ) {
okano 48:99cfe3a929ea 27 default_path.clear();
okano 48:99cfe3a929ea 28 return ( default_path );
okano 48:99cfe3a929ea 29 }
okano 48:99cfe3a929ea 30
okano 48:99cfe3a929ea 31 string file_name( default_path.c_str() + last_slash + 1 );
okano 48:99cfe3a929ea 32 string path_name( default_path.c_str(), default_path.c_str() + last_slash );
okano 48:99cfe3a929ea 33
okano 48:99cfe3a929ea 34 //printf( "path_name : %s\r\n", path_name.c_str() );
okano 48:99cfe3a929ea 35 //printf( "file_name : %s\r\n", file_name.c_str() );
okano 48:99cfe3a929ea 36
okano 48:99cfe3a929ea 37 file_name.push_back( '.' );
okano 49:380e7be429ef 38 std::transform( file_name.begin(), file_name.end(), file_name.begin(), (int (*)(int))std::toupper );
okano 49:380e7be429ef 39 // "toupper" function cast had been done for latest mbed-lib (checked with rev.100).
okano 49:380e7be429ef 40 // see --> http://stackoverflow.com/questions/7131858/stdtransform-and-toupper-no-matching-function
okano 48:99cfe3a929ea 41
okano 48:99cfe3a929ea 42 DirectoryList dir( path_name );
okano 48:99cfe3a929ea 43 std::vector<std::string> list;
okano 48:99cfe3a929ea 44
okano 48:99cfe3a929ea 45 for ( int i = 0; i < dir.size(); i++ ) {
okano 48:99cfe3a929ea 46 if ( dir[ i ] == file_name ) {
okano 48:99cfe3a929ea 47 return ( default_path );
okano 48:99cfe3a929ea 48 }
okano 48:99cfe3a929ea 49
okano 48:99cfe3a929ea 50 if ( *suffix == '*' ) {
okano 48:99cfe3a929ea 51 list = dir;
okano 48:99cfe3a929ea 52 } else {
okano 48:99cfe3a929ea 53 //printf( "-- [%s][%d]\r\n", dir[ i ].c_str(), dir[ i ].find( ".BIN" ) );
okano 48:99cfe3a929ea 54 //if ( (8 == dir[ i ].find( ".BIN" )) && (0 != dir[ i ].find( "IKA" )) ) {
okano 48:99cfe3a929ea 55 if ( (9 == dir[ i ].find( suffix )) ) {
okano 48:99cfe3a929ea 56 list.push_back( dir[ i ] );
okano 48:99cfe3a929ea 57 }
okano 48:99cfe3a929ea 58 }
okano 48:99cfe3a929ea 59 }
okano 48:99cfe3a929ea 60
okano 48:99cfe3a929ea 61 led_blink.attach( &user_action_waiting_indicator, 0.05 );
okano 48:99cfe3a929ea 62
okano 48:99cfe3a929ea 63 printf( "\r\n WARNING : No file which has name of \"%s\" was found.\r\n", default_path.c_str() );
okano 48:99cfe3a929ea 64 printf( " now showing \"%s\" directory to select a source file.\r\n\r\n", path_name.c_str() );
okano 48:99cfe3a929ea 65
okano 48:99cfe3a929ea 66 if ( !list.size() ) {
okano 48:99cfe3a929ea 67 printf( " WARNING : No file which has suffix of \"%s\" was found.\r\n", suffix );
okano 48:99cfe3a929ea 68 default_path.clear();
okano 48:99cfe3a929ea 69 return ( default_path );
okano 48:99cfe3a929ea 70 }
okano 48:99cfe3a929ea 71
okano 48:99cfe3a929ea 72 #define FORMAT_FOR_SELECTED_FILE_NAME " selected file : [%3d] : \"%-12s\" \r"
okano 48:99cfe3a929ea 73
okano 48:99cfe3a929ea 74 //printf( " ==== directory by \"%s/*.%s\" (excluding \"%s/ika*.bin\") ====\r\n", path_name.c_str(), suffix, path_name.c_str() );
okano 48:99cfe3a929ea 75 printf( " ==== directory by \"%s/*.%s\", %d files ====\r\n", path_name.c_str(), suffix, list.size() );
okano 48:99cfe3a929ea 76
okano 48:99cfe3a929ea 77 show_file_list( list );
okano 48:99cfe3a929ea 78
okano 48:99cfe3a929ea 79 int done = false;
okano 48:99cfe3a929ea 80 int index = 0;
okano 48:99cfe3a929ea 81 int c;
okano 48:99cfe3a929ea 82
okano 48:99cfe3a929ea 83 printf( FORMAT_FOR_SELECTED_FILE_NAME, index, list[ index ].c_str() );
okano 48:99cfe3a929ea 84 fflush( stdout );
okano 48:99cfe3a929ea 85
okano 48:99cfe3a929ea 86 while ( !done ) {
okano 48:99cfe3a929ea 87 if ( pc.readable() ) {
okano 48:99cfe3a929ea 88 switch ( c = pc.getc() ) {
okano 48:99cfe3a929ea 89 case '\r' :
okano 48:99cfe3a929ea 90 case '\n' :
okano 48:99cfe3a929ea 91 done = true;
okano 48:99cfe3a929ea 92 break;
okano 48:99cfe3a929ea 93
okano 48:99cfe3a929ea 94 case 'e' :
okano 48:99cfe3a929ea 95 case 'E' :
okano 48:99cfe3a929ea 96 printf( "\r\n Erasing the flash memory\r\n" );
okano 48:99cfe3a929ea 97 default_path = "\xFF";
okano 48:99cfe3a929ea 98 return ( default_path );
okano 48:99cfe3a929ea 99 //break;
okano 48:99cfe3a929ea 100
okano 48:99cfe3a929ea 101 case 'a' :
okano 48:99cfe3a929ea 102 case 'A' :
okano 48:99cfe3a929ea 103 case 'c' :
okano 48:99cfe3a929ea 104 case 'C' :
okano 48:99cfe3a929ea 105 printf( "\r\n Aborted to cancel the ISP execution\r\n" );
okano 48:99cfe3a929ea 106 default_path.clear();
okano 48:99cfe3a929ea 107 return ( default_path );
okano 48:99cfe3a929ea 108 //break;
okano 48:99cfe3a929ea 109
okano 48:99cfe3a929ea 110 case '0' :
okano 48:99cfe3a929ea 111 case '1' :
okano 48:99cfe3a929ea 112 case '2' :
okano 48:99cfe3a929ea 113 case '3' :
okano 48:99cfe3a929ea 114 case '4' :
okano 48:99cfe3a929ea 115 case '5' :
okano 48:99cfe3a929ea 116 case '6' :
okano 48:99cfe3a929ea 117 case '7' :
okano 48:99cfe3a929ea 118 case '8' :
okano 48:99cfe3a929ea 119 case '9' :
okano 48:99cfe3a929ea 120 index = c - '0';
okano 48:99cfe3a929ea 121 index = ( (list.size() - 1) < index ) ? (list.size() - 1) : index;
okano 48:99cfe3a929ea 122 break;
okano 48:99cfe3a929ea 123 case '?' :
okano 48:99cfe3a929ea 124 show_file_list( list );
okano 48:99cfe3a929ea 125 break;
okano 48:99cfe3a929ea 126
okano 48:99cfe3a929ea 127
okano 48:99cfe3a929ea 128 case 0x1B :
okano 48:99cfe3a929ea 129 if ( 0x5B == pc.getc() )
okano 48:99cfe3a929ea 130 // arrow key pressed
okano 48:99cfe3a929ea 131 switch ( c = pc.getc() ) {
okano 48:99cfe3a929ea 132 case 0x41 :
okano 48:99cfe3a929ea 133 case 0x43 :
okano 48:99cfe3a929ea 134 index += ( index == (list.size() - 1) ) ? 0 : 1;
okano 48:99cfe3a929ea 135 break;
okano 48:99cfe3a929ea 136 case 0x42 :
okano 48:99cfe3a929ea 137 case 0x44 :
okano 48:99cfe3a929ea 138 index -= ( index == 0 ) ? 0 : 1;
okano 48:99cfe3a929ea 139 break;
okano 48:99cfe3a929ea 140 default :
okano 48:99cfe3a929ea 141 break;
okano 48:99cfe3a929ea 142 }
okano 48:99cfe3a929ea 143 }
okano 48:99cfe3a929ea 144
okano 48:99cfe3a929ea 145 printf( FORMAT_FOR_SELECTED_FILE_NAME, index, list[ index ].c_str() );
okano 48:99cfe3a929ea 146 fflush( stdout );
okano 48:99cfe3a929ea 147 }
okano 48:99cfe3a929ea 148 }
okano 48:99cfe3a929ea 149
okano 48:99cfe3a929ea 150 default_path.clear();
okano 48:99cfe3a929ea 151 default_path = path_name + "/" + list[ index ];
okano 48:99cfe3a929ea 152
okano 48:99cfe3a929ea 153 printf( "\r\n flash writing source file : \"%s\"\r\n\r\n", default_path.c_str() );
okano 48:99cfe3a929ea 154
okano 48:99cfe3a929ea 155 return ( default_path );
okano 48:99cfe3a929ea 156 }
okano 48:99cfe3a929ea 157
okano 48:99cfe3a929ea 158 void show_file_list( std::vector<std::string> list )
okano 48:99cfe3a929ea 159 {
okano 48:99cfe3a929ea 160 int width;
okano 48:99cfe3a929ea 161 int height;
okano 48:99cfe3a929ea 162 int d_i;
okano 48:99cfe3a929ea 163
okano 48:99cfe3a929ea 164 width = (list.size() / 5) + 1;
okano 48:99cfe3a929ea 165 width = (4 < width) ? 4 : width;
okano 48:99cfe3a929ea 166 height = (list.size() + (width - 1)) / width;
okano 48:99cfe3a929ea 167
okano 48:99cfe3a929ea 168 for ( int i = 0; i < height; i++ ) {
okano 48:99cfe3a929ea 169 for ( int j = 0; j < width; j++ ) {
okano 48:99cfe3a929ea 170
okano 48:99cfe3a929ea 171 d_i = i + j * height;
okano 48:99cfe3a929ea 172
okano 48:99cfe3a929ea 173 if ( list.size() <= d_i )
okano 48:99cfe3a929ea 174 break;
okano 48:99cfe3a929ea 175
okano 48:99cfe3a929ea 176 printf( " %3d : %-12s", d_i, list[ d_i ].c_str() );
okano 48:99cfe3a929ea 177 }
okano 48:99cfe3a929ea 178 printf( "\r\n" );
okano 48:99cfe3a929ea 179 }
okano 48:99cfe3a929ea 180 printf( "\r\n" );
okano 48:99cfe3a929ea 181 printf( " ** Use arrow key (up/down or left/right) to select a file\r\n" );
okano 48:99cfe3a929ea 182 printf( " ** or ..\r\n" );
okano 48:99cfe3a929ea 183 printf( " ** press [a] key for abort and go to serial through mode\r\n" );
okano 48:99cfe3a929ea 184 printf( " ** press [e] key for erasing flash\r\n" );
okano 48:99cfe3a929ea 185 printf( " ** press [?] key to display this message again\r\n\r\n" );
okano 48:99cfe3a929ea 186 }
okano 48:99cfe3a929ea 187
okano 48:99cfe3a929ea 188
okano 48:99cfe3a929ea 189 void user_action_waiting_indicator()
okano 48:99cfe3a929ea 190 {
okano 48:99cfe3a929ea 191 static int i = 0;
okano 48:99cfe3a929ea 192
okano 48:99cfe3a929ea 193 if ( (i == 0) || (i == 3) )
okano 48:99cfe3a929ea 194 leds = 0xF;
okano 48:99cfe3a929ea 195 else
okano 48:99cfe3a929ea 196 leds = 0x0;
okano 48:99cfe3a929ea 197
okano 48:99cfe3a929ea 198 i++;
okano 48:99cfe3a929ea 199 i &= 0xF;
okano 48:99cfe3a929ea 200 }
okano 48:99cfe3a929ea 201
okano 48:99cfe3a929ea 202
okano 48:99cfe3a929ea 203