-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootloader_2bootloader_8c-example.html
92 lines (90 loc) · 16.3 KB
/
bootloader_2bootloader_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: bootloader/bootloader.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">bootloader/bootloader.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/bootloader.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.2 *</span></div><div class="line"><span class="comment">* Date : 23.10.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"><span class="preprocessor">#include <avr/io.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 "bootloader.h"</span></div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_start]*********************************</span></div><div class="line">uint8_t bootloader_start(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> <span class="comment">// check boot pin</span></div><div class="line"><span class="preprocessor"> #if ( defined (__AVR_ATmega2561__) || \</span></div><div class="line"><span class="preprocessor"> defined (__AVR_ATmega64__))</span></div><div class="line"> DDRG = 0x00;</div><div class="line"> PORTG = _BV(2);</div><div class="line"> delay_ms(50);</div><div class="line"> <span class="keywordflow">if</span> (PING & _BV(2)) {</div><div class="line"> PORTG = 0x00;</div><div class="line"> <span class="keywordflow">return</span> 0x00;</div><div class="line"> }</div><div class="line"> PORTG = 0x00;</div><div class="line"><span class="preprocessor"> #else</span></div><div class="line"> DDRB = 0x00;</div><div class="line"> PORTB = _BV(2);</div><div class="line"> delay_ms(50);</div><div class="line"> <span class="keywordflow">if</span> (PINB & _BV(2)) {</div><div class="line"> PORTB = 0x00;</div><div class="line"> <span class="keywordflow">return</span> 0x00;</div><div class="line"> }</div><div class="line"> PORTB = 0x00;</div><div class="line"><span class="preprocessor"> #endif</span></div><div class="line"></div><div class="line"> uart0_send(<span class="charliteral">'~'</span>);</div><div class="line"></div><div class="line"> string_from_const(display_print, <span class="stringliteral">"Bootloader V4.0"</span>);</div><div class="line"> display_gotoxy(0,1);</div><div class="line"> string_from_const(display_print, <span class="stringliteral">"P.W. 23.10.2015"</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0xFF;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_end]***********************************</span></div><div class="line"><span class="keywordtype">void</span> bootloader_end(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> display_clear();</div><div class="line"></div><div class="line"> uart0_flush();</div><div class="line"> delay_ms(10);</div><div class="line"> uart0_disable();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_data_in]*******************************</span></div><div class="line">uint8_t bootloader_data_in(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> uart0_get();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_data_stat]*****************************</span></div><div class="line">uint8_t bootloader_data_stat(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> uart0_rxcount_get();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_data_out]******************************</span></div><div class="line"><span class="keywordtype">void</span> bootloader_data_out(uint8_t data) {</div><div class="line"> uart0_send(data);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_idle]**********************************</span></div><div class="line">uint8_t bootloader_idle(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0xFF;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_command]*******************************</span></div><div class="line"><span class="keywordtype">void</span> bootloader_command(<span class="keywordtype">void</span>) {</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_help]**********************************</span></div><div class="line"><span class="keywordtype">void</span> bootloader_help(<span class="keywordtype">void</span>) {</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//**************************[bootloader_error]*********************************</span></div><div class="line">uint8_t bootloader_error(<span class="keywordtype">void</span>) {</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0xFF;</div><div class="line">}</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">* + bootloader.c (source code, this file) *</span></div><div class="line"><span class="comment">* + bootloader_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">* + set "BOOTSTART" to boot adress (e.g. 0xE000) *</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_AVRDUDE" to the serial device (e.g. /dev/ttyACM0) *</span></div><div class="line"><span class="comment">* + set "BAUDRATE_AVRDUDE" to the speed (e.g. 4µs) *</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 "avrdude" as parameter (e.g. make avrdude) *</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>