overview="This part of the platform interface groups functions related to the I2C interface(s) of the MCU. Currently only the I2C master mode is supported by eLua.",
-- Data structures, constants and types
structures=
{
{text=[[//I2Cspeed
enum
{
PLATFORM_I2C_SPEED_SLOW=100000,
PLATFORM_I2C_SPEED_FAST=400000
};]],
name="I2C speed",
desc="Constants used to configure the speed of the I2C interface."
},
{text=[[//I2Cdirection
enum
{
PLATFORM_I2C_DIRECTION_TRANSMITTER,
PLATFORM_I2C_DIRECTION_RECEIVER
};
]],
name="I2C transfer direction",
desc="Constants used to select the I2C master transfer direction (transmitter or receiver)."
desc=[[This function is used to initialize the parameters of the I2C interface. <span class="warning">NOTE</span>: currently, only master I2C mode is implemented in eLua.]],
args=
{
"$id$ - I2C interface ID.",
"$speed$ - the speed of the interface, can be either $PLATFORM_I2C_SPEED_SLOW$ or $PLATFORM_I2C_SPEED_FAST$ as defined @#i2c_speed@here@"
},
ret="the actual speed set for the I2C interface. Depending on the hardware, this may have a different value than the $speed$ argument."
},
{sig="void #platform_i2c_send_start#( unsigned id );",
desc="Send an I2C START condition on the specified interface.",
args="$id$ - I2C interface ID."
},
{sig="void #platform_i2c_send_stop#( unsigned id );",
desc="Send an I2C STOP condition on the specified interface.",
args="$id$ - I2C interface ID."
},
{sig="int #platform_i2c_send_address#( unsigned id, u16 address, int direction );",
desc=[[Send an address on the I2C with the specified transfer direction (transmitter or receiver).]],
args=
{
"$id$ - I2C interface ID.",
"$address$ - I2C peripheral address.",
"$direction$ - transfer direction, either $PLATFORM_I2C_DIRECTION_TRANSMITTER$ or $PLATFORM_I2C_DIRECTION_RECEIVER$ as defined @#i2c_transfer_direction@here@."
},
ret="1 for success, 0 for error."
},
{sig="int #platform_i2c_send_byte#( unsigned id, u8 data );",
desc="Send a byte on the I2C interface.",
args=
{
"$id$ - I2C interface ID.",
"$data$ - the byte to send.",
},
ret="1 for success, 0 for error.",
},
{sig="int #platform_i2c_recv_byte#( unsigned id, int ack );",
desc="Receive a byte from the I2C interface and send a positive (ACK) or negative (NAK) acknowledgement.",
args=
{
"$id$ - I2C interface ID.",
"$ack$ - 1 to send ACK, 0 to send NAK. If $ACK$ is 0 a STOP condition will automatically be generated after the NAK."