Tiny Basic for PSoC (CY8CKIT-044 / TSoC / CY8CKIT-059 / CY8CKIT-062-BLE)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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 です。

豊四季タイニーBASIC確定版 | 電脳伝説

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

001-schematic.JPG

pins

002-pins.JPG

Tera Term log

000-TeraTerm-log.JPG

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)

2 Replies