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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Sensor Watch: I2C Controller Driver</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Sensor Watch<span id="projectnumber"> 0.0.2</span>
</div>
<div id="projectbrief">A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">I2C Controller Driver</div></div>
</div><!--header-->
<div class="contents">
<p>This section covers functions related to the SAM L22's built-I2C driver, including configuring the I2C bus, putting values directly on the bus and reading data from registers on I2C devices.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gab9f25517d9dc3c32a707266dfd413e5b"><td class="memItemLeft" align="right" valign="top"><a id="gab9f25517d9dc3c32a707266dfd413e5b" name="gab9f25517d9dc3c32a707266dfd413e5b"></a>
void </td><td class="memItemRight" valign="bottom"><b>watch_enable_i2c</b> (void)</td></tr>
<tr class="memdesc:gab9f25517d9dc3c32a707266dfd413e5b"><td class="mdescLeft"> </td><td class="mdescRight">Enables the I2C peripheral. Call this before attempting to interface with I2C devices. <br /></td></tr>
<tr class="separator:gab9f25517d9dc3c32a707266dfd413e5b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga2189bdff3dcb40f451d0aa988ea99760"><td class="memItemLeft" align="right" valign="top"><a id="ga2189bdff3dcb40f451d0aa988ea99760" name="ga2189bdff3dcb40f451d0aa988ea99760"></a>
void </td><td class="memItemRight" valign="bottom"><b>watch_disable_i2c</b> (void)</td></tr>
<tr class="memdesc:ga2189bdff3dcb40f451d0aa988ea99760"><td class="mdescLeft"> </td><td class="mdescRight">Disables the I2C peripheral. <br /></td></tr>
<tr class="separator:ga2189bdff3dcb40f451d0aa988ea99760"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga8b44030f78c30dd4026b349fc0c8cf08"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga8b44030f78c30dd4026b349fc0c8cf08">watch_i2c_send</a> (int16_t addr, uint8_t *buf, uint16_t length)</td></tr>
<tr class="memdesc:ga8b44030f78c30dd4026b349fc0c8cf08"><td class="mdescLeft"> </td><td class="mdescRight">Sends a series of values to a device on the I2C bus. <a href="group__i2c.html#ga8b44030f78c30dd4026b349fc0c8cf08">More...</a><br /></td></tr>
<tr class="separator:ga8b44030f78c30dd4026b349fc0c8cf08"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga426971387b87286c8decca7342c06b4b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga426971387b87286c8decca7342c06b4b">watch_i2c_receive</a> (int16_t addr, uint8_t *buf, uint16_t length)</td></tr>
<tr class="memdesc:ga426971387b87286c8decca7342c06b4b"><td class="mdescLeft"> </td><td class="mdescRight">Receives a series of values from a device on the I2C bus. <a href="group__i2c.html#ga426971387b87286c8decca7342c06b4b">More...</a><br /></td></tr>
<tr class="separator:ga426971387b87286c8decca7342c06b4b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaf0a4c78215cbd85ab557fc6c786eb6ad"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gaf0a4c78215cbd85ab557fc6c786eb6ad">watch_i2c_write8</a> (int16_t addr, uint8_t reg, uint8_t data)</td></tr>
<tr class="memdesc:gaf0a4c78215cbd85ab557fc6c786eb6ad"><td class="mdescLeft"> </td><td class="mdescRight">Writes a byte to a register in an I2C device. <a href="group__i2c.html#gaf0a4c78215cbd85ab557fc6c786eb6ad">More...</a><br /></td></tr>
<tr class="separator:gaf0a4c78215cbd85ab557fc6c786eb6ad"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gac5644140ddda98198f9d5deabbeaf781"><td class="memItemLeft" align="right" valign="top">uint8_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gac5644140ddda98198f9d5deabbeaf781">watch_i2c_read8</a> (int16_t addr, uint8_t reg)</td></tr>
<tr class="memdesc:gac5644140ddda98198f9d5deabbeaf781"><td class="mdescLeft"> </td><td class="mdescRight">Reads a byte from a register in an I2C device. <a href="group__i2c.html#gac5644140ddda98198f9d5deabbeaf781">More...</a><br /></td></tr>
<tr class="separator:gac5644140ddda98198f9d5deabbeaf781"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaed749d3ca5e6e3aedcf1aefed3d7663e"><td class="memItemLeft" align="right" valign="top">uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gaed749d3ca5e6e3aedcf1aefed3d7663e">watch_i2c_read16</a> (int16_t addr, uint8_t reg)</td></tr>
<tr class="memdesc:gaed749d3ca5e6e3aedcf1aefed3d7663e"><td class="mdescLeft"> </td><td class="mdescRight">Reads an unsigned little-endian word from a register in an I2C device. <a href="group__i2c.html#gaed749d3ca5e6e3aedcf1aefed3d7663e">More...</a><br /></td></tr>
<tr class="separator:gaed749d3ca5e6e3aedcf1aefed3d7663e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga6732b5655fdada88d083e4b4d05d1ca8"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga6732b5655fdada88d083e4b4d05d1ca8">watch_i2c_read24</a> (int16_t addr, uint8_t reg)</td></tr>
<tr class="memdesc:ga6732b5655fdada88d083e4b4d05d1ca8"><td class="mdescLeft"> </td><td class="mdescRight">Reads three bytes as an unsigned little-endian int from a register in an I2C device. <a href="group__i2c.html#ga6732b5655fdada88d083e4b4d05d1ca8">More...</a><br /></td></tr>
<tr class="separator:ga6732b5655fdada88d083e4b4d05d1ca8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga3d1c750d1b228b11333d10fc9647d651"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga3d1c750d1b228b11333d10fc9647d651">watch_i2c_read32</a> (int16_t addr, uint8_t reg)</td></tr>
<tr class="memdesc:ga3d1c750d1b228b11333d10fc9647d651"><td class="mdescLeft"> </td><td class="mdescRight">Reads an unsigned little-endian int from a register in an I2C device. <a href="group__i2c.html#ga3d1c750d1b228b11333d10fc9647d651">More...</a><br /></td></tr>
<tr class="separator:ga3d1c750d1b228b11333d10fc9647d651"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >This section covers functions related to the SAM L22's built-I2C driver, including configuring the I2C bus, putting values directly on the bus and reading data from registers on I2C devices. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaed749d3ca5e6e3aedcf1aefed3d7663e" name="gaed749d3ca5e6e3aedcf1aefed3d7663e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaed749d3ca5e6e3aedcf1aefed3d7663e">◆ </a></span>watch_i2c_read16()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint16_t watch_i2c_read16 </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>reg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reads an unsigned little-endian word from a register in an I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to address. </td></tr>
<tr><td class="paramname">reg</td><td>The register on the device that you wish to read. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>An unsigned word representing the value of the register that was read. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>This reads two bytes into the word in bus order. If the device returns the LSB first and then the MSB, you can use this value as returned. If the device returns the data in big-endian order or uses some other kind of fancy bit packing, you may need to shuffle some bits around. </dd></dl>
</div>
</div>
<a id="ga6732b5655fdada88d083e4b4d05d1ca8" name="ga6732b5655fdada88d083e4b4d05d1ca8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6732b5655fdada88d083e4b4d05d1ca8">◆ </a></span>watch_i2c_read24()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t watch_i2c_read24 </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>reg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reads three bytes as an unsigned little-endian int from a register in an I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to address. </td></tr>
<tr><td class="paramname">reg</td><td>The register on the device that you wish to read. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>An unsigned word representing the value of the register that was read. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>This reads three bytes into the word in bus order. If the device returns these bytes LSB first, you can use this value as returned. If there is a sign bit, the device returns the data in big-endian order, or it uses some other kind of fancy bit packing, you may need to shuffle some bits around. </dd></dl>
</div>
</div>
<a id="ga3d1c750d1b228b11333d10fc9647d651" name="ga3d1c750d1b228b11333d10fc9647d651"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3d1c750d1b228b11333d10fc9647d651">◆ </a></span>watch_i2c_read32()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t watch_i2c_read32 </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>reg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reads an unsigned little-endian int from a register in an I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to address. </td></tr>
<tr><td class="paramname">reg</td><td>The register on the device that you wish to read. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>An unsigned word representing the value of the register that was read. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>This reads three bytes into the word in bus order. If the device returns these bytes LSB first, you can use this value as returned. If the device returns the data in big-endian order, or it uses some other kind of fancy bit packing, you may need to shuffle some bits around. </dd></dl>
</div>
</div>
<a id="gac5644140ddda98198f9d5deabbeaf781" name="gac5644140ddda98198f9d5deabbeaf781"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac5644140ddda98198f9d5deabbeaf781">◆ </a></span>watch_i2c_read8()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint8_t watch_i2c_read8 </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>reg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reads a byte from a register in an I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to address. </td></tr>
<tr><td class="paramname">reg</td><td>The register on the device that you wish to read. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>An unsigned byte representing the value of the register that was read. </dd></dl>
</div>
</div>
<a id="ga426971387b87286c8decca7342c06b4b" name="ga426971387b87286c8decca7342c06b4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga426971387b87286c8decca7342c06b4b">◆ </a></span>watch_i2c_receive()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void watch_i2c_receive </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t * </td>
<td class="paramname"><em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint16_t </td>
<td class="paramname"><em>length</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Receives a series of values from a device on the I2C bus. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to hear from. </td></tr>
<tr><td class="paramname">buf</td><td>Storage for the incoming bytes; on return, it will contain the received data. </td></tr>
<tr><td class="paramname">length</td><td>The number of bytes that you wish to receive. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="ga8b44030f78c30dd4026b349fc0c8cf08" name="ga8b44030f78c30dd4026b349fc0c8cf08"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8b44030f78c30dd4026b349fc0c8cf08">◆ </a></span>watch_i2c_send()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void watch_i2c_send </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t * </td>
<td class="paramname"><em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint16_t </td>
<td class="paramname"><em>length</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Sends a series of values to a device on the I2C bus. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to talk to. </td></tr>
<tr><td class="paramname">buf</td><td>A series of unsigned bytes; the data you wish to transmit. </td></tr>
<tr><td class="paramname">length</td><td>The number of bytes in buf that you wish to send. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="gaf0a4c78215cbd85ab557fc6c786eb6ad" name="gaf0a4c78215cbd85ab557fc6c786eb6ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf0a4c78215cbd85ab557fc6c786eb6ad">◆ </a></span>watch_i2c_write8()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void watch_i2c_write8 </td>
<td>(</td>
<td class="paramtype">int16_t </td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>reg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t </td>
<td class="paramname"><em>data</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Writes a byte to a register in an I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">addr</td><td>The address of the device you wish to address. </td></tr>
<tr><td class="paramname">reg</td><td>The register on the device that you wish to set. </td></tr>
<tr><td class="paramname">data</td><td>The value that you wish to set the register to. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
|