60 #include <ti/devices/msp/msp.h> 61 #include <ti/driverlib/driverlib.h> 62 #include <ti/driverlib/m0p/dl_core.h> 78 #ifndef SMB_TARGET_SUPPORTS_HOST_NOTIFY 79 #define SMB_TARGET_SUPPORTS_HOST_NOTIFY (true) 87 #ifndef SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY 88 #define SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY (true) 100 #define SMB_MAX_PAYLOAD_SIZE (255) 107 #define SMB_MAX_PACKET_SIZE (SMB_MAX_PAYLOAD_SIZE + 3) 114 #define SMB_HOST_ALERT_PACKET_SIZE (3) 121 #define SMB_HOST_DEFAULT_ADDRESS (0x08) 128 #define RESPONSE_NTR 0xFF 135 #define SMBUS_RET_OK (1) 141 #define SMBUS_RET_OK_FIXED (2) 147 #define SMBUS_RET_OK_BLOCK (3) 155 #define SMBUS_RET_ERROR (-1) 162 #define SMBUS_BLOCK_LENGTH (0xFFFF) 169 #define SMBUS_CMD_PREPARE_TO_ARP 0x01 175 #define SMBUS_CMD_ARP_RESET_DEVICE 0x02 181 #define SMBUS_CMD_ARP_GET_UDID 0x03 187 #define SMBUS_CMD_ARP_ASSIGN_ADDRESS 0x04 199 #define SMBUS_ADR_HOST 0x08 205 #define SMBUS_ADR_SMART_BATTERY_CHARGER 0x09 211 #define SMBUS_ADR_SMART_BATTERY_SELECTOR 0x0A 217 #define SMBUS_ADR_SMART_BATTERY 0x0B 223 #define SMBUS_ADR_DEFAULT_DEVICE 0x61 229 #define SMBUS_TARGET_OWN_ADDRESS SMBUS_ADR_SMART_BATTERY_CHARGER 235 #define SMBUS_ARP_UDID_LEN 0x11 241 #define ARP_ADD_RESOLVED 0x00 246 #define ARP_ADD_VALID 0x00 251 #define ARP_ADD_TYPE 0x00 264 SMBus_Stop_After_Transfer = 0,
265 SMBus_No_Stop_After_Transfer
311 uint8_t hostNotifyEn : 1;
319 uint8_t controller : 1;
321 uint8_t reserved2 : 2;
331 uint8_t writeBits : 2;
333 uint8_t reserved : 6;
572 uint8_t packOvrErr : 1;
574 uint8_t byteOvrErr : 1;
578 uint8_t reserved : 2;
832 SMBus_ErrorCode errorCode);
922 uint8_t deviceAddress,
1191 extern int8_t SMBus_controllerReceiveByte(
SMBus *smbus,
1251 extern int8_t SMBus_controllerReadBlock(
SMBus *smbus,
1306 extern int8_t SMBus_controllerWriteBlock(
SMBus *smbus,
1759 #endif //__SMBUS_H__ void SMBus_targetReportBlock(SMBus *smbus)
Report to hardware that the command type is a block command.
Definition: smbus.c:186
uint8_t ownTargetAddr
Definition: smbus.h:632
uint8_t SMBus_targetGetAddress(SMBus *smbus)
Get the target's own I2C address.
Definition: smbus.c:540
SMBus_Auto_Ack
List of auto ack codes used within the NWK and PHY layers.
Definition: smbus.h:286
void SMBus_controllerReset(SMBus *smbus)
Force reset to SMBus controller interface.
Definition: smbus.c:279
uint8_t SMBus_targetGetARPInProgress(SMBus *smbus)
Get ARP Address Progress Status.
Definition: smbus.c:792
uint16_t ui16VendorID
Definition: smbus.h:410
uint8_t SMBus_targetClearStatusReg(SMBus *smbus, uint8_t val)
Clear the target's status register.
Definition: smbus.c:203
uint16_t rxLen
Definition: smbus.h:461
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.
Definition: smbus.c:308
int8_t SMBus_controllerQuickCommand(SMBus *smbus, uint8_t targetAddr, bool write)
Send a SMBus "quick command".
Definition: smbus.c:482
uint8_t currentCmd
Definition: smbus.h:457
uint16_t ui16Interface
Definition: smbus.h:422
SMBus_State SMBus_controllerProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a controller.
Definition: smbus.c:274
uint8_t SMBus_targetGetAddressDirect(SMBus *smbus)
Get Target Direct Address in ARP Direct Address Call.
Definition: smbus.c:817
uint8_t arpAddResolved
Definition: smbus.h:592
SMBus_Nwk nwk
Definition: smbus.h:622
bool SMBus_Phy_AckPending
Definition: smbus.h:351
uint16_t txIndex
Definition: smbus.h:467
uint8_t arpInProgress
Definition: smbus.h:596
SMBus_Ctrl ctrl
Definition: smbus.h:624
SMBus_Stop SMBus_Phy_stop
Definition: smbus.h:349
uint8_t arpCommand
Definition: smbus.h:598
SMBus_Phy phy
Definition: smbus.h:620
uint8_t ui8DeviceCapabilities
Definition: smbus.h:397
uint8_t ui8Version
Definition: smbus.h:404
SMBus_ErrorCode
List of error codes used by the application to indicate an error to the library.
Definition: smbus.h:497
void SMBus_targetSetARStatus(SMBus *smbus, uint8_t val)
Set ARP Address Resolved Status.
Definition: smbus.c:802
uint8_t u8byte
Definition: smbus.h:581
void SMBus_targetReportError(SMBus *smbus, SMBus_ErrorCode errorCode)
Reports an error to SMBus driver from the target.
Definition: smbus.c:161
SMBus control register.
Definition: smbus.h:299
void SMBus_controllerDisableHostNotify(SMBus *smbus)
Disable support for Host Notify Protocol.
Definition: smbus.c:534
volatile SMBus_NwkState eState
Definition: smbus.h:453
uint8_t * txBuffPtr
Definition: smbus.h:471
uint8_t arpAddressValid
Definition: smbus.h:594
uint8_t * hostNotifyRxBuffPtr
Definition: smbus.h:479
SMBus_State SMBus_targetProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a target.
Definition: smbus.c:123
SMBus_State state
Definition: smbus.h:630
void SMBus_controllerInit(SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk)
Initialize the SMBus Interface for a controller.
Definition: smbus.c:239
void SMBus_disablePEC(SMBus *smbus)
Disables PEC support.
Definition: smbus.c:83
void SMBus_targetSetRxBuffer(SMBus *smbus, uint8_t *data, uint16_t size)
Initialize the reception buffer for target.
Definition: smbus.c:143
uint8_t arpUDIDNacked
Definition: smbus.h:606
int8_t SMBus_controllerSendByte(SMBus *smbus, uint8_t targetAddr, uint8_t txData)
Sends byte to the target.
Definition: smbus.c:338
uint16_t rxIndex
Definition: smbus.h:459
uint16_t ui16SubSystemDeviceID
Definition: smbus.h:434
SMBus_ARP_Status arpStatus
Definition: smbus.h:628
uint8_t SMBus_targetGetARStatus(SMBus *smbus)
Get ARP Address Valid Status.
Definition: smbus.c:797
void SMBus_processDone(SMBus *smbus)
Clears the current state of SMBus.
Definition: smbus.c:41
int8_t SMBus_controllerReadByteWord(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *rxData, uint8_t rxSize)
Receive a byte from the target.
Definition: smbus.c:426
void ARP_invalidCMD(SMBus *smbus)
ARP Invalid Command Routine.
Definition: smbus.c:914
uint8_t arpUDIDTransmit
Definition: smbus.h:608
int8_t SMBus_controllerWaitUntilDone(SMBus *smbus, int32_t timeout)
Wait until the previous SMBus command is executed.
Definition: smbus.c:509
void SMBusARPGetUDIDPacketDirect(SMBus *smbus)
Encodes a UDID structure and address into SMBus-transferable byte order.
Definition: smbus.c:677
uint8_t arpRxData
Definition: smbus.h:602
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.
Definition: smbus.c:284
uint32_t ui32VendorSpecificID
Definition: smbus.h:440
void SMBus_targetSetTxBuffer(SMBus *smbus, uint8_t *data, uint16_t size)
Initialize the transmission buffer for target.
Definition: smbus.c:152
uint8_t u8byte
Definition: smbus.h:336
void SMBus_enablePEC(SMBus *smbus)
Enables PEC support.
Definition: smbus.c:78
void SMBusARP_RESET(SMBus *smbus)
Resets the States of the AR Flag and AV flag based on POR status.
Definition: smbus.c:735
uint16_t txSize
Definition: smbus.h:475
uint8_t * recByteTxPtr
Definition: smbus.h:473
SMBus_State SMBus_getState(SMBus *smbus)
Returns the state of the SMBus module.
Definition: smbus.c:72
uint8_t SMBus_targetGetCommand(SMBus *smbus)
Return the current command (Rxbuffer[0]) received by the target.
Definition: smbus.c:181
void SMBus_controllerEnableInt(SMBus *smbus)
Enables the I2C interrupts for a controller.
Definition: smbus.c:263
void SMBus_targetSetAVStatus(SMBus *smbus, uint8_t val)
Set ARP Address Valid Status.
Definition: smbus.c:807
SMBus_NwkState
SMBus network layer states.
Definition: smbus.h:359
uint8_t * rxBuffPtr
Definition: smbus.h:465
SMBus_State errorState
Definition: smbus.h:604
tSMBusUDID * pUDID
Definition: smbus.h:488
SMBus_Status status
Definition: smbus.h:626
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:512
void SMBus_controllerDisableInt(SMBus *smbus)
Disables the I2C interrupts for a controller.
Definition: smbus.c:268
int8_t SMBus_targetHostAlert(SMBus *smbus, uint8_t deviceAddress, uint8_t *txData)
Send a Host Alert from the target.
Definition: smbus.c:218
SMBus ARP Status Register.
Definition: smbus.h:589
void SMBus_targetSetAddress(SMBus *smbus, uint8_t targetAddr)
Set the target's own I2C address.
Definition: smbus.c:136
uint8_t pecBlockLenOverride
Definition: smbus.h:477
int8_t ARP_CmdComplete(SMBus *smbus)
ARP Command complete callback.
Definition: smbus.c:931
Physical and Data Link Layer object.
Definition: smbus.h:344
void SMBusARPGetUDIDPacket(SMBus *smbus)
Encodes a UDID structure and address into SMBus-transferable byte order.
Definition: smbus.c:717
uint8_t currentAddr
Definition: smbus.h:455
int8_t ARP_UDIDValidate(SMBus *smbus)
ARP_UDIDValidate.
Definition: smbus.c:905
int8_t ARP_isCmdValid(SMBus *smbus)
Validates a command for ARP.
Definition: smbus.c:827
void SMBus_targetInit(SMBus *smbus, I2C_Regs *i2cAddr)
Initialize the SMBus interface as a target.
Definition: smbus.c:89
Main SMBus object.
Definition: smbus.h:617
void SMBus_targetEnableInt(SMBus *smbus)
Enables the I2C interrupts for a target.
Definition: smbus.c:112
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:262
uint8_t arpUDIDNacked
Definition: smbus.h:634
uint8_t SMBus_targetGetDirectCmd(SMBus *smbus)
Get Target Direct Command with Direct Address Call.
Definition: smbus.c:822
I2C_Regs * SMBus_Phy_i2cBase
Definition: smbus.h:347
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.
Definition: smbus.c:454
void SMBusARPUDIDPacketDecode(tSMBusUDID *pUDID, uint8_t *pui8Data)
Decodes an SMBus packet into a UDID structure and address.
Definition: smbus.c:771
uint8_t SMBus_targetWriteCtrlReg(SMBus *smbus, uint8_t val)
Write a value to the target's control register.
Definition: smbus.c:210
uint16_t txLen
Definition: smbus.h:469
void SMBus_targetDisableInt(SMBus *smbus)
Disables the I2C interrupts for a target.
Definition: smbus.c:117
SMBus Status Register.
Definition: smbus.h:556
uint16_t arpDataLength
Definition: smbus.h:600
void SMBus_targetReportLength(SMBus *smbus, uint16_t length)
Report to hardware the fixed length of a given command.
Definition: smbus.c:196
uint32_t arpWriteState
Definition: smbus.h:610
Definition of SMBus Network structure.
Definition: smbus.h:450
uint16_t ui16SubSystemVendorID
Definition: smbus.h:428
void SMBus_controllerEnableHostNotify(SMBus *smbus, uint8_t *hostAlertBuffer)
Enable support for Host Notify Protocol.
Definition: smbus.c:527
void SMBusARPAssignAddress(SMBus *smbus)
Validates the Received Address into SMBus-transferable byte order.
Definition: smbus.c:547
uint16_t rxSize
Definition: smbus.h:463
uint16_t ui16DeviceID
Definition: smbus.h:416
int8_t SMBusARPUDIDByteValidate(SMBus *smbus)
Validates the Received UDID Byte and address into SMBus-transferable byte order.
Definition: smbus.c:557
SMBus_Start
List of start codes used within the NWK and PHY layers.
Definition: smbus.h:273
uint8_t SMBus_targetGetAVStatus(SMBus *smbus)
Get ARP Address Valid Status.
Definition: smbus.c:812
uint16_t SMBus_getRxPayloadAvailable(SMBus *smbus)
Returns the number of received bytes from last transaction.
Definition: smbus.c:67