SMBus Library for MSP430G2xx3 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_MSP430G2xxx_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 // Define Timer to use for Timeout detection
31 //! Timer control register
32 #define TAxCTL TA0CTL
33 //! Timer Capture/Compare 0 reg
34 #define TAxCCR0 TA0CCR0
35 //! Timer cap/comp control 0 reg
36 #define TAxCCTL0 TA0CCTL0
37 //! Timeout Count for Clock low detection based on ACLK counts (VLO/(VLO/33) = ~30ms)
38 #define TAxSCLTIMEOUT (12000 / 33)
39 
40 //*****************************************************************************
41 //
42 //! \brief Disables the PHY and Data Link layer
43 //
44 //! \param smbus Pointer to SMBus structure
45 //
46 //! \return None
47 //
48 //*****************************************************************************
49 extern void SMBus_PHY_disable(SMBus *smbus);
50 
51 //*****************************************************************************
52 //
53 //! \brief Enables the PHY and Data Link layer
54 //
55 //! \param smbus Pointer to SMBus structure
56 //
57 //! \return None
58 //
59 //*****************************************************************************
60 extern void SMBus_PHY_enable(SMBus *smbus);
61 
62 //*****************************************************************************
63 //
64 //! \brief Enables the PHY and Data Link layer for slave operation
65 //
66 //! \param smbus Pointer to SMBus structure
67 //
68 //! \return None
69 //
70 //*****************************************************************************
71 extern void SMBus_PHY_slaveEnable(SMBus *smbus);
72 
73 //*****************************************************************************
74 //
75 //! \brief Enables the I2C interrupts
76 //
77 //! This function enables the USCI Start,Stop, RX,TX, Timeout interrupts.
78 //
79 //! \param smbus Pointer to SMBus structure
80 //
81 //! \return None
82 //
83 //*****************************************************************************
84 extern void SMBus_PHY_slaveEnableInt(SMBus *smbus);
85 
86 //*****************************************************************************
87 //
88 //! \brief Initializes the I2C Slave module supporting SMBus functionality
89 //
90 //! - Resets and then configures the I2C for SMBus support
91 //! - I2C is enabled using Automatic ACK and Slave address is initialized to 0x00
92 //! - Call SMBus_slaveSetAddress() in order to set the Slave address
93 //
94 //! \param smbus Pointer to SMBus structure
95 //! \param unused This parameter is unused
96 //
97 // \return None
98 //
99 //*****************************************************************************
100 extern void SMBus_PHY_slaveInit(SMBus *smbus,
101  uint16_t unused);
102 
103 //*****************************************************************************
104 //
105 //! \brief I2C Interrupt Service routine
106 //
107 //! Handles the interrupts from USCI module and passes the information to
108 //! the network layer. Should be called by application when an USCI
109 //! interrupt is detected.
110 //
111 //! \param smbus Pointer to SMBus structure
112 //
113 //! \return The new state of Slave (see SMBus_slaveProcessInt())
114 //
115 //*****************************************************************************
117 
118 //*****************************************************************************
119 //
120 //! \brief Timer interrupt service routine
121 //
122 //! Handles the timeout interrupts from the Timer module and passes the
123 //! information to the network layer. Should be callsed by the application
124 //! when a timer interrupt is detected
125 //
126 //*****************************************************************************
128 
129 //*****************************************************************************
130 //
131 //! \brief Enables the PHY and Data Link layer
132 //
133 //! \param smbus Pointer to SMBus structure
134 //
135 //! \return None
136 //
137 //*****************************************************************************
138 extern void SMBus_PHY_masterEnable(SMBus *smbus);
139 
140 //*****************************************************************************
141 //
142 //! \brief Enables the I2C interrupts
143 //
144 //! This function enables the USCI Start,Stop, RX,TX interrupts.
145 //! SMBus_PHY_slaveInit() must be called before this function.
146 //
147 //! \param smbus Pointer to SMBus structure
148 //
149 //! \return None
150 //
151 //*****************************************************************************
152 extern void SMBus_PHY_masterEnableInt(SMBus *smbus);
153 
154 //*****************************************************************************
155 //
156 //! \brief Initializes the I2C Master module supporting SMBus functionality
157 //
158 //! - Resets and then configures the I2C for SMBus support
159 //! - I2C is enabled using Automatic ACK and Slave address is initialized to 0x00
160 //
161 //! \param smbus Pointer to SMBus structure
162 //! \param unused This parameter is unused
163 //! \param busClk SMCLK Frequency (used for USCI baud rate)
164 //
165 //! \return None
166 //
167 //*****************************************************************************
168 extern void SMBus_PHY_masterInit(SMBus *smbus,
169  uint16_t unused,
170  uint32_t busClk);
171 
172 //*****************************************************************************
173 //
174 //! \brief Generate Stop condition if it hasn't been sent
175 //
176 //! \param smbus Pointer to SMBus structure
177 //! \return None
178 //
179 //*****************************************************************************
180 extern void SMBus_PHY_masterSendStop(SMBus *smbus);
181 
182 //*****************************************************************************
183 //
184 //! \brief Prepare to send stop at next byte
185 //
186 //! \param smbus Pointer to SMBus structure
187 //! \return None
188 //
189 //*****************************************************************************
190 extern void SMBus_PHY_masterSendPreStop(SMBus *smbus);
191 
192 //*****************************************************************************
193 //
194 //! \brief Start a TX transfer
195 //
196 //! \param smbus Pointer to SMBus structure
197 //! \param targetaddr Slave target address
198 //! \param stopFlag Indicates the stop condition
199 //
200 //! \return None
201 //
202 //*****************************************************************************
203 extern void SMBus_PHY_masterStartTx(SMBus *smbus,
204  uint8_t targetaddr,
205  SMBus_Stop stopFlag);
206 
207 //*****************************************************************************
208 //
209 //! \brief Start a RX transfer
210 //! \param smbus Pointer to SMBus structure
211 //! \param targetaddr Slave target address
212 //! \param stopFlag Indicates the stop condition
213 //
214 //! \return None
215 //
216 //*****************************************************************************
217 extern void SMBus_PHY_masterStartRx(SMBus *smbus,
218  uint8_t targetaddr,
219  SMBus_Stop stopFlag);
220 
221 //*****************************************************************************
222 //
223 //! \brief I2C Interrupt Service routine
224 //
225 //! Handles the interrupts from USCI module and passes the information to
226 //! the network layer. Should be called by application when an USCI
227 //! interrupt is detected.
228 //
229 //! \param smbus Pointer to SMBus structure
230 //
231 //! \return The new state of master (see SMBus_masterProcessInt())
232 //
233 //*****************************************************************************
235 
236 //*****************************************************************************
237 //
238 //! \brief Timer interrupt service routine
239 //
240 //! Handles the timeout interrupts from the Timer module and passes the
241 //! information to the network layer. Should be callsed by the application
242 //! when a timer interrupt is detected
243 //
244 //! \param smbus Pointer to SMBus structure
245 //
246 //*****************************************************************************
248 
249 //*****************************************************************************
250 //
251 // Mark the end of the C bindings section for C++ compilers.
252 //
253 //*****************************************************************************
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 //*****************************************************************************
259 //
260 // Close the Doxygen group.
261 //! @}
262 //
263 //*****************************************************************************
264 
265 #endif //__SMBUS_PHY_H__
SMBus_State SMBus_PHY_slaveProcessTimeoutInt(SMBus *smbus)
Timer interrupt service routine.
Definition: smbus_phy.c:176
void SMBus_PHY_masterStartTx(SMBus *smbus, uint8_t targetaddr, SMBus_Stop stopFlag)
Start a TX transfer.
Definition: smbus_phy.c:284
void SMBus_PHY_masterEnableInt(SMBus *smbus)
Enables the I2C interrupts.
Definition: smbus_phy.c:205
void SMBus_PHY_slaveInit(SMBus *smbus, uint16_t unused)
Initializes the I2C Slave module supporting SMBus functionality.
Definition: smbus_phy.c:85
void SMBus_PHY_slaveEnableInt(SMBus *smbus)
Enables the I2C interrupts.
Definition: smbus_phy.c:67
void SMBus_PHY_disable(SMBus *smbus)
Disables the PHY and Data Link layer.
Definition: smbus_phy.c:21
SMBus_State SMBus_PHY_slaveProcessInt(SMBus *smbus)
I2C Interrupt Service routine.
Definition: smbus_phy.c:109
SMBus_State SMBus_PHY_masterProcessTimeoutInt(SMBus *smbus)
Timer interrupt service routine.
Definition: smbus_phy.c:435
void SMBus_PHY_masterSendPreStop(SMBus *smbus)
Prepare to send stop at next byte.
Definition: smbus_phy.c:279
void SMBus_PHY_enable(SMBus *smbus)
Enables the PHY and Data Link layer.
Definition: smbus_phy.c:31
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:224
void SMBus_PHY_masterInit(SMBus *smbus, uint16_t unused, uint32_t busClk)
Initializes the I2C Master module supporting SMBus functionality.
Definition: smbus_phy.c:223
void SMBus_PHY_slaveEnable(SMBus *smbus)
Enables the PHY and Data Link layer for slave operation.
Definition: smbus_phy.c:43
Main SMBus object.
Definition: smbus.h:274
SMBus_State SMBus_PHY_masterProcessInt(SMBus *smbus)
I2C Interrupt Service routine.
Definition: smbus_phy.c:359
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:110
void SMBus_PHY_masterStartRx(SMBus *smbus, uint8_t targetaddr, SMBus_Stop stopFlag)
Start a RX transfer.
Definition: smbus_phy.c:313
void SMBus_PHY_masterSendStop(SMBus *smbus)
Generate Stop condition if it hasn't been sent.
Definition: smbus_phy.c:259
void SMBus_PHY_masterEnable(SMBus *smbus)
Enables the PHY and Data Link layer.
Definition: smbus_phy.c:181

Copyright 2015, Texas Instruments Incorporated