![]() |
![]() |
|
SMBusLibrary
1.0
|
Macros | |
| #define | I2C_WRITE 0 |
| #define | I2C_READ 1 |
| #define | SMB_SW_TIMEOUT (10000) |
| #define | SMB_TIMEOUT_WAIT_CYCLES (200) |
| #define | SMB_POWER_STARTUP_DELAY (16) |
Functions | |
| void | SMBus_PHY_disable (SMBus *smbus) |
| Disables the PHY and Data Link layer. More... | |
| void | SMBus_PHY_targetEnable (SMBus *smbus) |
| Enables the PHY and Data Link layer for target operation. More... | |
| void | SMBus_PHY_targetInit (SMBus *smbus, I2C_Regs *i2cAddr) |
| Initializes the I2C Target module supporting SMBus functionality. More... | |
| void | SMBus_PHY_targetEnableInt (SMBus *smbus) |
| Enables the I2C interrupts. More... | |
| void | SMBus_PHY_targetDisableInt (SMBus *smbus) |
| Disables the I2C interrupts. More... | |
| SMBus_State | SMBus_PHY_targetProcessInt (SMBus *smbus) |
| I2C Interrupt Service routine for SMBus Target. More... | |
| void | SMBus_PHY_targetSetPECCount (SMBus *smbus, uint16_t length) |
| Sets the number of bytes left to be counted. More... | |
| void | SMBus_PHY_targetManualACK (SMBus *smbus, bool ackVal) |
| Send a Manual ACK or NACK depending on data validity. More... | |
| void | SMBus_Phy_ARP_TARGET_ADDR_Reset (SMBus *smbus) |
| Resets the Target's Address based on the ARP Status. More... | |
| void | SMBus_PHY_controllerEnable (SMBus *smbus) |
| Enables the PHY and Data Link layer. More... | |
| uint8_t | SMBus_Phy_ARP_Get_Write_Status (SMBus *smbus) |
| Returns the Write Bus direction of the ARP transaction. More... | |
| uint8_t | SMBus_Phy_ARP_Get_Read_Status (SMBus *smbus) |
| Returns the Read Bus direction of the ARP transaction. More... | |
| void | SMBus_PHY_controllerInit (SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk) |
| Initializes the I2C Controller module supporting SMBus functionality. More... | |
| void | SMBus_PHY_controllerEnableInt (SMBus *smbus) |
| Enables the I2C interrupts for Controller. More... | |
| void | SMBus_PHY_controllerDisableInt (SMBus *smbus) |
| Disables the I2C interrupts for Controller. More... | |
| void | SMBus_PHY_controllerSendStop (SMBus *smbus) |
| Generate Stop condition if it hasn't been sent. More... | |
| void | SMBus_PHY_controllerStartTx (SMBus *smbus, uint8_t targetaddr, uint16_t length, SMBus_Stop stopFlag, uint8_t setPEC) |
| Start a TX transfer. More... | |
| void | SMBus_PHY_controllerStartRx (SMBus *smbus, uint8_t targetaddr, uint16_t length, SMBus_Start startFlag, SMBus_Stop stopFlag, SMBus_Auto_Ack ackFlag, uint8_t setPEC) |
| Start a RX transfer. More... | |
| SMBus_State | SMBus_PHY_controllerProcessInt (SMBus *smbus) |
| I2C Interrupt Service routine for SMBus Controller. More... | |
| void | SMBus_PHY_controllerEnableHostNotify (SMBus *smbus) |
| Enable the hardware functionality to respond to Host Default address (0b000_1000) More... | |
| void | SMBus_PHY_controllerDisableHostNotify (SMBus *smbus) |
| Disable the hardware functionality to respond to Host Default address (0b000_1000) More... | |
| #define I2C_WRITE 0 |
R/W state when write is received
| #define I2C_READ 1 |
R/W state when read is received
| #define SMB_SW_TIMEOUT (10000) |
Software timeout to avoid lockup
Referenced by SMBus_PHY_controllerStartRx().
| #define SMB_TIMEOUT_WAIT_CYCLES (200) |
Delay cycles after reseting the I2C interface on timeout
Referenced by SMBus_NWK_targetProcessTimeout().
| #define SMB_POWER_STARTUP_DELAY (16) |
Delay cycles for module Power up
Referenced by SMBus_PHY_controllerEnable(), and SMBus_PHY_targetEnable().
| void SMBus_PHY_disable | ( | SMBus * | smbus | ) |
Disables the PHY and Data Link layer.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::phy, SMBus_Ctrl::phyEn, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_NWK_controllerReset(), SMBus_NWK_targetProcessTimeout(), SMBus_PHY_controllerInit(), and SMBus_PHY_targetInit().
| void SMBus_PHY_targetEnable | ( | SMBus * | smbus | ) |
Enables the PHY and Data Link layer for target operation.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::phy, SMBus_Ctrl::phyEn, SMB_POWER_STARTUP_DELAY, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_NWK_targetProcessTimeout(), and SMBus_PHY_targetInit().
| void SMBus_PHY_targetInit | ( | SMBus * | smbus, |
| I2C_Regs * | i2cAddr | ||
| ) |
Initializes the I2C Target module supporting SMBus functionality.
| *smbus | Pointer to SMBus structure |
| i2cAddr | Base address of I2C module |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::phy, SMBus_Phy::SMBus_Phy_AckPending, SMBus_PHY_disable(), SMBus_Phy::SMBus_Phy_i2cBase, SMBus_PHY_targetEnable(), and SMBus_Ctrl::swackEn.
Referenced by SMBus_targetInit().
| void SMBus_PHY_targetEnableInt | ( | SMBus * | smbus | ) |
Enables the I2C interrupts.
This function enables the I2C Start ,Stop, RX ,TX, Timeout interrupts. SMBus_PHY_targetInit() must be called before this function.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_targetEnableInt().
| void SMBus_PHY_targetDisableInt | ( | SMBus * | smbus | ) |
Disables the I2C interrupts.
This function disables the I2C Start ,Stop, RX ,TX, Timeout interrupts.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_targetDisableInt().
| SMBus_State SMBus_PHY_targetProcessInt | ( | SMBus * | smbus | ) |
I2C Interrupt Service routine for SMBus Target.
Handles the interrupts from I2C module and passes the information to the network layer. Should be called by application when acting as a target and an I2C interrupt is detected. Note that a target can also act as Host in some scenarios (like Host notify), so the ISR needs to handle such cases.
| smbus | Pointer to SMBus structure |
References SMBus_Status::bits, SMBus_Status::pecErr, SMBus::phy, SMBus_NWK_controllerProcessNACK(), SMBus_NWK_controllerProcessStop(), SMBus_NWK_controllerProcessTx(), SMBus_NWK_controllerTxDone(), SMBus_NWK_targetArbLost(), SMBus_NWK_targetProcessRx(), SMBus_NWK_targetProcessStart(), SMBus_NWK_targetProcessStop(), SMBus_NWK_targetProcessTimeout(), SMBus_NWK_targetProcessTx(), SMBus_Phy::SMBus_Phy_AckPending, SMBus_Phy::SMBus_Phy_i2cBase, SMBus_State_PECError, SMBus_State_Target_NTR, and SMBus::status.
Referenced by SMBus_targetProcessInt().
| void SMBus_PHY_targetSetPECCount | ( | SMBus * | smbus, |
| uint16_t | length | ||
| ) |
Sets the number of bytes left to be counted.
This function should be called when the number of bytes left to be received is known by the application. Once written, the I2C hardware will calculate the PEC and either indicate that the PEC was checked correctly, or than a PEC error occurred.
| smbus | Pointer to SMBus structure |
| length | Number of bytes left to be counted in current packet |
References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_NWK_targetProcessRx(), and SMBus_targetReportLength().
| void SMBus_PHY_targetManualACK | ( | SMBus * | smbus, |
| bool | ackVal | ||
| ) |
Send a Manual ACK or NACK depending on data validity.
Sends a NACK or ACK manually. Note that the bus is stretched by the I2C hardware until data is validated and a NACK/ACK is sent.
| smbus | Pointer to SMBus structure |
| ackVal | true for ACK, false for NACK |
References SMBus::phy, SMBus_Phy::SMBus_Phy_AckPending, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by ARP_invalidCMD(), SMBus_NWK_targetProcessRx(), and SMBus_processDone().
| void SMBus_Phy_ARP_TARGET_ADDR_Reset | ( | SMBus * | smbus | ) |
Resets the Target's Address based on the ARP Status.
| *smbus | Pointer to SMBus structure |
References SMBus_ARP_Status::arpAddressValid, SMBus::arpStatus, SMBus::ownTargetAddr, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBusARP_RESET(), and SMBusARPAssignAddress().
| void SMBus_PHY_controllerEnable | ( | SMBus * | smbus | ) |
Enables the PHY and Data Link layer.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::phy, SMBus_Ctrl::phyEn, SMB_POWER_STARTUP_DELAY, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_NWK_controllerReset(), and SMBus_PHY_controllerInit().
| uint8_t SMBus_Phy_ARP_Get_Write_Status | ( | SMBus * | smbus | ) |
Returns the Write Bus direction of the ARP transaction.
| *smbus | Pointer to SMBus structure |
References SMBus::arpStatus, and SMBus_ARP_Status::arpWriteState.
Referenced by ARP_isCmdValid(), and SMBus_NWK_targetProcessStart().
| uint8_t SMBus_Phy_ARP_Get_Read_Status | ( | SMBus * | smbus | ) |
Returns the Read Bus direction of the ARP transaction.
| *smbus | Pointer to SMBus structure |
References SMBus::arpStatus, and SMBus_ARP_Status::arpWriteState.
Referenced by SMBus_NWK_targetProcessStart().
| void SMBus_PHY_controllerInit | ( | SMBus * | smbus, |
| I2C_Regs * | i2cAddr, | ||
| uint32_t | busClk | ||
| ) |
Initializes the I2C Controller module supporting SMBus functionality.
| smbus | Pointer to SMBus structure |
| i2cAddr | Base address of I2C module |
| busClk | SMCLK Frequency (used for I2C) |
References SMBus::ownTargetAddr, SMBus::phy, SMBus_PHY_controllerEnable(), SMBus_PHY_disable(), and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_controllerInit().
| void SMBus_PHY_controllerEnableInt | ( | SMBus * | smbus | ) |
Enables the I2C interrupts for Controller.
This function enables the I2C Start, Stop, RX,TX, Timeout interrupts. SMBus_PHY_targetInit() must be called before this function.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_controllerDisableInt(), and SMBus_controllerEnableInt().
| void SMBus_PHY_controllerDisableInt | ( | SMBus * | smbus | ) |
Disables the I2C interrupts for Controller.
This function disables the I2C Start, Stop, RX,TX, Timeout interrupts.
| *smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
| void SMBus_PHY_controllerSendStop | ( | SMBus * | smbus | ) |
Generate Stop condition if it hasn't been sent.
| smbus | Pointer to SMBus structure |
References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_NWK_controllerProcessNACK(), and SMBus_NWK_controllerProcessRx().
| void SMBus_PHY_controllerStartTx | ( | SMBus * | smbus, |
| uint8_t | targetaddr, | ||
| uint16_t | length, | ||
| SMBus_Stop | stopFlag, | ||
| uint8_t | setPEC | ||
| ) |
Start a TX transfer.
| smbus | Pointer to SMBus structure |
| targetaddr | Target target address |
| length | Number of bytes to send, not including the address byte |
| stopFlag | Indicates whether the HW will generate stop condition |
| setPEC | Packet Error Checking (PEC) count value |
| void SMBus_PHY_controllerStartRx | ( | SMBus * | smbus, |
| uint8_t | targetaddr, | ||
| uint16_t | length, | ||
| SMBus_Start | startFlag, | ||
| SMBus_Stop | stopFlag, | ||
| SMBus_Auto_Ack | ackFlag, | ||
| uint8_t | setPEC | ||
| ) |
Start a RX transfer.
| smbus | Pointer to SMBus structure |
| targetaddr | Target target address |
| length | Number of bytes to send, not including the address byte |
| stopFlag | Indicates whether the HW will generate stop condition |
| startFlag | Indicates whether the HW will generate start condition |
| ackFlag | Indicates whether the HW will auto ack the last byte |
| setPEC | Packet Error Checking (PEC) count value |
References SMB_SW_TIMEOUT, and SMBus_Start_Before_Transfer.
| SMBus_State SMBus_PHY_controllerProcessInt | ( | SMBus * | smbus | ) |
I2C Interrupt Service routine for SMBus Controller.
Handles the interrupts from I2C module and passes the information to the network layer. Should be called by application when acting as a controller and an I2C interrupt is detected. Note that a controller can also act as target in some scenarios (like Host notify), so the ISR needs to handle such cases.
| smbus | Pointer to SMBus structure |
References SMBus::phy, SMBus_NWK_controllerProcessNACK(), SMBus_NWK_controllerProcessRx(), SMBus_NWK_controllerProcessStop(), SMBus_NWK_controllerProcessTimeout(), SMBus_NWK_controllerProcessTx(), SMBus_NWK_controllerTxDone(), SMBus_NWK_targetProcessRx(), SMBus_NWK_targetProcessStart(), SMBus_NWK_targetProcessStop(), and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_controllerProcessInt().
| void SMBus_PHY_controllerEnableHostNotify | ( | SMBus * | smbus | ) |
Enable the hardware functionality to respond to Host Default address (0b000_1000)
| smbus | Pointer to SMBus structure |
References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_controllerEnableHostNotify().
| void SMBus_PHY_controllerDisableHostNotify | ( | SMBus * | smbus | ) |
Disable the hardware functionality to respond to Host Default address (0b000_1000)
| smbus | Pointer to SMBus structure |
References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.
Referenced by SMBus_controllerDisableHostNotify().