-
Notifications
You must be signed in to change notification settings - Fork 0
/
adc_2adc_8c-example.html
92 lines (90 loc) · 13.1 KB
/
adc_2adc_8c-example.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>RoboLib: adc/adc.c</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>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</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 style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="robologo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">RoboLib
 <span id="projectnumber">1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</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="headertitle">
<div class="title">adc/adc.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">* examples/adc.c *</span></div><div class="line"><span class="comment">* ============== *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* Version: 1.0.0 *</span></div><div class="line"><span class="comment">* Date : 27.09.15 *</span></div><div class="line"><span class="comment">* Author : Peter Weissig *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* For help or bug report please visit: *</span></div><div class="line"><span class="comment">* https://github.com/RoboAG/avr_robolib *</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"></div><div class="line"><span class="comment">// include from gcc</span></div><div class="line"><span class="preprocessor">#include <inttypes.h></span></div><div class="line"></div><div class="line"><span class="comment">// include all necessary headers from robolib</span></div><div class="line"><span class="preprocessor">#include "adc.h"</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div><div class="line"> <span class="comment">// number of current channel to be measured</span></div><div class="line"> uint8_t nr = 0;</div><div class="line"></div><div class="line"> <span class="comment">// initialize robolib</span></div><div class="line"> <a name="a0"></a><a class="code" href="robolib_8dox_a73ba7be7f0f88aacfbaa7d1129377e86.html#a73ba7be7f0f88aacfbaa7d1129377e86">robolib_init</a>();</div><div class="line"></div><div class="line"> <span class="comment">// endless loop</span></div><div class="line"> <span class="keywordflow">while</span> (1) {</div><div class="line"> <span class="comment">// start a new conversion</span></div><div class="line"> uint16_t value;</div><div class="line"> value = adc_get(nr);</div><div class="line"></div><div class="line"> <span class="comment">// print result to uart0</span></div><div class="line"> string_from_const(uart0_send, <span class="stringliteral">"channel["</span>);</div><div class="line"> string_from_uint (uart0_send, nr, 1);</div><div class="line"> string_from_const(uart0_send, <span class="stringliteral">"] = "</span>);</div><div class="line"> string_from_uint (uart0_send, value, 5);</div><div class="line"> string_from_const(uart0_send, <span class="stringliteral">"\r\n"</span>);</div><div class="line"></div><div class="line"> <span class="comment">// calculate number of next channel</span></div><div class="line"> nr++;</div><div class="line"> <span class="keywordflow">if</span> (nr > 7) { nr = 0;}</div><div class="line"></div><div class="line"> <span class="comment">// wait for 0.25 seconds</span></div><div class="line"> delay_ms(250);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> (0);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* How to compile this example *</span></div><div class="line"><span class="comment">* =========================== *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* required files *</span></div><div class="line"><span class="comment">* + adc.c (source code, this file) *</span></div><div class="line"><span class="comment">* + adc_header.ini (headerfile as '.ini') *</span></div><div class="line"><span class="comment">* + Makefile (needed for compiling, linking and downloading) *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* 1. adjust Makefile (only needed once) *</span></div><div class="line"><span class="comment">* + set "MCU" to the controller type (e.g. atmega64) *</span></div><div class="line"><span class="comment">* + set "PATH_LIB" to the library (e.g. ~/avr/robolib) *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* 2. compile library and create headerfile (only needed once) *</span></div><div class="line"><span class="comment">* + open a console (e.g. strg+alt+t) *</span></div><div class="line"><span class="comment">* + change to the directory of the files (e.g. cd ~/avr/test/) *</span></div><div class="line"><span class="comment">* + run make with "ini" as parameter (e.g. make ini) *</span></div><div class="line"><span class="comment">* ==> check output for errors *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* 3. compile main file and link everything (needed for all changes) *</span></div><div class="line"><span class="comment">* + open a console (e.g. strg+alt+t) *</span></div><div class="line"><span class="comment">* + change to the directory of the files (e.g. cd ~/avr/test/) *</span></div><div class="line"><span class="comment">* + run make with "all" as parameter (e.g. make all) *</span></div><div class="line"><span class="comment">* ==> check output for errors *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* How to download this example *</span></div><div class="line"><span class="comment">* ============================ *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* required files *</span></div><div class="line"><span class="comment">* + out.hex (machine code, created in the steps above) *</span></div><div class="line"><span class="comment">* + Makefile (needed for compiling, linking and downloading) *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* 1. adjust Makefile (only needed once) *</span></div><div class="line"><span class="comment">* + set "COMPORT_PROG" to the serial device (e.g. /dev/ttyS0) *</span></div><div class="line"><span class="comment">* + set "BAUDRATE_PROG" to the speed (e.g. 57600) *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">* 2. download result (needed for all changes) *</span></div><div class="line"><span class="comment">* + open a console (e.g. strg+alt+t) *</span></div><div class="line"><span class="comment">* + change to the directory of the files (e.g. cd ~/avr/test/) *</span></div><div class="line"><span class="comment">* + run make with "program" as parameter (e.g. make program) *</span></div><div class="line"><span class="comment">* ==> check output for errors *</span></div><div class="line"><span class="comment">* *</span></div><div class="line"><span class="comment">******************************************************************************/</span></div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Mar 13 2021 10:15:20 for RoboLib by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>