Difference between revisions of "Colibri Forth Cookbook"
Jump to navigation
Jump to search
(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...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
All examples assumes `hex` mode, unless otherwise stated or indicated. | All examples assumes `hex` mode, unless otherwise stated or indicated. | ||
+ | |||
+ | == (Re)Initialize I2C == | ||
+ | i2c1-init | ||
+ | |||
+ | == (Re)Initialize SPI == | ||
+ | spi1-init | ||
+ | |||
+ | == Select expansion slot == | ||
+ | 2 io-slot! ( set the expansion slot multiplexers to IO2 | ||
+ | |||
+ | == Load and Run program from expansion module's EEPROM == | ||
+ | |||
+ | == Save new program to expansion module's EEPROM == | ||
== Get GPIO pin == | == Get GPIO pin == | ||
Line 10: | Line 23: | ||
portA pin5 low gpio! ( set gpio PA5 low ) | portA pin5 low gpio! ( set gpio PA5 low ) | ||
+ | |||
+ | == Set multiple GPIO pins == | ||
+ | portA pin5 pin6 or pin15 or high gpio! ( set gpio PA5, PA6 and PA15 high in a single write ) | ||
== Write byte to I2C == | == Write byte to I2C == | ||
Line 18: | Line 34: | ||
== Read byte from I2C == | == Read byte from I2C == | ||
− | 1 61 i2c1> (reads 1 byte from I2C address 0x61 on to the stack ) | + | 1 61 i2c1> ( reads 1 byte from I2C address 0x61 on to the stack ) |
== Read 5 bytes from I2C == | == Read 5 bytes from I2C == |
Latest revision as of 13:03, 20 July 2023
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.
(Re)Initialize I2C
i2c1-init
(Re)Initialize SPI
spi1-init
Select expansion slot
2 io-slot! ( set the expansion slot multiplexers to IO2
Load and Run program from expansion module's EEPROM
Save new program to expansion module's EEPROM
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 )
Set multiple GPIO pins
portA pin5 pin6 or pin15 or high gpio! ( set gpio PA5, PA6 and PA15 high in a single write )
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 )