LoginSignup
3
1

More than 5 years have passed since last update.

Macで lpc21isp を簡単に利用するためのアプリケーション

Last updated at Posted at 2014-12-08

このアプリは

UARTでISP(In-System Programming)でLPC1114にFlashする際、lpc21lisp を使用するたびにコマンドラインで実行するのが面倒なので、AppleScriptでラッピングするものです。
更に、USB-Serialアダプターの仮想装置名を調べてプルダウンリストから選択できるようにしたので、便利だど思います。
lpc21lisp は HEXもBINも書き込めるので、両方扱えるようにしています。
(注:このAppleScriptでは lpc21lisp が Maclpc21isp.appのフォルダー内においてあることを前提にしています。スクリプトエディタでAPPとして保存した後、Maclpc21lisp.appを右クリックし内容を表示した後、lpc21lispをドラッグ&ドロップでコピーしてからご使用ください。)

Flashに書き込む準備

ISPで書き込みをするには、USB-SerialアダプターのTX,RXをLPC1114FN28のRX(dp15), TX(dp16)と接続します。
また、LPC1114FN28は、リセット時にPIO0_1(dp24)をLOWにしておくことでISPモードに投入することができます。
24番ピンとGNDをつないだ後、リセットを行い、リセットしたあとで外します。

プログラムのソース

Maclpc21isp.scpt
-- spesial thanks to Yoshihiro TSUBOI for mac port of lpc21isp
-- see also http://mbed.org/users/ytsuboi/notebook/getting-started-with-mbed-lpc1114-ja/

set cmdPath to POSIX path of (path to me)
set cmdPath to "'" & cmdPath & "lpc21isp' -control "
set cmdSufix to " 115200 1200"
set openMSG to "書き込むファイルを選択してください"
set doCmdMSG to "書き込みを開始します。結果が表示されるまでお待ちください。"

set targetFileName to POSIX path of (choose file of type {"hex", "bin"} with prompt openMSG)
set fileExtention to characters -3 thru -1 of targetFileName as text
if fileExtention = "bin" then set cmdPath to cmdPath & " -bin "
set targetFileName to "'" & targetFileName & "'"
do shell script "ls /dev/tty.*"
set serealDevice to result as text
set orgDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set aList to text items of serealDevice
set AppleScript's text item delimiters to orgDelim
if the number of items of aList > 1 then
    choose from list aList
    set serealDevice to result as text
end if
set serealDevice to "'" & serealDevice & "'"
set cmd to cmdPath & targetFileName & " " & serealDevice & cmdSufix
display dialog cmd & return & return & doCmdMSG
do shell script cmd
display dialog result as string
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1