summaryrefslogtreecommitdiff
path: root/driverlib/onewire.h
blob: 78aa6aba559724eae56fc231571e99e7356f8fe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
//*****************************************************************************
//
// onewire.h - Prototypes for the OneWire Driver.
//
// Copyright (c) 2012-2014 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
//   Redistribution and use in source and binary forms, with or without
//   modification, are permitted provided that the following conditions
//   are met:
// 
//   Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the  
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
//
//*****************************************************************************

#ifndef __DRIVERLIB_ONEWIRE_H__
#define __DRIVERLIB_ONEWIRE_H__

//*****************************************************************************
//
//! \addtogroup onewire_api
//! @{
//
//*****************************************************************************

//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif

//*****************************************************************************
//
// Defines used in the OneWireInit() function call.
//
//*****************************************************************************

//
// This define is used in initialization to request standard speed bus
// timings.  This is the default.
//
#define ONEWIRE_INIT_SPD_STD    0x00000000

//
// This define is used in initialization to request overdrive speed bus
// timings.
//
#define ONEWIRE_INIT_SPD_OD     0x00000020

//
// This define is used in initialization to request standard read sampling
// timing (2us for ONEWIRE_INIT_SPD_OD and 16us for ONEWIRE_INIT_SPD_STD).
// This is the default.
//
#define ONEWIRE_INIT_READ_STD   0x00000000

//
// This define is used in initialization to request late read sampling
// timing (7us for ONEWIRE_INIT_SPD_OD and 50us for ONEWIRE_INIT_SPD_STD).
//
#define ONEWIRE_INIT_READ_LATE  0x00000040

//
// This define is used in initialization to request a standard
// Answer-to-Reset (presence detect) monitor.  This is the default.
//
#define ONEWIRE_INIT_ATR        0x00000000

//
// This define is used in initialization to request no Answer-to-Reset
// (presence detect) monitor.  The module will delay operations after a bus
// reset for the expected presence detect period in this case.
//
#define ONEWIRE_INIT_NO_ATR     0x00000080

//
// This define is used in initialization to request standard signal polarity
// on the 1-Wire bus (pin is driven low to drive bus low).  This is the
// default.
//
#define ONEWIRE_INIT_STD_POL    0x00000000

//
// This define is used in initialization to request alternate signal polarity
// on the 1-Wire bus (pin is driven high to drive bus low).
//
#define ONEWIRE_INIT_ALT_POL    0x40000000

//
// This define is used in initialization to request normal 1-Wire operational
// mode.  This is the default.
//
#define ONEWIRE_INIT_1_WIRE_CFG 0x00000000

//
// This define is used in initialization to request a 2 pin operational
// mode where one pin is used exclusively for TX operations and the other
// for RX.
//
#define ONEWIRE_INIT_2_WIRE_CFG 0x80000000

//*****************************************************************************
//
// Defines for bus status conditions.  These values can be returned by
// OneWireBusStatus().
//
//*****************************************************************************

//
// This will be set if the bus is busy handling a Read, Write or
// Reset activity.
//
#define ONEWIRE_BUS_STATUS_BUSY 0x00000100

//
// This will be set if the module did not detect any slave presence pulses
// after a bus reset.
//
#define ONEWIRE_BUS_STATUS_NO_SLAVE                                           \
                                0x00000200

//
// This will be set if the bus is being held low outside of a normal Read,
// Write or Reset activity.
//
#define ONEWIRE_BUS_STATUS_STUCK                                              \
                                0x00000400

//*****************************************************************************
//
// OneWire operation modes used with OneWireTransaction().
//
//*****************************************************************************

//
// This mode flag indicates a single reset should be issued prior to a write
// and/or read operation.
//
#define ONEWIRE_OP_RESET        0x00000001

//
// This mode flag indicates a read operation.
//
#define ONEWIRE_OP_READ         0x00000002

//
// This mode flag indicates a write operation.
//
#define ONEWIRE_OP_WRITE        0x00000004

//*****************************************************************************
//
// OneWire DMA used with OneWireDMAEnable().
//
//*****************************************************************************

//
// This indicates the DMA should issue a 1-Wire bus reset before starting.
//
#define ONEWIRE_DMA_BUS_RESET   0x00000001

//
// The DMA operation will be a single Read after each module transaction.
//
#define ONEWIRE_DMA_OP_READ     0x00000002

//
// The DMA will write values to the 1-Wire interface as each previous DMA
// write operation completes.
//
#define ONEWIRE_DMA_OP_MULTI_WRITE                                            \
                                0x00000004

//
// The DMA will read values from the 1-Wire interface as each previous DMA
// read operation completes.
//
#define ONEWIRE_DMA_OP_MULTI_READ                                             \
                                0x00000006

//
// This Scatter Gather DMA mode is paired with ONEWIRE_DMA_OP_READ to instruct
// the 1-Wire DMA to initiate an operation at the start of and then on each
// transition completion thereafter.
//
#define ONEWIRE_DMA_MODE_SG     0x00000008

//
// DMA expects a Read/Write bus operation size of 8 bits.  This should match
// the uDMA channel setup.
//
#define ONEWIRE_DMA_OP_SZ_8     0x00000000

//
// DMA expects a Read/Write bus operation size of 16 bits.  This should match
// the uDMA channel setup.
//
#define ONEWIRE_DMA_OP_SZ_16    0x00000800

//
// DMA expects a Read/Write bus operation size of 32 bits.  This should match
// the uDMA channel setup.
//
#define ONEWIRE_DMA_OP_SZ_32    0x00001800

//*****************************************************************************
//
// OneWire interrupt defines.  Use in calls to OneWireIntEnable(),
// OneWireIntDisable(), OneWireIntClear() and returned by OneWireIntStatus().
//
//*****************************************************************************

//
// This interrupt indicates a bus reset has just completed.
//
#define ONEWIRE_INT_RESET_DONE  0x00000001

//
// The interrupt indicates a Read or Write master initiated operation
// has just completed.
//
#define ONEWIRE_INT_OP_DONE     0x00000002

//
// This interrupt indicates that no presence detect was signaled by a slave
// on the bus after a reset.
//
#define ONEWIRE_INT_NO_SLAVE    0x00000004

//
// This interrupt indicates the bus is being held low outside of normal
// operations.
//
#define ONEWIRE_INT_STUCK       0x00000008

//
// This interrupt indicates a OneWire DMA operation has completed.
//
#define ONEWIRE_INT_DMA_DONE    0x00000010

//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************

//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
extern void OneWireBusReset(uint32_t ui32Base);
extern uint32_t OneWireBusStatus(uint32_t ui32Base);
extern void OneWireDataGet(uint32_t u3i2Base, uint32_t *pui32Data);
extern bool OneWireDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data);
extern void OneWireDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags);
extern void OneWireDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags);
extern void OneWireInit(uint32_t ui32Base, uint32_t ui32InitFlags);
extern void OneWireIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
extern void OneWireIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
extern void OneWireIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
extern void OneWireIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
extern void OneWireIntUnregister(uint32_t ui32Base);
extern uint32_t OneWireIntStatus(uint32_t ui32Base, bool bMasked);
extern void OneWireTransaction(uint32_t ui32Base, uint32_t ui32OpFlags,
                               uint32_t ui32Data, uint32_t ui32BitCnt);

//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif

#endif // __DRIVERLIB_ONEWIRE_H__