SMBusLibrary
1.0
|
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... | |
uint16_t SMBus_NWK_getRxPayloadSize | ( | SMBus * | smbus | ) |
Returns the number of received bytes from last transaction.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::nwk, SMBus_Ctrl::pecEn, SMBus_Nwk::rxIndex, and SMBus_NWK_addCrc8().
Referenced by SMBus_getRxPayloadAvailable().
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:
*crc | Pointer to current CRC-8 value, will get updated |
newData | New byte added to CRC-8 calulation |
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().
void SMBus_NWK_startTxTransfer | ( | SMBus * | smbus | ) |
Start the TX transfer process.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Nwk::currentAddr, SMBus::nwk, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMBus_NWK_addCrc8(), SMBus_State_OK, SMBus::state, SMBus_Nwk::txIndex, and SMBus_Nwk::txLen.
Referenced by SMBus_controllerProcessCall(), SMBus_controllerProcessCallBlock(), SMBus_controllerQuickCommand(), SMBus_controllerReadByteWord(), SMBus_controllerSendByte(), and SMBus_controllerWriteByteWord().
void SMBus_NWK_startRxTransfer | ( | SMBus * | smbus | ) |
Start the RX transfer process.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Nwk::currentAddr, SMBus_Nwk::eState, I2C_READ, SMBus::nwk, SMBus_Nwk::pec, SMBus_Ctrl::pecEn, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMBus_NWK_addCrc8(), SMBus_NwkState_RX, SMBus_State_OK, and SMBus::state.
Referenced by SMBus_controllerSendByte(), and SMBus_NWK_controllerTxDone().
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.
smbus | Pointer to SMBus structure |
addrRw | Current Address+RW as received by PHY_DL |
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_State SMBus_NWK_targetProcessRx | ( | SMBus * | smbus, |
uint8_t | data | ||
) |
RX callback for SMBus target.
Handles the protocol when a reception is requested.
smbus | Pointer to SMBus structure |
data | Data byte as received by the PHY layer |
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_State SMBus_NWK_targetProcessTx | ( | SMBus * | smbus, |
uint8_t * | data | ||
) |
TX callback for SMBus target.
Handles the protocol when a transmission is requested.
smbus | Pointer to SMBus structure |
*data | Pointer to tranmission byte, must be written with value being sent |
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_State SMBus_NWK_targetProcessStop | ( | SMBus * | smbus | ) |
Stop callback for SMBus-based protocol.
Handles SMus protocol when a stop is detected
smbus | Pointer to SMBus structure |
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_State SMBus_NWK_targetProcessTimeout | ( | SMBus * | smbus | ) |
Handles the SMBus protocol when a Timeout error is detected by PHY.
smbus | Pointer to SMBus structure |
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_State SMBus_NWK_controllerProcessRx | ( | SMBus * | smbus, |
uint8_t | data | ||
) |
RX callback for SMBus controller.
Handles the protocol when a reception is requested.
smbus | Pointer to SMBus structure |
data | Data byte as received by the PHY layer |
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_State SMBus_NWK_controllerProcessTx | ( | SMBus * | smbus, |
uint8_t * | data | ||
) |
TX callback for SMBus controller.
Handles the protocol when a transmission is requested.
smbus | Pointer to SMBus structure |
*data | Pointer to tranmission byte, must be written with value being sent |
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_State SMBus_NWK_controllerTxDone | ( | SMBus * | smbus | ) |
Process a Done condition, between restarts.
smbus | Pointer to SMBus structure |
References SMBus::nwk, SMBus_Nwk::rxLen, SMBus_NWK_startRxTransfer(), and SMBus::state.
Referenced by SMBus_PHY_controllerProcessInt().
SMBus_State SMBus_NWK_controllerProcessStop | ( | SMBus * | smbus | ) |
Process a Stop condition.
smbus | Pointer to SMBus structure |
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_State SMBus_NWK_controllerProcessTimeout | ( | SMBus * | smbus | ) |
Handles the SMBus protocol when a Timeout error is detected by PHY.
smbus | Pointer to SMBus structure |
References SMBus_Status::bits, SMBus_NWK_controllerReset(), SMBus_State_TimeOutError, SMBus::state, SMBus::status, and SMBus_Status::toErr.
Referenced by SMBus_PHY_controllerProcessInt().
SMBus_State SMBus_NWK_controllerProcessNACK | ( | SMBus * | smbus | ) |
Handles the SMBus protocol when a NACK.
smbus | Pointer to SMBus structure |
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().
void SMBus_NWK_controllerReset | ( | SMBus * | smbus | ) |
Resets the SMBus network layer.
smbus | Pointer to SMBus structure |
References SMBus_Nwk::eState, SMBus::nwk, SMBus_NwkState_Idle, SMBus_PHY_controllerEnable(), and SMBus_PHY_disable().
Referenced by SMBus_controllerReset(), and SMBus_NWK_controllerProcessTimeout().