SMBusLibrary  1.0
smbus_phy.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_PHY_H__
33 #define __SMBUS_PHY_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 #include "smbus_phy.h"
54 #include "smbus.h"
55 
57 #define I2C_WRITE 0
58 
59 #define I2C_READ 1
60 
62 #define SMB_SW_TIMEOUT (10000)
63 
64 #define SMB_TIMEOUT_WAIT_CYCLES (200)
65 
66 #define SMB_POWER_STARTUP_DELAY (16)
67 
68 //*****************************************************************************
69 //
71 //
73 //
75 //
76 //*****************************************************************************
77 extern void SMBus_PHY_disable(SMBus *smbus);
78 
79 //*****************************************************************************
80 //
82 //
84 //
86 //
87 //*****************************************************************************
88 extern void SMBus_PHY_targetEnable(SMBus *smbus);
89 
90 //*****************************************************************************
91 //
93 //
97 //
100 //
101 // \return None
102 //
103 //*****************************************************************************
104 extern void SMBus_PHY_targetInit(SMBus *smbus,
105  I2C_Regs *i2cAddr);
106 
107 //*****************************************************************************
108 //
110 //
113 //
115 //
117 //
118 //*****************************************************************************
119 extern void SMBus_PHY_targetEnableInt(SMBus *smbus);
120 
121 //*****************************************************************************
122 //
124 //
126 //
128 //
130 //
131 //*****************************************************************************
132 extern void SMBus_PHY_targetDisableInt(SMBus *smbus);
133 
134 //*****************************************************************************
135 //
137 //
143 //
145 //
147 //
148 //*****************************************************************************
150 
151 //*****************************************************************************
152 //
154 //
159 //
162 //
164 //
165 //*****************************************************************************
166 extern void SMBus_PHY_targetSetPECCount(SMBus * smbus, uint16_t length);
167 
168 //*****************************************************************************
169 //
171 //
175 //
178 //
180 //
181 //*****************************************************************************
182 extern void SMBus_PHY_targetManualACK(SMBus *smbus, bool ackVal);
183 
184 //*****************************************************************************
185 //
187 //
189 //
191 //
192 //*****************************************************************************
193 extern void SMBus_Phy_ARP_TARGET_ADDR_Reset(SMBus *smbus);
194 //*****************************************************************************
195 //
197 //
199 //
201 //
202 //*****************************************************************************
203 extern void SMBus_PHY_controllerEnable(SMBus *smbus);
204 
205 //*****************************************************************************
206 //
208 //
210 //
212 //
213 //*****************************************************************************
214 extern uint8_t SMBus_Phy_ARP_Get_Write_Status(SMBus *smbus);
215 //*****************************************************************************
216 //
218 //
220 //
222 //
223 //*****************************************************************************
224 extern uint8_t SMBus_Phy_ARP_Get_Read_Status(SMBus *smbus);
225 //*****************************************************************************
226 //
228 //
231 //
235 //
237 //
238 //*****************************************************************************
239 extern void SMBus_PHY_controllerInit(SMBus *smbus,
240  I2C_Regs *i2cAddr,
241  uint32_t busClk);
242 
243 //*****************************************************************************
244 //
246 //
249 //
251 //
253 //
254 //*****************************************************************************
255 extern void SMBus_PHY_controllerEnableInt(SMBus *smbus);
256 
257 //*****************************************************************************
258 //
260 //
262 //
264 //
266 //
267 //*****************************************************************************
268 extern void SMBus_PHY_controllerDisableInt(SMBus *smbus);
269 
270 //*****************************************************************************
271 //
273 //
276 //
277 //*****************************************************************************
278 extern void SMBus_PHY_controllerSendStop(SMBus *smbus);
279 
280 
281 //*****************************************************************************
282 //
284 //
290 //
292 //
293 //*****************************************************************************
294 extern void SMBus_PHY_controllerStartTx(SMBus *smbus,
295  uint8_t targetaddr,
296  uint16_t length,
297  SMBus_Stop stopFlag,
298  uint8_t setPEC);
299 
300 //*****************************************************************************
301 //
310 //
312 //
313 //*****************************************************************************
314 extern void SMBus_PHY_controllerStartRx(SMBus *smbus,
315  uint8_t targetaddr,
316  uint16_t length,
317  SMBus_Start startFlag,
318  SMBus_Stop stopFlag,
319  SMBus_Auto_Ack ackFlag,
320  uint8_t setPEC);
321 
322 //*****************************************************************************
323 //
325 //
331 //
333 //
335 //
336 //*****************************************************************************
338 
339 //*****************************************************************************
340 //
343 //
345 //
347 //
348 //*****************************************************************************
349 extern void SMBus_PHY_controllerEnableHostNotify(SMBus *smbus);
350 
351 //*****************************************************************************
352 //
355 //
357 //
359 //
360 //*****************************************************************************
361 extern void SMBus_PHY_controllerDisableHostNotify(SMBus *smbus);
362 
363 //*****************************************************************************
364 //
365 // Mark the end of the C bindings section for C++ compilers.
366 //
367 //*****************************************************************************
368 #ifdef __cplusplus
369 }
370 #endif
371 
372 //*****************************************************************************
373 //
374 // Close the Doxygen group.
376 //
377 //*****************************************************************************
378 
379 #endif //__SMBUS_PHY_H__
void SMBus_PHY_targetSetPECCount(SMBus *smbus, uint16_t length)
Sets the number of bytes left to be counted.
Definition: smbus_phy.c:229
SMBus_Auto_Ack
List of auto ack codes used within the NWK and PHY layers.
Definition: smbus.h:286
SMBus_State SMBus_PHY_targetProcessInt(SMBus *smbus)
I2C Interrupt Service routine for SMBus Target.
Definition: smbus_phy.c:138
void SMBus_PHY_controllerEnable(SMBus *smbus)
Enables the PHY and Data Link layer.
Definition: smbus_phy.c:267
void SMBus_PHY_controllerEnableHostNotify(SMBus *smbus)
Enable the hardware functionality to respond to Host Default address (0b000_1000) ...
Definition: smbus_phy.c:492
void SMBus_PHY_targetEnable(SMBus *smbus)
Enables the PHY and Data Link layer for target operation.
Definition: smbus_phy.c:52
void SMBus_PHY_targetInit(SMBus *smbus, I2C_Regs *i2cAddr)
Initializes the I2C Target module supporting SMBus functionality.
Definition: smbus_phy.c:68
SMBus_State SMBus_PHY_controllerProcessInt(SMBus *smbus)
I2C Interrupt Service routine for SMBus Controller.
Definition: smbus_phy.c:503
void SMBus_PHY_controllerDisableHostNotify(SMBus *smbus)
Disable the hardware functionality to respond to Host Default address (0b000_1000) ...
Definition: smbus_phy.c:497
uint8_t SMBus_Phy_ARP_Get_Write_Status(SMBus *smbus)
Returns the Write Bus direction of the ARP transaction.
Definition: smbus_phy.c:259
void SMBus_PHY_controllerEnableInt(SMBus *smbus)
Enables the I2C interrupts for Controller.
Definition: smbus_phy.c:284
void SMBus_PHY_targetManualACK(SMBus *smbus, bool ackVal)
Send a Manual ACK or NACK depending on data validity.
Definition: smbus_phy.c:233
void SMBus_PHY_controllerSendStop(SMBus *smbus)
Generate Stop condition if it hasn't been sent.
Definition: smbus_phy.c:359
void SMBus_Phy_ARP_TARGET_ADDR_Reset(SMBus *smbus)
Resets the Target's Address based on the ARP Status.
Definition: smbus_phy.c:247
void SMBus_PHY_targetDisableInt(SMBus *smbus)
Disables the I2C interrupts.
Definition: smbus_phy.c:115
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:512
void SMBus_PHY_controllerStartTx(SMBus *smbus, uint8_t targetaddr, uint16_t length, SMBus_Stop stopFlag, uint8_t setPEC)
Start a TX transfer.
Definition: smbus_phy.c:370
void SMBus_PHY_controllerInit(SMBus *smbus, I2C_Regs *i2cAddr, uint32_t busClk)
Initializes the I2C Controller module supporting SMBus functionality.
Definition: smbus_phy.c:344
void SMBus_PHY_targetEnableInt(SMBus *smbus)
Enables the I2C interrupts.
Definition: smbus_phy.c:81
void SMBus_PHY_disable(SMBus *smbus)
Disables the PHY and Data Link layer.
Definition: smbus_phy.c:43
uint8_t SMBus_Phy_ARP_Get_Read_Status(SMBus *smbus)
Returns the Read Bus direction of the ARP transaction.
Definition: smbus_phy.c:263
void SMBus_PHY_controllerStartRx(SMBus *smbus, uint8_t targetaddr, uint16_t length, SMBus_Start startFlag, SMBus_Stop stopFlag, SMBus_Auto_Ack ackFlag, uint8_t setPEC)
Start a RX transfer.
Definition: smbus_phy.c:422
Main SMBus object.
Definition: smbus.h:617
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:262
void SMBus_PHY_controllerDisableInt(SMBus *smbus)
Disables the I2C interrupts for Controller.
Definition: smbus_phy.c:321
SMBus_Start
List of start codes used within the NWK and PHY layers.
Definition: smbus.h:273
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale