トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

PRG-cFORTH

  ESP32 cforth

GIT

https://github.com/MitchBradley/cforth.git

install

PRG-esp32

git clone https://github.com/MitchBradley/cforth.git
cd ./cforth/build/esp32
make
COMPORT=/dev/ttyUSB0 make flash

Hello world.

ok : HELLOW  ( -- )  CR ." Hello, world!" ;
ok HELLOW

emit star

ok : emit-star ( the ASCII value for the character '*' )  2a EMIT ;

gpio

コマンド
gpio-is-input-pulldown
gpio-is-input-pullup
gpio-is-input
gpio-is-output-open-drain
gpio-is-output
gpio-toggle
gpio-pin!
gpio-pin@

GPIO2 の LED を点灯・消灯

ok 2 gpio-is-output 
ok 0 2 gpio-pin!    
ok 1 2 gpio-pin!

GPIO18 の LED を点灯・消灯

# BPI-BIT
ok decimal
ok 18 gpio-is-output
ok 0 18 gpio-pin!
ok 1 18 gpio-pin!

INP

ok decimal
ok 35 gpio-is-input
ok 35 gpio-pin@

ADC

hall@
adc@
adc-atten!
adc-width!

 ADC を使う1 ( BPI-BIT 温度 )

ok 2 adc-width!   \ set 11 bit precision
ok 2 6 adc-atten!  \ set ADC1_CH6 :: 2 is for 6dB attenuation - range from 0 - 1.8V
ok 6 adc@     \ get adc 
ok . 
327
ok

ADC を使う2 ( BPI-BIT 照度 )

ok 2 adc-width!   \ 11 bit precision
ok 2 0 adc-atten!  \ ADC1_CH0 :: 2 is for 6dB attenuation - range from 0 - 1.8V
ok 2 3 adc-atten!  \ ADC1_CH3 :: 2 is for 6dB attenuation - range from 0 - 1.8V

ok 0 adc@
ok 3 adc@