Select Git revision
creating-an-application.html
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
creating-an-application.html 12.12 KiB
<!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=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>RcdMathLib_doc: Creating an application</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">RcdMathLib_doc
</div>
<div id="projectbrief">Open Source Library for Linear and Non-linear Algebra</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('creating-an-application.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- 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="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Creating an application </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#creating-an-application-full-fledge">Creating an application for full-fledged devices</a></li>
<li class="level1"><a href="#creating-an-application-res-lim">Creating an application for resource-limited devices</a></li>
<li class="level1"><a href="#the-main-function">The main function</a></li>
<li class="level1"><a href="#the-applications-makefile">The application's Makefile</a><ul><li class="level2"><a href="#the-minimal-makefile">The minimal Makefile</a></li>
<li class="level2"><a href="#including-modules">Including modules</a></li>
</ul>
</li>
</ul>
</div>
<div class="textblock"><dl class="section author"><dt>Author</dt><dd>Zakaria Kasmi</dd></dl>
<p>An application can be created for full-fledged or resource-limited devices.</p>
<h1><a class="anchor" id="creating-an-application-full-fledge"></a>
Creating an application for full-fledged devices</h1>
<p>We recommend to use the <a href="https://www.eclipse.org/">Eclipse IDE</a> for C/C++ Developers for creating own application. The simplest way to write your own application, is to put your *.c and *.h files under the <code>src</code> directory. Another way is to create a directory containing the multiple C file(s) with your source code. The header files can be imported in the Eclipse IDE by opening Project->Properties and selecting ''C/C++ General->Paths and Symbols->Languages->GNU C'' from the Selection Wizard. Click the ''Add..'' button to browse to the header-directory and the select the ''Apply'' and ''OK'' buttons. The users can be oriented to the main.c and the examples in the <a href="https://git.imp.fu-berlin.de/zkasmi/RcdMathLib/-/tree/master/">main-directory</a> of the RcdMathLib.</p>
<h1><a class="anchor" id="creating-an-application-res-lim"></a>
Creating an application for resource-limited devices</h1>
<p>To create your own application for a resource-limited device you need to create a directory containing one or multiple C file(s) with your source code and a Makefile. An example Makefile is available in the <code>src</code> folder of the <a href="https://git.imp.fu-berlin.de/zkasmi/RcdMathLib/-/blob/master/eclipse_projects/RcdMathLib_resource_limited_devices.zip">Eclipse project for resource-limited devices</a>.</p>
<h1><a class="anchor" id="the-main-function"></a>
The main function</h1>
<p>RIOT starts two threads the idle and main threads after the board is initialized. The idle thread has the lowest priority while the main thread has a priority that is in the middle between the lowest and the highest available priorities. The main thread is the first that runs and calls the <code>main()</code> function. This function needs to be defined in the source code of each application (typically located in the <code>main.c</code> file).</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <stdio.h></span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include "<a class="code" href="matrix__test_8h.html">matrix_test.h</a>"</span></div>
<div class="line"><span class="preprocessor">#include "<a class="code" href="vector__test_8h.html">vector_test.h</a>"</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> puts(<span class="stringliteral">"RcdMathLib Application!"</span>);</div>
<div class="line"> <span class="comment">// Test the basic operations module;</span></div>
<div class="line"> <a class="code" href="matrix__test_8h.html#aad3d0f4acb79e8a9b61eda59dc3a12b2">matrix_test</a>();</div>
<div class="line"> <a class="code" href="vector__test_8h.html#ab0aed13072bc11b97766634c625d6f21">vector_test</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> EXIT_SUCCESS;</div>
<div class="line">}</div>
</div><!-- fragment --><p>The above C code shows an application testing the basic operations sub-modules. This application run operations of the vector and matrix sub-modules.</p>
<h1><a class="anchor" id="the-applications-makefile"></a>
The application's Makefile</h1>
<h2><a class="anchor" id="the-minimal-makefile"></a>
The minimal Makefile</h2>
<p>At minimum the Makefile of an application (see <a class="el" href="getting-started.html">Getting started</a>) needs to define the following macros:</p><ul>
<li><code>APPLICATION</code>: contains the name of your application</li>
<li><code>RIOTBASE</code>: specifies the path to your copy of the RIOT repository (note, the <code></code> macro can be used to give a relative path)</li>
<li><code>RCDMATHLIB</code>: specifies the path to the copy of the RcdMathLib repository (note, the <code></code> macro can be used to give a relative path)</li>
<li><code>USEMODULE</code>: specifies the module of the RcdMathLib that you may want to use</li>
</ul>
<p>The <code>BOARD</code> macro is also required and recommended to be set to <code>native</code> by default, but is recommended to be overridable with the <code>?=</code> operator. Additionally, it is required to include the <code>Makefile.include</code> from the RcdMathLib and from the <code>RIOTBASE</code>.</p>
<div class="fragment"><div class="line"># Set the name of your application:</div>
<div class="line">APPLICATION = foobar</div>
<div class="line"> </div>
<div class="line"># If no BOARD is found in the environment, use this default:</div>
<div class="line">BOARD ?= native</div>
<div class="line"> </div>
<div class="line"># This has to be the absolute path to the RcdMathLib base directory:</div>
<div class="line">RCDMATHLIB ?= $(CURDIR)/../RcdMathLib</div>
<div class="line"> </div>
<div class="line"># This has to be the absolute path to the RIOT base directory:</div>
<div class="line">RIOTBASE ?= $(CURDIR)/../../RIOT</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">include $(RCDMATHLIB)/Makefile.include</div>
<div class="line">include $(RIOTBASE)/Makefile.include</div>
</div><!-- fragment --><h2><a class="anchor" id="including-modules"></a>
Including modules</h2>
<p>The modules of the RcdMathLib as well as of the RcdMathLib can be included. In order to use additional modules, such as a particular driver or a system library, the modules' names must be appended to the USEMODULE variable. For example, to build an application using the SHT11 temperature sensor and UDP/IPv6 functionalities, the Makefile needs to contain the following lines:</p>
<div class="fragment"><div class="line">USEMODULE += sht11</div>
<div class="line">USEMODULE += gnrc_ipv6_default</div>
<div class="line">USEMODULE += gnrc_udp</div>
</div><!-- fragment --><p>For example, to create an application using the matrix decompositions, the pseudo-inverse, and solving linear equations sub-modules, the Makefile must comprise the following lines:</p>
<div class="fragment"><div class="line">USEMODULE += matrix_decompositions</div>
<div class="line">USEMODULE += pseudo_inverse</div>
<div class="line">USEMODULE += utilities</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<div class="ttc" id="avector__test_8h_html_ab0aed13072bc11b97766634c625d6f21"><div class="ttname"><a href="vector__test_8h.html#ab0aed13072bc11b97766634c625d6f21">vector_test</a></div><div class="ttdeci">void vector_test(void)</div><div class="ttdoc">Examples of vector operations.</div><div class="ttdef"><b>Definition:</b> <a href="vector__test_8c_source.html#l00030">vector_test.c:30</a></div></div>
<div class="ttc" id="amatrix__test_8h_html"><div class="ttname"><a href="matrix__test_8h.html">matrix_test.h</a></div><div class="ttdoc">Examples of matrix computations.</div></div>
<div class="ttc" id="avector__test_8h_html"><div class="ttname"><a href="vector__test_8h.html">vector_test.h</a></div><div class="ttdoc">Examples of vector computations.</div></div>
<div class="ttc" id="amatrix__test_8h_html_aad3d0f4acb79e8a9b61eda59dc3a12b2"><div class="ttname"><a href="matrix__test_8h.html#aad3d0f4acb79e8a9b61eda59dc3a12b2">matrix_test</a></div><div class="ttdeci">void matrix_test(void)</div><div class="ttdoc">Test some matrix operations.</div><div class="ttdef"><b>Definition:</b> <a href="matrix__test_8c_source.html#l00031">matrix_test.c:31</a></div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li>
</ul>
</div>
</body>
</html>