![]() |
![]() |
SMBusLibrary
1.0
|
Data Structures | |
union | SMBus_Ctrl |
SMBus control register. More... | |
struct | SMBus_Phy |
Physical and Data Link Layer object. More... | |
struct | tSMBusUDID |
struct | SMBus_Nwk |
Definition of SMBus Network structure. More... | |
union | SMBus_Status |
SMBus Status Register. More... | |
struct | SMBus_ARP_Status |
SMBus ARP Status Register. More... | |
struct | SMBus |
Main SMBus object. More... | |
Macros | |
#define | SMB_TARGET_SUPPORTS_HOST_NOTIFY (true) |
Enables Host Notify support as target. | |
#define | SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY (true) |
Enables Host Notify support as Controller. | |
#define | SMB_MAX_PAYLOAD_SIZE (255) |
Maximum payload as specified by SMBus Spec. | |
#define | SMB_MAX_PACKET_SIZE (SMB_MAX_PAYLOAD_SIZE + 3) |
Max packet size = Payload+PEC+CMD+Len. | |
#define | SMB_HOST_ALERT_PACKET_SIZE (3) |
Host Alert packet size = Address + Data Byte Low + Data Byte High. | |
#define | SMB_HOST_DEFAULT_ADDRESS (0x08) |
Default Host Address used for Host Alert. | |
#define | RESPONSE_NTR 0xFF |
Default response when there's nothing to send. | |
#define | SMBUS_RET_OK (1) |
SMBus Return value when successful. | |
#define | SMBUS_RET_OK_FIXED (2) |
SMBUS_RET_OK_FIXED Return value when successful. | |
#define | SMBUS_RET_OK_BLOCK (3) |
SMBUS_RET_OK_BLOCK Return value when successful. | |
#define | SMBUS_RET_ERROR (-1) |
Return value when an error ocurred. | |
#define | SMBUS_BLOCK_LENGTH (0xFFFF) |
Definition when using variable lenght for block transactions. | |
#define | SMBUS_CMD_PREPARE_TO_ARP 0x01 |
ARP Command PREPARE_TO_ARP. | |
#define | SMBUS_CMD_ARP_RESET_DEVICE 0x02 |
ARP Command RESET_DEVICE. | |
#define | SMBUS_CMD_ARP_GET_UDID 0x03 |
ARP Command GET_UDID. | |
#define | SMBUS_CMD_ARP_ASSIGN_ADDRESS 0x04 |
ARP Commands ASSIGN_ADDRESS. | |
#define | SMBUS_ADR_HOST 0x08 |
SMBus Specification Host Address. | |
#define | SMBUS_ADR_SMART_BATTERY_CHARGER 0x09 |
SMBus Specification SMART_BATTERY_CHARGER Address. | |
#define | SMBUS_ADR_SMART_BATTERY_SELECTOR 0x0A |
SMBus Specification SMART_BATTERY_CHARGER Address. | |
#define | SMBUS_ADR_SMART_BATTERY 0x0B |
SMBus Specification SMART_BATTERY Address. | |
#define | SMBUS_ADR_DEFAULT_DEVICE 0x61 |
SMBus Specification DEFAULT Device Address. | |
#define | SMBUS_TARGET_OWN_ADDRESS SMBUS_ADR_SMART_BATTERY_CHARGER |
SMBus Specification TARGET_OWN_ADDRESS Address. | |
#define | SMBUS_ARP_UDID_LEN 0x11 |
Length of UDID Packet including Target Address. | |
#define | ARP_ADD_RESOLVED 0x00 |
Default ARP Address Resolved Flags Status. | |
#define | ARP_ADD_VALID 0x00 |
Default ARP Address Valid Flags Status. | |
#define | ARP_ADD_TYPE 0x00 |
Default ARP Address Type. | |
Functions | |
void | SMBus_processDone (SMBus *smbus) |
Clears the current state of SMBus. More... | |
uint16_t | SMBus_getRxPayloadAvailable (SMBus *smbus) |
Returns the number of received bytes from last transaction. More... | |
SMBus_State | SMBus_getState (SMBus *smbus) |
Returns the state of the SMBus module. More... | |
void | SMBus_enablePEC (SMBus *smbus) |
Enables PEC support. More... | |
void | SMBus_disablePEC (SMBus *smbus) |
Disables PEC support. More... | |
void | SMBus_targetInit (SMBus *smbus, I2C_Regs *i2cAddr) |
Initialize the SMBus interface as a target. More... | |
void | SMBus_targetEnableInt (SMBus *smbus) |
Enables the I2C interrupts for a target. More... | |
void | SMBus_targetDisableInt (SMBus *smbus) |
Disables the I2C interrupts for a target. More... | |
SMBus_State | SMBus_targetProcessInt (SMBus *smbus) |
I2C Interrupt Service routine for a target. More... | |
void | SMBus_controllerReset (SMBus *smbus) |
Force reset to SMBus controller interface. More... | |
void | SMBus_targetSetAddress (SMBus *smbus, uint8_t targetAddr) |
Set the target's own I2C address. More... | |
void | SMBus_targetSetRxBuffer (SMBus *smbus, uint8_t *data, uint16_t size) |
Initialize the reception buffer for target. More... | |
void | SMBus_targetSetTxBuffer (SMBus *smbus, uint8_t *data, uint16_t size) |
Initialize the transmission buffer for target. More... | |
void | SMBus_targetReportError (SMBus *smbus, SMBus_ErrorCode errorCode) |
Reports an error to SMBus driver from the target. More... | |
uint8_t | SMBus_targetGetCommand (SMBus *smbus) |
Return the current command (Rxbuffer[0]) received by the target. More... | |
void | SMBus_targetReportBlock (SMBus *smbus) |
Report to hardware that the command type is a block command. More... | |
void | SMBus_targetReportLength (SMBus *smbus, uint16_t length) |
Report to hardware the fixed length of a given command. More... | |
uint8_t | SMBus_targetClearStatusReg (SMBus *smbus, uint8_t val) |
Clear the target's status register. More... | |
uint8_t | SMBus_targetWriteCtrlReg (SMBus *smbus, uint8_t val) |
Write a value to the target's control register. More... | |
int8_t | SMBus_targetHostAlert (SMBus *smbus, uint8_t deviceAddress, uint8_t *txData) |
Send a Host Alert from the target. More... | |
void | SMBus_controllerInit (SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk) |
Initialize the SMBus Interface for a controller. More... | |
void | SMBus_controllerEnableInt (SMBus *smbus) |
Enables the I2C interrupts for a controller. More... | |
void | SMBus_controllerDisableInt (SMBus *smbus) |
Disables the I2C interrupts for a controller. More... | |
SMBus_State | SMBus_controllerProcessInt (SMBus *smbus) |
I2C Interrupt Service routine for a controller. More... | |
int8_t | SMBus_controllerProcessCall (SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t *rxData) |
Sends a process call to a target. More... | |
int8_t | SMBus_controllerProcessCallBlock (SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t txSize, uint8_t *rxData) |
Sends a block write-block read process call. More... | |
int8_t | SMBus_controllerSendByte (SMBus *smbus, uint8_t targetAddr, uint8_t txData) |
Sends byte to the target. More... | |
int8_t | SMBus_controllerReadByteWord (SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *rxData, uint8_t rxSize) |
Receive a byte from the target. More... | |
int8_t | SMBus_controllerWriteByteWord (SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t txSize) |
Send a command transmitting a byte or word of data from the target. More... | |
int8_t | SMBus_controllerQuickCommand (SMBus *smbus, uint8_t targetAddr, bool write) |
Send a SMBus "quick command". More... | |
int8_t | SMBus_controllerWaitUntilDone (SMBus *smbus, int32_t timeout) |
Wait until the previous SMBus command is executed. More... | |
void | SMBus_controllerEnableHostNotify (SMBus *smbus, uint8_t *hostAlertBuffer) |
Enable support for Host Notify Protocol. More... | |
void | SMBus_controllerDisableHostNotify (SMBus *smbus) |
Disable support for Host Notify Protocol. More... | |
uint8_t | SMBus_targetGetAddress (SMBus *smbus) |
Get the target's own I2C address. More... | |
void | SMBusARPAssignAddress (SMBus *smbus) |
Validates the Received Address into SMBus-transferable byte order. More... | |
int8_t | SMBusARPUDIDByteValidate (SMBus *smbus) |
Validates the Received UDID Byte and address into SMBus-transferable byte order. More... | |
void | SMBusARPGetUDIDPacket (SMBus *smbus) |
Encodes a UDID structure and address into SMBus-transferable byte order. More... | |
void | SMBusARPGetUDIDPacketDirect (SMBus *smbus) |
Encodes a UDID structure and address into SMBus-transferable byte order. More... | |
void | SMBusARP_RESET (SMBus *smbus) |
Resets the States of the AR Flag and AV flag based on POR status. More... | |
void | SMBusARPUDIDPacketDecode (tSMBusUDID *pUDID, uint8_t *pui8Data) |
Decodes an SMBus packet into a UDID structure and address. More... | |
uint8_t | SMBus_targetGetARPInProgress (SMBus *smbus) |
Get ARP Address Progress Status. More... | |
uint8_t | SMBus_targetGetARStatus (SMBus *smbus) |
Get ARP Address Valid Status. More... | |
void | SMBus_targetSetARStatus (SMBus *smbus, uint8_t val) |
Set ARP Address Resolved Status. More... | |
void | SMBus_targetSetAVStatus (SMBus *smbus, uint8_t val) |
Set ARP Address Valid Status. More... | |
uint8_t | SMBus_targetGetAVStatus (SMBus *smbus) |
Get ARP Address Valid Status. More... | |
uint8_t | SMBus_targetGetAddressDirect (SMBus *smbus) |
Get Target Direct Address in ARP Direct Address Call. More... | |
uint8_t | SMBus_targetGetDirectCmd (SMBus *smbus) |
Get Target Direct Command with Direct Address Call. More... | |
int8_t | ARP_UDIDValidate (SMBus *smbus) |
ARP_UDIDValidate. More... | |
void | ARP_invalidCMD (SMBus *smbus) |
ARP Invalid Command Routine. More... | |
int8_t | ARP_isCmdValid (SMBus *smbus) |
Validates a command for ARP. More... | |
int8_t | ARP_CmdComplete (SMBus *smbus) |
ARP Command complete callback. More... | |
enum SMBus_Start |
enum SMBus_Auto_Ack |
enum SMBus_NwkState |
SMBus network layer states.
enum SMBus_ErrorCode |
enum SMBus_State |
SMBus state sent to application layer.
Enumerator | |
---|---|
SMBus_State_OK | Nothing special to report |
SMBus_State_DataSizeError | Incorrect packet size |
SMBus_State_PECError | PEC Error detected |
SMBus_State_TimeOutError | Timeout Error |
SMBus_State_Target_FirstByte | 1st byte (cmd) received |
SMBus_State_Target_ByteReceived | Case where second byte is length in a block command |
SMBus_State_Target_QCMD | Quick Command detected |
SMBus_State_Target_CmdComplete | Complete packet received by target |
SMBus_State_Target_Error | SMBus Target Error |
SMBus_State_Target_NotReady | SMBus Buffers haven't been initialized |
SMBus_State_Target_NTR | No Interrupt flags detected |
SMBus_State_Controller_ArbLost | Arbitration Lost |
SMBus_State_Controller_NACK | Unexpected NACKed |
SMBus_State_Controller_Error | SMBus Controller error |
SMBus_State_Controller_HostNotify | SMBus Controller Host Notify Received |
SMBus_State_Invalid_ARP_Cmd | SMBus State Invalid ARP Command |
SMBus_State_Unknown | SMBus State Unknown |
void SMBus_processDone | ( | SMBus * | smbus | ) |
Clears the current state of SMBus.
Must be called by application in order to clear the state machine when a byte/packet was processed
smbus | Pointer to SMBus structure |
References SMBus_ARP_Status::arpInProgress, SMBus::arpStatus, SMBus_Ctrl::bits, SMBus::ctrl, SMBus::phy, SMBus_Phy::SMBus_Phy_AckPending, SMBus_PHY_targetManualACK(), SMBus_State_OK, SMBus_State_Target_ByteReceived, SMBus_State_Target_FirstByte, SMBus::state, and SMBus_Ctrl::swackEn.
uint16_t SMBus_getRxPayloadAvailable | ( | SMBus * | smbus | ) |
Returns the number of received bytes from last transaction.
smbus | Pointer to SMBus structure |
References SMBus_NWK_getRxPayloadSize().
SMBus_State SMBus_getState | ( | SMBus * | smbus | ) |
Returns the state of the SMBus module.
smbus | Pointer to SMBus structure |
References SMBus::state.
void SMBus_enablePEC | ( | SMBus * | smbus | ) |
Enables PEC support.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, and SMBus_Ctrl::pecEn.
void SMBus_disablePEC | ( | SMBus * | smbus | ) |
Disables PEC support.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, and SMBus_Ctrl::pecEn.
void SMBus_targetInit | ( | SMBus * | smbus, |
I2C_Regs * | i2cAddr | ||
) |
Initialize the SMBus interface as a target.
Initializes the NWK and PHY layers.
smbus | Pointer to SMBus structure |
i2cAddr | Base address of I2C module. |
References SMBus_Ctrl::bits, SMBus_Ctrl::controller, SMBus::ctrl, SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::pecBlockLenOverride, SMBus_Nwk::recByteTxPtr, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMBus_Nwk::rxSize, SMBus_NwkState_Idle, SMBus_PHY_targetInit(), SMBus_State_OK, SMBus::state, SMBus::status, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, SMBus_Nwk::txLen, SMBus_Nwk::txSize, SMBus_Ctrl::u8byte, and SMBus_Status::u8byte.
void SMBus_targetEnableInt | ( | SMBus * | smbus | ) |
Enables the I2C interrupts for a target.
This function enables the I2C Start, Stop, RX, TX, Timeout interrupts
smbus | Pointer to SMBus structure |
References SMBus_PHY_targetEnableInt().
void SMBus_targetDisableInt | ( | SMBus * | smbus | ) |
Disables the I2C interrupts for a target.
This function disables the I2C Start, Stop, RX, TX, Timeout interrupts
smbus | Pointer to SMBus structure |
References SMBus_PHY_targetDisableInt().
SMBus_State SMBus_targetProcessInt | ( | SMBus * | smbus | ) |
I2C Interrupt Service routine for a target.
Handles the interrupts for SMBus passing information to NWK layer Should be called by application when I2C interrupt is detected
smbus | Pointer to SMBus structure |
References SMBus_PHY_targetProcessInt(), SMBus_State_Target_NTR, and SMBus::state.
void SMBus_controllerReset | ( | SMBus * | smbus | ) |
Force reset to SMBus controller interface.
Resets the network and PHY layers
smbus | Pointer to SMBus structure |
References SMBus_NWK_controllerReset().
void SMBus_targetSetAddress | ( | SMBus * | smbus, |
uint8_t | targetAddr | ||
) |
Set the target's own I2C address.
smbus | Pointer to SMBus structure |
targetAddr | Target I2C address |
References SMBus::ownTargetAddr.
void SMBus_targetSetRxBuffer | ( | SMBus * | smbus, |
uint8_t * | data, | ||
uint16_t | size | ||
) |
Initialize the reception buffer for target.
smbus | Pointer to SMBus structure |
data | Pointer to Application RX buffer |
size | Maximum size of buffer |
References SMBus::nwk, SMBus_Nwk::rxBuffPtr, and SMBus_Nwk::rxSize.
void SMBus_targetSetTxBuffer | ( | SMBus * | smbus, |
uint8_t * | data, | ||
uint16_t | size | ||
) |
Initialize the transmission buffer for target.
smbus | Pointer to SMBus structure |
data | Pointer to Application TX buffer |
size | Maximum size of buffer |
References SMBus::nwk, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txSize.
void SMBus_targetReportError | ( | SMBus * | smbus, |
SMBus_ErrorCode | errorCode | ||
) |
Reports an error to SMBus driver from the target.
Used to signal an error when incorrect command/data is detected by the target
smbus | Pointer to SMBus structure |
errorCode | SMBus_ErrorCode |
References SMBus_Status::bits, SMBus_Status::cmdErr, SMBus_Nwk::eState, SMBus::nwk, SMBus_Status::packErr, SMBus_ErrorCode_Cmd, SMBus_ErrorCode_Packet, SMBus_NwkState_Error, SMBus_State_Target_Error, SMBus::state, and SMBus::status.
uint8_t SMBus_targetGetCommand | ( | SMBus * | smbus | ) |
Return the current command (Rxbuffer[0]) received by the target.
smbus | Pointer to SMBus structure |
References SMBus_Nwk::currentCmd, and SMBus::nwk.
Referenced by ARP_isCmdValid().
void SMBus_targetReportBlock | ( | SMBus * | smbus | ) |
Report to hardware that the command type is a block command.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus::nwk, SMBus_Nwk::pecBlockLenOverride, and SMBus_Ctrl::pecEn.
void SMBus_targetReportLength | ( | SMBus * | smbus, |
uint16_t | length | ||
) |
Report to hardware the fixed length of a given command.
smbus | Pointer to SMBus structure |
length | Length of payload (without PEC byte), max supported is 0xFF |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::pecEn, and SMBus_PHY_targetSetPECCount().
Referenced by ARP_invalidCMD().
uint8_t SMBus_targetClearStatusReg | ( | SMBus * | smbus, |
uint8_t | val | ||
) |
Clear the target's status register.
smbus | Pointer to SMBus structure |
val | Bits cleared from status register (1=X, 0=clear) |
References SMBus::status, and SMBus_Status::u8byte.
uint8_t SMBus_targetWriteCtrlReg | ( | SMBus * | smbus, |
uint8_t | val | ||
) |
Write a value to the target's control register.
smbus | Pointer to SMBus structure |
val | Value being written to the Control register |
References SMBus::ctrl, SMBus_Ctrl::u8byte, SMBus_Ctrl::writeableBits, and SMBus_Ctrl::writeBits.
int8_t SMBus_targetHostAlert | ( | SMBus * | smbus, |
uint8_t | deviceAddress, | ||
uint8_t * | txData | ||
) |
Send a Host Alert from the target.
smbus | Pointer to SMBus structure |
deviceAddress | Own Address |
txData | Pointer to TX data (2 bytes) |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxLen, SMB_HOST_DEFAULT_ADDRESS, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TXHostAlert, SMBUS_RET_ERROR, SMBUS_RET_OK, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
void SMBus_controllerInit | ( | SMBus * | smbus, |
I2C_Regs * | i2cAddr, | ||
uint32_t | busClk | ||
) |
Initialize the SMBus Interface for a controller.
Initializes the NWK and PHY layers
smbus | Pointer to SMBus structure |
i2cAddr | Base address of I2C module. |
busClk | SMCLK Frequency |
References SMBus_Ctrl::bits, SMBus_Ctrl::controller, SMBus::ctrl, SMBus_Nwk::currentAddr, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::pecBlockLenOverride, SMBus_Nwk::recByteTxPtr, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBus_Nwk::rxLen, SMBus_Nwk::rxSize, SMBus_NwkState_Idle, SMBus_PHY_controllerInit(), SMBus_State_OK, SMBus::state, SMBus::status, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txIndex, SMBus_Nwk::txLen, SMBus_Nwk::txSize, SMBus_Ctrl::u8byte, and SMBus_Status::u8byte.
void SMBus_controllerEnableInt | ( | SMBus * | smbus | ) |
Enables the I2C interrupts for a controller.
This function enables the I2C Start, Stop, RX, TX, Timeout interrupts. SMBus_controllerInit() must be called before this function.
smbus | Pointer to SMBus structure |
References SMBus_PHY_controllerEnableInt().
void SMBus_controllerDisableInt | ( | SMBus * | smbus | ) |
Disables the I2C interrupts for a controller.
This function disables the I2C Start, Stop, RX, TX, Timeout interrupts.
smbus | Pointer to SMBus structure |
References SMBus_PHY_controllerEnableInt().
SMBus_State SMBus_controllerProcessInt | ( | SMBus * | smbus | ) |
I2C Interrupt Service routine for a controller.
Handles the interrupts for SMBus passing information to NWK layer Should be called by application when I2C interrupt is detected
smbus | Pointer to SMBus structure |
References SMBus_PHY_controllerProcessInt().
int8_t SMBus_controllerProcessCall | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
uint8_t | command, | ||
uint8_t * | txData, | ||
uint8_t * | rxData | ||
) |
Sends a process call to a target.
Send process call to the target. A command byte and 2 bytes of TX data are required. Two bytes of data will be returned by the target in rxData.
smbus | Pointer to SMBus structure |
targetAddr | Target address |
command | Command byte for target |
txData | TX data buffer |
rxData | RX data buffer |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxLen, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TX, SMBUS_RET_ERROR, SMBUS_RET_OK, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
int8_t SMBus_controllerProcessCallBlock | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
uint8_t | command, | ||
uint8_t * | txData, | ||
uint8_t | txSize, | ||
uint8_t * | rxData | ||
) |
Sends a block write-block read process call.
Send block write-block read process call to the target. A command byte, length and tx data byte array are required. Ensure that rxData is large enough to hold the data received from the target.
smbus | Pointer to SMBus structure |
targetAddr | Target address |
command | Command byte for target |
txData | TX data buffer |
txSize | Size of the txData buffer |
rxData | RX data buffer |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxLen, SMB_MAX_PAYLOAD_SIZE, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TX_Block, SMBUS_RET_ERROR, SMBUS_RET_OK, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
int8_t SMBus_controllerSendByte | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
uint8_t | txData | ||
) |
Sends byte to the target.
smbus | Pointer to SMBus structure |
targetAddr | Target address |
txData | TX data buffer |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxLen, SMB_MAX_PAYLOAD_SIZE, SMBus_NWK_startRxTransfer(), SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_RX, SMBus_NwkState_TX, SMBus_NwkState_TX_Block, SMBUS_RET_ERROR, SMBUS_RET_OK, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
int8_t SMBus_controllerReadByteWord | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
uint8_t | command, | ||
uint8_t * | rxData, | ||
uint8_t | rxSize | ||
) |
Receive a byte from the target.
SMBus Block Read command protocol
Block Read:
Block Read with PEC:
where: S = Start bit Sr = Reapeated Start bit Wr = Write bit (0) Rd = Read bit (1) Target Adddress = SMBus address for target Command Code = Command byte sent to target Data Byte = data sent to target A = Acknowledge from target PEC = Optional Packet Error Code P = Stop bit
SMBus Block Write command protocol
Block Write:
8 1 8 1 1
| Data Byte 2 | A | ... | Data Byte N | A | P |
Block Write with PEC:
8 1 8 1 8 1 1
| Data Byte 2 | A | ... | Data Byte N | A | PEC | A | P |
where: S = Start bit Wr = Write bit (0) Target Adddress = SMBus address for target Command Code = Command byte sent to target Data Byte = data sent to target A = Acknowledge from target PEC = Optional Packet Error Code P = Stop bit
SMBus Read ByteWord command protocol
Read Byte:
Read Byte with PEC:
Read Word:
Read Word with PEC:
where: S = Start bit Wr = Read bit (0) Rd = Read bit (1) Target Adddress = SMBus address for target Command Code = Command byte sent to target Data Byte = data sent to target A = Acknowledge from target PEC = Optional Packet Error Code P = Stop bit
~~~~~~~~
smbus | Pointer to SMBus structure |
targetAddr | Target address |
command | Command byte for target |
rxData | RX data buffer |
rxSize | Must be 1 or 2 bytes |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxLen, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TX, SMBUS_RET_ERROR, SMBUS_RET_OK, and SMBus_Nwk::txLen.
int8_t SMBus_controllerWriteByteWord | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
uint8_t | command, | ||
uint8_t * | txData, | ||
uint8_t | txSize | ||
) |
Send a command transmitting a byte or word of data from the target.
smbus | Pointer to SMBus structure |
targetAddr | Target address |
command | Command byte for target |
txData | TX data buffer |
txSize | Must be 1 or 2 bytes |
References SMBus_Nwk::currentAddr, SMBus_Nwk::currentCmd, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxLen, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TX, SMBUS_RET_ERROR, SMBUS_RET_OK, SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
int8_t SMBus_controllerQuickCommand | ( | SMBus * | smbus, |
uint8_t | targetAddr, | ||
bool | write | ||
) |
Send a SMBus "quick command".
A "quick command" is only a trigger. There is no data sent or received.
smbus | Pointer to SMBus structure |
targetAddr | Target address |
write | true if this is a write command, false if this is a read command |
References SMBus_Nwk::currentAddr, SMBus_Nwk::eState, SMBus::nwk, SMBus_Nwk::rxLen, SMBus_NWK_startTxTransfer(), SMBus_NwkState_Idle, SMBus_NwkState_TXQuickCMD, SMBUS_RET_ERROR, SMBUS_RET_OK, and SMBus_Nwk::txLen.
int8_t SMBus_controllerWaitUntilDone | ( | SMBus * | smbus, |
int32_t | timeout | ||
) |
Wait until the previous SMBus command is executed.
smbus | Pointer to SMBus structure |
timeout | Software timeout |
References SMBus_Nwk::eState, SMBus::nwk, SMBus_NwkState_Idle, SMBUS_RET_ERROR, and SMBUS_RET_OK.
void SMBus_controllerEnableHostNotify | ( | SMBus * | smbus, |
uint8_t * | hostAlertBuffer | ||
) |
Enable support for Host Notify Protocol.
Controller will respond to Default host address and recognize a host notify protocol.
smbus | Pointer to SMBus structure |
hostAlertBuffer | Pointer to buffer to store host Alert response |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::hostNotifyEn, SMBus_NWK_controllerEnableHostNotify(), and SMBus_PHY_controllerEnableHostNotify().
void SMBus_controllerDisableHostNotify | ( | SMBus * | smbus | ) |
Disable support for Host Notify Protocol.
Controller will not respond to Default host address and won't recognize the host notify protocol.
smbus | Pointer to SMBus structure |
References SMBus_Ctrl::bits, SMBus::ctrl, SMBus_Ctrl::hostNotifyEn, SMBus_NWK_controllerDisableHostNotify(), and SMBus_PHY_controllerDisableHostNotify().
uint8_t SMBus_targetGetAddress | ( | SMBus * | smbus | ) |
Get the target's own I2C address.
smbus | Pointer to SMBus structure |
References SMBus::ownTargetAddr.
Referenced by ARP_CmdComplete(), and ARP_isCmdValid().
void SMBusARPAssignAddress | ( | SMBus * | smbus | ) |
Validates the Received Address into SMBus-transferable byte order.
This function takes a tSMBusUDID and Acknowledges the Target Address Upon Successful Identification of UDID
smbus | specifies the SMBUS structure UDIA Data to encode. |
References SMBus_ARP_Status::arpAddResolved, SMBus_ARP_Status::arpAddressValid, SMBus::arpStatus, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, and SMBus_Phy_ARP_TARGET_ADDR_Reset().
Referenced by ARP_CmdComplete().
int8_t SMBusARPUDIDByteValidate | ( | SMBus * | smbus | ) |
Validates the Received UDID Byte and address into SMBus-transferable byte order.
smbus | specifies the SMBUS structure UDIA Data to encode. |
This function takes a tSMBusUDID structure and re-orders the bytes so that it can be transferred on the bus. The destination data buffer must contain at least 17 bytes.
References SMBus_ARP_Status::arpRxData, SMBus::arpStatus, SMBus::nwk, SMBus_Nwk::pUDID, SMBus_Nwk::rxBuffPtr, SMBus_Nwk::rxIndex, SMBUS_ARP_UDID_LEN, SMBUS_RET_ERROR, SMBUS_RET_OK_FIXED, tSMBusUDID::ui16DeviceID, tSMBusUDID::ui16Interface, tSMBusUDID::ui16SubSystemDeviceID, tSMBusUDID::ui16SubSystemVendorID, tSMBusUDID::ui16VendorID, tSMBusUDID::ui32VendorSpecificID, tSMBusUDID::ui8DeviceCapabilities, and tSMBusUDID::ui8Version.
Referenced by ARP_UDIDValidate().
void SMBusARPGetUDIDPacket | ( | SMBus * | smbus | ) |
Encodes a UDID structure and address into SMBus-transferable byte order.
smbus | specifies the SMBUS structure UDIA Data to encode. |
This function takes a tSMBusUDID structure and re-orders the bytes so that it can be transferred on the bus. The destination data buffer must contain at least 17 bytes.
References SMBus_ARP_Status::arpAddResolved, SMBus::arpStatus, SMBus::nwk, RESPONSE_NTR, SMBusARPGetUDIDPacketDirect(), SMBus_Nwk::txBuffPtr, and SMBus_Nwk::txLen.
Referenced by ARP_CmdComplete().
void SMBusARPGetUDIDPacketDirect | ( | SMBus * | smbus | ) |
Encodes a UDID structure and address into SMBus-transferable byte order.
smbus | specifies the SMBUS structure UDIA Data to encode. |
This function takes a tSMBusUDID structure and re-orders the bytes so that it can be transferred on the bus. The destination data buffer must contain at least 17 bytes.
References SMBus_ARP_Status::arpAddressValid, SMBus::arpStatus, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Nwk::pUDID, SMBUS_ARP_UDID_LEN, SMBus_Nwk::txBuffPtr, SMBus_Nwk::txLen, tSMBusUDID::ui16DeviceID, tSMBusUDID::ui16Interface, tSMBusUDID::ui16SubSystemDeviceID, tSMBusUDID::ui16SubSystemVendorID, tSMBusUDID::ui16VendorID, tSMBusUDID::ui32VendorSpecificID, tSMBusUDID::ui8DeviceCapabilities, and tSMBusUDID::ui8Version.
Referenced by ARP_CmdComplete(), and SMBusARPGetUDIDPacket().
void SMBusARP_RESET | ( | SMBus * | smbus | ) |
Resets the States of the AR Flag and AV flag based on POR status.
smbus | specifies the SMBUS structure UDIA Data to encode. |
This function takes a data buffer and decodes it into a tSMBusUDID structure and an address variable. It is assumed that there are 17 bytes in the data buffer.
References ARP_ADD_VALID, SMBus_ARP_Status::arpAddResolved, SMBus_ARP_Status::arpAddressValid, SMBus::arpStatus, SMBus::nwk, SMBus::ownTargetAddr, SMBus_Nwk::pUDID, SMBus_Phy_ARP_TARGET_ADDR_Reset(), SMBUS_TARGET_OWN_ADDRESS, and tSMBusUDID::ui8DeviceCapabilities.
Referenced by ARP_CmdComplete().
void SMBusARPUDIDPacketDecode | ( | tSMBusUDID * | pUDID, |
uint8_t * | pui8Data | ||
) |
Decodes an SMBus packet into a UDID structure and address.
pUDID | specifies the EDID structure. |
pui8Data | specifies the EDID that is updated with new data. |
References tSMBusUDID::ui16DeviceID, tSMBusUDID::ui16Interface, tSMBusUDID::ui16SubSystemDeviceID, tSMBusUDID::ui16SubSystemVendorID, tSMBusUDID::ui16VendorID, tSMBusUDID::ui32VendorSpecificID, tSMBusUDID::ui8DeviceCapabilities, and tSMBusUDID::ui8Version.
uint8_t SMBus_targetGetARPInProgress | ( | SMBus * | smbus | ) |
Get ARP Address Progress Status.
smbus | With Received command |
References SMBus_ARP_Status::arpInProgress, and SMBus::arpStatus.
uint8_t SMBus_targetGetARStatus | ( | SMBus * | smbus | ) |
Get ARP Address Valid Status.
smbus | With Received command |
References SMBus_ARP_Status::arpAddResolved, and SMBus::arpStatus.
Referenced by ARP_isCmdValid().
void SMBus_targetSetARStatus | ( | SMBus * | smbus, |
uint8_t | val | ||
) |
Set ARP Address Resolved Status.
smbus | With ARP Status |
val | : AR Flag Value |
References SMBus_ARP_Status::arpAddResolved, and SMBus::arpStatus.
Referenced by ARP_CmdComplete().
void SMBus_targetSetAVStatus | ( | SMBus * | smbus, |
uint8_t | val | ||
) |
Set ARP Address Valid Status.
smbus | With ARP Status |
val | : AV Flag Value |
References SMBus_ARP_Status::arpAddressValid, and SMBus::arpStatus.
uint8_t SMBus_targetGetAVStatus | ( | SMBus * | smbus | ) |
Get ARP Address Valid Status.
smbus | With Received command |
References SMBus_ARP_Status::arpAddressValid, and SMBus::arpStatus.
Referenced by ARP_isCmdValid().
uint8_t SMBus_targetGetAddressDirect | ( | SMBus * | smbus | ) |
Get Target Direct Address in ARP Direct Address Call.
smbus | With Received command |
References SMBus_Nwk::currentCmd, and SMBus::nwk.
Referenced by ARP_CmdComplete(), and ARP_isCmdValid().
uint8_t SMBus_targetGetDirectCmd | ( | SMBus * | smbus | ) |
Get Target Direct Command with Direct Address Call.
smbus | With Received command |
References SMBus_Nwk::currentCmd, and SMBus::nwk.
Referenced by ARP_CmdComplete(), and ARP_isCmdValid().
int8_t ARP_UDIDValidate | ( | SMBus * | smbus | ) |
ARP_UDIDValidate.
smbus | SMBus structure with UDID and ARP Status |
This function is called when a new RX packet is received and to be Validated
References SMBus_ARP_Status::arpCommand, SMBus::arpStatus, SMBUS_CMD_ARP_ASSIGN_ADDRESS, SMBUS_RET_OK_FIXED, and SMBusARPUDIDByteValidate().
void ARP_invalidCMD | ( | SMBus * | smbus | ) |
ARP Invalid Command Routine.
This function is called when a received packet is invalid
References SMBus_ARP_Status::arpDataLength, SMBus_ARP_Status::arpInProgress, SMBus::arpStatus, SMBus_ARP_Status::errorState, SMBus::nwk, SMBus_Nwk::pecBlockLenOverride, SMBus::phy, RESPONSE_NTR, SMBUS_ARP_UDID_LEN, SMBus_Phy::SMBus_Phy_AckPending, SMBus_PHY_targetManualACK(), SMBus_State_Invalid_ARP_Cmd, SMBus_targetReportLength(), and SMBus_Nwk::txBuffPtr.
Referenced by ARP_CmdComplete(), and ARP_isCmdValid().
int8_t ARP_isCmdValid | ( | SMBus * | smbus | ) |
Validates a command for ARP.
smbus | With Received command and ARP Status |
This function is called when a command is received with Default Device Address (0x61) and the target needs to Respond with NACK for Invalid Scenarios check if the command is valid
References ARP_invalidCMD(), SMBus_ARP_Status::arpCommand, SMBus_ARP_Status::arpDataLength, SMBus::arpStatus, SMBus_ARP_Status::arpUDIDNacked, SMBus_ARP_Status::arpUDIDTransmit, SMBus::nwk, SMBus_Nwk::pecBlockLenOverride, SMBUS_ARP_UDID_LEN, SMBUS_CMD_ARP_ASSIGN_ADDRESS, SMBUS_CMD_ARP_GET_UDID, SMBUS_CMD_ARP_RESET_DEVICE, SMBUS_CMD_PREPARE_TO_ARP, SMBus_Phy_ARP_Get_Write_Status(), SMBUS_RET_OK_FIXED, SMBus_targetGetAddress(), SMBus_targetGetAddressDirect(), SMBus_targetGetARStatus(), SMBus_targetGetAVStatus(), SMBus_targetGetCommand(), and SMBus_targetGetDirectCmd().
int8_t ARP_CmdComplete | ( | SMBus * | smbus | ) |
ARP Command complete callback.
This function is called when a received packet is ready to process after a STOP or RE-START.
References ARP_invalidCMD(), SMBus_ARP_Status::arpCommand, SMBus_ARP_Status::arpInProgress, SMBus::arpStatus, SMBUS_CMD_ARP_ASSIGN_ADDRESS, SMBUS_CMD_ARP_GET_UDID, SMBUS_CMD_ARP_RESET_DEVICE, SMBUS_CMD_PREPARE_TO_ARP, SMBUS_RET_OK_FIXED, SMBus_targetGetAddress(), SMBus_targetGetAddressDirect(), SMBus_targetGetDirectCmd(), SMBus_targetSetARStatus(), SMBusARP_RESET(), SMBusARPAssignAddress(), SMBusARPGetUDIDPacket(), and SMBusARPGetUDIDPacketDirect().