Colibri Forth Cookbook

From Stm32World Wiki
Revision as of 12:56, 20 July 2023 by Niclas (talk | contribs) (Created page with "Useful Forth routines for Colibri family of products, listed in no particular order. This will also act as in informal tutorial in how to program the Colibri System. All exam...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Useful Forth routines for Colibri family of products, listed in no particular order. This will also act as in informal tutorial in how to program the Colibri System.

All examples assumes `hex` mode, unless otherwise stated or indicated.

Get GPIO pin

portA pin5 gpio@

Set GPIO pin

portA pin5 high gpio! ( set gpio PA5 high )
portA pin5 low gpio! ( set gpio PA5 low )

Write byte to I2C

41 1 61 >i2c1  ( writes 0x41, 0x42 and 0x43 to I2C address 0x61 )

Write 3 bytes to I2C

41 42 43 3 61 >i2c1  ( writes 0x41, 0x42 and 0x43 to I2C address 0x61 )

Read byte from I2C

1 61 i2c1> (reads 1 byte from I2C address 0x61 on to the stack )

Read 5 bytes from I2C

5 61 i2c1> ( reads 5 bytes from I2C address 0x61 )

Write byte to SPI

Write 5 bytes to SPI

Read byte from SPI

Read 5 bytes from SPI

Toggle Gpio every 1 second