Syntax:
HI2CRestart
Command Availability:
Only available for microcontrollers with the hardware I2C or TWI module.
Explanation:
If the HI2C routines are operating in Master mode, this command will send a start and restart condition in a single command.
Note:
This command is also available on microcontrollers with a second hardware I2C port.
HI2C2Restart
Example:
do
HI2CReStart ;generate a start signal ' <<< the HI2CRestart instruction
HI2CSend(eepDev) ;inidcate a write
loop While HI2CAckPollState
HI2CSend(eepAddr_H) ;as two bytes
HI2CSend(eepAddr)
HI2CReStart
HI2CSend(eepDev + 1) ;indicate a read
eep_i = 0 ;loop consecutively
do while (eep_i < eepLen) ;these many bytes
eep_j = eep_i + 1 ;arrays begin at 1 not 0
if (eep_i < (eepLen - 1)) then
HI2CReceive(eepArray(eep_j), ACK) ;more data to get
else
HI2CReceive(eepArray(eep_j), NACK ) ;send NACK on last byte
end if
eep_i++ ;get set for next
loop
HI2CStopKey line: HI2CReStart — issues a start condition without first sending a stop, letting the loop retry addressing the same device (via HI2CAckPollState) or, on its second use below, switch the transaction from writing to reading.
See Also:
- HI2C Overview — category overview
- HI2CReceive — related command in the same category
- HI2CAckPollState — related command in the same category
Supported in <HI2C.H>

