SMBus Library for MSP430G2xx3 Devices  1.10.00.00
 All Data Structures Functions Variables Enumerations Enumerator Modules Pages
NWK layer

Functions

uint8_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_slaveProcessStart (SMBus *smbus, uint8_t addrRw)
 Start callback for SMBus. More...
 
SMBus_State SMBus_NWK_slaveProcessRx (SMBus *smbus, uint8_t data)
 RX callback for SMBus slave. More...
 
SMBus_State SMBus_NWK_slaveProcessTx (SMBus *smbus, uint8_t *data)
 TX callback for SMBus slave. More...
 
SMBus_State SMBus_NWK_slaveProcessStop (SMBus *smbus)
 Stop callback for SMBus-based protocol. More...
 
SMBus_State SMBus_NWK_slaveProcessTimeout (SMBus *smbus)
 Handles the SMBus protocol when a Timeout error is detected by PHY. More...
 
SMBus_State SMBus_NWK_masterProcessRx (SMBus *smbus, uint8_t data)
 RX callback for SMBus master. More...
 
SMBus_State SMBus_NWK_masterProcessTx (SMBus *smbus, uint8_t *data)
 TX callback for SMBus master. More...
 
SMBus_State SMBus_NWK_masterProcessStop (SMBus *smbus)
 Process a Stop condition. More...
 
SMBus_State SMBus_NWK_masterProcessTimeout (SMBus *smbus)
 Handles the SMBus protocol when a Timeout error is detected by PHY. More...
 
SMBus_State SMBus_NWK_masterProcessNACK (SMBus *smbus)
 Handles the SMBus protocol when a NACK. More...
 
void SMBus_NWK_masterReset (SMBus *smbus)
 Resets the SMBus network layer. More...
 

Detailed Description

Function Documentation

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_masterProcessRx(), SMBus_NWK_masterProcessTx(), SMBus_NWK_slaveProcessRx(), SMBus_NWK_slaveProcessStart(), SMBus_NWK_slaveProcessTx(), SMBus_NWK_startRxTransfer(), and SMBus_NWK_startTxTransfer().

uint8_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, and SMBus_Nwk::rxIndex.

Referenced by SMBus_getRxPayloadAvailable().

SMBus_State SMBus_NWK_masterProcessNACK ( 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_Master_NACK

References SMBus::nwk, SMBus_NwkState_Ending, SMBus_NwkState_Error, SMBus_PHY_masterSendStop(), SMBus_State_Master_NACK, and SMBus::state.

Referenced by SMBus_PHY_masterProcessInt().

SMBus_State SMBus_NWK_masterProcessRx ( SMBus smbus,
uint8_t  data 
)

RX callback for SMBus master.

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_Master_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, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMB_MAX_PACKET_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_RX, SMBus_NwkState_RX_Block, SMBus_PHY_masterSendPreStop(), SMBus_PHY_masterSendStop(), SMBus_State_DataSizeError, SMBus_State_Master_Error, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_masterProcessInt().

SMBus_State SMBus_NWK_masterProcessStop ( 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, SMBus_Nwk::pec, SMBus_NwkState_RX, SMBus_NwkState_RX_Block, SMBus_State_PECError, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_masterSendStop(), and SMBus_PHY_masterStartRx().

SMBus_State SMBus_NWK_masterProcessTimeout ( SMBus smbus)

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

Used for USCI devices that do not support timeouts inherently (as in eUSCI).

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State_TimeOutError

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

Referenced by SMBus_PHY_masterProcessTimeoutInt().

SMBus_State SMBus_NWK_masterProcessTx ( SMBus smbus,
uint8_t *  data 
)

TX callback for SMBus master.

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_Master_Error : not expecting TX

References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Nwk::currentCmd, SMBus::nwk, SMBus_Nwk::pec, SMBus_Nwk::rxLen, SMBus_NWK_addCrc8(), SMBus_NWK_startRxTransfer(), SMBus_NwkState_Ending, SMBus_NwkState_Error, SMBus_NwkState_TX, SMBus_NwkState_TX_Block, SMBus_NwkState_TXQuickCMD, SMBus_PHY_masterSendStop(), SMBus_State_Master_Error, SMBus::state, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, and SMBus_Nwk::txLen.

Referenced by SMBus_PHY_masterProcessInt().

void SMBus_NWK_masterReset ( SMBus smbus)

Resets the SMBus network layer.

Parameters
smbusPointer to SMBus structure
Returns
none

References SMBus::nwk, SMBus_PHY_disable(), and SMBus_PHY_masterEnable().

Referenced by SMBus_masterReset(), and SMBus_NWK_masterProcessTimeout().

SMBus_State SMBus_NWK_slaveProcessRx ( SMBus smbus,
uint8_t  data 
)

RX callback for SMBus slave.

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_Slave_NotReady : Packet in progress
  • SMBus_State_Slave_FirstByte : First byte (Command) was received
  • SMBus_State_Slave_ByteReceived : Data byte (2-n) was received
  • SMBus_State_Slave_Error : not expecting RX
  • SMBus_State_Slave_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, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxSize, SMB_MAX_PACKET_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_RX, SMBus_State_DataSizeError, SMBus_State_Slave_ByteReceived, SMBus_State_Slave_Error, SMBus_State_Slave_FirstByte, SMBus_State_Slave_NotReady, SMBus::state, and SMBus::status.

Referenced by SMBus_PHY_slaveProcessInt().

SMBus_State SMBus_NWK_slaveProcessStart ( 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_Slave_NotReady : Packet in progress
  • SMBus_State_PECError : Packet was invalid
  • SMBus_State_Slave_CmdComplete : restart received after command, process previous packet

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus::ctrl, SMBus_Nwk::currentAddr, I2C_READ, SMBus::nwk, SMBus_Status::packOvrErr, SMBus_Nwk::pec, SMBus_Nwk::rxIndex, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_RX, SMBus_NwkState_TX, SMBus_NwkState_TX_Resp, SMBUS_RET_OK, SMBus_State_PECError, SMBus_State_Slave_CmdComplete, SMBus_State_Slave_QCMD, SMBus::state, SMBus::status, SMBus_Nwk::txIndex, and SMBus_Nwk::txLen.

Referenced by SMBus_PHY_slaveProcessInt().

SMBus_State SMBus_NWK_slaveProcessStop ( 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_Slave_NotReady : Packet in progress
  • SMBus_State_PECError : Packet was invalid
  • SMBus_State_Slave_QCMD : Quick Command was detected
  • SMBus_State_Slave_CmdComplete : Stop was detected and packet is ready to process

References SMBus::nwk, SMBus_Nwk::rxIndex, SMBus_NwkState_RX, SMBUS_RET_OK, SMBus_State_PECError, SMBus_State_Slave_CmdComplete, and SMBus_State_Slave_QCMD.

Referenced by SMBus_PHY_slaveProcessInt().

SMBus_State SMBus_NWK_slaveProcessTimeout ( SMBus smbus)

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

Used for USCI devices that do not support timeouts inherently (as in eUSCI).

Parameters
smbusPointer to SMBus structure
Returns
SMBus_State_TimeOutError

References SMBus_Status::bits, SMBus::nwk, SMBus_PHY_disable(), SMBus_PHY_slaveEnable(), SMBus_State_TimeOutError, SMBus::status, and SMBus_Status::toErr.

Referenced by SMBus_PHY_slaveProcessTimeoutInt().

SMBus_State SMBus_NWK_slaveProcessTx ( SMBus smbus,
uint8_t *  data 
)

TX callback for SMBus slave.

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_Slave_NotReady : Buffer not initialized
  • SMBus_State_Slave_Error : not expecting TX
  • SMBus_State_Slave_NotReady : not ready for TX
  • SMBus_State_DataSizeError : Max packet size exceeded

References SMBus_Ctrl::bits, SMBus_Status::bits, SMBus::ctrl, SMBus::nwk, SMBus_Status::packErr, SMBus_Nwk::pec, SMBus_Nwk::recByteTxPtr, RESPONSE_NTR, SMB_MAX_PACKET_SIZE, SMBus_NWK_addCrc8(), SMBus_NwkState_Error, SMBus_NwkState_TX, SMBus_NwkState_TX_Resp, SMBus_State_DataSizeError, SMBus_State_Slave_Error, SMBus_State_Slave_NotReady, SMBus::status, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, SMBus_Nwk::txLen, and SMBus_Nwk::txSize.

Referenced by SMBus_PHY_slaveProcessInt().


Copyright 2015, Texas Instruments Incorporated