SMBus Library for MSP430FR5xx_6xx Devices  1.10.00.00
 All Data Structures Functions Variables Enumerations Enumerator Modules Pages
smbus_phy.h
1 #ifndef __SMBUS_PHY_H__
2 #define __SMBUS_PHY_H__
3 
4 //*****************************************************************************
5 //
6 //! \addtogroup smbus_MSP430FR5xx_6xx_phy MSP430 PHY layer
7 //! @{
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 #include "smbus_phy.h"
23 #include "smbus.h"
24 
25 //! R/W state when write is received
26 #define I2C_WRITE 0
27 //! R/W state when read is received
28 #define I2C_READ 1
29 
30 //*****************************************************************************
31 //
32 //! \brief Disables the PHY and Data Link layer
33 //
34 //! \param *smbus Pointer to SMBus structure
35 //
36 //! \return None
37 //
38 //*****************************************************************************
39 extern void SMBus_PHY_disable(SMBus *smbus);
40 
41 //*****************************************************************************
42 //
43 //! \brief Enables the PHY and Data Link layer
44 //
45 //! \param *smbus Pointer to SMBus structure
46 //
47 //! \return None
48 //
49 //*****************************************************************************
50 extern void SMBus_PHY_enable(SMBus *smbus);
51 
52 //*****************************************************************************
53 //
54 //! \brief Enables the PHY and Data Link layer for slave operation
55 //
56 //! \param *smbus Pointer to SMBus structure
57 //
58 //! \return None
59 //
60 //*****************************************************************************
61 extern void SMBus_PHY_slaveEnable(SMBus *smbus);
62 
63 //*****************************************************************************
64 //
65 //! \brief Enables the I2C interrupts
66 //
67 //! This function enables the eUSCI Start,Stop, RX,TX, Timeout interrupts.
68 //! If Manual_ACK is enabled, it enables DMA to handle the RX
69 //! SMBus_PHY_slaveInit() must be called before this function.
70 //
71 //! \param *smbus Pointer to SMBus structure
72 //
73 //! \return None
74 //
75 //*****************************************************************************
76 extern void SMBus_PHY_slaveEnableInt(SMBus *smbus);
77 
78 //*****************************************************************************
79 //
80 //! \brief Initializes the I2C Slave module supporting SMBus functionality
81 //
82 //! - Resets and then configures the I2C for SMBus support
83 //! - I2C is enabled using Automatic ACK and Slave address is initialized to 0x00
84 //! - Call SMBus_slaveSetAddress() in order to set the Slave address
85 //! - Call SMBus_slaveEnableManualACK() in order to enable Manual ACK
86 //
87 //! \param *smbus Pointer to SMBus structure
88 //! \param i2cAddr Base address of I2C module
89 //
90 // \return None
91 //
92 //*****************************************************************************
93 extern void SMBus_PHY_slaveInit(SMBus *smbus,
94  uint16_t i2cAddr);
95 
96 //*****************************************************************************
97 //
98 //! \brief I2C Interrupt Service routine
99 //
100 //! Handles the interrupts from eUSCI module and passes the information to
101 //! the network layer. Should be called by application when an eUSCI
102 //! interrupt is detected.
103 //
104 //! \param smbus Pointer to SMBus structure
105 //
106 //! \return The new state of Slave (see SMBus_slaveProcessInt())
107 //
108 //*****************************************************************************
110 
111 //*****************************************************************************
112 //
113 //! \brief This function is not used in the MSP430FR5xx_6xx implementation.
114 //
115 //*****************************************************************************
117 
118 #if (SMB_MANUAL_ACK_ENABLE == 1)
119 //*****************************************************************************
120 //
121 //! \brief DMA Interrupt Service routine
122 //
123 //! Used when SW ACK/NACK is enabled since the double-buffer mechanism of eUSCI
124 //! doesn't allow us to perform manual ACK/NACK
125 //
126 //! \param smbus Pointer to SMBus structure
127 //
128 //! \return new state of Slave (see SMBus_slaveProcessInt())
129 //
130 //*****************************************************************************
131 extern SMBus_State SMBus_PHY_slaveProcessIntDMA(SMBus *smbus);
132 
133 //*****************************************************************************
134 //
135 //! \brief Enables functionality to perform manual ACK/NACK
136 //
137 //! DMA will be used to stretch SCL
138 //
139 //! \param *smbus Pointer to SMBus structure
140 //
141 //! \return None
142 //
143 //*****************************************************************************
144 extern void SMBus_PHY_slaveEnableManualACK(SMBus *smbus);
145 
146 //*****************************************************************************
147 //
148 //! \brief Disables functionality to perform manual ACK/NACK
149 //
150 //! \param *smbus Pointer to SMBus structure
151 //
152 //! \return None
153 //
154 //*****************************************************************************
155 extern void SMBus_PHY_slaveDisableManualACK(SMBus *smbus);
156 
157 //******************************************************************************
158 //
159 //! \brief Send a manual ACK
160 //
161 //! \param *smbus Pointer to SMBus structure
162 //! \param sendAck
163 //! - true: sends ACK
164 //! - false: sends NACK
165 //
166 //! \return None
167 //
168 //*****************************************************************************
169 extern void SMBus_PHY_slaveSendACK(SMBus *smbus,
170  bool sendAck);
171 #endif
172 
173 //*****************************************************************************
174 //
175 //! \brief Enables the PHY and Data Link layer
176 //
177 //! \param *smbus Pointer to SMBus structure
178 //
179 //! \return None
180 //
181 //*****************************************************************************
182 extern void SMBus_PHY_masterEnable(SMBus *smbus);
183 
184 //*****************************************************************************
185 //
186 //! \brief Enables the I2C interrupts
187 //
188 //! This function enables the eUSCI Start,Stop, RX,TX, Timeout interrupts.
189 //! If Manual_ACK is enabled, it enables DMA to handle the RX
190 //! SMBus_PHY_slaveInit() must be called before this function.
191 //
192 //! \param *smbus Pointer to SMBus structure
193 //
194 //! \return None
195 //
196 //*****************************************************************************
197 extern void SMBus_PHY_masterEnableInt(SMBus *smbus);
198 
199 //*****************************************************************************
200 //
201 //! \brief Initializes the I2C Master module supporting SMBus functionality
202 //
203 //! - Resets and then configures the I2C for SMBus support
204 //! - I2C is enabled using Automatic ACK and Slave address is initialized to 0x00
205 //
206 //! \param smbus Pointer to SMBus structure
207 //! \param i2cAddr Base address of I2C module
208 //! \param busClk SMCLK Frequency (used for eUSCI)
209 //
210 //! \return None
211 //
212 //*****************************************************************************
213 extern void SMBus_PHY_masterInit(SMBus *smbus,
214  uint16_t i2cAddr,
215  uint32_t busClk);
216 
217 //*****************************************************************************
218 //
219 //! \brief Generate Stop condition if it hasn't been sent
220 //
221 //! \param smbus Pointer to SMBus structure
222 //! \return None
223 //
224 //*****************************************************************************
225 extern void SMBus_PHY_masterSendStop(SMBus *smbus);
226 
227 //*****************************************************************************
228 //
229 //! \brief Prepare to send stop at next byte
230 //
231 //! \param smbus Pointer to SMBus structure
232 //! \return None
233 //
234 //*****************************************************************************
235 extern void SMBus_PHY_masterSendPreStop(SMBus *smbus);
236 
237 //*****************************************************************************
238 //
239 //! \brief Start a TX transfer
240 //
241 //! \param smbus Pointer to SMBus structure
242 //! \param targetaddr Slave target address
243 //! \param stopFlag Indicates the stop condition
244 //
245 //! \return None
246 //
247 //*****************************************************************************
248 extern void SMBus_PHY_masterStartTx(SMBus *smbus,
249  uint8_t targetaddr,
250  SMBus_Stop stopFlag);
251 
252 //*****************************************************************************
253 //
254 //! \brief Start a RX transfer
255 //! \param smbus Pointer to SMBus structure
256 //! \param targetaddr Slave target address
257 //! \param stopFlag Indicates the stop condition
258 //
259 //! \return None
260 //
261 //*****************************************************************************
262 extern void SMBus_PHY_masterStartRx(SMBus *smbus,
263  uint8_t targetaddr,
264  SMBus_Stop stopFlag);
265 
266 //*****************************************************************************
267 //
268 //! \brief I2C Interrupt Service routine
269 //
270 //! Handles the interrupts from eUSCI module and passes the information to
271 //! the network layer. Should be called by application when an eUSCI
272 //! interrupt is detected.
273 //
274 //! \param smbus Pointer to SMBus structure
275 //
276 //! \return The new state of master (see SMBus_masterProcessInt())
277 //
278 //*****************************************************************************
280 
281 //*****************************************************************************
282 //
283 //! \brief This function is not used in the MSP430FR5xx_6xx implementation.
284 //
285 //*****************************************************************************
287 
288 //*****************************************************************************
289 //
290 // Mark the end of the C bindings section for C++ compilers.
291 //
292 //*****************************************************************************
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 //*****************************************************************************
298 //
299 // Close the Doxygen group.
300 //! @}
301 //
302 //*****************************************************************************
303 
304 #endif //__SMBUS_PHY_H__
void SMBus_PHY_masterStartTx(SMBus *smbus, uint8_t targetaddr, SMBus_Stop stopFlag)
Start a TX transfer.
Definition: smbus_phy.c:408
SMBus_State SMBus_PHY_slaveProcessTimeoutInt(SMBus *smbus)
This function is not used in the MSP430FR5xx_6xx implementation.
void SMBus_PHY_enable(SMBus *smbus)
Enables the PHY and Data Link layer.
Definition: smbus_phy.c:42
SMBus_State SMBus_PHY_slaveProcessInt(SMBus *smbus)
I2C Interrupt Service routine.
Definition: smbus_phy.c:148
void SMBus_PHY_masterInit(SMBus *smbus, uint16_t i2cAddr, uint32_t busClk)
Initializes the I2C Master module supporting SMBus functionality.
Definition: smbus_phy.c:358
void SMBus_PHY_masterStartRx(SMBus *smbus, uint8_t targetaddr, SMBus_Stop stopFlag)
Start a RX transfer.
Definition: smbus_phy.c:428
void SMBus_PHY_disable(SMBus *smbus)
Disables the PHY and Data Link layer.
Definition: smbus_phy.c:35
void SMBus_PHY_masterSendStop(SMBus *smbus)
Generate Stop condition if it hasn't been sent.
Definition: smbus_phy.c:393
void SMBus_PHY_masterSendPreStop(SMBus *smbus)
Prepare to send stop at next byte.
Definition: smbus_phy.c:403
void SMBus_PHY_slaveEnable(SMBus *smbus)
Enables the PHY and Data Link layer for slave operation.
Definition: smbus_phy.c:54
SMBus_State SMBus_PHY_masterProcessTimeoutInt(SMBus *smbus)
This function is not used in the MSP430FR5xx_6xx implementation.
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:224
SMBus_State SMBus_PHY_masterProcessInt(SMBus *smbus)
I2C Interrupt Service routine.
Definition: smbus_phy.c:464
void SMBus_PHY_slaveInit(SMBus *smbus, uint16_t i2cAddr)
Initializes the I2C Slave module supporting SMBus functionality.
Definition: smbus_phy.c:124
void SMBus_PHY_masterEnable(SMBus *smbus)
Enables the PHY and Data Link layer.
Definition: smbus_phy.c:321
void SMBus_PHY_masterEnableInt(SMBus *smbus)
Enables the I2C interrupts.
Definition: smbus_phy.c:342
Main SMBus object.
Definition: smbus.h:274
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:110
void SMBus_PHY_slaveEnableInt(SMBus *smbus)
Enables the I2C interrupts.
Definition: smbus_phy.c:92

Copyright 2015, Texas Instruments Incorporated