SMBusLibrary  1.0
Macros | Functions
MSPM0 PHY layer

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...
 

Detailed Description

Macro Definition Documentation

§ I2C_WRITE

#define I2C_WRITE   0

R/W state when write is received

§ I2C_READ

#define I2C_READ   1

R/W state when read is received

§ SMB_SW_TIMEOUT

#define SMB_SW_TIMEOUT   (10000)

Software timeout to avoid lockup

Referenced by SMBus_PHY_controllerStartRx().

§ SMB_TIMEOUT_WAIT_CYCLES

#define SMB_TIMEOUT_WAIT_CYCLES   (200)

Delay cycles after reseting the I2C interface on timeout

Referenced by SMBus_NWK_targetProcessTimeout().

§ SMB_POWER_STARTUP_DELAY

#define SMB_POWER_STARTUP_DELAY   (16)

Delay cycles for module Power up

Referenced by SMBus_PHY_controllerEnable(), and SMBus_PHY_targetEnable().

Function Documentation

§ SMBus_PHY_disable()

void SMBus_PHY_disable ( SMBus smbus)

Disables the PHY and Data Link layer.

Parameters
*smbusPointer to SMBus structure
Returns
None

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().

§ SMBus_PHY_targetEnable()

void SMBus_PHY_targetEnable ( SMBus smbus)

Enables the PHY and Data Link layer for target operation.

Parameters
*smbusPointer to SMBus structure
Returns
None

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().

§ SMBus_PHY_targetInit()

void SMBus_PHY_targetInit ( SMBus smbus,
I2C_Regs *  i2cAddr 
)

Initializes the I2C Target module supporting SMBus functionality.

  • Resets and then configures the I2C for SMBus support
  • I2C is enabled using Automatic ACK and Target address is initialized to 0x00
  • Call SMBus_targetSetAddress() in order to set the Target address
    Parameters
    *smbusPointer to SMBus structure
    i2cAddrBase 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().

§ SMBus_PHY_targetEnableInt()

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.

Parameters
*smbusPointer to SMBus structure
Returns
None

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_targetEnableInt().

§ SMBus_PHY_targetDisableInt()

void SMBus_PHY_targetDisableInt ( SMBus smbus)

Disables the I2C interrupts.

This function disables the I2C Start ,Stop, RX ,TX, Timeout interrupts.

Parameters
*smbusPointer to SMBus structure
Returns
None

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_targetDisableInt().

§ SMBus_PHY_targetProcessInt()

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.

Parameters
smbusPointer to SMBus structure
Returns
The new state of Target (see SMBus_targetProcessInt())

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().

§ SMBus_PHY_targetSetPECCount()

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.

Parameters
smbusPointer to SMBus structure
lengthNumber of bytes left to be counted in current packet
Returns
None

References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_NWK_targetProcessRx(), and SMBus_targetReportLength().

§ SMBus_PHY_targetManualACK()

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.

Parameters
smbusPointer to SMBus structure
ackValtrue for ACK, false for NACK
Returns
None

References SMBus::phy, SMBus_Phy::SMBus_Phy_AckPending, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by ARP_invalidCMD(), SMBus_NWK_targetProcessRx(), and SMBus_processDone().

§ SMBus_Phy_ARP_TARGET_ADDR_Reset()

void SMBus_Phy_ARP_TARGET_ADDR_Reset ( SMBus smbus)

Resets the Target's Address based on the ARP Status.

Parameters
*smbusPointer to SMBus structure
Returns
None

References SMBus_ARP_Status::arpAddressValid, SMBus::arpStatus, SMBus::ownTargetAddr, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBusARP_RESET(), and SMBusARPAssignAddress().

§ SMBus_PHY_controllerEnable()

void SMBus_PHY_controllerEnable ( SMBus smbus)

Enables the PHY and Data Link layer.

Parameters
*smbusPointer to SMBus structure
Returns
None

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().

§ SMBus_Phy_ARP_Get_Write_Status()

uint8_t SMBus_Phy_ARP_Get_Write_Status ( SMBus smbus)

Returns the Write Bus direction of the ARP transaction.

Parameters
*smbusPointer to SMBus structure
Returns
Read / Write status

References SMBus::arpStatus, and SMBus_ARP_Status::arpWriteState.

Referenced by ARP_isCmdValid(), and SMBus_NWK_targetProcessStart().

§ SMBus_Phy_ARP_Get_Read_Status()

uint8_t SMBus_Phy_ARP_Get_Read_Status ( SMBus smbus)

Returns the Read Bus direction of the ARP transaction.

Parameters
*smbusPointer to SMBus structure
Returns
Read / Write status

References SMBus::arpStatus, and SMBus_ARP_Status::arpWriteState.

Referenced by SMBus_NWK_targetProcessStart().

§ SMBus_PHY_controllerInit()

void SMBus_PHY_controllerInit ( SMBus smbus,
I2C_Regs *  i2cAddr,
uint32_t  busClk 
)

Initializes the I2C Controller module supporting SMBus functionality.

  • Resets and then configures the I2C for SMBus support
  • I2C is enabled using Automatic ACK and Target address is initialized to 0x00
    Parameters
    smbusPointer to SMBus structure
    i2cAddrBase address of I2C module
    busClkSMCLK Frequency (used for I2C)
    Returns
    None

References SMBus::ownTargetAddr, SMBus::phy, SMBus_PHY_controllerEnable(), SMBus_PHY_disable(), and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_controllerInit().

§ SMBus_PHY_controllerEnableInt()

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.

Parameters
*smbusPointer to SMBus structure
Returns
None

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_controllerDisableInt(), and SMBus_controllerEnableInt().

§ SMBus_PHY_controllerDisableInt()

void SMBus_PHY_controllerDisableInt ( SMBus smbus)

Disables the I2C interrupts for Controller.

This function disables the I2C Start, Stop, RX,TX, Timeout interrupts.

Parameters
*smbusPointer to SMBus structure
Returns
None

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::intEn, SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

§ SMBus_PHY_controllerSendStop()

void SMBus_PHY_controllerSendStop ( SMBus smbus)

Generate Stop condition if it hasn't been sent.

Parameters
smbusPointer to SMBus structure
Returns
None

References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_NWK_controllerProcessNACK(), and SMBus_NWK_controllerProcessRx().

§ SMBus_PHY_controllerStartTx()

void SMBus_PHY_controllerStartTx ( SMBus smbus,
uint8_t  targetaddr,
uint16_t  length,
SMBus_Stop  stopFlag,
uint8_t  setPEC 
)

Start a TX transfer.

Parameters
smbusPointer to SMBus structure
targetaddrTarget target address
lengthNumber of bytes to send, not including the address byte
stopFlagIndicates whether the HW will generate stop condition
setPECPacket Error Checking (PEC) count value
Returns
None

§ SMBus_PHY_controllerStartRx()

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.

Parameters
smbusPointer to SMBus structure
targetaddrTarget target address
lengthNumber of bytes to send, not including the address byte
stopFlagIndicates whether the HW will generate stop condition
startFlagIndicates whether the HW will generate start condition
ackFlagIndicates whether the HW will auto ack the last byte
setPECPacket Error Checking (PEC) count value
Returns
None

References SMB_SW_TIMEOUT, and SMBus_Start_Before_Transfer.

§ SMBus_PHY_controllerProcessInt()

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.

Parameters
smbusPointer to SMBus structure
Returns
The new state of controller (see SMBus_controllerProcessInt())

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().

§ SMBus_PHY_controllerEnableHostNotify()

void SMBus_PHY_controllerEnableHostNotify ( SMBus smbus)

Enable the hardware functionality to respond to Host Default address (0b000_1000)

Parameters
smbusPointer to SMBus structure
Returns
The new state of controller (see SMBus_controllerProcessInt())

References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_controllerEnableHostNotify().

§ SMBus_PHY_controllerDisableHostNotify()

void SMBus_PHY_controllerDisableHostNotify ( SMBus smbus)

Disable the hardware functionality to respond to Host Default address (0b000_1000)

Parameters
smbusPointer to SMBus structure
Returns
The new state of controller (see SMBus_controllerProcessInt())

References SMBus::phy, and SMBus_Phy::SMBus_Phy_i2cBase.

Referenced by SMBus_controllerDisableHostNotify().

© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale