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;
344 #ifdef __MSPM0_HAS_I2C__ 356 #if defined(__MCU_HAS_UNICOMMI2CC__) && defined(__MCU_HAS_UNICOMMI2CT__) 362 SMBus_Stop SMBus_Phy_stop;
364 bool SMBus_Phy_AckPending;
586 uint8_t packOvrErr : 1;
588 uint8_t byteOvrErr : 1;
592 uint8_t reserved : 2;
715 #if defined(__MSPM0_HAS_I2C__) 731 #if defined(__MCU_HAS_UNICOMMI2CT__) 864 SMBus_ErrorCode errorCode);
954 uint8_t deviceAddress,
958 #if defined(__MSPM0_HAS_I2C__) 975 #if defined(__MCU_HAS_UNICOMMI2CC__) 1241 extern int8_t SMBus_controllerReceiveByte(
SMBus *smbus,
1301 extern int8_t SMBus_controllerReadBlock(
SMBus *smbus,
1356 extern int8_t SMBus_controllerWriteBlock(
SMBus *smbus,
1809 #endif //__SMBUS_H__ void SMBus_targetReportBlock(SMBus *smbus)
Report to hardware that the command type is a block command.
Definition: smbus.c:190
uint8_t ownTargetAddr
Definition: smbus.h:646
uint8_t SMBus_targetGetAddress(SMBus *smbus)
Get the target's own I2C address.
Definition: smbus.c:547
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:286
uint8_t SMBus_targetGetARPInProgress(SMBus *smbus)
Get ARP Address Progress Status.
Definition: smbus.c:799
uint16_t ui16VendorID
Definition: smbus.h:424
uint8_t SMBus_targetClearStatusReg(SMBus *smbus, uint8_t val)
Clear the target's status register.
Definition: smbus.c:207
uint16_t rxLen
Definition: smbus.h:475
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:315
int8_t SMBus_controllerQuickCommand(SMBus *smbus, uint8_t targetAddr, bool write)
Send a SMBus "quick command".
Definition: smbus.c:489
uint8_t currentCmd
Definition: smbus.h:471
uint16_t ui16Interface
Definition: smbus.h:436
SMBus_State SMBus_controllerProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a controller.
Definition: smbus.c:281
uint8_t SMBus_targetGetAddressDirect(SMBus *smbus)
Get Target Direct Address in ARP Direct Address Call.
Definition: smbus.c:824
uint8_t arpAddResolved
Definition: smbus.h:606
SMBus_Nwk nwk
Definition: smbus.h:636
bool SMBus_Phy_AckPending
Definition: smbus.h:352
uint16_t txIndex
Definition: smbus.h:481
uint8_t arpInProgress
Definition: smbus.h:610
SMBus_Ctrl ctrl
Definition: smbus.h:638
SMBus_Stop SMBus_Phy_stop
Definition: smbus.h:350
uint8_t arpCommand
Definition: smbus.h:612
SMBus_Phy phy
Definition: smbus.h:634
uint8_t ui8DeviceCapabilities
Definition: smbus.h:411
uint8_t ui8Version
Definition: smbus.h:418
SMBus_ErrorCode
List of error codes used by the application to indicate an error to the library.
Definition: smbus.h:511
void SMBus_targetSetARStatus(SMBus *smbus, uint8_t val)
Set ARP Address Resolved Status.
Definition: smbus.c:809
uint8_t u8byte
Definition: smbus.h:595
void SMBus_targetReportError(SMBus *smbus, SMBus_ErrorCode errorCode)
Reports an error to SMBus driver from the target.
Definition: smbus.c:165
SMBus control register.
Definition: smbus.h:299
void SMBus_controllerDisableHostNotify(SMBus *smbus)
Disable support for Host Notify Protocol.
Definition: smbus.c:541
volatile SMBus_NwkState eState
Definition: smbus.h:467
uint8_t * txBuffPtr
Definition: smbus.h:485
uint8_t arpAddressValid
Definition: smbus.h:608
uint8_t * hostNotifyRxBuffPtr
Definition: smbus.h:493
UNICOMM_Inst_Regs * SMBus_Phy_i2cBase
Definition: smbus.h:360
SMBus_State SMBus_targetProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a target.
Definition: smbus.c:127
SMBus_State state
Definition: smbus.h:644
void SMBus_controllerInit(SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk)
Initialize the SMBus Interface for a controller.
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:147
uint8_t arpUDIDNacked
Definition: smbus.h:620
int8_t SMBus_controllerSendByte(SMBus *smbus, uint8_t targetAddr, uint8_t txData)
Sends byte to the target.
Definition: smbus.c:345
uint16_t rxIndex
Definition: smbus.h:473
uint16_t ui16SubSystemDeviceID
Definition: smbus.h:448
SMBus_ARP_Status arpStatus
Definition: smbus.h:642
uint8_t SMBus_targetGetARStatus(SMBus *smbus)
Get ARP Address Valid Status.
Definition: smbus.c:804
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:433
void ARP_invalidCMD(SMBus *smbus)
ARP Invalid Command Routine.
Definition: smbus.c:921
uint8_t arpUDIDTransmit
Definition: smbus.h:622
int8_t SMBus_controllerWaitUntilDone(SMBus *smbus, int32_t timeout)
Wait until the previous SMBus command is executed.
Definition: smbus.c:516
void SMBusARPGetUDIDPacketDirect(SMBus *smbus)
Encodes a UDID structure and address into SMBus-transferable byte order.
Definition: smbus.c:684
uint8_t arpRxData
Definition: smbus.h:616
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:291
uint32_t ui32VendorSpecificID
Definition: smbus.h:454
void SMBus_targetSetTxBuffer(SMBus *smbus, uint8_t *data, uint16_t size)
Initialize the transmission buffer for target.
Definition: smbus.c:156
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:742
uint16_t txSize
Definition: smbus.h:489
uint8_t * recByteTxPtr
Definition: smbus.h:487
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:185
void SMBus_controllerEnableInt(SMBus *smbus)
Enables the I2C interrupts for a controller.
Definition: smbus.c:270
void SMBus_targetSetAVStatus(SMBus *smbus, uint8_t val)
Set ARP Address Valid Status.
Definition: smbus.c:814
SMBus_NwkState
SMBus network layer states.
Definition: smbus.h:373
uint8_t * rxBuffPtr
Definition: smbus.h:479
SMBus_State errorState
Definition: smbus.h:618
tSMBusUDID * pUDID
Definition: smbus.h:502
SMBus_Status status
Definition: smbus.h:640
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:526
void SMBus_controllerDisableInt(SMBus *smbus)
Disables the I2C interrupts for a controller.
Definition: smbus.c:275
int8_t SMBus_targetHostAlert(SMBus *smbus, uint8_t deviceAddress, uint8_t *txData)
Send a Host Alert from the target.
Definition: smbus.c:222
SMBus ARP Status Register.
Definition: smbus.h:603
void SMBus_targetSetAddress(SMBus *smbus, uint8_t targetAddr)
Set the target's own I2C address.
Definition: smbus.c:140
uint8_t pecBlockLenOverride
Definition: smbus.h:491
int8_t ARP_CmdComplete(SMBus *smbus)
ARP Command complete callback.
Definition: smbus.c:938
Physical and Data Link Layer object.
Definition: smbus.h:345
void SMBusARPGetUDIDPacket(SMBus *smbus)
Encodes a UDID structure and address into SMBus-transferable byte order.
Definition: smbus.c:724
uint8_t currentAddr
Definition: smbus.h:469
int8_t ARP_UDIDValidate(SMBus *smbus)
ARP_UDIDValidate.
Definition: smbus.c:912
int8_t ARP_isCmdValid(SMBus *smbus)
Validates a command for ARP.
Definition: smbus.c:834
void SMBus_targetInit(SMBus *smbus, I2C_Regs *i2cAddr)
Initialize the SMBus interface as a target.
Main SMBus object.
Definition: smbus.h:631
void SMBus_targetEnableInt(SMBus *smbus)
Enables the I2C interrupts for a target.
Definition: smbus.c:116
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:262
uint8_t arpUDIDNacked
Definition: smbus.h:648
uint8_t SMBus_targetGetDirectCmd(SMBus *smbus)
Get Target Direct Command with Direct Address Call.
Definition: smbus.c:829
I2C_Regs * SMBus_Phy_i2cBase
Definition: smbus.h:348
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:461
void SMBusARPUDIDPacketDecode(tSMBusUDID *pUDID, uint8_t *pui8Data)
Decodes an SMBus packet into a UDID structure and address.
Definition: smbus.c:778
uint8_t SMBus_targetWriteCtrlReg(SMBus *smbus, uint8_t val)
Write a value to the target's control register.
Definition: smbus.c:214
uint16_t txLen
Definition: smbus.h:483
void SMBus_targetDisableInt(SMBus *smbus)
Disables the I2C interrupts for a target.
Definition: smbus.c:121
SMBus Status Register.
Definition: smbus.h:570
uint16_t arpDataLength
Definition: smbus.h:614
void SMBus_targetReportLength(SMBus *smbus, uint16_t length)
Report to hardware the fixed length of a given command.
Definition: smbus.c:200
uint32_t arpWriteState
Definition: smbus.h:624
Definition of SMBus Network structure.
Definition: smbus.h:464
uint16_t ui16SubSystemVendorID
Definition: smbus.h:442
void SMBus_controllerEnableHostNotify(SMBus *smbus, uint8_t *hostAlertBuffer)
Enable support for Host Notify Protocol.
Definition: smbus.c:534
void SMBusARPAssignAddress(SMBus *smbus)
Validates the Received Address into SMBus-transferable byte order.
Definition: smbus.c:554
uint16_t rxSize
Definition: smbus.h:477
uint16_t ui16DeviceID
Definition: smbus.h:430
int8_t SMBusARPUDIDByteValidate(SMBus *smbus)
Validates the Received UDID Byte and address into SMBus-transferable byte order.
Definition: smbus.c:564
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:819
uint16_t SMBus_getRxPayloadAvailable(SMBus *smbus)
Returns the number of received bytes from last transaction.
Definition: smbus.c:67