- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many years ago, when Wizardy was the game and 6502 was the CPU,
the only computer language for the rest of us was BASIC.
それは昔、ゲームといえばスペースインベーダーで、
マイコンといえばNECの8から始まる型番のやつだったころ
個人が手をだせるコンピュータ言語はベーシック(BASIC)でした。
Recently I had chance(s) to connect a full keyboard and TFT to a PSoC board.
Naturally next project would be a PC wannabe.
最近、PSoC ボードにフルキーボードを付けたり、TFT を付けたりする機会がありました。
当然、次にくるのはなんちゃってPCですよね。
But I'm afraid that I'm too old to port Linux onto PSoC 4. (Does age matter, btw?)
しかし、Linux を PSoC 4 に移植するのに私は歳をとりすぎたと思います。(歳の問題かい?)
So, I surfed the Internet and found an ancient treasure, the TOYOSHIKI TinyBasic,
which is a C implementation of the TinyBasic.
そんな訳で、ネットを徘徊していたら古代の秘宝、豊四季タイニーBASICを見つけました、
これは C言語で実装された TinyBaisc です。
Porting to other platform required to implement the following 3 functions.
他のプラットフォームへの移植には下記の3関数を実装する必要がありました。
===========
c_putch(c)
char c_getch(void)
char c_kbhit(void)
===========
so I added the following 3 functions into my tty_utils library.
その為、私は自分の tty_utils ライブラリに下記の3関数を追加しました。
===========
void printc(char c)
uint8_t get_char(void)
int get_size_of_rx(void)
===========
Then I got
結果として
====================
// Terminal control
#define c_putch(c) printc(c)
char c_getch(void){
char c ;
c = get_char() ;
return( c ) ;
}
char c_kbhit(void)
{
if (get_size_of_rx()) {
return 1 ;
} else {
return 0 ;
}
}
====================
Last but not least, since I was porting from the linux version, KEY_ENTER was 10 (LF)
but for the Windows platform I modified it to 13(CR).
最後に改行は、移植元が Linux だったので 10 (LF) になっていましたが、
Windows で使用することを考えて 13 (CR) に変更しておきました。
===========
// for linux
// #define KEY_ENTER 10
// for Windows
#define KEY_ENTER 13
===========
Now in the PSoC Creator, I used CY8CKIT-044
Note: Versions for TSoC, CY8CKIT-059, CY8CKIT-062-BLE are also attached.
さて、いよいよ PSoC Creator の出番ですが、今回は CY8CKIT-044 を使用しました。
※ TSoC 版、CY8CKIT-59版, CY8CKIT-062-BLE版も添付してあります。
schematic
pins
Tera Term log
Well, later I noticed that the ad-lib program I wrote above had a bug.
I needed to have the value s cleared before the for loop.
25 s = 0
otherwise, we will get quite wrong result from the second loop. orz
さて、上に書いた即興のベーシックプログラムにはバグがありました。
FOR ループに入る前に変数 s を初期化しておく必要があったのです。
25 s = 0
これを忘れた為に 2週目からの計算はカオスなことになっていました。 orz
31-Mar-2020
moto
P.S. A version for TSoC added (31-Mar-2020)
P.S.2 Another version for CY8CKIT-059 (5LP) added (31-Mar-2020)
P.S.3 Another version for CY8CKIT-062-BLE (PSoC 6) added (1-Apr-2020)
- Labels:
-
PSoC 345 LP
-
PSoC 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So it's 5th of May. In Japan this is supposed to be a day of boys.
今日は五月五日で、娑婆では子供の日と呼ばれています。
Anyway, during this Golden Week, I was playing with some programs
and while debugging my MCU Tester sample
この自粛ゴールデンウィーク中、プログラムをいじっていたのですが、
MCU Tester というサンプルをデバッグしていた時に
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-044 version)
I decided that "Backspace" is crucial for this kind of application.
So I implemented "Backspace" in my "tty_utils."
この手のアプリでバックスペース使えないのはキツ過ぎだと気が付いて
tty_utils に手を入れてバックスペースに対応させました。
tty_utils a utility sample for CLI type program
And now MCU Tester seems to be happier.
But it reminded me of something else.
Well, TinyBasic surely deserve for Backspace, too.
これで MCU Tester はそれなりに使いやすくなったのですが
何か忘れちゃいけないサンプルがあったことに気が付きました。
TinyBasic もバックスペースないとまずいよねと。
So I came back this discussion, and to my surprise this sample was prepared for 4 boards!?
という訳でこのスレッドに戻ってきたのですが、なんとサポートしている基板が4種類 !?
... I did it, but I may not want to write more programs today...
・・・仕方ないからやりました、もう今日はプログラムを書きたくないかも知れません・・・
moto
P.S. 19-Jun-2020
For PSoC 6 version, I needed some delay after each printc() or list output stalled with print "string".
printc() の後に少しディレイを入れないとリストがハングする現象が見えたのでマイナー修正を加えました。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Moto-san,
We appreciate your contribution for this.
Best regards.