SMBusLibrary  1.0
Functions
NWK layer

Functions

uint16_t SMBus_NWK_getRxPayloadSize (SMBus *smbus)
 Returns the number of received bytes from last transaction. More...
 
void SMBus_NWK_addCrc8 (uint8_t *crc, uint8_t newData)
 Adds a new value to CRC-8 Calculation. More...
 
void SMBus_NWK_startTxTransfer (SMBus *smbus)
 Start the TX transfer process. More...
 
void SMBus_NWK_startRxTransfer (SMBus *smbus)
 Start the RX transfer process. More...
 
SMBus_State SMBus_NWK_targetProcessStart (SMBus *smbus, uint8_t addrRw)
 Start callback for SMBus. More...
 
SMBus_State SMBus_NWK_targetProcessRx (SMBus *smbus, uint8_t data)
 RX callback for SMBus target. More...
 
SMBus_State SMBus_NWK_targetProcessTx (SMBus *smbus, uint8_t *data)
 TX callback for SMBus target. More...
 
SMBus_State SMBus_NWK_targetProcessStop (SMBus *smbus)
 Stop callback for SMBus-based protocol. More...
 
SMBus_State SMBus_NWK_targetProcessTimeout (SMBus *smbus)
 Handles the SMBus protocol when a Timeout error is detected by PHY. More...
 
SMBus_State SMBus_NWK_controllerProcessRx (SMBus *smbus, uint8_t data)
 RX callback for SMBus controller. More...
 
SMBus_State SMBus_NWK_controllerProcessTx (SMBus *smbus, uint8_t *data)
 TX callback for SMBus controller. More...
 
SMBus_State SMBus_NWK_controllerTxDone (SMBus *smbus)
 Process a Done condition, between restarts. More...
 
SMBus_State SMBus_NWK_controllerProcessStop (SMBus *smbus)
 Process a Stop condition. More...
 
SMBus_State SMBus_NWK_controllerProcessTimeout (SMBus *smbus)
 Handles the SMBus protocol when a Timeout error is detected by PHY. More...
 
SMBus_State SMBus_NWK_controllerProcessNACK (SMBus *smbus)
 Handles the SMBus protocol when a NACK. More...
 
void SMBus_NWK_controllerReset (SMBus *smbus)
 Resets the SMBus network layer. More...
 

Detailed Description

Function Documentation

§ SMBus_NWK_getRxPayloadSize()

uint16_t SMBus_NWK_getRxPayloadSize ( SMBus smbus)

Returns the number of received bytes from last transaction.

Parameters
smbusPointer to SMBus structure
Returns
Number of bytes in the RX buffer. PEC byte is not included.

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::nwk, SMBus_Ctrl::pecEn, SMBus_Nwk::rxIndex, and SMBus_NWK_addCrc8().

Referenced by SMBus_getRxPayloadAvailable().

§ SMBus_NWK_addCrc8()

void SMBus_NWK_addCrc8 ( uint8_t *  crc,
uint8_t  newData 
)

Adds a new value to CRC-8 Calculation.

Follows format: C(x) = x8 + x2 + x + 1
Two methods are available:

  • SMB_CRC8_USE_LOOKUP_TABLE : Use a 256B lookup table (faster but takes more memory)
  • SMB_CRC8_CALCULATION : Calculate CRC8 manually (slower but takes less memory)
    Parameters
    *crcPointer to current CRC-8 value, will get updated
    newDataNew byte added to CRC-8 calulation
    Returns
    None

Referenced by SMBus_NWK_controllerProcessRx(), SMBus_NWK_controllerProcessTx(), SMBus_NWK_getRxPayloadSize(), SMBus_NWK_startRxTransfer(), SMBus_NWK_startTxTransfer(), SMBus_NWK_targetProcessRx(), SMBus_NWK_targetProcessStart(), and SMBus_NWK_targetProcessTx().

§ SMBus_NWK_startTxTransfer()

void SMBus_NWK_startTxTransfer ( SMBus smbus)

§ SMBus_NWK_startRxTransfer()

void SMBus_NWK_startRxTransfer ( SMBus smbus)

§ SMBus_NWK_targetProcessStart()

SMBus_State SMBus_NWK_targetProcessStart ( SMBus smbus,
uint8_t  addrRw 
)

Start callback for SMBus.

Handles the protocol when a Start is received. Depending on the current state, the start could also mean re-start.

Parameters
smbusPointer to SMBus structure
addrRwCurrent Address+RW as received by PHY_DL
Returns
SMBus_State value as follows:
  • SMBus_State_Target_NotReady : Packet in progress
  • SMBus_State_PECError : Packet was invalid
  • SMBus_State_Target_CmdComplete : restart received after command, process previous packet

References SMBus_Status::bits, SMBus_Nwk::currentAddr, SMBus_Nwk::eState, I2C_READ, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Status::packOvrErr, SMBus_Nwk::pec, SMBus_Nwk::rxIndex, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_Idle, SMBus_NwkState_RX, SMBus_NwkState_TX_Resp, SMBUS_RET_OK, SMBus_State_OK, SMBus_State_PECError, SMBus_State_Target_CmdComplete, SMBus_State_Target_QCMD, SMBus::state, SMBus::status, SMBus_Nwk::txIndex, and SMBus_Nwk::txLen.

Referenced by SMBus_PHY_targetProcessInt().

§ SMBus_NWK_targetProcessRx()

SMBus_State SMBus_NWK_targetProcessRx ( SMBus smbus,
uint8_t  data 
)

RX callback for SMBus target.

Handles the protocol when a reception is requested.

Parameters
smbusPointer to SMBus structure
dataData byte as received by the PHY layer
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Target_NotReady : Packet in progress
  • SMBus_State_Target_FirstByte : First byte (Command) was received
  • SMBus_State_Target_ByteReceived : Data byte (2-n) was received
  • SMBus_State_Target_Error : not expecting RX
  • SMBus_State_Target_NotReady : not ready for RX
  • SMBus_State_DataSizeError : Max packet size exceeded

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus_Status::byteOvrErr, SMBus::ctrl, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxSize, SMB_MAX_PACKET_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_Idle, SMBus_NwkState_RX, SMBus_State_DataSizeError, SMBus_State_OK, SMBus_State_Target_ByteReceived, SMBus_State_Target_Error, SMBus_State_Target_FirstByte, SMBus_State_Target_NotReady, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_targetProcessInt().

§ SMBus_NWK_targetProcessTx()

SMBus_State SMBus_NWK_targetProcessTx ( SMBus smbus,
uint8_t *  data 
)

TX callback for SMBus target.

Handles the protocol when a transmission is requested.

Parameters
smbusPointer to SMBus structure
*dataPointer to tranmission byte, must be written with value being sent
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Target_NotReady : Buffer not initialized
  • SMBus_State_Target_Error : not expecting TX
  • SMBus_State_Target_NotReady : not ready for TX
  • SMBus_State_DataSizeError : Max packet size exceeded

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus::ctrl, SMBus_Nwk::eState, I2C_READ, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Nwk::recByteTxPtr, RESPONSE_NTR, SMB_MAX_PACKET_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_Idle, SMBus_NwkState_TX, SMBus_NwkState_TX_Resp, SMBus_State_DataSizeError, SMBus_State_OK, SMBus_State_Target_Error, SMBus_State_Target_NotReady, SMBus::status, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, SMBus_Nwk::txLen, and SMBus_Nwk::txSize.

Referenced by SMBus_PHY_targetProcessInt().

§ SMBus_NWK_targetProcessStop()

SMBus_State SMBus_NWK_targetProcessStop ( SMBus smbus)

Stop callback for SMBus-based protocol.

Handles SMus protocol when a stop is detected

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Target_NotReady : Packet in progress
  • SMBus_State_PECError : Packet was invalid
  • SMBus_State_Target_QCMD : Quick Command was detected
  • SMBus_State_Target_CmdComplete : Stop was detected and packet is ready to process

References SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxIndex, SMBus_NwkState_Idle, SMBus_NwkState_RX, SMBUS_RET_OK, SMBus_State_OK, SMBus_State_PECError, SMBus_State_Target_CmdComplete, and SMBus_State_Target_QCMD.

Referenced by SMBus_PHY_targetProcessInt().

§ SMBus_NWK_targetProcessTimeout()

SMBus_State SMBus_NWK_targetProcessTimeout ( SMBus smbus)

Handles the SMBus protocol when a Timeout error is detected by PHY.

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State_TimeOutError

References SMBus_Status::bits, SMBus_Nwk::eState, SMBus::nwk, SMBus_NwkState_Idle, SMBus_PHY_disable(), SMBus_PHY_targetEnable(), SMBus_State_TimeOutError, SMBus::status, and SMBus_Status::toErr.

§ SMBus_NWK_controllerProcessRx()

SMBus_State SMBus_NWK_controllerProcessRx ( SMBus smbus,
uint8_t  data 
)

RX callback for SMBus controller.

Handles the protocol when a reception is requested.

Parameters
smbusPointer to SMBus structure
dataData byte as received by the PHY layer
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Controller_Error : not expecting RX
  • SMBus_State_DataSizeError : Max packet size exceeded, or greater than expected

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus::ctrl, SMBus_Nwk::eState, SMBus::nwk, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMB_MAX_PACKET_SIZE, SMB_MAX_PAYLOAD_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_RX, SMBus_NwkState_RX_Block_Byte_Count, SMBus_NwkState_RX_Block_Payload, SMBus_PHY_controllerSendStop(), SMBus_State_Controller_Error, SMBus_State_DataSizeError, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerProcessTx()

SMBus_State SMBus_NWK_controllerProcessTx ( SMBus smbus,
uint8_t *  data 
)

TX callback for SMBus controller.

Handles the protocol when a transmission is requested.

Parameters
smbusPointer to SMBus structure
*dataPointer to tranmission byte, must be written with value being sent
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Controller_Error : not expecting TX

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_TX, SMBus_NwkState_TX_Block, SMBus_NwkState_TXQuickCMD, SMBus_State_Controller_Error, SMBus::state, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, and SMBus_Nwk::txLen.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerTxDone()

SMBus_State SMBus_NWK_controllerTxDone ( SMBus smbus)

Process a Done condition, between restarts.

Parameters
smbusPointer to SMBus structure
Returns
Current SMBus_State.

References SMBus::nwk, SMBus_Nwk::rxLen, SMBus_NWK_startRxTransfer(), and SMBus::state.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerProcessStop()

SMBus_State SMBus_NWK_controllerProcessStop ( SMBus smbus)

Process a Stop condition.

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_PECError

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus::ctrl, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Status::pecErr, SMBus_NwkState_Idle, SMBus_NwkState_RX, SMBus_NwkState_RX_Block_Payload, SMBus_State_PECError, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerProcessTimeout()

SMBus_State SMBus_NWK_controllerProcessTimeout ( SMBus smbus)

Handles the SMBus protocol when a Timeout error is detected by PHY.

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State_TimeOutError

References SMBus_Status::bits, SMBus_NWK_controllerReset(), SMBus_State_TimeOutError, SMBus::state, SMBus::status, and SMBus_Status::toErr.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerProcessNACK()

SMBus_State SMBus_NWK_controllerProcessNACK ( SMBus smbus)

Handles the SMBus protocol when a NACK.

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State value as follows:
  • SMBus_State_OK
  • SMBus_State_Controller_NACK

References SMBus_Nwk::eState, SMBus::nwk, SMBus_NwkState_Ending, SMBus_NwkState_Error, SMBus_PHY_controllerSendStop(), SMBus_State_Controller_NACK, SMBus_State_OK, and SMBus::state.

Referenced by SMBus_PHY_controllerProcessInt().

§ SMBus_NWK_controllerReset()

void SMBus_NWK_controllerReset ( SMBus smbus)

Resets the SMBus network layer.

Parameters
smbusPointer to SMBus structure
Returns
none

References SMBus_Nwk::eState, SMBus::nwk, SMBus_NwkState_Idle, SMBus_PHY_controllerEnable(), and SMBus_PHY_disable().

Referenced by SMBus_controllerReset(), and SMBus_NWK_controllerProcessTimeout().

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