Op 23 september 2019 13:17:49 schreef MGP:
@Lambiek, misschien kun je mij ook vertellen of Proton de hardware I2C ondersteund?
Zo als ik al zei, I2C wordt gewoon ondersteund.
code:
I2Cin
Syntax
I2Cin Dpin, Cpin, Control, { Address }, [ Variable {, Variable…} ]
Overview
Receives a value from the I2C bus, and places it into variable/s.
Operators
Dpin is a Port.Pin constant that specifies the I/O pin that will be connected to the I2C device's
data line (SDA). This pin's I/O direction will be changed to input and will remain in that state after
the instruction is completed.
Cpin is a Port.Pin constant that specifies the I/O pin that will be connected to the I2C device's
clock line (SCL). This pin's I/O direction will be changed to output.
Variable is a user defined variable of type Bit, Byte, Word, Dword, Float, Array.
Control is a constant value or a byte sized variable expression.
Address is an optional constant value or a variable expression.
The I2Cin command operates as an I2C master, and may be used to interface with any device
that complies with the 2-wire I2C protocol. The most significant 7-bits of control byte contain the
control code and the slave address of the device being interfaced with. Bit-0 is the flag that indicates
whether a read or write command is being implemented.
For example, if we were interfacing to an external eeprom such as the 24LC32, the control
code would be %10100001 or $A1. The most significant 4-bits (1010) are the eeprom's unique
slave address. Bits 1 to 3 reflect the three address pins of the eeprom. And bit-0 is set to signify
that we wish to read from the eeprom. Note that this bit is automatically set by the I2Cin command,
regardless of its initial setting.
code:
I2Cout
Syntax
I2Cout Control, { Address }, [ OutputData ]
Overview
Transmit a value to the I2C bus, by first sending the control and optional address out of the
clock pin (SCL), and data pin (SDA).
Operators
Dpin is a Port.Pin constant that specifies the I/O pin that will be connected to the I2C device's
data line (SDA). This pin's I/O direction will be changed to input and will remain in that state after
the instruction is completed.
Cpin is a Port.Pin constant that specifies the I/O pin that will be connected to the I2C device's
clock line (SCL). This pin's I/O direction will be changed to output.
Control is a constant value or a byte sized variable expression.
Address is an optional constant, variable, or expression.
OutputData is a list of variables, constants, expressions and modifiers that informs I2Cout how
to format outgoing data. I2Cout can transmit individual or repeating bytes, convert values into
decimal, hex or binary text representations, or transmit strings of bytes from variable arrays.
These actions can be combined in any order in the OutputData list.
The I2Cout command operates as an I2C master and may be used to interface with any device
that complies with the 2-wire I2C protocol. The most significant 7-bits of control byte contain the
control code and the slave address of the device being interfaced with. Bit-0 is the flag that indicates
whether a read or write command is being implemented.
For example, if we were interfacing to an external eeprom such as the 24LC32, the control
code would be %10100000 or $A0. The most significant 4-bits (1010) are the eeprom's unique
slave address. Bits 1 to 3 reflect the three address pins of the eeprom. And Bit-0 is clear to signify
that we wish to write to the eeprom. Note that this bit is automatically cleared by the I2Cout
command, regardless of its initial value.