51
1. Write_Byte Mode
2. Read_Byte Mode
3. Check Device (F75111)
4. SMBus_Clear
5 SMBus_Wait
6. SMBus_Busy
7. IO_Write
8. IO_Read
9. Define SMBus IO address
10. Define SMBus pin in SMBus.
int SMBus::Write_Byte(WORD dwSlave, BYTE pCmd, BYTE pByte)
{
this->SMBus_Clear();
// Clear SMBus data first
if (this->SMBus_Busy()) // Check SMBus busy or not, return busy if busy
return SMBUS_BUSY;
this->IO_Write(SMBHSTADD , dwSlave & ~1 ); // write address in first variable
this->IO_Write(SMBHSTCMD , pCmd ); // write command in second variable
this->IO_Write(SMBHSTDAT0 , pByte ); // write data in third variable
this->IO_Write(SMBHSTCNT , SMBHSTCNT_START | SMBHSTCNT_BYTE);
// Sent start command to SMBus control register
return (int)this->SMBus_Wait(); // return wait command when SMBus finish the job
}
int SMBus::Read_Byte(WORD dwSlave, BYTE pCmd, BYTE *pByte)
{
this->SMBus_Clear();
// Clear SMBus data first
if (this->SMBus_Busy())
// Check SMBus busy or not, return busy if busy
return SMBUS_BUSY;
this->IO_Write(SMBHSTADD , dwSlave | 1 ); // write address in first variable
this->IO_Write(SMBHSTCMD , pCmd ); // write command in second variable
this->IO_Write(SMBHSTCNT , SMBHSTCNT_START | SMBHSTCNT_BYTE);
// Sent start command to SMBus control register
Contents
1. Write Byte Mode
2. Read Byte Mode