onewire.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // onewire.h - Prototypes for the OneWire Driver.
4 //
5 // Copyright (c) 2012-2017 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 //*****************************************************************************
37 
38 #ifndef __DRIVERLIB_ONEWIRE_H__
39 #define __DRIVERLIB_ONEWIRE_H__
40 
41 #include <stdint.h>
42 #include <stdbool.h>
43 
44 //*****************************************************************************
45 //
48 //
49 //*****************************************************************************
50 
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 //*****************************************************************************
63 //
64 // Defines used in the OneWireInit() function call.
65 //
66 //*****************************************************************************
67 
68 //
69 // This define is used in initialization to request standard speed bus
70 // timings. This is the default.
71 //
72 #define ONEWIRE_INIT_SPD_STD 0x00000000
73 
74 //
75 // This define is used in initialization to request overdrive speed bus
76 // timings.
77 //
78 #define ONEWIRE_INIT_SPD_OD 0x00000020
79 
80 //
81 // This define is used in initialization to request standard read sampling
82 // timing (2us for ONEWIRE_INIT_SPD_OD and 16us for ONEWIRE_INIT_SPD_STD).
83 // This is the default.
84 //
85 #define ONEWIRE_INIT_READ_STD 0x00000000
86 
87 //
88 // This define is used in initialization to request late read sampling
89 // timing (7us for ONEWIRE_INIT_SPD_OD and 50us for ONEWIRE_INIT_SPD_STD).
90 //
91 #define ONEWIRE_INIT_READ_LATE 0x00000040
92 
93 //
94 // This define is used in initialization to request a standard
95 // Answer-to-Reset (presence detect) monitor. This is the default.
96 //
97 #define ONEWIRE_INIT_ATR 0x00000000
98 
99 //
100 // This define is used in initialization to request no Answer-to-Reset
101 // (presence detect) monitor. The module will delay operations after a bus
102 // reset for the expected presence detect period in this case.
103 //
104 #define ONEWIRE_INIT_NO_ATR 0x00000080
105 
106 //
107 // This define is used in initialization to request standard signal polarity
108 // on the 1-Wire bus (pin is driven low to drive bus low). This is the
109 // default.
110 //
111 #define ONEWIRE_INIT_STD_POL 0x00000000
112 
113 //
114 // This define is used in initialization to request alternate signal polarity
115 // on the 1-Wire bus (pin is driven high to drive bus low).
116 //
117 #define ONEWIRE_INIT_ALT_POL 0x40000000
118 
119 //
120 // This define is used in initialization to request normal 1-Wire operational
121 // mode. This is the default.
122 //
123 #define ONEWIRE_INIT_1_WIRE_CFG 0x00000000
124 
125 //
126 // This define is used in initialization to request a 2 pin operational
127 // mode where one pin is used exclusively for TX operations and the other
128 // for RX.
129 //
130 #define ONEWIRE_INIT_2_WIRE_CFG 0x80000000
131 
132 //*****************************************************************************
133 //
134 // Defines for bus status conditions. These values can be returned by
135 // OneWireBusStatus().
136 //
137 //*****************************************************************************
138 
139 //
140 // This will be set if the bus is busy handling a Read, Write or
141 // Reset activity.
142 //
143 #define ONEWIRE_BUS_STATUS_BUSY 0x00000100
144 
145 //
146 // This will be set if the module did not detect any slave presence pulses
147 // after a bus reset.
148 //
149 #define ONEWIRE_BUS_STATUS_NO_SLAVE \
150  0x00000200
151 
152 //
153 // This will be set if the bus is being held low outside of a normal Read,
154 // Write or Reset activity.
155 //
156 #define ONEWIRE_BUS_STATUS_STUCK \
157  0x00000400
158 
159 //*****************************************************************************
160 //
161 // OneWire operation modes used with OneWireTransaction().
162 //
163 //*****************************************************************************
164 
165 //
166 // This mode flag indicates a single reset should be issued prior to a write
167 // and/or read operation.
168 //
169 #define ONEWIRE_OP_RESET 0x00000001
170 
171 //
172 // This mode flag indicates a read operation.
173 //
174 #define ONEWIRE_OP_READ 0x00000002
175 
176 //
177 // This mode flag indicates a write operation.
178 //
179 #define ONEWIRE_OP_WRITE 0x00000004
180 
181 //*****************************************************************************
182 //
183 // OneWire DMA used with OneWireDMAEnable().
184 //
185 //*****************************************************************************
186 
187 //
188 // This indicates the DMA should issue a 1-Wire bus reset before starting.
189 //
190 #define ONEWIRE_DMA_BUS_RESET 0x00000001
191 
192 //
193 // The DMA operation will be a single Read after each module transaction.
194 //
195 #define ONEWIRE_DMA_OP_READ 0x00000002
196 
197 //
198 // The DMA will write values to the 1-Wire interface as each previous DMA
199 // write operation completes.
200 //
201 #define ONEWIRE_DMA_OP_MULTI_WRITE \
202  0x00000004
203 
204 //
205 // The DMA will read values from the 1-Wire interface as each previous DMA
206 // read operation completes.
207 //
208 #define ONEWIRE_DMA_OP_MULTI_READ \
209  0x00000006
210 
211 //
212 // This Scatter Gather DMA mode is paired with ONEWIRE_DMA_OP_READ to instruct
213 // the 1-Wire DMA to initiate an operation at the start of and then on each
214 // transition completion thereafter.
215 //
216 #define ONEWIRE_DMA_MODE_SG 0x00000008
217 
218 //
219 // DMA expects a Read/Write bus operation size of 8 bits. This should match
220 // the uDMA channel setup.
221 //
222 #define ONEWIRE_DMA_OP_SZ_8 0x00000000
223 
224 //
225 // DMA expects a Read/Write bus operation size of 16 bits. This should match
226 // the uDMA channel setup.
227 //
228 #define ONEWIRE_DMA_OP_SZ_16 0x00000800
229 
230 //
231 // DMA expects a Read/Write bus operation size of 32 bits. This should match
232 // the uDMA channel setup.
233 //
234 #define ONEWIRE_DMA_OP_SZ_32 0x00001800
235 
236 //*****************************************************************************
237 //
238 // OneWire interrupt defines. Use in calls to OneWireIntEnable(),
239 // OneWireIntDisable(), OneWireIntClear() and returned by OneWireIntStatus().
240 //
241 //*****************************************************************************
242 
243 //
244 // This interrupt indicates a bus reset has just completed.
245 //
246 #define ONEWIRE_INT_RESET_DONE 0x00000001
247 
248 //
249 // The interrupt indicates a Read or Write master initiated operation
250 // has just completed.
251 //
252 #define ONEWIRE_INT_OP_DONE 0x00000002
253 
254 //
255 // This interrupt indicates that no presence detect was signaled by a slave
256 // on the bus after a reset.
257 //
258 #define ONEWIRE_INT_NO_SLAVE 0x00000004
259 
260 //
261 // This interrupt indicates the bus is being held low outside of normal
262 // operations.
263 //
264 #define ONEWIRE_INT_STUCK 0x00000008
265 
266 //
267 // This interrupt indicates a OneWire DMA operation has completed.
268 //
269 #define ONEWIRE_INT_DMA_DONE 0x00000010
270 
271 //*****************************************************************************
272 //
273 // Close the Doxygen group.
275 //
276 //*****************************************************************************
277 
278 //*****************************************************************************
279 //
280 // Prototypes for the APIs.
281 //
282 //*****************************************************************************
283 extern void OneWireBusReset(uint32_t ui32Base);
284 extern uint32_t OneWireBusStatus(uint32_t ui32Base);
285 extern void OneWireDataGet(uint32_t u3i2Base, uint32_t *pui32Data);
286 extern bool OneWireDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data);
287 extern void OneWireDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags);
288 extern void OneWireDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags);
289 extern void OneWireInit(uint32_t ui32Base, uint32_t ui32InitFlags);
290 extern void OneWireIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
291 extern void OneWireIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
292 extern void OneWireIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
293 extern void OneWireIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
294 extern void OneWireIntUnregister(uint32_t ui32Base);
295 extern uint32_t OneWireIntStatus(uint32_t ui32Base, bool bMasked);
296 extern void OneWireTransaction(uint32_t ui32Base, uint32_t ui32OpFlags,
297  uint32_t ui32Data, uint32_t ui32BitCnt);
298 
299 //*****************************************************************************
300 //
301 // Mark the end of the C bindings section for C++ compilers.
302 //
303 //*****************************************************************************
304 #ifdef __cplusplus
305 }
306 #endif
307 
308 #endif // __DRIVERLIB_ONEWIRE_H__
void OneWireIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: onewire.c:331
void OneWireDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags)
Definition: onewire.c:571
void OneWireDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags)
Definition: onewire.c:621
bool OneWireDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
Definition: onewire.c:234
void OneWireTransaction(uint32_t ui32Base, uint32_t ui32OpFlags, uint32_t ui32Data, uint32_t ui32BitCnt)
Definition: onewire.c:690
uint32_t OneWireBusStatus(uint32_t ui32Base)
Definition: onewire.c:163
uint32_t OneWireIntStatus(uint32_t ui32Base, bool bMasked)
Definition: onewire.c:408
void OneWireIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: onewire.c:294
void OneWireInit(uint32_t ui32Base, uint32_t ui32InitFlags)
Definition: onewire.c:107
void OneWireIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: onewire.c:475
void OneWireIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: onewire.c:370
void OneWireDataGet(uint32_t u3i2Base, uint32_t *pui32Data)
Definition: onewire.c:194
void OneWireBusReset(uint32_t ui32Base)
Definition: onewire.c:133
void OneWireIntUnregister(uint32_t ui32Base)
Definition: onewire.c:520
Copyright 2018, Texas Instruments Incorporated