Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
TWI_Start
TWI_Read
TWI_Write
466
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function TWI_Start() as byte
Returns
If there is no error function returns 0, otherwise returns 1.
Description
Determines if TWI bus is free and issues START signal.
Requires
TWI must be configured before using this function. See TWI_Init.
Example
if (TWI_Start = 1) 
...
end if
Prototype
sub function TWI_Read(dim ack as byteas byte
Returns
Returns one byte from the slave.
Description
Reads one byte from the slave, and sends not acknowledge signal if parameter
ack is 0, otherwise it sends acknowledge.
Requires
TWI must be configured before using this function. See TWI_Init.
Also, START signal needs to be issued in order to use this function. See
TWI_Start.
Example
Read data and send not acknowledge signal:
tmp = TWI_Read(0)
Prototype
sub procedure TWI_Write(dim data_ as byte)
Returns
Nothing.
Description
Sends data byte (parameter data_) via TWI bus.
Requires
TWI must be configured before using this function. See TWI_Init.
Also, START signal needs to be issued in order to use this function. See
TWI_Start.
Example
TWI_Write(0xA3)