SMBusLibrary  1.0
smbus.h
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __SMBUS_H__
33 #define __SMBUS_H__
34 
35 //*****************************************************************************
36 //
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 //
54 // Include files
55 //
56 #include <stdlib.h>
57 #include <stdint.h>
58 #include <stdbool.h>
59 
60 #include <ti/devices/msp/msp.h>
61 #include <ti/driverlib/driverlib.h>
62 #include <ti/driverlib/m0p/dl_core.h>
63 
64 //*****************************************************************************
65 // defines
66 //*****************************************************************************
67 
68 
69 //*****************************************************************************
70 // Configuration
71 //*****************************************************************************
72 
73 //*****************************************************************************
74 //
76 //
77 //*****************************************************************************
78 #ifndef SMB_TARGET_SUPPORTS_HOST_NOTIFY
79 #define SMB_TARGET_SUPPORTS_HOST_NOTIFY (true)
80 #endif
81 
82 //*****************************************************************************
83 //
85 //
86 //*****************************************************************************
87 #ifndef SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY
88 #define SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY (true)
89 #endif
90 
91 //*****************************************************************************
92 // Constant definitions
93 //*****************************************************************************
94 
95 //*****************************************************************************
96 //
98 //
99 //*****************************************************************************
100 #define SMB_MAX_PAYLOAD_SIZE (255)
101 
102 //*****************************************************************************
103 //
105 //
106 //*****************************************************************************
107 #define SMB_MAX_PACKET_SIZE (SMB_MAX_PAYLOAD_SIZE + 3)
108 
109 //*****************************************************************************
110 //
112 //
113 //*****************************************************************************
114 #define SMB_HOST_ALERT_PACKET_SIZE (3)
115 
116 //*****************************************************************************
117 //
119 //
120 //*****************************************************************************
121 #define SMB_HOST_DEFAULT_ADDRESS (0x08)
122 
123 //*****************************************************************************
124 //
126 //
127 //*****************************************************************************
128 #define RESPONSE_NTR 0xFF
129 
130 //*****************************************************************************
131 //
133 //
134 //*****************************************************************************
135 #define SMBUS_RET_OK (1)
136 //*****************************************************************************
137 //
139 //
140 //*****************************************************************************
141 #define SMBUS_RET_OK_FIXED (2)
142 //*****************************************************************************
143 //
145 //
146 //*****************************************************************************
147 #define SMBUS_RET_OK_BLOCK (3)
148 
149 
150 //*****************************************************************************
151 //
153 //
154 //*****************************************************************************
155 #define SMBUS_RET_ERROR (-1)
156 
157 //*****************************************************************************
158 //
160 //
161 //*****************************************************************************
162 #define SMBUS_BLOCK_LENGTH (0xFFFF)
163 
164 //*****************************************************************************
165 //
167 //
168 //*****************************************************************************
169 #define SMBUS_CMD_PREPARE_TO_ARP 0x01
170 //*****************************************************************************
171 //
173 //
174 //*****************************************************************************
175 #define SMBUS_CMD_ARP_RESET_DEVICE 0x02
176 //*****************************************************************************
177 //
179 //
180 //*****************************************************************************
181 #define SMBUS_CMD_ARP_GET_UDID 0x03
182 //*****************************************************************************
183 //
185 //
186 //*****************************************************************************
187 #define SMBUS_CMD_ARP_ASSIGN_ADDRESS 0x04
188 
189 //*****************************************************************************
190 //
191 // Fixed addresses defined by the SMBus specification.
192 //
193 //*****************************************************************************
194 //*****************************************************************************
195 //
197 //
198 //*****************************************************************************
199 #define SMBUS_ADR_HOST 0x08
200 //*****************************************************************************
201 //
203 //
204 //*****************************************************************************
205 #define SMBUS_ADR_SMART_BATTERY_CHARGER 0x09
206 //*****************************************************************************
207 //
209 //
210 //*****************************************************************************
211 #define SMBUS_ADR_SMART_BATTERY_SELECTOR 0x0A
212 //*****************************************************************************
213 //
215 //
216 //*****************************************************************************
217 #define SMBUS_ADR_SMART_BATTERY 0x0B
218 //*****************************************************************************
219 //
221 //
222 //*****************************************************************************
223 #define SMBUS_ADR_DEFAULT_DEVICE 0x61
224 //*****************************************************************************
225 //
227 //
228 //*****************************************************************************
229 #define SMBUS_TARGET_OWN_ADDRESS SMBUS_ADR_SMART_BATTERY_CHARGER
230 //*****************************************************************************
231 //
233 //
234 //*****************************************************************************
235 #define SMBUS_ARP_UDID_LEN 0x11
236 
237 //*****************************************************************************
238 //
240 //*****************************************************************************
241 #define ARP_ADD_RESOLVED 0x00
242 //*****************************************************************************
243 //
245 //*****************************************************************************
246 #define ARP_ADD_VALID 0x00
247 //*****************************************************************************
248 //
250 //*****************************************************************************
251 #define ARP_ADD_TYPE 0x00
252 
253 //*****************************************************************************
254 // typedefs
255 //*****************************************************************************
256 
257 //*****************************************************************************
258 //
260 //
261 //*****************************************************************************
262 typedef enum
263 {
264  SMBus_Stop_After_Transfer = 0,
265  SMBus_No_Stop_After_Transfer
266 } SMBus_Stop;
267 
268 //*****************************************************************************
269 //
271 //
272 //*****************************************************************************
273 typedef enum
274 {
279 } SMBus_Start;
280 
281 //*****************************************************************************
282 //
284 //
285 //*****************************************************************************
286 typedef enum
287 {
293 
294 //*****************************************************************************
295 //
297 //
298 //*****************************************************************************
299 typedef union
300 {
301  //*****************************************************************************
302  //
304  //
305  //*****************************************************************************
306  struct
307  {
309  uint8_t pecEn : 1;
311  uint8_t hostNotifyEn : 1;
313  uint8_t swackEn : 1;
315  uint8_t intEn : 1;
317  uint8_t phyEn : 1;
319  uint8_t controller : 1;
321  uint8_t reserved2 : 2;
322  } bits;
323  //*****************************************************************************
324  //
326  //
327  //*****************************************************************************
328  struct
329  {
331  uint8_t writeBits : 2;
333  uint8_t reserved : 6;
334  } writeableBits;
336  uint8_t u8byte;
337 } SMBus_Ctrl;
338 
339 //*****************************************************************************
340 //
342 //
343 //*****************************************************************************
344 #ifdef __MSPM0_HAS_I2C__
345 typedef struct
346 {
348  I2C_Regs* SMBus_Phy_i2cBase;
350  SMBus_Stop SMBus_Phy_stop;
353 } SMBus_Phy;
354 #endif
355 
356 #if defined(__MCU_HAS_UNICOMMI2CC__) && defined(__MCU_HAS_UNICOMMI2CT__)
357 typedef struct
358 {
360  UNICOMM_Inst_Regs* SMBus_Phy_i2cBase;
362  SMBus_Stop SMBus_Phy_stop;
364  bool SMBus_Phy_AckPending;
365 } SMBus_Phy;
366 #endif
367 
368 //*****************************************************************************
369 //
371 //
372 //*****************************************************************************
373 typedef enum
374 {
398 
399 //*****************************************************************************
400 //
403 //
404 //*****************************************************************************
405 typedef struct
406 {
410 
412 
417 
418  uint8_t ui8Version;
419 
423 
424  uint16_t ui16VendorID;
425 
429 
430  uint16_t ui16DeviceID;
431 
435 
436  uint16_t ui16Interface;
437 
441 
443 
447 
449 
453 
455 }
456 tSMBusUDID;
457 
458 /****************************************************************************** */
459 
460 //
462 //
463 //*****************************************************************************
464 typedef struct
465 {
467  volatile SMBus_NwkState eState;
469  uint8_t currentAddr;
471  uint8_t currentCmd;
473  uint16_t rxIndex;
475  uint16_t rxLen;
477  uint16_t rxSize;
479  uint8_t *rxBuffPtr;
481  uint16_t txIndex;
483  uint16_t txLen;
485  uint8_t *txBuffPtr;
487  uint8_t *recByteTxPtr;
489  uint16_t txSize;
494 
503 
504 } SMBus_Nwk;
505 
506 //*****************************************************************************
507 //
509 //
510 //*****************************************************************************
511 typedef enum
512 {
520 
521 //*****************************************************************************
522 //
524 //
525 //*****************************************************************************
526 typedef enum
527 {
562 } SMBus_State;
563 
564 /****************************************************************************** */
565 
566 //
568 //
569 //*****************************************************************************
570 typedef union
571 {
572  //*****************************************************************************
573  //
575  //
576  //*****************************************************************************
577  struct
578  {
580  uint8_t pecErr : 1;
582  uint8_t toErr : 1;
584  uint8_t packErr : 1;
586  uint8_t packOvrErr : 1;
588  uint8_t byteOvrErr : 1;
590  uint8_t cmdErr : 1;
592  uint8_t reserved : 2;
593  } bits;
595  uint8_t u8byte;
596 } SMBus_Status;
597 
598 /****************************************************************************** */
599 //
601 //
602 //*****************************************************************************
603 typedef struct
604 {
606  uint8_t arpAddResolved;
610  uint8_t arpInProgress;
612  uint8_t arpCommand;
614  uint16_t arpDataLength;
616  uint8_t arpRxData;
618  SMBus_State errorState;
620  uint8_t arpUDIDNacked;
624  uint32_t arpWriteState;
626 //*****************************************************************************
627 //
629 //
630 //*****************************************************************************
631 typedef struct
632 {
644  SMBus_State state;
646  uint8_t ownTargetAddr;
648  uint8_t arpUDIDNacked;
649 } SMBus;
650 
651 //*****************************************************************************
652 // globals
653 //*****************************************************************************
654 
655 //*****************************************************************************
656 // Public functions called by applications
657 //*****************************************************************************
658 //*****************************************************************************
659 //
661 //
664 //
666 //
667 // \return None
668 //
669 //*****************************************************************************
670 extern void SMBus_processDone(SMBus *smbus);
671 
672 //*****************************************************************************
673 //
675 //
677 //
679 //
680 //*****************************************************************************
681 extern uint16_t SMBus_getRxPayloadAvailable(SMBus *smbus);
682 
683 //*****************************************************************************
684 //
686 //
688 //
690 //
691 //*****************************************************************************
692 extern SMBus_State SMBus_getState(SMBus *smbus);
693 
694 //*****************************************************************************
695 //
697 //
699 //
700 // \return None
701 //
702 //*****************************************************************************
703 extern void SMBus_enablePEC(SMBus *smbus);
704 //*****************************************************************************
705 //
707 //
709 //
710 // \return None
711 //
712 //*****************************************************************************
713 extern void SMBus_disablePEC(SMBus *smbus);
714 
715 #if defined(__MSPM0_HAS_I2C__)
716 //*****************************************************************************
717 //
719 //
721 //
724 //
725 // \return None
726 //
727 //*****************************************************************************
728 extern void SMBus_targetInit(SMBus *smbus, I2C_Regs *i2cAddr);
729 #endif
730 
731 #if defined(__MCU_HAS_UNICOMMI2CT__)
732 //*****************************************************************************
733 //
735 //
737 //
740 //
741 // \return None
742 //
743 //*****************************************************************************
744 extern void SMBus_targetInit(SMBus *smbus, UNICOMM_Inst_Regs *i2cAddr);
745 #endif
746 
747 //*****************************************************************************
748 //
750 //
752 //
754 //
755 // \return None
756 //
757 //*****************************************************************************
758 extern void SMBus_targetEnableInt(SMBus *smbus);
759 
760 //*****************************************************************************
761 //
763 //
765 //
767 //
768 // \return None
769 //
770 //*****************************************************************************
771 extern void SMBus_targetDisableInt(SMBus *smbus);
772 
773 //*****************************************************************************
774 //
776 //
779 //
781 //
791 //
792 //*****************************************************************************
793 extern SMBus_State SMBus_targetProcessInt(SMBus *smbus);
794 
795 //*****************************************************************************
796 //
798 //
800 //
802 //
803 // \return None
804 //
805 //*****************************************************************************
806 extern void SMBus_controllerReset(SMBus *smbus);
807 
808 //*****************************************************************************
809 //
811 //
814 //
815 // \return None
816 //
817 //*****************************************************************************
818 extern void SMBus_targetSetAddress(SMBus *smbus,
819  uint8_t targetAddr);
820 
821 //*****************************************************************************
822 //
824 //
828 //
829 // \return None
830 //
831 //*****************************************************************************
832 extern void SMBus_targetSetRxBuffer(SMBus *smbus,
833  uint8_t *data,
834  uint16_t size);
835 
836 //*****************************************************************************
837 //
839 //
843 //
844 // \return None
845 //
846 //*****************************************************************************
847 extern void SMBus_targetSetTxBuffer(SMBus *smbus,
848  uint8_t *data,
849  uint16_t size);
850 
851 //*****************************************************************************
852 //
854 //
856 //
859 //
860 // \return None
861 //
862 //*****************************************************************************
863 extern void SMBus_targetReportError(SMBus *smbus,
864  SMBus_ErrorCode errorCode);
865 
866 //*****************************************************************************
867 //
869 //
871 //
873 //
874 //*****************************************************************************
875 extern uint8_t SMBus_targetGetCommand(SMBus *smbus);
876 
877 //*****************************************************************************
878 //
880 //
882 //
883 //*****************************************************************************
884 extern void SMBus_targetReportBlock(SMBus *smbus);
885 
886 //*****************************************************************************
887 //
889 //
892 //
893 //*****************************************************************************
894 extern void SMBus_targetReportLength(SMBus *smbus, uint16_t length);
895 
896 //*****************************************************************************
897 //
899 //
902 //
904 //
905 //*****************************************************************************
906 extern uint8_t SMBus_targetClearStatusReg(SMBus *smbus,
907  uint8_t val);
908 
909 //*****************************************************************************
910 //
912 //
915 //
917 //
918 //*****************************************************************************
919 extern uint8_t SMBus_targetWriteCtrlReg(SMBus *smbus,
920  uint8_t val);
921 
922 //*****************************************************************************
923 //
925 //
945 //
949 //
951 //
952 //*****************************************************************************
953 extern int8_t SMBus_targetHostAlert(SMBus *smbus,
954  uint8_t deviceAddress,
955  uint8_t *txData);
956 
957 
958 #if defined(__MSPM0_HAS_I2C__)
959 //*****************************************************************************
960 //
962 //
964 //
968 //
969 // \return None
970 //
971 //*****************************************************************************
972 extern void SMBus_controllerInit(SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk);
973 #endif
974 
975 #if defined(__MCU_HAS_UNICOMMI2CC__)
976 //*****************************************************************************
977 //
979 //
981 //
985 //
986 // \return None
987 //
988 //*****************************************************************************
989 extern void SMBus_controllerInit(SMBus *smbus, UNICOMM_Inst_Regs *i2cAddr, uint32_t busClk);
990 #endif
991 
992 //*****************************************************************************
993 //
995 //
998 //
1000 //
1001 // \return None
1002 //
1003 //*****************************************************************************
1004 extern void SMBus_controllerEnableInt(SMBus *smbus);
1005 
1006 //*****************************************************************************
1007 //
1009 //
1011 //
1013 //
1014 // \return None
1015 //
1016 //*****************************************************************************
1017 extern void SMBus_controllerDisableInt(SMBus *smbus);
1018 
1019 
1020 //*****************************************************************************
1021 //
1023 //
1026 //
1028 //
1030 //
1031 //*****************************************************************************
1032 extern SMBus_State SMBus_controllerProcessInt(SMBus *smbus);
1033 
1034 
1035 //*****************************************************************************
1036 //
1038 //
1075 //
1081 //
1083 //
1084 //*****************************************************************************
1085 extern int8_t SMBus_controllerProcessCall(SMBus *smbus,
1086  uint8_t targetAddr,
1087  uint8_t command,
1088  uint8_t *txData,
1089  uint8_t *rxData);
1090 
1091 //*****************************************************************************
1092 //
1094 //
1098 //
1150 //
1157 //
1159 //
1160 //*****************************************************************************
1161 extern int8_t SMBus_controllerProcessCallBlock(SMBus *smbus,
1162  uint8_t targetAddr,
1163  uint8_t command,
1164  uint8_t *txData,
1165  uint8_t txSize,
1166  uint8_t *rxData);
1167 
1168 //*****************************************************************************
1169 //
1171 //
1195 //
1199 //
1201 //
1202 //*****************************************************************************
1203 extern int8_t SMBus_controllerSendByte(SMBus *smbus,
1204  uint8_t targetAddr,
1205  uint8_t txData);
1206 
1207 //*****************************************************************************
1208 //
1210 //
1233 //
1237 //
1239 //
1240 //*****************************************************************************
1241 extern int8_t SMBus_controllerReceiveByte(SMBus *smbus,
1242  uint8_t targetAddr,
1243  uint8_t *rxData);
1244 
1245 //*****************************************************************************
1246 //
1248 //
1252 //
1292 //
1297 //
1299 //
1300 //*****************************************************************************
1301 extern int8_t SMBus_controllerReadBlock(SMBus *smbus,
1302  uint8_t targetAddr,
1303  uint8_t command,
1304  uint8_t *rxData);
1305 
1306 //*****************************************************************************
1307 //
1309 //
1312 //
1346 //
1352 //
1354 //
1355 //*****************************************************************************
1356 extern int8_t SMBus_controllerWriteBlock(SMBus *smbus,
1357  uint8_t targetAddr,
1358  uint8_t command,
1359  uint8_t *txData,
1360  uint16_t txSize);
1361 
1362 //*****************************************************************************
1363 //
1365 //
1366 //
1415 //
1421 //
1423 //
1424 //*****************************************************************************
1425 extern int8_t SMBus_controllerReadByteWord(SMBus *smbus,
1426  uint8_t targetAddr,
1427  uint8_t command,
1428  uint8_t *rxData,
1429  uint8_t rxSize);
1430 
1431 //*****************************************************************************
1432 //
1470 //
1476 //
1478 //
1479 //*****************************************************************************
1480 extern int8_t SMBus_controllerWriteByteWord(SMBus *smbus,
1481  uint8_t targetAddr,
1482  uint8_t command,
1483  uint8_t *txData,
1484  uint8_t txSize);
1485 
1486 //*****************************************************************************
1487 //
1489 //
1505 //
1509 //
1511 //
1512 //*****************************************************************************
1513 extern int8_t SMBus_controllerQuickCommand(SMBus *smbus,
1514  uint8_t targetAddr,
1515  bool write);
1516 
1517 //*****************************************************************************
1518 //
1520 //
1523 //
1525 //
1526 //*****************************************************************************
1527 extern int8_t SMBus_controllerWaitUntilDone(SMBus *smbus,
1528  int32_t timeout);
1529 
1530 //*****************************************************************************
1531 //
1533 //
1536 //
1539 //
1540 // \return None
1541 //
1542 //*****************************************************************************
1543 extern void SMBus_controllerEnableHostNotify(SMBus *smbus, uint8_t *hostAlertBuffer);
1544 
1545 //*****************************************************************************
1546 //
1548 //
1551 //
1553 //
1554 // \return None
1555 //
1556 //*****************************************************************************
1557 extern void SMBus_controllerDisableHostNotify(SMBus *smbus);
1558 //*****************************************************************************
1559 //
1561 //
1563 //
1565 //
1566 //*****************************************************************************
1567 extern uint8_t SMBus_targetGetAddress(SMBus *smbus);
1568 //*****************************************************************************
1569 //
1571 //
1574 //
1578 // \return None.
1579 //
1580 //*****************************************************************************
1581 extern void SMBusARPAssignAddress(SMBus *smbus);
1582 //*****************************************************************************
1583 //
1593 //
1594 //*****************************************************************************
1595 extern int8_t SMBusARPUDIDByteValidate(SMBus *smbus);
1596 
1597 //*****************************************************************************
1598 //
1607 // \return None.
1608 //
1609 //*****************************************************************************
1610 extern void SMBusARPGetUDIDPacket(SMBus *smbus);
1611 
1612 //*****************************************************************************
1613 //
1622 // \return None.
1623 //
1624 //*****************************************************************************
1625 extern void SMBusARPGetUDIDPacketDirect(SMBus *smbus);
1626 //*****************************************************************************
1627 //
1636 // \return None.
1637 //
1638 //*****************************************************************************
1639 extern void SMBusARP_RESET(SMBus *smbus);
1640 //*****************************************************************************
1641 //
1648 // \return None.
1649 //
1650 //*****************************************************************************
1651 extern void SMBusARPUDIDPacketDecode(tSMBusUDID *pUDID, uint8_t *pui8Data);
1652 //*****************************************************************************
1653 //
1661 //
1662 // *****************************************************************************
1663 extern uint8_t SMBus_targetGetARPInProgress(SMBus *smbus);
1664 //*****************************************************************************
1665 //
1673 //
1674 // *****************************************************************************
1675 extern uint8_t SMBus_targetGetARStatus(SMBus *smbus);
1676 //*****************************************************************************
1677 //
1684 // \return None
1686 //
1687 // *****************************************************************************
1688 extern void SMBus_targetSetARStatus(SMBus *smbus , uint8_t val);
1689 //*****************************************************************************
1690 //
1697 // \return None
1699 //
1700 // *****************************************************************************
1701 extern void SMBus_targetSetAVStatus(SMBus *smbus, uint8_t val);
1702 //*****************************************************************************
1703 //
1711 //
1712 // *****************************************************************************
1713 extern uint8_t SMBus_targetGetAVStatus(SMBus *smbus);
1714 //*****************************************************************************
1715 //
1723 //
1724 // *****************************************************************************
1725 extern uint8_t SMBus_targetGetAddressDirect(SMBus *smbus);
1726 
1727 //*****************************************************************************
1728 //
1736 //
1737 // *****************************************************************************
1738 extern uint8_t SMBus_targetGetDirectCmd(SMBus *smbus);
1739 
1740 //*****************************************************************************
1741 //
1750 //
1751 // *****************************************************************************
1752 extern int8_t ARP_UDIDValidate(SMBus *smbus);
1753 //*****************************************************************************
1754 //
1761 // *****************************************************************************
1762 extern void ARP_invalidCMD(SMBus *smbus);
1763 
1764 //*****************************************************************************
1765 //
1775 //
1776 // *****************************************************************************
1777 extern int8_t ARP_isCmdValid(SMBus *smbus);
1778 //*****************************************************************************
1779 //*****************************************************************************
1780 //
1790 //
1791 // *****************************************************************************
1792 extern int8_t ARP_CmdComplete(SMBus *smbus);
1793 //*****************************************************************************
1794 //
1795 // Mark the end of the C bindings section for C++ compilers.
1796 //
1797 //*****************************************************************************
1798 #ifdef __cplusplus
1799 }
1800 #endif
1801 
1802 //*****************************************************************************
1803 //
1804 // Close the Doxygen group.
1806 //
1807 //*****************************************************************************
1808 
1809 #endif //__SMBUS_H__
void SMBus_targetReportBlock(SMBus *smbus)
Report to hardware that the command type is a block command.
Definition: smbus.c:190
Definition: smbus.h:555
uint8_t ownTargetAddr
Definition: smbus.h:646
uint8_t SMBus_targetGetAddress(SMBus *smbus)
Get the target&#39;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
Definition: smbus.h:537
uint8_t SMBus_targetClearStatusReg(SMBus *smbus, uint8_t val)
Clear the target&#39;s status register.
Definition: smbus.c:207
Definition: smbus.h:380
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
Definition: smbus.h:545
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
Definition: smbus.h:531
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
Definition: smbus.h:535
Definition: smbus.h:557
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
Definition: smbus.h:539
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
Definition: smbus.h:514
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
Definition: smbus.h:561
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.
Definition: smbus.h:547
Definition: smbus.h:549
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
Definition: smbus.h:390
Definition: smbus.h:384
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
Definition: smbus.h:553
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
Definition: smbus.h:278
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
Definition: smbus.h:382
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
Definition: smbus.h:541
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
Definition: smbus.h:533
void SMBus_controllerEnableInt(SMBus *smbus)
Enables the I2C interrupts for a controller.
Definition: smbus.c:270
Definition: smbus.h:276
Definition: smbus.h:386
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
Definition: smbus.h:289
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
Definition: smbus.h:291
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&#39;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
Definition: smbus.h:551
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
Definition: smbus.h:392
void SMBus_targetInit(SMBus *smbus, I2C_Regs *i2cAddr)
Initialize the SMBus interface as a target.
Definition: smbus.h:518
Definition: smbus.h:376
Main SMBus object.
Definition: smbus.h:631
void SMBus_targetEnableInt(SMBus *smbus)
Enables the I2C interrupts for a target.
Definition: smbus.c:116
Definition: smbus.h:378
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
Definition: smbus.h:388
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&#39;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
Definition: smbus.h:559
Definition: smbus.h:529
void SMBus_targetReportLength(SMBus *smbus, uint16_t length)
Report to hardware the fixed length of a given command.
Definition: smbus.c:200
Definition: smbus.h:394
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
Definition: smbus.h:516
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
Definition: smbus.h:543
int8_t SMBusARPUDIDByteValidate(SMBus *smbus)
Validates the Received UDID Byte and address into SMBus-transferable byte order.
Definition: smbus.c:564
Definition: smbus.h:396
Definition: smbus.h:405
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
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale