Project

General

Profile

Revision 241

Updated libdragonfly documentation.

View differences:

group__i2c.html
1 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3 3
<title>libdragonfly: I2C</title>
4 4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5 5
<link href="tabs.css" rel="stylesheet" type="text/css">
6 6
</head><body>
7
<!-- Generated by Doxygen 1.4.6 -->
7
<!-- Generated by Doxygen 1.5.3 -->
8 8
<div class="tabs">
9 9
  <ul>
10 10
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11 11
    <li><a href="modules.html"><span>Modules</span></a></li>
12 12
    <li><a href="files.html"><span>Files</span></a></li>
13
  </ul></div>
13
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
14
  </ul>
15
</div>
14 16
<h1>I2C</h1>Provides Inter-Interconnected-Communications (I2C).  
15 17
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
16 18
<tr><td></td></tr>
......
41 43
It is implemented using callback functions. Whenever you want to send a packet you can call the built in send function (as a master) and it will send an array of bytes. Master recieve and slave send/receive are all handled by the call back functions. It is up to the end user to create functions that will handle the receiving of packets. Their functions will be called with every byte recieved so you must either buffer the inputs or handle each one separately.<p>
42 44
On errors we will simply flush the entire buffer.<p>
43 45
For information on how I2C operates, read the wikipedia article <a href="http://en.wikipedia.org/wiki/I2c">http://en.wikipedia.org/wiki/I2c</a> for a good explanation of how it works. <hr><h2>Function Documentation</h2>
44
<a class="anchor" name="g28bd4994859c49763a282579c4c772a1"></a><!-- doxytag: member="i2c.c::i2c_init" ref="g28bd4994859c49763a282579c4c772a1" args="(char addr, fun_mrecv_t master_recv, fun_srecv_t slave_recv, fun_send_t slave_send)" --><p>
45
<table class="mdTable" cellpadding="2" cellspacing="0">
46
  <tr>
47
    <td class="mdRow">
48
      <table cellpadding="0" cellspacing="0" border="0">
46
<a class="anchor" name="g28bd4994859c49763a282579c4c772a1"></a><!-- doxytag: member="i2c.c::i2c_init" ref="g28bd4994859c49763a282579c4c772a1" args="(char addr, fun_mrecv_t master_recv, fun_srecv_t slave_recv, fun_send_t slave_send)" -->
47
<div class="memitem">
48
<div class="memproto">
49
      <table class="memname">
49 50
        <tr>
50
          <td class="md" nowrap valign="top">int i2c_init           </td>
51
          <td class="md" valign="top">(&nbsp;</td>
52
          <td class="md" nowrap valign="top">char&nbsp;</td>
53
          <td class="mdname" nowrap> <em>addr</em>, </td>
51
          <td class="memname">int i2c_init           </td>
52
          <td>(</td>
53
          <td class="paramtype">char&nbsp;</td>
54
          <td class="paramname"> <em>addr</em>, </td>
54 55
        </tr>
55 56
        <tr>
56
          <td class="md" nowrap align="right"></td>
57
          <td class="md"></td>
58
          <td class="md" nowrap><a class="el" href="i2c_8h.html#3e550321eadebd4a697a3016e6ee918b">fun_mrecv_t</a>&nbsp;</td>
59
          <td class="mdname" nowrap> <em>master_recv</em>, </td>
57
          <td class="paramkey"></td>
58
          <td></td>
59
          <td class="paramtype"><a class="el" href="i2c_8h.html#3e550321eadebd4a697a3016e6ee918b">fun_mrecv_t</a>&nbsp;</td>
60
          <td class="paramname"> <em>master_recv</em>, </td>
60 61
        </tr>
61 62
        <tr>
62
          <td class="md" nowrap align="right"></td>
63
          <td class="md"></td>
64
          <td class="md" nowrap><a class="el" href="i2c_8h.html#e1453fbad57354c82d465c704edeead5">fun_srecv_t</a>&nbsp;</td>
65
          <td class="mdname" nowrap> <em>slave_recv</em>, </td>
63
          <td class="paramkey"></td>
64
          <td></td>
65
          <td class="paramtype"><a class="el" href="i2c_8h.html#e1453fbad57354c82d465c704edeead5">fun_srecv_t</a>&nbsp;</td>
66
          <td class="paramname"> <em>slave_recv</em>, </td>
66 67
        </tr>
67 68
        <tr>
68
          <td class="md" nowrap align="right"></td>
69
          <td class="md"></td>
70
          <td class="md" nowrap><a class="el" href="i2c_8h.html#4b946a38c2f1c58d838f59c6099feba1">fun_send_t</a>&nbsp;</td>
71
          <td class="mdname" nowrap> <em>slave_send</em></td>
69
          <td class="paramkey"></td>
70
          <td></td>
71
          <td class="paramtype"><a class="el" href="i2c_8h.html#4b946a38c2f1c58d838f59c6099feba1">fun_send_t</a>&nbsp;</td>
72
          <td class="paramname"> <em>slave_send</em></td><td>&nbsp;</td>
72 73
        </tr>
73 74
        <tr>
74
          <td class="md"></td>
75
          <td class="md">)&nbsp;</td>
76
          <td class="md" colspan="2"></td>
75
          <td></td>
76
          <td>)</td>
77
          <td></td><td></td><td width="100%"></td>
77 78
        </tr>
78 79
      </table>
79
    </td>
80
  </tr>
81
</table>
82
<table cellspacing="5" cellpadding="0" border="0">
83
  <tr>
84
    <td>
85
      &nbsp;
86
    </td>
87
    <td>
80
</div>
81
<div class="memdoc">
88 82

  
89 83
<p>
90 84
Initializes the i2c module. 
......
95 89
    <tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>Your address on the I2C bus. </td></tr>
96 90
    <tr><td valign="top"></td><td valign="top"><em>master_recv</em>&nbsp;</td><td>The address of the function to call when you receive a byte when you are a master. </td></tr>
97 91
    <tr><td valign="top"></td><td valign="top"><em>slave_recv</em>&nbsp;</td><td>The address of the function to call when you are a slave you receive data from the master </td></tr>
98
    <tr><td valign="top"></td><td valign="top"><em>slave_send</em>&nbsp;</td><td>The address of the function to call when you are a slave and the master requests data from you. </td></tr>
92
    <tr><td valign="top"></td><td valign="top"><em>slave_send</em>&nbsp;</td><td>The address of the function to call when you are a slave and the master requests data from you.</td></tr>
99 93
  </table>
100 94
</dl>
101
    </td>
102
  </tr>
103
</table>
104
<a class="anchor" name="gf5d4ed96f03670ca300298019b7f2f72"></a><!-- doxytag: member="i2c.c::i2c_request" ref="gf5d4ed96f03670ca300298019b7f2f72" args="(char dest)" --><p>
105
<table class="mdTable" cellpadding="2" cellspacing="0">
106
  <tr>
107
    <td class="mdRow">
108
      <table cellpadding="0" cellspacing="0" border="0">
95
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 for success, nonzero for failure </dd></dl>
96

  
97
</div>
98
</div><p>
99
<a class="anchor" name="gf5d4ed96f03670ca300298019b7f2f72"></a><!-- doxytag: member="i2c.c::i2c_request" ref="gf5d4ed96f03670ca300298019b7f2f72" args="(char dest)" -->
100
<div class="memitem">
101
<div class="memproto">
102
      <table class="memname">
109 103
        <tr>
110
          <td class="md" nowrap valign="top">int i2c_request           </td>
111
          <td class="md" valign="top">(&nbsp;</td>
112
          <td class="md" nowrap valign="top">char&nbsp;</td>
113
          <td class="mdname1" valign="top" nowrap> <em>dest</em>          </td>
114
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
115
          <td class="md" nowrap></td>
104
          <td class="memname">int i2c_request           </td>
105
          <td>(</td>
106
          <td class="paramtype">char&nbsp;</td>
107
          <td class="paramname"> <em>dest</em>          </td>
108
          <td>&nbsp;)&nbsp;</td>
109
          <td width="100%"></td>
116 110
        </tr>
117 111
      </table>
118
    </td>
119
  </tr>
120
</table>
121
<table cellspacing="5" cellpadding="0" border="0">
122
  <tr>
123
    <td>
124
      &nbsp;
125
    </td>
126
    <td>
112
</div>
113
<div class="memdoc">
127 114

  
128 115
<p>
129 116
Send a master request to the destination. 
......
131 118
Sends a request of data from the target address and calls the callback function to handle data as it comes in. This function will not work if the slave has not informationt to send or has nothing implemented to send it.<p>
132 119
<dl compact><dt><b>Parameters:</b></dt><dd>
133 120
  <table border="0" cellspacing="2" cellpadding="0">
134
    <tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td>The destination that we want to receive information from. </td></tr>
121
    <tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td>The destination that we want to receive information from.</td></tr>
135 122
  </table>
136 123
</dl>
137
    </td>
138
  </tr>
139
</table>
140
<a class="anchor" name="g15f534819e0f3405c4e05769af1f1e19"></a><!-- doxytag: member="i2c.c::i2c_send" ref="g15f534819e0f3405c4e05769af1f1e19" args="(char dest, char *data, size_t bytes)" --><p>
141
<table class="mdTable" cellpadding="2" cellspacing="0">
142
  <tr>
143
    <td class="mdRow">
144
      <table cellpadding="0" cellspacing="0" border="0">
124
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 for success, nonzero for failure </dd></dl>
125

  
126
</div>
127
</div><p>
128
<a class="anchor" name="g15f534819e0f3405c4e05769af1f1e19"></a><!-- doxytag: member="i2c.c::i2c_send" ref="g15f534819e0f3405c4e05769af1f1e19" args="(char dest, char *data, size_t bytes)" -->
129
<div class="memitem">
130
<div class="memproto">
131
      <table class="memname">
145 132
        <tr>
146
          <td class="md" nowrap valign="top">int i2c_send           </td>
147
          <td class="md" valign="top">(&nbsp;</td>
148
          <td class="md" nowrap valign="top">char&nbsp;</td>
149
          <td class="mdname" nowrap> <em>dest</em>, </td>
133
          <td class="memname">int i2c_send           </td>
134
          <td>(</td>
135
          <td class="paramtype">char&nbsp;</td>
136
          <td class="paramname"> <em>dest</em>, </td>
150 137
        </tr>
151 138
        <tr>
152
          <td class="md" nowrap align="right"></td>
153
          <td class="md"></td>
154
          <td class="md" nowrap>char *&nbsp;</td>
155
          <td class="mdname" nowrap> <em>data</em>, </td>
139
          <td class="paramkey"></td>
140
          <td></td>
141
          <td class="paramtype">char *&nbsp;</td>
142
          <td class="paramname"> <em>data</em>, </td>
156 143
        </tr>
157 144
        <tr>
158
          <td class="md" nowrap align="right"></td>
159
          <td class="md"></td>
160
          <td class="md" nowrap>size_t&nbsp;</td>
161
          <td class="mdname" nowrap> <em>bytes</em></td>
145
          <td class="paramkey"></td>
146
          <td></td>
147
          <td class="paramtype">size_t&nbsp;</td>
148
          <td class="paramname"> <em>bytes</em></td><td>&nbsp;</td>
162 149
        </tr>
163 150
        <tr>
164
          <td class="md"></td>
165
          <td class="md">)&nbsp;</td>
166
          <td class="md" colspan="2"></td>
151
          <td></td>
152
          <td>)</td>
153
          <td></td><td></td><td width="100%"></td>
167 154
        </tr>
168 155
      </table>
169
    </td>
170
  </tr>
171
</table>
172
<table cellspacing="5" cellpadding="0" border="0">
173
  <tr>
174
    <td>
175
      &nbsp;
176
    </td>
177
    <td>
156
</div>
157
<div class="memdoc">
178 158

  
179 159
<p>
180 160
Sends a byte array over I2C as a master. 
......
184 164
  <table border="0" cellspacing="2" cellpadding="0">
185 165
    <tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td>Destination address of the data on the I2C bus. </td></tr>
186 166
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>The pointer to the byte array of data </td></tr>
187
    <tr><td valign="top"></td><td valign="top"><em>bytes</em>&nbsp;</td><td>The amount of bytes long that the byte array is. This is how many bytes from the array that the function will send. </td></tr>
167
    <tr><td valign="top"></td><td valign="top"><em>bytes</em>&nbsp;</td><td>The amount of bytes long that the byte array is. This is how many bytes from the array that the function will send.</td></tr>
188 168
  </table>
189 169
</dl>
190
    </td>
191
  </tr>
192
</table>
193
<hr size="1"><address style="align: right;"><small>Generated on Wed Sep 26 17:39:31 2007 for libdragonfly by&nbsp;
170
<dl class="return" compact><dt><b>Returns:</b></dt><dd>zero for success, nonzero for failure </dd></dl>
171

  
172
</div>
173
</div><p>
174
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Nov 8 23:15:40 2007 for libdragonfly by&nbsp;
194 175
<a href="http://www.doxygen.org/index.html">
195
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
176
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
196 177
</body>
197 178
</html>

Also available in: Unified diff