]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - doc/rpp_simulink.tex
doc: fix typos, add missing links and labels
[jenkicar/rpp-simulink.git] / doc / rpp_simulink.tex
1 \newcommand{\superscript}[1]{\ensuremath{^{\textrm{\small#1}}}}
2 \newcommand{\subscript}[1]{\ensuremath{_{\textrm{\small#1}}}}
3
4 \documentclass{scrreprt}
5
6 \usepackage{graphicx} % images and graphics
7 \usepackage{paralist} % needed for compact lists
8 \usepackage[normalem]{ulem} % needed by strike
9 \usepackage{listings} % required for code blocks
10 \usepackage[urlcolor=blue,colorlinks=true,hyperfootnotes=false]{hyperref} % links
11 \usepackage[utf8x]{inputenc}  % char encoding
12 \usepackage[bottom]{footmisc} % footnotes
13 \usepackage{todonotes}
14
15 % header
16 \usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
17 \usepackage{float} % To fix images position
18
19 % Prettify code documentation
20 \usepackage{color}
21 \definecolor{gray97}{gray}{.97}
22 \definecolor{gray75}{gray}{.75}
23 \definecolor{gray45}{gray}{.45}
24 \lstset{ frame=Ltb,
25      framerule=0pt,
26      aboveskip=0.5cm,
27      framextopmargin=3pt,
28      framexbottommargin=3pt,
29      framexleftmargin=0.4cm,
30      framesep=0pt,
31      rulesep=.4pt,
32      backgroundcolor=\color{gray97},
33      rulesepcolor=\color{black},
34      %
35      stringstyle=\ttfamily,
36      showstringspaces = false,
37      basicstyle=\small\ttfamily,
38      commentstyle=\color{gray45},
39      keywordstyle=\bfseries,
40      %
41      numbers=left,
42      numbersep=15pt,
43      numberstyle=\tiny,
44      numberfirstline = false,
45      breaklines=true,
46      xleftmargin=20px,
47    }
48
49 % Spacing
50 \linespread{1.15} % Lines spacing
51 \setlength{\plitemsep}{0.5\baselineskip} % List items spacing
52 \definecolor{deepblue}{RGB}{0,0,61}
53 \hypersetup{linkcolor=deepblue,}
54
55 % Table of content depth
56 \setcounter{tocdepth}{4}
57
58 % Landscape pages
59 \usepackage{lscape}
60 \usepackage{pdflscape}
61
62 % Change page
63 \usepackage{changepage}
64
65 % Font options
66 % Sans-serif
67 % \renewcommand{\familydefault}{\sfdefault}
68 % Better PDF font
69 \usepackage{lmodern}
70
71 % Multiple columns
72 \usepackage{multicol}
73 \usepackage{caption}
74
75 \newcommand{\repo}{$\langle$repo$\rangle$}
76
77 \begin{document}
78
79 % Title
80 \newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
81
82 \begin{titlepage}
83 \begin{center}
84
85 % Upper part of the page
86 \includegraphics[width=0.70\textwidth]{images/logos.png}\\[1cm]
87 \textsc{\LARGE Costa Rica Institute of Technology}\\[0.5cm]
88 \textsc{\LARGE Czech Technical University in Prague}\\[1.5cm]
89
90
91 % Document title
92 \HRule \\[0.4cm]
93 { \huge \bfseries Code generation for automotive rapid prototyping platform using Matlab/Simulink}\\[0.4cm]
94 \HRule \\[1.5cm]
95
96
97 % Author
98 \emph{Authors:}\\
99 Carlos \textsc{Jenkins}\\
100 Michal \textsc{Sojka}\\[\baselineskip]
101
102 \emph{Version:}
103 \input{version.tex}
104
105 \vfill
106
107 % Bottom of the page
108 {\large \today}
109
110 \end{center}
111 \end{titlepage}
112 % Title end
113
114 \tableofcontents
115
116 \newpage
117
118 \listoffigures
119
120 \newpage
121
122 \addtolength{\parskip}{\baselineskip} % Paragraph spacing
123
124 \chapter{Introduction}
125 \label{chap-introduction}
126
127 This text is a documentation for a Rapid Prototyping Platform (RPP) project. It may serve as a
128 guideline for development tools installation, Simulink Coder configuration, creation of new models as
129 well as downloading the resulting firmware to the hardware. It can also be used as a reference for a
130 testing tool, Matlab Simulink blocks and RPP Matlab Simulink Code generator. The document also
131 provides an overall description of the hardware design and architecture of its control software.
132
133 \section{Background}
134 \label{sec-background}
135
136 The Rapid Prototyping Platform is an ECU (Electronic Control Unit) designed for use in Automotive, thus requirements for Automotive communication interfaces, durable IO ports and analog-digital converters were applied.
137
138 The ECU is controlled by TMS570LS5137ZWT MCU, which is an ARM Cortex R4 based microcontroller developed by Texas Instruments. This MCU contains several protective mechanisms (two cores in lockstep, error correction mechanisms for SRAM and Flash memory, voltage monitoring...) to fulfill the requirements for safety critical applications. TODO: add ref to Ti Reference
139
140 Besides the right MCU, an operating system is necessary for nontrivial applications. The RPP board runs FreeRTOS, which is an opensource operating system with real-time kernel, aimed not only on embedded systems. The FreeRTOS provides an API for creation and managing multiple tasks, scheduler, memory manager, semaphores, queues, mutexes, timers and lots of other features wich can be used in the applications. TODO: add ref to FreeRTOS pages
141
142 Even with the operating system it is quite hard and non-intuitive to control the hardware directly. That is the point when abstraction comes in the play. RPP software is made of several layers implementing from the bottom to the top driver to the hardware itself, hardware abstraction for common functionality on different hardware and final API which is easy for the user to use. The whole thing, the operating system and the control software, can be compiled as a library and easily used in any project. More details about the library can be found in Chapter \ref{chap-c-support-library}.
143
144 Because humans make mistakes and in safety critical applications any mistake can cause damage, looses of money or in the worst case even death of other people, the room for making mistakes has to be as small as possible. An approach called Model-based development has been introduced. In Simulink  the application is developed as a model made of blocks connected together. Every block implements some functionality. For example one block receives a voltage from an analog-digital converter, provides the value as an input to another block which implements some clever algorithm and the product is passed as an input to another block, which sends the value as a CAN message to some other MCU. The final model can be simulated and tested even before the real hardware exists. Finally a C code is generated from the model by a Simulink Code Generator. The code can be compiled by the MCU compatible compiler and downloaded to the MCU Flash memory on the device. Because every block and code generated from the block has to pass a series of tests during their development, the room for making mistakes during the application development has significantly decreased and developers can focus on the functionality instead of the hardware and control software implementation. More information about Code generation can be found in Chapter \ref{chap-simulink-coder-target}.
145
146 \section{Software architecture}
147 \label{sec-software-architecture}
148 The RPP control software, also called RPP library, is structured into 5 layers, described in Figure \ref{fig-layers}, with the following guidelines:
149
150 \begin{compactitem}
151 \item Top-down dependency only. No lower layer depends on anything from upper layers.
152 \item 1-1 layer dependency only. The top layer depends exclusively on the bottom layer, not on any
153   lower level layer (except for a couple of exceptions).
154 \item Each layer should provide a unified layer interface (\textsc{rpp.h}, \textsc{drv.h}, \textsc{hal.h}, \textsc{sys.h}
155   and \textsc{os.h}), so top layers depends on that layer interface and not on individual elements from
156   that layer.
157 \end{compactitem}
158
159 \begin{figure}[H]
160 \begin{center}
161 \noindent
162 \includegraphics[width=250px]{images/layers.pdf}
163 \caption{The RPP library layers.}
164 \label{fig-layers}
165 \end{center}
166 \end{figure}
167
168 As a consequence of this division the source code files and interface files are placed in
169 private directories like \textsc{drv/din.h}. With this organization user applications only needs
170 to include the top layer interface files (for example \textsc{rpp/rpp\_can.h}) to be able to use the selected library API.
171
172 The rest of the section provides basic description of each layer.
173
174 \subsection{Operating System layer}
175 \label{sec-operating-system-layer}
176 This is an operating system interchangeable layer, containing the FreeRTOS source files. The system can be easily replaced by another version thanks to this layer. For example it is possible to compile the library for Linux (using POSIX version of the FreeRTOS), which can be desirable for some testing. The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/os} folder.
177
178 Following FreeRTOS versions are distributed:
179 \begin{description}
180         \item[6.0.4\_posix] POSIX version, usable for compilation of the library for Linux system.
181         \item[7.0.2] Prefered version of the FreeRTOS, distributed by the Texas Instruments. This version is in use in the current version of the library.
182         \item[7.4.0] Newest version distributed by the Texas Instruments.
183         \item[7.4.2] Newer version available from FreeRTOS pages. Slightly modified to run on TMS570 MCU.  
184 \end{description}
185
186 \subsection{System Layer} 
187 \label{sec-system-layer}
188 This layer contains system files with data types definitions, clock definitions, interrupts mapping, MCU startup sequence, MCU selftests, and other low level code for controlling some of the MCU peripherals. The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/sys}, the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/sys} folder.
189
190 \subsection{HAL abstraction layer}
191 \label{sec-hal-abstraction-layer}
192 Hardware Abstraction Layer (HAL) creates an abstraction over the real hardware. For example imagine an IO port with 8 pins. First four pins are connected to the MCU directly to GPIO pins, another four pins are connected to an external integrated circuit, communicating with the MCU via SPI. It would be annoying to have to remember which group is which and to have two sets of control functions for one peripheral. This layer maps every pin of the port to a control function from the System Layer, groups the pins together, names them in a unified style and provides common read, write and configure functions.
193
194 As a result, the higher layers do not have to know anything about the wiring of the peripherals, they can just call read, write or configure function with a pin name as a parameter and the HAL handles all the details.
195
196 The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/hal} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/hal} folder.
197
198 \subsection{Drivers layer} 
199 \label{sec-drivers-layer}
200 The Drivers layer contains code for controlling the RPP peripherals. The layer benefits from the lower layers thus it is not too low level, but still there are some peripherals like ADC or H-bridge, which needs some special procedure for initialization and running, that would not be very intuitive for the user. For example the H-bridge needs a watchdog reset task to be started before the bridge is enabled.
201
202 The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/drv} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/drv} folder.
203
204 \subsection{RPP Layer}
205 \label{sec-rpp-layer} 
206 The RPP Layer is the highest layer of the control software. This layer provides the easiest set of functions for every peripheral and requires only basic knowledge about them. For example the H-bridge again from the previous section. The user can call just \textsc{rpp\_hbr\_init()} function to enable the H-bridge and the function calls a sequence of Drivers layer functions to start the Watchdog and configure the peripheral.
207
208 The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/rpp} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/rpp}.
209
210 \section{Hardware description}
211 \label{sec-hardware-description}
212
213 This section provides reference documentation for the RPP board:
214
215 %%TODO: operating conditions as a reference to the Ti documentation
216
217 \begin{compactitem}
218 \item Layout description.
219 \item Connectors pinout.
220 \item Modules capabilities and features.
221 \end{compactitem}
222
223 \subsection{Layout description}
224 \label{sec-layout-description}
225 The RPP board has been designed with strict Automotive standards and safety in mind. The components and pins are placed in sections and wires are routed in a way to avoid any significant electromagnetic interference.
226
227 As can be seen on Figure \ref{board_photo}, the high power output logic is placed in the top left corner, the low power output logic is placed on the bottom left corner, while the communication logic is placed on the top right corner.  In the middle there is the only one button available, the reset button and below it is placed the TMS570 MCU itself. In the bottom right corner there are components of analog inputs.
228
229 \begin{figure}[H]\begin{center}
230 \noindent
231 \includegraphics[width=300px]{images/board-photo.png}
232 \caption{The RPP board (signal connector missing).}
233 \label{board_photo}
234 \end{center}\end{figure}
235
236
237 \subsection{Connectors pinout}
238 \label{sec-connector-pinout}
239 The pinout of the board, described by the Figure \ref{pinout}, follows the layout described in the previous section. The side connectors for communication (24 pins), signals (56 pins) and power (24 pins) are automotive approved humidity resistant connectors.
240 \begin{figure}[H]
241 \advance\leftskip-1cm
242 \noindent
243 \includegraphics[width=530px]{images/pinout.pdf}
244 \caption{The RPP connectors pinout.}
245 \label{pinout}
246 \end{figure}
247
248 \subsection{Modules description}
249 \label{sec-modules-description}
250 This section enumerates the capabilities of the hardware modules from Software perspective. The block diagram of the modules can be seen in Figure \ref{blocks}.
251 \begin{figure}[H]
252 \advance
253 \leftskip-1cm
254 \noindent
255 \includegraphics[width=500px]{images/blocks.pdf}
256 \caption{The RPP layer modules.}
257 \label{blocks}
258 \end{figure}
259
260 \subsubsection{Logic IO}
261 \label{sec-logic-io}
262
263 \paragraph{Digital Inputs (DIN)}
264 \label{par-digital-inputs}
265 \begin{compactitem}
266 \item 16 pins available on Signal Connector.
267 \item Pins 8-15 status can be read via GPIO using configurable threshold. \newline{}
268   Pins 8-11 use variable threshold B and pins 12-15 use variable threshold A.
269 \item Variable threshold is a DAC chip MCP4922.
270 \item All pins are read at once via SPI (fixed threshold) using chip MC33972.
271 \item 0-7 are programmable pins and can be set to pull-up or pull-down. 8-15 are pull-down only.
272 \item All pins can be set to be active or tri-stated.
273 \item All pins can be set to trigger interrupt.
274 \item On-line diagnostic of broken wire.
275 \end{compactitem}
276
277 \paragraph{Digital Outputs (LOUT)}
278 \label{par-digital-outputs}
279 \begin{compactitem}
280 \item 8 pins available on Signal Connector.
281 \item Pins for logic output only, up to 100mA.
282 \item All pins are set at once using a chip through SPI.
283 \end{compactitem}
284
285 \paragraph{Analog Input (ADC)}
286 \label{par-analog-input}
287 \begin{compactitem}
288 \item 12 channels available.
289 \item Differential inputs, thus 24 pins available on Signal Connector.
290 \item Range for 0-20 volts.
291 \item 12 bits resolution.
292 \item Using CPU ADC.
293 \end{compactitem}
294
295 \paragraph{Analog Output (DAC)}
296 \label{par-analog-output}
297 \begin{compactitem}
298 \item 4 pins available on Signal Connector.
299 \item Output range is 0-12 volts.
300 \item Using 2 x MCP4922 DACs controlled using SPI.
301 \item Resolution is 12 bits. But because of amplification and voltage reference not all range is used.
302 \end{compactitem}
303
304 \subsubsection{Power Output}
305 \label{sec-power-output}
306 \paragraph{H-Bridge (HBR)}
307 \label{par-hbr}
308 \begin{compactitem}
309 \item 1 port (2 pins) available on Power Connector.
310 \item Communication is done through SPI.
311 \item H-Bridge can be enabled or disabled.
312 \item Current direction can be set.
313 \item PWM control with 1\% resolution change of the duty cycle.
314 \item Port can drive load up to 10A.
315 \end{compactitem}
316
317 \paragraph{Power Output (MOUT)}
318 \label{par-power-output}
319 \begin{compactitem}
320 \item 6 pins available on Power Connector.
321 \item Pins can drive a load up to 2A. Push/Pull.
322 \item Pins are set using 6 CPU output GPIOs. Diagnostic are read using 6 externally pulled-up
323   open-drain input GPIOs.
324 \item On-line diagnostics. Driver chip will pull-down the corresponding diagnostic pin on the CPU.
325 \end{compactitem}
326
327 \paragraph{High-Power Output (HOUT)}
328 \label{par-high-power-output}
329 \begin{compactitem}
330 \item 6 pins available on Power Connector.
331 \item Pins can be set ON/OFF.
332 \item Pins can drive a load up to 10A with PWM.
333 \item System can read analog values of current flowing (IFBK).
334 \item System can read diagnostics values (DIAG). Detection of a fault condition.
335 \end{compactitem}
336
337 \subsubsection{Communication}
338 \label{sec-communication}
339 \paragraph{CAN bus (CAN)}
340 \label{par-can}
341 \begin{compactitem}
342 \item 3 ports available (CAN uses differential signaling) thus 6 pins are available on Communication
343   connector.
344 \item High speed.
345 \item Recover from error.
346 \item Detection of network errors.
347 \end{compactitem}
348
349 \paragraph{Local Interconnect Network (LIN)}
350 \label{par-lin}
351 \begin{compactitem}
352 \item 2 ports/pins available on Communication Connector.
353 \item Only first port can be used when using the SCI. Second port is shared with SCI.
354 \end{compactitem}
355
356 \paragraph{FlexRay (FR)}
357 \label{par-flexray}
358 \begin{compactitem}
359 \item 2 ports available. FlexRay uses differential signaling thus 4 pins are available on
360   Communication Connector.
361 \end{compactitem}
362
363 \paragraph{Serial Comm. Interface (SCI)}
364 \label{par-sci}
365 \begin{compactitem}
366 \item 1 port available inside the box on SCI connector (4 pins).
367 \item Variable baud rate. Tested on 9600 and 115200.
368 \item RS232 standard compatible.
369 \end{compactitem}
370
371 \paragraph{Ethernet (ETH)}
372 \label{par-eth}
373 \begin{compactitem}
374 \item 1 port available. Standard Ethernet connector available inside box.
375 \end{compactitem}
376
377 \subsubsection{Data storage/logging}
378 \label{sec-data-storage}
379 \paragraph{External Memory SD-RAM (SDR)}
380 \label{par-external-memory}
381 \begin{compactitem}
382 \item 64MB (currently installed) external RAM used for logging. Maximal supported capacity is 256MB.
383 \item Memory test routine available with test Software.
384 \end{compactitem}
385
386 \paragraph{SD Card (SDC)}
387 \label{par-sd-card}
388 \begin{compactitem}
389 \item Standard SD-Card connector or microSD connector available inside box.
390 \item Communication done using SPI.
391 \end{compactitem}
392
393 \section{Document structure}
394 \label{sec-document-structure}
395 The general layout of this document is as follows:
396
397 \chapter{Getting started}
398 \label{chap-getting-started}
399
400 \section{Software requirements}
401 \label{sec-software-requirements}
402 The RPP software stack was developed to be functional on both platforms Windows and Linux. Despite of older and newer versions of the software and tools might work as well, usage of the following versions is suggested:
403
404 \subsection{Linux environment} 
405 \label{sec-linux-environment}
406 \begin{itemize}
407         \item Debian based 64b Linux distribution (Debian 7.0 or Ubuntu 14.4 for example).
408         \item Kernel version 3.11.0-12.
409         \item GCC version 4.8.1
410         \item GtkTerm 0.99.7-rc1
411         \item Ti Code Composer Studio 5.5.0.00077
412         \item Matlab 2013b 64b
413         \item Doxygen 1.8.4 (optionaly, see Section \ref{sec-compiling-api-documentation})
414         \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation}).
415 \end{itemize}
416
417 \subsection{Windows environment}
418 \label{sec-windows-environment}
419 \begin{itemize}
420         \item Windows 7 Enterprise 64b Service Pack 1.
421         \item C/C++ compiler from Windows SDK
422         \item Bray Terminal v1.9b
423         \item Ti Code Composer Studio 5.5.0.00077
424         \item Matlab 2013b 64b
425         \item Doxygen 1.8.4 (optionaly, see Section \ref{sec-compiling-api-documentation})
426         \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation}).
427 \end{itemize}
428
429 \section{Software and tools} 
430 \label{sec-software-and-tools}
431
432 \subsection{TI Code Composer Studio}
433 \label{sec-ti-ccs}
434 Code Composer Studio (CCS) is the official Integrated Development Environment (IDE) for developing
435 applications for Texas Instruments embedded processors. CCS is multiplatform Software based on
436 Eclipse Open Source IDE.
437
438 CCS includes Texas Instruments Code Generation Tools (CGT) (compiler, linker, etc). Simulink code
439 generation requires the CGT to be available in the system, and thus, even if no library development
440 will be done or the IDE is not going to be used CCS is still required.
441
442 %% TODO: Zjistit podminky pro distribuci dokumentu
443 You can find documentation for CGT compiler in \textsc{\repo/ref/armcl.pdf} and for CGT archiver in
444 \textsc{\repo/ref/armar.pdf}.
445
446 The version used in this project is the 5.5.0.00077.
447
448 \subsubsection{Installation on Linux} 
449 \label{sec-installation-on-linux}
450 Download CCS for Linux from:
451
452         \begin{quotation}
453 \url{http://processors.wiki.ti.com/index.php/Category:Code\_Composer\_Studio\_v5}
454         \end{quotation}
455
456 Once downloaded, add executable permission to the installation file and launch the installation by executing it. Installation must be done as root in order to install a driver set.
457
458 \lstset{language=bash}
459 \begin{lstlisting}
460 chmod +x ccs_setup_5.5.0.00077.bin
461 sudo ./ccs_setup_5.5.0.00077.bin
462 \end{lstlisting}
463
464 After installation the application can be executed with:
465
466 \lstset{language=bash}
467 \begin{lstlisting}
468 cd <ccs>/ccsv5/eclipse/
469 ./ccstudio
470 \end{lstlisting}
471
472 The first launch on 64bits systems might fail. This can happen because CCS5 is 32b application and thus requires 32bits libraries:
473
474 \lstset{language=bash}
475 \begin{lstlisting}
476 sudo apt-get install libgtk2.0-0:i386 libxtst6:i386
477 \end{lstlisting}
478
479 If the application crashes with a segmentation fault edit file:
480
481 \lstset{language=bash}
482 \begin{lstlisting}
483 nano <ccs>/ccsv5/eclipse/plugins/com.ti.ccstudio.branding_<version>/plugin_customization.ini
484 \end{lstlisting}
485
486 And change key \textsc{org.eclipse.ui/showIntro} to false.
487
488 \subsubsection{ Installation on Windows }
489 \label{sec-installation-on-windows}
490 The installation for Windows is more straightforward than the previous procedure for Linux.
491
492 Download CCS for Windows from:
493
494         \begin{quotation}
495 \url{http://processors.wiki.ti.com/index.php/Category:Code\_Composer\_Studio\_v5}
496         \end{quotation}
497
498 Once downloaded run the ccs\_setup\_5.5.0.00077.exe and install the CCS.
499
500 \subsubsection{ First launch } 
501 \label{sec-first-launch}
502 If another licence is not available, choose ``FREE License - for use with XDS100 JTAG Emulators" from the licensing options. Code download for the board is using that particular hardware.
503
504 \subsection{Matlab/Simulink}
505 \label{sec-matlab-simulink}
506 Matlab Simulink is a set of tools, runtime environment and development environment for Model-Based applications development, simulations and generation code for target platforms.
507 Supported Matlab Simulink version is R2013b for 64 bits Linux and Windows.
508
509 \subsection{GtkTerm and Bray Terminal}
510 \label{sec-gtkterm-bray-terminal}
511 Most of the interaction with the board is done through a RS-232 serial connection. The terminal Software used for communication is called GtkTerm for Linux and Bray terminal for Windows.
512
513 To install GtkTerm execute:
514
515 \lstset{language=bash}
516 \begin{lstlisting}
517 sudo apt-get install gtkterm
518 \end{lstlisting}
519
520 The Bray Terminal does not require any installation and the executable file is available at 
521
522 \begin{quotation}
523 \url{https://sites.google.com/site/terminalbpp/}
524 \end{quotation}
525
526 \subsection{C Compiler}
527 \label{sec-c-compiler}
528 In order to be able to compile Matlab Simulink blocks S-functions a C language compiler has to be available on the development system.
529
530 For Linux a GCC 4.8.1 compiler is recommended and can be installed with a command
531
532 \lstset{language=bash}
533 \begin{lstlisting}
534 sudo apt-get install gcc
535 \end{lstlisting}
536
537 For Windows, the C/C++ compiler is a part of Windows SDK, which installation file is available at 
538
539 \begin{quotation}
540 \url{http://www.microsoft.com/en-us/download/details.aspx?id=8279}
541 \end{quotation}
542
543 \section{Code Composer Studio usage}
544 \label{sec-code-composerpstudio-usage}
545
546 \subsection{Opening of existing project}
547 \label{sec-openning-of-existing-project}
548 The project opening procedure is similar to standard Eclipse project opening.
549
550 \begin{enumerate}
551         \item Launch Code Composer Studio
552         \item Select \textsc{File$\rightarrow$Import}
553         \item In the dialog window select \textsc{Code Composer Studio$\rightarrow$Existing CCS Eclipse project} as an import source as depicted in Figure \ref{fig-import-project}.
554         \item In the next dialog window click on \textsc{Browse} button and find the root directory of the project.
555         \item Select the requested project in the \textsc{Discovered project} section so that the result looks like in Figure \ref{fig-select-project}.
556         \item Click on \textsc{Finish} button.
557 \end{enumerate}
558
559 \begin{center}
560         \includegraphics[width=350px]{images/import_project.png}
561         \captionof{figure}{Import project dialog}
562         \label{fig-import-project}
563 \end{center}
564
565 \begin{center}
566         \includegraphics[width=350px]{images/select_project.png}
567         \captionof{figure}{Select project dialog}
568         \label{fig-select-project}
569 \end{center}
570
571 \subsection{Creating new project}
572 \label{sec-creating-new-project}
573 In \textsc{\repo/rpp/lib/apps/} there are two RPP based
574 applications, \textsc{helloworld} and \textsc{helloworld\_posix}, that are
575 already configured for the RPP Library. It is advised that new applications use this project as a
576 foundation.
577
578 To create a new application copy this directory and rename it. Now open files \textsc{.project},
579 \textsc{.cproject} and \textsc{.ccsproject} (if available) and change any occurrence of the work \textsc{helloworld}
580 with the name of your project. Use lower case ASCII letters and underscores only.
581
582 \textbf{Steps to configure a new CCS (ARM, using CGT) RPP application:}
583
584 \begin{compactenum}
585 \item Create a new CCS project. \newline{}
586 \noindent\includegraphics[width=400px]{images/base_1.png}
587 \item Create a normal folder \textsc{include}.
588 \item Create a source folder \textsc{src}.
589 \item Add common \textsc{.gitignore} to the root of that project:
590 \lstset{language=}
591 \begin{lstlisting}
592 Debug
593 Release
594 .settings/*
595 \end{lstlisting}
596 \newpage
597 \item Add new variable \textsc{RPP\_LIB\_ROOT} and point to this repository branch root.\newline{}
598 \noindent\includegraphics[width=400px]{images/base_2.png}
599 \item Add \textsc{rpp-lib.lib} static library to linker libraries and add \textsc{RPP\_LIB\_ROOT} to the library
600   search path.\newline{}
601 \noindent\includegraphics[width=400px]{images/base_3.png}
602 \newpage
603 \item Configure linker to retain \textsc{.intvecs} from RPP static library.\newline{}
604 \noindent\includegraphics[width=350px]{images/base_4.png}
605 \item Configure compiler to include local includes, OS includes for TMS570 and RPP includes, in that
606   order\todo{Add lwip include paths as well}.\newline{}
607 \noindent\includegraphics[width=350px]{images/base_5.png}
608 \newpage
609 \item Configure compiler to allow GCC extensions.\newline{}
610 \noindent\includegraphics[width=400px]{images/base_6.png}
611 \item Import and link (\underline{do not copy!}) linker file and board upload descriptor.\newline{}
612 \noindent\includegraphics[width=200px]{images/base_7.png}
613 \end{compactenum}
614
615 \textbf{Steps to configure a new GCC (x86(\_64)) RPP simulated application:}
616
617 \begin{compactenum}
618 \item Create a new managed C project that uses Linux GCC toolchain.
619 \item Create a source folder \textsc{src}. Link all files from original CCS application to this folder.
620 \item Create a normal folder \textsc{include}. Create a folder \textsc{rpp} inside of it.
621 \item Add common \textsc{.gitignore} to the root of that project:
622 \lstset{language=}
623 \begin{lstlisting}
624 Debug
625 Release
626 .settings/*
627 \end{lstlisting}
628 \newpage
629 \item Add new variable \textsc{RPP\_LIB\_ROOT} and point to this repository branch root.\newline{}
630 \noindent\includegraphics[width=400px]{images/base_posix_1.png}
631 \item Configure compiler to include local includes, CCS application includes, OS includes for POSIX and
632   RPP includes, in that order.\newline{}
633 \noindent\includegraphics[width=400px]{images/base_posix_2.png}
634 \newpage
635 \item Add \textsc{rpp} and \textsc{pthread}to linker libraries and add \textsc{RPP\_LIB\_ROOT} to the library search
636   path.\newline{}
637 \noindent\includegraphics[width=400px]{images/base_posix_3.png}
638 \end{compactenum}
639
640 \textbf{In general any RPP application uses the layout/template:}
641
642 \begin{enumerate}
643 \item Include RPP library header file. You may also include only a selected modules to save space.
644 \lstset{language=c++}
645 \begin{lstlisting}
646 #include "rpp/rpp.h"
647 \end{lstlisting}
648
649 You may not want to include the whole library to save space and compile time. In this case you may
650 include only those modules, that you want to use. Inclusion selected modules only requires two more
651 header files to be included as well: base.h and, in case sci is used for printing, rpp/sci.h.
652 \begin{lstlisting}
653 #include "rpp/hbr.h" /* We want to use H-bridge */
654 #include <base.h>       /* This is a necessary base header file of the rpp library. */
655 #include "rpp/sci.h" /* This is needed, because we are using rpp_sci_printf in following examples. */
656 \end{lstlisting}
657
658 \newpage
659 \item Create one or as many FreeRTOS task function definitions as required. Those tasks should use
660   functions from this library.
661 \lstset{language=c++}
662 \begin{lstlisting}
663 void my_task(void* p)
664 {
665     static const portTickType freq_ticks = 1000 / portTICK_RATE_MS;
666     portTickType last_wake_time = xTaskGetTickCount();
667     while (TRUE) {
668         /* Wait until next step */
669         vTaskDelayUntil(&last_wake_time, freq_ticks);
670         rpp_sci_printf((const char*)"Hello RPP.\r\n");
671     }
672 }
673 \end{lstlisting}
674
675 \item Create the main function that will:
676  \begin{itemize}
677  \item Initialize the RPP board. If you have included only selected modules in step 1, initialize only
678    those modules by calling their init functions, for example rpp\_hbr\_init\(\).
679  \item Spawn the tasks the application requires. Refer to FreeRTOS API for
680    details.
681  \item Start the FreeRTOS Scheduler. Refer to FreeRTOS API for details.
682  \item Catch if idle task could not be created.
683 +
684 \lstset{language=c++}
685 \begin{lstlisting}
686 void main(void)
687 {
688     /* In case whole library is included: */
689         /* Initialize RPP board */
690         rpp_init();
691     /* In case only selected modules are included: */
692         /* Initialize HBR */
693             rpp_hbr_init();
694         /* Initialize sci for printf */
695         rpp_sci_init();
696         /* Enable interrups */
697         _enable_IRQ();
698
699     /* Spawn tasks */
700     if (xTaskCreate(my_task, (const signed char*)"my_task",
701             512, NULL, 0, NULL) != pdPASS) {
702         #ifdef DEBUG
703         rpp_sci_printf((const char*)
704             "ERROR: Cannot spawn control task.\r\n"
705         );
706         #endif
707         while (TRUE) { asm(" nop"); }
708     }
709
710     /* Start the FreeRTOS Scheduler */
711     vTaskStartScheduler();
712
713     /* Catch scheduler start error */
714     #ifdef DEBUG
715     rpp_sci_printf((const char*)
716             "ERROR: Problem allocating memory for idle task.\r\n"
717         );
718     #endif
719     while (TRUE) { asm(" nop"); }
720 }
721 \end{lstlisting}
722
723  \end{itemize}
724 \item Create hook functions for FreeRTOS:
725  \begin{itemize}
726  \item \textsc{vApplicationMallocFailedHook()} allows to catch memory allocation errors.
727  \item \textsc{vApplicationStackOverflowHook()} allows to catch if a task overflows it's
728    stack.
729 +
730 \lstset{language=c++}
731 \begin{lstlisting}
732 #if configUSE_MALLOC_FAILED_HOOK == 1
733 /**
734  * FreeRTOS malloc() failed hook.
735  */
736 void vApplicationMallocFailedHook(void) {
737     #ifdef DEBUG
738     rpp_sci_printf((const char*)
739             "ERROR: manual memory allocation failed.\r\n"
740         );
741     #endif
742 }
743 #endif
744
745
746 #if configCHECK_FOR_STACK_OVERFLOW > 0
747 /**
748  * FreeRTOS stack overflow hook.
749  */
750 void vApplicationStackOverflowHook(xTaskHandle xTask,
751                                    signed portCHAR *pcTaskName) {
752     #ifdef DEBUG
753     rpp_sci_printf((const char*)
754             "ERROR: Stack overflow : \"%s\".\r\n", pcTaskName
755         );
756     #endif
757 }
758 #endif
759 \end{lstlisting}
760
761 \newpage
762  \end{itemize}
763 \end{enumerate}
764
765
766 \subsection{Running software on the HW}
767 \label{sec-running-software-on-hw}
768 \subsubsection{Code Composer Studio Project}
769 \label{sec-ccs-run-project}
770 When the application is distributed as a CCS project, you have to open the project in the CCS as described in the Section \ref{sec-openning-of-existing-project}. Once the project is opened and built, it can be easily downloaded to the target hardware with the following procedure:
771
772 \begin{enumerate}
773         \item Connect the Texas Instruments XDS100v2 USB emulator to the JTAG port (see Figure \ref{pinout}, port 1).
774         \item Connect a USB cable to the XDS100v2 USB emulator and the development computer.
775         \item Plug in the power supply.
776         \item In the Code Composer Studio click on the \textsc{Run$\rightarrow$Debug}. The project will  be optionaly built and the download process will start. The Code Composer Studio will switch into debug mode, when the download is finished.
777         \item Run the program by clicking on the \textsc{Run} button, with the green arrow.
778 \end{enumerate}
779
780 \subsubsection{Binary File}
781 \label{sec-binary-file}
782 If the application is distributed as a binary file, without source codes and CCS project files, you can download and run just the binary file by creating a new empty CCS project and configuring the debug session according the following procedure:
783
784 \begin{enumerate}
785         \item In Code Composer Studio click on \textsc{File$\rightarrow$New$\rightarrow$CCS Project}.
786         \item In the dialog window, type in a project name, for example myBinaryLoad, Select \textsc{Device variant} (ARM, Cortex R, TMS570LS3137, Texas Instruments XDS100v2 USB Emulator) and select project template to \textsc{Empty Project}. The filled dialog should look like on the Figure \ref{fig-new-empty-project}
787         \item Click on the \textsc{Finish} button and new empty project will be created.
788         \item In the \textsc{Project Explorer} click on the project with a right mouse button and in the context menu select \textsc{Debug as$\rightarrow$Debug configurations}.
789         \item Click on a button \textsc{New launch configuration}
790         \item Rename the New\_configuration, for example to myConfiguration.
791         \item Select configuration target file by clicking the \textsc{File System} button, finding and selecting the TMS5703137.ccxml file. The result should look like on the Figure \ref{fig-debug-conf-main-diag}.
792         \item On the \textsc{program} pane select the binary file you want to download to the board. Click on the \textsc{File System} button, find and select the binary file. Rpp-test-sw.out for example. The result should look like on the Figure \ref{fig-debug-conf-program-diag}.
793         \item You may also tune the target configuration like in the Section \ref{sec-target-configuration}.
794         \item Finish the configuration by clicking on the \textsc{Apply} button and download the code by clicking on the \textsc{Debug} button. You can later invoke the download also from the \textsc{Run$\rightarrow$Debug} CCS menu. You may not need to create more Debug configurations and CCS empty project as you can easily change the binary file in the Debug configuration to load different binary file.
795 \end{enumerate}
796
797 \begin{center}
798         \includegraphics[width=350px]{images/new_empty_project.png}
799         \captionof{figure}{New empty project dialog}
800         \label{fig-new-empty-project}
801 \end{center}
802
803 \begin{center}
804         \includegraphics[width=350px]{images/debug_configuration_main.png}
805         \captionof{figure}{Debug Configuration Main dialog}
806         \label{fig-debug-conf-main-diag}
807 \end{center}
808
809 \subsubsection{Target configuration}
810 \label{sec-target-configuration}
811 Default target configuration erases the whole Flash memory, before downloading the code. This is however not needed in most cases. You may disable this feature by the following procedure:
812 \begin{enumerate}
813         \item Right click on the project name in the \textsc{Project Browser}
814         \item Select \textsc{Debug as$\rightarrow$Debug Configurations}
815         \item In the dialog window select \textsc{Target} pane.
816         \item In the \textsc{Flash Settings}, \textsc{Erase Options} select \textsc{Necessary sectors only}.
817         \item Save the configuration by clicking on the \textsc{Apply} button and close the dialog.
818 \end{enumerate}
819
820 \begin{center}
821         \includegraphics[width=350px]{images/debug_configuration_program.png}
822         \captionof{figure}{Debug Configuration Program dialog}
823         \label{fig-debug-conf-program-diag}
824 \end{center}
825
826 \section{Matlab Simulink usage}
827 \label{sec-matlab-simulink-usage}
828
829 \subsection{Configuring Simulink for RPP}
830 \label{sec-configuration-simulink-for-rpp}
831 \begin{enumerate}
832 \item Download and install CCS for Linux:
833
834 Details on how to setup CCS are available in Section \ref{sec-ti-ccs}.
835
836 \item Install RPP Target:
837
838 Open Matlab and type on command window:
839
840 \lstset{language=Matlab}
841 \begin{lstlisting}
842 cd <repo>/rpp/rpp/
843 rpp_setup
844 \end{lstlisting}
845
846 This will launch the RPP setup script. This script will ask the user to provide the path to the CCS
847 compiler root directory (the directory where \textsc{armcl} binary is located), normally:
848
849 \begin{verbatim}
850 <ccs>/tools/compiler/arm_5.X.X/
851 \end{verbatim}
852
853 This script will, among other things, ask the user to provide the location of the armcl parent
854 directory, infer and save some relevant CCS paths, add paths to Matlab path and build S-Function
855 blocks for user's architecture (using Matlab's mex command line tool).
856
857 \item Create a new model or load a demo:
858
859 Demos are located on \textsc{\repo/rpp/demo} or you can start a new model and configure target to RPP.
860 For new models see \htmladdnormallink{Target Reference}{\#target\_reference} section below.
861 \end{enumerate}
862
863
864 \subsection{Working with demo models}
865 \label{sec-openning-demo-models}
866 The demo models are available from the directory \textsc{\repo/rpp/demos}. To access the demo models for reference or for downloading to the RPP board you have to change the directory to the one, containing the desired demo. For example to open the cantransmit demo you have to type these commands into the Matlab command line:
867
868 \begin{lstlisting}[language=Matlab]
869 cd <rpp-simulink-root>/rpp/demos
870 open('cantransmit.slx')
871 \end{lstlisting}
872
873 The same procedure can be used to open any other models.
874
875 \subsection{Creating new model}
876 \label{sec-crating-new-model}
877 \begin{enumerate}
878 \item Open or create a model you want to generate code from.
879 \item Make sure that the model is configured (\textsc{Simulation $\rightarrow$
880   Model Configuration Parameters}) as described later in this section.
881 \item From Matlab command window change the current directory to where
882   you want your generated code to appear, e.g.:
883 \begin{lstlisting}[language=Matlab]
884 cd /tmp/my-code
885 \end{lstlisting}
886   The code will be generated in a subdirectory of that directory. The
887   name of the subdirectory will be \textsc{<model>\_rpp}, where
888   \textsc{model} is the name of the Simulink model.
889 \item Generate the code by choosing \textsc{Code $\rightarrow$ C/C++ Code
890   $\rightarrow$ Build Model}.
891 \end{enumerate}
892
893 If you want to run the model on the RPP board, see Section \ref{sec-running-model-on-hw}.
894
895 The new Simulink model needs to be configured in the following way:
896
897 \begin{compactitem}
898 \item Solver (Figure \ref{fig-solver}):
899  \begin{compactitem}
900  \item Options: \emph{Fixed-step, discrete}
901  \item Tasking mode set to \textit{SingleTasking}.
902    \begin{figure}
903      \centering
904      \includegraphics[width=400px]{images/simulink_solver.png}
905      \caption{Solver settings}
906          \label{fig-solver}
907 \end{figure}
908  \end{compactitem}
909 \item Diagnostics $\rightarrow$ Sample Time (Figure~\ref{fig-sample-time-settings}):
910  \begin{compactitem}
911  \item Disable warning source block specifies -1 sampling time. It's ok for the source blocks to run
912    once per tick.
913    \begin{figure}
914      \centering
915      \includegraphics[width=400px]{images/simulink_diagnostics.png}
916      \caption{Sample Time settings}
917          \label{fig-sample-time-settings}
918 \end{figure}
919 \end{compactitem}
920 \item Code generation (Figure~\ref{fig-code-gen-settings}):
921  \begin{compactitem}
922  \item Set to \textsc{rpp.tlc}.
923    \begin{figure}
924      \centering
925      \includegraphics[width=400px]{images/simulink_code.png}
926      \caption{Code Generation settings}
927          \label{fig-code-gen-settings}
928 \end{figure}
929 \end{compactitem}
930 \end{compactitem}
931
932
933 \subsection{Running model on the HW}
934 \label{sec-running-model-on-hw}
935 To run the model on the target RPP hardware you have to enable the download feature and build the model by following this procedure:
936 \begin{enumerate}
937         \item Open the model you want to run (See Section \ref{sec-openning-demo-models}.)
938         \item Click on \textsc{Simulation$\rightarrow$Model Configuration Parameters}.
939         \item In the \textsc{Code Generation$\rightarrow$RPP Options} pane check \textsc{Download compiled binary to RPP} checkbox.
940         \item Click on \textsc{OK} button, connect the target HW to the computer like in the Section \ref{sec-ccs-run-project} and build the model. If the build ends with a success, the download process will start and once the downloading is finished, the application will run immediatelly.
941 \end{enumerate}
942
943 The code downloading is supported for Windows and Linux development systems. If you are using Linux, you may also try to use the OpenOCD by checking Use OpenOCD to download the compiled binary checkbox in addition. Refer 
944
945 \begin{verbatim}
946 http://rtime.felk.cvut.cz/hw/index.php/TMS570LS3137#OpenOCD_setup_and_Flashing
947 \end{verbatim}
948 fore more information about the OpenOCD configuration.
949
950   Note: You should end the Code Composer Studio debug session before
951   downloading the generated code to the RPP board. Otherwise the
952   download fails.
953
954  
955 \section{Configuring serial interface}
956 \label{sec-configuration-serial-interface}
957 The main interface for communicating with the RPP board is the serial interface. The application may define its own interface settings, but the following settings is the default one:
958 \begin{itemize}
959         \item Baudrate: 115200
960         \item Parity: none
961         \item Bits: 8
962         \item Stopbits: 1
963         \item Flow control: none
964 \end{itemize}
965
966 Use GtkTerm in Linux or Bray Terminal for accessing the serial interface. See Section \ref{sec-hardware-description} for reference about the position of the serial interface connector on the RPP board.
967
968 \section{Bug reporting}
969 \label{sec-bug-reporting}
970
971 % TODO: implement
972
973 \chapter{C Support Library}
974 \label{chap-c-support-library}
975
976 This chapter describes the implementation of a C support library (RPP Library) to provide an overall
977 insight for future development.
978
979 \section{Description}
980 \label{sec-description}
981 The RPP C Support Library (also called RPP library) defines the API for communication with the board. It includes drivers and operating system and is designed from the board user perspective and exposes a simplified high-level API to handle the board's peripheral modules in a safe manner. The library is compiled as a static library with the name rpp-lib.lib and can be found in \textsc{\repo/rpp/lib}.
982
983 The RPP library can be used in any project, where the RPP hardware support is required and is also used in two modules, described later in this document. The Command line testing tool, described in Chapter \ref{chap-rpp-test-software} and Simulink Coder target, described in Chapter \ref{chap-simulink-coder-target}.
984
985 For details about the library architecture, refer the Section \ref{sec-software-architecture} in Chapter \ref{chap-introduction}  
986
987 \section{API development guidelines}
988 \label{sec-api-development-guidlines}
989
990 The following are the development guidelines used for developing the RPP API:
991
992 \begin{compactitem}
993 \item User documentation should be placed in header files, not in source code, and should be Doxygen
994   formatted using autobrief. Documentation for each function present is mandatory.
995 \item Function declarations on the headers files is for public functions only. Do not declare
996   local/static/private functions on the header.
997 \item Documentation on source code files should be non-doxygen formatted and intended for developers,
998   not users. Documentation here is optional and at the discretion of the developer.
999 \item Always use standard data types for IO when possible. Use custom structs as very last resort.
1000 \item Use prefix based functions names to avoid clash. The prefix is of the form \textsc{[layer]\_[module]\_},
1001   for example \textsc{rpp\_din\_update()} for the update function of the DIN module in the RPP Layer.
1002 \item Be very careful about symbol export. Because it is used as a static library the modules should
1003   not export any symbol that is not intended to be used (function) or \textsc{extern}'ed (variable) from
1004   application. As a rule of thumb declare all global variables as static.
1005 \item Only the RPP Layer symbols are available to user applications. All information related to lower  layers is hidden for the application. This is accomplished by the inclusion of the rpp.h or rpp\_\{mnemonic\}.h file on the implementations files only and never on the interface files. Never expose any other layer to the application or to the whole system below the RPP layer. In other words, never \textsc{\#include "foo/foo.h"} in any RPP Layer interface file.
1006 \end{compactitem}
1007
1008 \section{Coding style}
1009 \label{sec-coding-style}
1010 In order to keep the code as clean as possible, a unified coding style should be followed by any contributor to the code. The RPP library project is prepared for a usage of a program named Uncrustify.
1011
1012 The Uncrustify program checks the code and fixes those lines that does not match the coding style. However keep in mind that the program is not perfect and sometimes some lines can be modified even when the suggested coding style has been followed. This does not causes problems as long as the contributor follows the committing procedure described in next paragraph.
1013
1014 When contributing to the code, the contributor should learn the current coding style from the existing code. When a new feature is implemented, before committing to the repository, a command :
1015 \lstset{language=bash}
1016 \begin{lstlisting}
1017 make uncrustify
1018 \end{lstlisting}
1019 in a Linux terminal should be called. This command fixes any coding style errors. After that all changes can be committed.
1020
1021 \section{Subdirectory  content description}
1022 \label{sec-subdirectory-content-description}
1023 \begin{description}
1024         \item[librpp.a and rpp-lib.lib] Version controlled RPP static libraries.
1025
1026 The first one is for POSIX simulation, the second one for Simulink models and other ARM/TMS570 applications. This files are placed here by the Makefile, when the library is built.
1027
1028         \item[apps/] Demo applications related to the RPP library.
1029
1030 This include the CCS studio project for generation of the static library and the a test suite. The test suit in this directory does not match the test suite mentioned later in Chapter 5 and those two suits are going to be merged in the future. Also other demo Hello World like applications are included as a reference about how to create a TMS570 application.
1031         \item[os/] OS layers directory. See OS interchangeable layer for more information.
1032         \item[rpp/] Main directory for the RPP Library.
1033         \item[rpp/doc/] Documentation directory for the RPP Library.
1034         \item[rpp/TMS570LS3137.ccxml] Descriptor for code download.
1035
1036 This file is used by all the projects including the Simulink RPP Target for code download. It is
1037 configured to use the Texas Instruments XDS100v2 USB Emulator.
1038         \item[rpp/TMS570LS313xFlashLnk.cmd] CGT Linker command file.
1039
1040 This file is used by all applications linked for the board, including the Simulink models, static
1041 library and test suite. It includes instructions for the CGT Linker on where to place sections
1042 and size of some sections.
1043         \item[rpp/include/\{layer\} and rpp/src/\{layer\}] Interface files and implementations files for given \textsc{\{layer\}}. See Section \ref{sec-software-architecture} in Chapter \ref{chap-introduction} for details on the RPP Layer.
1044         \item[rpp/include/rpp/rpp.h] Main library header file.
1045
1046 To use this library with all its modules, just include this file and this file only. Also, before using any library function please call \textsc{rpp\_init()} function for hardware initialization.
1047
1048         \item[rpp/include/rpp/rpp\_\{mnemonic\}.h] Header file for \textsc{\{mnemonic\}} module.
1049
1050 This files includes function definitions, pin definitions, etc, specific to \{mnemonic\} module. See Section \ref{sec-api-development-guidlines}.
1051
1052 You may include only selected rpp\_\{mnemonic\}.h header files and call the specific rpp\_\{mnemonic\}\_init functions, instead of the rpp.h and rpp\_init function, if you want to use only a subset of the library functions.
1053
1054         \item[rpp/src/rpp/rpp\_\{mnemonic\}.c] Module implementation.
1055
1056 Implementation of \textsc{rpp\_\{mnemonic\}.h}'s functions on top of the DRV library.
1057         \item[rpp/src/rpp/rpp.c] Implementation of library-wide functions.
1058
1059 \end{description}
1060
1061 \section{Compilation}
1062 \label{sec-compilation}
1063
1064 The RPP Library can be compiled as a static library for ARM using a Code Composer Studio project or for x86 Linux using an Eclipse project. After the compilation, as part of the build process, both procedures will automatically update the version-controlled static libraries in the library root.
1065
1066 For the compilation of the library as a static library open the Code Composer studio project for the rpp-lib (see Section \ref{sec-openning-of-existing-project}) and build the project. As a result of the build process, if successful, a \textsc{rpp-lib.lib} file will appear in the library root directory.
1067
1068 \begin{compactitem}
1069 \item \textsc{rpp-lib.lib}, static library for ARM using TI naming scheme.
1070 \item \textsc{librpp.a}, static library for x86(\_64) using standard Linux naming scheme.
1071 \end{compactitem}
1072
1073 Because compilation of the libraries in Eclipse IDE can be error
1074 prone, there is a \textsc{Makefile} that allows to compile the
1075 libraries from the Linux command line:
1076
1077 \begin{lstlisting}[language=bash]
1078 cd <library-root>
1079 make
1080 \end{lstlisting}
1081
1082 This option is available for Linux based development systems only.
1083
1084 Note that this Makefile still requires the Code Composer Studio to be
1085 installed.
1086
1087 The relevant aspects for compiling and linking an application using the static libraries are:
1088 \begin{itemize}
1089         \item \textbf{ARM compilation using CCS for the RPP board:}
1090         \begin{compactitem}
1091                 \item Include headers files of the OS for which the library was compiled against. At the time of this
1092           writing the OS is FreeRTOS 7.0.2. See Section \ref{sec-software-architecture}
1093                 \item Include header files for the RPP library or for modules you want to use rpp\_can.h for CAN module for example.
1094                 \item Add library \textsc{rpp-lib.lib} to the linker libraries. The RPP library \textbf{MUST} be looked for
1095           before Texas Instruments support library \textsc{rtsv7R4\_T\_be\_v3D16\_eabi.lib}.
1096                 \item Configure linker to retain \textsc{.intvecs} section from RPP Library:\newline{}
1097           \textsc{--retain="rpp-lib.lib$\langle$sys\_intvecs.obj$\rangle$(.intvecs)"}
1098                 \item Use the provided linker command file \textsc{TMS570LS313xFlashLnk.cmd}.
1099         \end{compactitem}
1100         \item \textbf{x86(\_64) compilation using GCC for Simulation:}
1101         \begin{compactitem}
1102                 \item Include headers files of the OS for Simulation. At the time of this writing the OS is POSIX
1103           FreeRTOS 6.0.4.
1104                 \item Include header files for the RPP library or for modules you want to use (rpp\_can.h for CAN module for example).
1105                 \item Add library \textsc{librpp.a} to the linker libraries.
1106                 \item Add \textsc{pthread} to the linker libraries.
1107         \end{compactitem}
1108 \end{itemize}
1109
1110 As an important note, all the models compiled using Simulink will link against \textsc{rpp-lib.lib}.
1111 When compiling a Simulink model, neither Simulink nor the
1112 \textsc{make} invoked during the build process, will update the generated binary
1113 if the model hasn't changed, and then if the source code hasn't changed. Static libraries changes
1114 are not considered for re-compilation and re-linking. If library development is being done and
1115 static library is updated, in order for the Simulink model to generate a newly linked version of
1116 the binary the whole code generation folder needs to be deleted in order to force code generation,
1117 compilation and linking with the new static library.
1118
1119 \section{Compiling API documentation}
1120 \label{sec-compiling-api-documentation}
1121 The RPP Layer is formatted using Doxygen documentation generator. This allows to generate a high
1122 quality API reference. To generate the API reference run in a Linux terminal:
1123
1124 \lstset{language=bash}
1125 \begin{lstlisting}
1126 cd <repo>/rpp/lib/rpp/doc/api
1127 make
1128 xdg-open html/index.html
1129 \end{lstlisting}
1130
1131 The files under \textsc{\repo/rpp/lib/rpp/doc/api/content} are used for the API reference generation
1132 are their name is self-explanatory:
1133
1134 \begin{verbatim}
1135 blocks_map.html
1136 blocks.png
1137 cvut.png
1138 footer.html
1139 main_page.dox
1140 \end{verbatim}
1141
1142 \chapter{Simulink Coder Target}
1143 \label{chap-simulink-coder-target}
1144
1145 The Simulink Coder Target allows to convert Simulink models to C code,
1146 compile it and download to the board.
1147
1148 \section{Introduction}
1149 \label{sec-introduction}
1150
1151 The Simulink RPP Target provides support for C source code generation from Simulink models and
1152 compilation of that code on top of the RPP library and the FreeRTOS operating system. This target
1153 uses Texas Instruments ARM compiler (\textsc{armcl}) included in the Code Generation Tools distributed with
1154 Code Composer Studio, and thus it depends on it for proper functioning.
1155
1156 This target also provides support for automatic download of the compiled binary to the RPP
1157 board.
1158
1159 \begin{figure}[H]\begin{center}
1160 \noindent
1161 \includegraphics[width=300px]{images/tlc_process.png}
1162 \caption{TLC code generation process.}
1163 \end{center}\end{figure}
1164
1165 \section{Features}
1166 \label{sec-features}
1167
1168 \begin{itemize}
1169 \item Supports only single tasking.  If multitasking is required, it has to be implemented in a new file \textsc{rpp\_mrmain.tlc} in \textsc{\repo/rpp/rpp/} and \textsc{rpp\_file\_process.tlc} has to be edited to use that file, when multitasking is selected.
1170 \item No External mode support
1171 \item Custom compiler options, available via OPTS variable in \emph{Make command} at \emph{Code Generation} tab (see Figure \ref{fig-code-gen-settings}). For example \textsc{make\_rtw OPTS="-O0 -g"}.
1172
1173 \end{itemize}
1174
1175 \section{RPP Options pane}
1176 \label{sec-rpp-target-options}
1177
1178 The RPP Target includes the following configuration options, all of them configurable per model
1179 under  \textsc{Code Generation} \noindent$\rightarrow$ \textsc{RPP Options}:
1180
1181 \begin{itemize}
1182 \item \textbf{C system stack size}: this parameter is passed directly
1183   to the linker for the allocation of the stack. Note that this stack
1184   is used only for initializing the application and FreeRTOS. Once
1185   everything is initialized, another stack is used by the generated
1186   code. See below. Default value is 4096.
1187
1188 \item \textbf{C system heap size}:
1189   \label{sec-rpp-target-options-heap-size} this parameter is passed
1190   directly to the linker for the allocation of the heap. Currently,
1191   the heap is not used, but will be used by the external mode in the future. Note that FreeRTOS uses its own heap whose size is independent of this parameter.
1192 \item \textbf{Model step task stack size}: this parameter will be passed to the \textsc{xTaskCreate()} that
1193   creates the task for the model to run. In a Simulink model there are always two tasks:
1194  \begin{itemize}
1195  \item The worker task. This task is the one that executes the model
1196    step. This task requires enough stack memory to execute the step.
1197    If your model does not run, it might be caused by too small stack.
1198    The memory needed for the stack depends on the size and structure
1199    of the model.
1200  \item The control task. This task controls when the worker task should execute and controls overruns.
1201
1202  \end{itemize}
1203 \item \textbf{Download compiled binary to RPP}: if set, this option will download the generated binary to
1204   the board after the model is successfully built. Note that this option is unaware of the option
1205   \textit{Generate code only} in the \textit{Code Generation} options panel, so it will try to download even if
1206   only source code has been generated, failing graciously or uploading an old binary laying around
1207   in the build directory. This option calls the \textsc{rpp\_download.m} script, which is in turn a
1208   wrapper on the \textsc{loadti.sh}, \textsc{loadti.bat} and \textsc{loadopenocd.sh} script. More information on the \textsc{loadti.sh}
1209   script can be found in:
1210 \begin{verbatim}
1211 <css>/ccs_base/scripting/examples/loadti/readme.txt
1212 http://processors.wiki.ti.com/index.php/Loadti
1213 \end{verbatim}
1214
1215   The \textsc{loadti.sh} and\textsc{loadti.bat} script will close after the download of the generated program, leaving the loaded program running.
1216
1217   The \textsc{loadopenocd.sh} script will close after the download of the generated program as well, but the program will be stopped.
1218   In order to test the loaded program a manual reset of the board is required.
1219
1220 \item \textbf{Download compiled binary to SDRAM}: This feature is not yet implemented for the simulink target.
1221
1222 \item \textbf{Use OpenOCD to download the compiled binary}: This option switches from Ti loading script \textsc{loadti.sh}
1223   to OpenOCD script \textsc{loadopenocd.sh}. The benefit of using OpenOCD, besides that it is open source
1224   software, is much shorter loading time. More information about the right OpenOCD version and its installation
1225   can be found at:
1226 \begin{verbatim}
1227 http://rtime.felk.cvut.cz/hw/index.php/TMS570LS3137#OpenOCD_setup_and_Flashing
1228 \end{verbatim}
1229 This feature is available for Linux system only.
1230
1231 \item \textbf{Print model metadata to SCI at start}: if set this option will print a message to the Serial
1232   Communication Interface when the model start execution on the board. This is very helpful to
1233   identify the model running on the board. The message is in the form:
1234 \begin{verbatim}
1235 `model_name' - generated_date (TLC tlc_version)
1236 \end{verbatim}
1237
1238   For example:
1239 \begin{verbatim}
1240 `hbridge_analog_control' - Wed Jun 19 14:10:44 2013 (TLC 8.3 (Jul 20 2012))
1241 \end{verbatim}
1242 \end{itemize}
1243
1244 \section{Subdirectory  content description}
1245 \label{sec-subdirectory-content-description}
1246 This section describes the directories of the Simulink Coder. If you are interested in particular file, refer the description at the beginning of the file.
1247 \begin{description}
1248         \item[doc/] Contains the sources of the documentation, you are now reading.
1249         \item[refs/] Contains third party references, which license allows the distribution.
1250         \item[rpp/blocks] Contains the TLC files, which defines the blocks for the Matlab Simulink and \textsc{rpp\_lib.slx}, which is the Simulink RPP Library, containing all the Simulink blocks for RPP.
1251         \item[rpp/blocks/tlc\_c]Contains the templates for C code generation from the Matlab Simulink model.
1252         \item[rpp/demos] Contains demo models, which purpose is to serve as a reference for the usage and for testing.
1253         \item[rpp/lib] Contains the C Support Library. See Chapter \ref{chap-c-support-library}.
1254         \item[rpp/loadopenocd] Contains download scripts for Linux support of the OpenOCD, for code downloading to the target.
1255         \item[rpp/loadti] Contains download scripts for Linux and Windows support for code downloading to the target, using Texas Instruments CCS code downloader.
1256         \item[rpp/rpp] Contains set of support script for the Code Generator.
1257 \end{description}
1258
1259 \section{Block Library Overview}
1260 \label{sec-block-library-overview}
1261 The Simulink Block Library is a set of blocks that allows Simulink models to use board IO and 
1262 communication peripherals. The available blocks are summarized in
1263 Table~\ref{tab:block-lib-status} and more detailed description is
1264 given in Section~\ref{sec-blocks-description}.
1265
1266 \begin{table}
1267 \begin{center}\begin{tabular}{lp{5cm}lll}
1268 \textbf{Category} & \textbf{Name} & \textbf{Status} & \textbf{Mnemonic} & \textbf{Header} \\
1269 \input{block_table.tex}
1270 System blocks & High-Power output block & \textsc{X} & \textsc{[HOUT]} & \textsc{rpp\_hout.h} \\
1271  & LIN receive block & \textsc{X} & \textsc{[LINR]} & \textsc{rpp\_lin.h} \\
1272  & LIN send msg block & \textsc{X} & \textsc{[LINS]} & - Idem - \\
1273  & Ethernet receive block & \textsc{X} & \textsc{[ETHR]} & \textsc{rpp\_eth.h} \\
1274  & Ethernet send msg block & \textsc{X} & \textsc{[ETHS]} & - Idem - \\
1275  & SDRAM write block & \textsc{X} & \textsc{[SDRW]} & \textsc{rpp\_sdr.h} \\
1276  & Stack overflow detected block & \textsc{X} & \textsc{[TRSO]} & - None - \\
1277  & Malloc Failed detected block & \textsc{X} & \textsc{[TRMF]} & - None - \\
1278 \end{tabular}\end{center}
1279
1280   \caption{Block library overview}
1281   \label{tab:block-lib-status}
1282 \end{table}
1283
1284 \subsection{Blocks implementation}
1285 \label{sec-blocks-implementation}
1286 All of the blocks are implemented as a C Mex S-Function coded by hand. In this section the 
1287 approach taken is briefly explained.
1288
1289 \subsubsection{C MEX S-Functions}
1290 \label{sec-c-mex-functions}
1291  \begin{compactitem}
1292  \item C : Implemented in C language. Other options are Fortran and Matlab language itself.
1293  \item MEX: Matlab Executable. They are compiled by Matlab - C compiler wrapper called MEX.
1294  \item S-Function: System Function, as opposed to standard functions, or user functions.
1295  \end{compactitem}
1296
1297 A C-MEX S-Function is a structured C file that implements some mandatory and optional  callbacks for a specification of a number of inputs, outputs, data types, parameters, rate, validity checking, etc.
1298 A complete list of callbacks can be found in:
1299         \begin{quotation}
1300 \htmladdnormallink{http://www.mathworks.com/help/simulink/create-cc-s-functions.html}{http://www.mathworks.com/help/simulink/create-cc-s-functions.html}
1301         \end{quotation}
1302
1303 The way a C-MEX S-Function participates in a Simulink simulation is shown on the diagram \ref{fig-sfunctions-process}:
1304
1305 \begin{figure}[H]\begin{center}
1306 \noindent
1307 \includegraphics[width=250px]{images/sfunctions_process.png}
1308 \caption{Simulation cycle of a S-Function.}
1309 \label{fig-sfunctions-process}
1310 \end{center}\end{figure}
1311
1312 In general, the S-Function can perform calculations, inputs and outputs for simulation. Because 
1313 the RPP blocks are for hardware peripherals control and IO the blocks are 
1314 implemented as pure sink or pure source, the S-Function is just a descriptor of the block and does not perform any calculation and does not provide any input or output for simulations. 
1315
1316 The implementation of the S-Functions in the RPP project has following layout:
1317
1318 \begin{itemize}
1319 \item Define S-Function name \textsc{S\_FUNCTION\_NAME}.
1320 \item Include header file \textsc{header.c}, which in connection with \textsc{trailer.c} creates a miniframework for writing S-Functions.
1321 \item In \textsc{mdlInitializeSizes} define:
1322         \begin{itemize}
1323         \item Number of \textit{dialog} parameter.
1324         \item Number of input ports.
1325                 \begin{compactitem}
1326                 \item Data type of each input port.
1327                 \end{compactitem}
1328         \item Number of output ports.
1329                 \begin{compactitem}
1330                 \item Data type of each output port.
1331                 \end{compactitem}
1332         \item Standard options for driver blocks.
1333         \end{itemize}
1334 \item In \textsc{mdlCheckParameters}:
1335         \begin{itemize}
1336         \item Check data type of each parameter.
1337         \item Check range, if applicable, of each parameter.
1338         \end{itemize}
1339 \item In \textsc{mdlSetWorkWidths}:
1340         \begin{compactitem}
1341         \item Map \textit{dialog} parameter to \textit{runtime} parameters.
1342                 \begin{itemize}
1343                 \item Data type of each \textit{runtime} parameter.
1344                 \end{itemize}
1345         \end{compactitem}
1346 \item Define symbols for unused functions.
1347 \item Include trailer file \textsc{trailer.c}.
1348 \end{itemize}
1349
1350 The C-MEX S-Function implemented can be compiled with the following command:
1351
1352 \lstset{language=bash}
1353 \begin{lstlisting}
1354 <matlabroot>/bin/mex sfunction_{mnemonic}.c
1355 \end{lstlisting}
1356
1357 As noted the standard is to always prefix S-Function with \textsc{sfunction\_} and use lower case 
1358 mnemonic of the block.
1359
1360 Also a script called \textsc{compile\_blocks.m} is included. The script that allows all \textsc{sfunctions\_*.c} to be fed to the \textsc{mex} compiler so all S-Functions are compiled at once. To use this script, in Matlab do:
1361
1362 \lstset{language=Matlab}
1363 \begin{lstlisting}
1364 cd <repo>/rpp/blocks/
1365 compile_blocks()
1366 \end{lstlisting}
1367
1368 \subsubsection{Target Language Compiler files}
1369 \label{sec-target-language-compiler-files}
1370
1371 In order to generate code for each one of the S-Functions, every S-Function implements a TLC file
1372 for \textit{inlining} the S-Function on the generated code. The TLC files describe how to 
1373 generate code for a specific C-MEX S-Function block. They are programmed using TLC own language and 
1374 include C code within TLC instructions, just like LaTeX files include normal text in between LaTeX 
1375 macros.
1376
1377 The standard for a TLC file is to be located under the \textsc{tlc\_c} subfolder from where the 
1378 S-Function is located and to use the very exact file name as the S-Function but with the \textsc{.tlc}
1379 extension: \textsc{sfunction\_foo.c} \noindent$\rightarrow$ \textsc{tlc\_c/sfunction\_foo.tlc}
1380
1381 The TLC files implemented for this project use 3 hook functions in particular (other are available, 
1382 see TLC reference documentation):
1383 \begin{itemize}
1384 \item \textsc{BlockTypeSetup}: \newline{}
1385   BlockTypeSetup executes once per block type before code generation begins.
1386   This function can be used to include elements required by this block type, like includes or
1387   definitions.
1388 \item \textsc{Start}: \newline{}
1389   Code here will be placed in the \textsc{void $\langle$modelname$\rangle$\_initialize(void)}. Code placed here will
1390   execute only once.
1391 \item \textsc{Outputs}: \newline{}
1392   Code here will be placed in the \textsc{void $\langle$modelname$\rangle$\_step(void)} function. Should be used to 
1393   get the inputs o a block and/or to set the outputs of that block.
1394 \end{itemize}
1395
1396 The general layout of the TLC files implemented for this project are:
1397 \begin{itemize}
1398 \item In \textsc{BlockTypeSetup}: \newline{}
1399   Call common function \textsc{\%$<$RppCommonBlockTypeSetup(block, system)$>$} that will include the 
1400   \textsc{rpp/rpp\i\_mnemonic.h} header file (can be called multiple times but header is included only once).
1401 \item \textsc{Start}: \newline{}
1402   Call setup routines from RPP Layer for the specific block type, like HBR enable, DIN pin setup, 
1403   DAC value initialization, SCI baud rate setup, among others.
1404 \item \textsc{Outputs}: \newline{}
1405   Call common IO routines from RPP Layer, like DIN read, DAC set, etc. Success of this functions
1406   is checked and in case of failure error is reported to the block using ErrFlag.
1407 \end{itemize}
1408
1409 C code generated from a Simulink model is placed on a file called \textsc{$\langle$modelname$\rangle$.c} along with other support files in a folder called \textsc{$\langle$modelname$\rangle$\_$\langle$target$\rangle$/}. For example, the source code generated for model \textsc{foobar} will be placed in current Matlab directory \textsc{foobar\_rpp/foobar.c}.
1410
1411 The file \textsc{$\langle$modelname$\rangle$.c} has 3 main functions:
1412 \begin{compactitem}
1413 \item \textsc{void $\langle$modelname$\rangle$\_step(void)}: \newline{}
1414   This function recalculates all the outputs of the blocks and should be called once per step. This
1415   is the main working function.
1416 \item \textsc{void $\langle$modelname$\rangle$\_initialize(void)}: \newline{}
1417   This function is called only once before the first step is issued. Default values for blocks IOs
1418   should be placed here.
1419 \item \textsc{void $\langle$modelname$\rangle$\_terminate(void)}: \newline{}
1420   This function is called when terminating the model. This should be used to free memory of revert 
1421   other operations made on the initialization function. With current implementation this function
1422   should never be called unless an error is detected and in most models it is empty.
1423 \end{compactitem}
1424
1425 \subsection{Blocks description}
1426 \label{sec-blocks-description}
1427
1428 This section describes each one of the Simulink blocks present in the Simulink RPP Library, illustrated in Figure \ref{fig-block-library}:
1429
1430 \begin{figure}[H]
1431 \advance
1432 \leftskip-1cm
1433 \noindent
1434 \includegraphics[width=530px]{images/block_library.png}
1435 \caption{Simulink RPP Block Library.}
1436 \label{fig-block-library}
1437 \end{figure}
1438
1439 % Include automatically generated documentation
1440 % TODO: the block_desc is badly generated
1441 \input{block_desc.tex}
1442
1443 \section{Demos}
1444 The Simulink RPP Demo Library is a set of Simulink models that use blocks from the Simulink RPP
1445 Block Library and generates code using the Simulink RPP Target.
1446
1447 This demos library is used as a test suite for the Simulink RPP Block Library but they are also
1448 intended to show basic programs built using it. Because of this, the demos try to use more than one
1449 type of block and more than one block per block type.
1450
1451 In the reference below you can find a complete description for each of the demos.
1452
1453 \subsection{Analog pass-through}
1454 \begin{figure}[H]\begin{center}
1455 \noindent
1456 \includegraphics[width=450px]{images/demo_analog_passthrough.png}
1457 \caption{Analog Passthrough Simulink demo for RPP.}
1458 \end{center}\end{figure}
1459
1460 \textbf{Description:}
1461 This demo will read analog input 1 and write it to analog output 1.
1462
1463 In laboratory the minimum read value for analog input a 0 volts is 107. The maximum read at 12
1464 volts is 2478. The map subsystem will map the input domain (ADC)\textsc{[110, 2400]} to the output domain
1465 (DAC)\textsc{[0, 4095]}.
1466
1467
1468 \subsection{Analog sinewave}
1469 \begin{figure}[H]\begin{center}
1470 \noindent
1471 \includegraphics[width=450px]{images/demo_analog_sinewave.png}
1472 \caption{Analog Sinewave Simulink demo for RPP.}
1473 \end{center}\end{figure}
1474
1475 \textbf{Description:}
1476 This demo will generate a sinewave on analog output 1. The frequency
1477 of the sine wave is 10Hz and sampling rate is set to
1478 1000Hz (driven from Simulink step of 1ms, same as operating system). Amplitude is set to use DAC
1479 full range [0-4095] which means output amplitude will be [0-12] volts.
1480
1481 The Software oscilloscope shown should match an external one connected to DAC 1.
1482
1483 Note that the driver configuration of the MCP4922 is set to unbuffered (which should eventually
1484 be changed to buffered) and thus the last resolution millivolts are lost.
1485
1486
1487 \subsection{CAN transmit}
1488 \begin{figure}[H]\begin{center}
1489 \noindent
1490 \includegraphics[width=450px]{images/demo_cantransmit.png}
1491 \caption{Example of the usage of the CAN blocks for RPP.}
1492 \end{center}\end{figure}
1493
1494 \textbf{Description:}
1495
1496 Demostrates how to use CAN Transmit blocks in order to:
1497
1498 \begin{compactenum}
1499 \item Send unpacked data with data type uint8, uint16 and uint32.
1500 \item Send single and multiple signals packed into CAN\_MESSAGE by CAN Pack block.
1501 \item Send a message as extended frame type to be received by CAN Receive configured to receive both, standard and extended frame types. 
1502 \end{compactenum}
1503
1504 Demostrates how to use CAN Receive blocks in order to:
1505
1506 \begin{compactenum}
1507 \item Receive unpacked data of data types uint8, uint16 and uint32.
1508 \item Receive and unpack received CAN\_MESSAGE by CAN Unpack block.
1509 \item Configure CAN Receive block to receive Standard, Extended and both frame types.
1510 \item Use function-call mechanism to process received messages
1511 \end{compactenum}
1512
1513 \subsection{CAN demo}
1514
1515 \begin{figure}[H]\begin{center}
1516 \noindent
1517 \includegraphics[width=450px]{images/demo_can_demo.png}
1518 \caption{CAN bus demo for RPP.}
1519 \end{center}\end{figure}
1520
1521 \textbf{Description:}
1522
1523 This demo demonstrates simple processing of received messages.
1524
1525 \subsection{Digital pass-through}
1526 \begin{figure}[H]\begin{center}
1527 \noindent
1528 \includegraphics[width=400px]{images/demo_digital_passthrough.png}
1529 \caption{Digital Pass-through Simulink demo for RPP.}
1530 \end{center}\end{figure}
1531
1532 \textbf{Description:}
1533
1534 This demo will directly pass the digital values read on DIN [1-8] to LOUT [1-8], and thus acting
1535 as a digital pass-through or gateway.
1536
1537 Also note that all the ErrFlag are aggregated on a global ErrFlag.
1538
1539 \subsection{Echo char}
1540 \begin{figure}[H]\begin{center}
1541 \noindent
1542 \includegraphics[width=450px]{images/demo_echo_char.png}
1543 \caption{Echo Character Simulink demo for RPP.}
1544 \end{center}\end{figure}
1545
1546 \textbf{Description:}
1547
1548 This demo will echo twice (print back) any character received through the Serial Communication
1549 Interface (9600-8-N-1).
1550
1551 Note that the send subsystem is implemented a as \textit{triggered} subsystem and will execute only
1552 if data is received, that is, Serial Receive output is non-negative. Negative values are errors.
1553
1554
1555 \subsection{H-bridge analog control}
1556 \begin{figure}[H]\begin{center}
1557 \noindent
1558 \includegraphics[width=450px]{images/demo_hbridge_analog_control.png}
1559 \caption{H-Bridge Analog Control Simulink demo for RPP.}
1560 \end{center}\end{figure}
1561
1562 \textbf{Description:}
1563
1564 This demo will read values from the analog input, map them, and control the H-Bridge. This allows
1565 a motor connected to the H-Bridge to be controlled with a potentiometer connected to Analog Input 1.
1566
1567 Setting the potentiometer to output around 6 volts will stop the motor. Less (or greater) than 6
1568 volts will trigger the motor in one sense (or in the other sense) and speed proportional with 1\%
1569 resolution.
1570
1571 In laboratory the minimum read value for analog input is 107 at 0 volts. The maximum read at 12 volts
1572 is 2478. The map subsystem will map the input domain (ADC)\textsc{[110, 2400]} to the output domain
1573 (HBR)\textsc{[-1.0, 1.0]}.
1574
1575
1576 \subsection{H-bridge digital control}
1577 \begin{figure}[H]\begin{center}
1578 \noindent
1579 \includegraphics[width=450px]{images/demo_hbridge_digital_control.png}
1580 \caption{H-Bridge Digital Control Simulink demo for RPP.}
1581 \end{center}\end{figure}
1582
1583 \textbf{Description:}
1584
1585 This demo toggle the H-Bridge from stop to full speed in one direction using digital input 1.
1586 So basically is a ON/OFF switch on DIN 1 for a motor connected on the HBR. Note the data type
1587 conversion because the output of the DIN is a boolean and the input to the HBR is a double.
1588
1589 \subsection{H-bridge sine wave control}
1590 \begin{figure}[H]\begin{center}
1591 \noindent
1592 \includegraphics[width=300px]{images/demo_hbridge_sinewave_control.png}
1593 \caption{H-Bridge Sinewave Control Simulink demo for RPP.}
1594 \end{center}\end{figure}
1595
1596 \textbf{Description:}
1597
1598 This demo will generate a sine wave to control the H-Bridge. Sine wave is one period per 20
1599 seconds or 0.05Hz. Sampling rate is 20Hz or 100 samples per 1/4 of period (for 1\% speed
1600 resolution change).
1601
1602 Note that the Software oscilloscope should is not the output of the H-Bridge, the H-Bridge will
1603 change current sense and the duty cycle of the pulse that drive it (PWM), it does not output
1604 analog values. The Software oscilloscope just shows what the input to the HBR block is.
1605
1606 \subsection{Hello world}
1607 \begin{figure}[H]\begin{center}
1608 \noindent
1609 \includegraphics[width=450px]{images/demo_hello_world.png}
1610 \caption{Hello World Simulink demo for RPP.}
1611 \end{center}\end{figure}
1612
1613 \textbf{Description:}
1614
1615 This demo will print \textsc{"Hello Simulink"} to the Serial Communication Interface (9600-8-N-1) one
1616 character per second. The output speed is driven by the Simulink model step which is set to one
1617 second.
1618
1619 \subsection{IRC input}
1620 \begin{figure}[H]\begin{center}
1621
1622 \noindent
1623 \includegraphics[width=450px]{images/demo_irc_input.png}
1624 \caption{LED Blink Simulink demo for RPP.}
1625 \end{center}\end{figure}
1626
1627 \textbf{Description:}
1628
1629 This demo is printing IRC sensor (connected to DIN10 and DIN11) value to the Serial Communication
1630 Interface (115200-8-N-1) with six values to one line.
1631
1632 \subsection{LED blink}
1633 \begin{figure}[H]\begin{center}
1634 \noindent
1635 \includegraphics[width=450px]{images/demo_led_blink.png}
1636 \caption{LED Blink Simulink demo for RPP.}
1637 \end{center}\end{figure}
1638
1639 \textbf{Description:}
1640
1641 This the simplest demo of all that shows the basics of using the RPP target and blocks. The
1642 goal of this demo is to show the configuration of the model (not shown on the picture above),
1643 that is, how the RPP Simulink Coder Target is setup, general model setup and step setup.
1644
1645 This demo will toggle each second a LED connected on LOUT 1. The timing is set by the Simulink
1646 model step which is set to 1 second.
1647
1648 \subsection{LED blink all}
1649 \begin{figure}[H]\begin{center}
1650 \noindent
1651 \includegraphics[width=350px]{images/demo_led_blink_all.png}
1652 \caption{LED Blink All Simulink demo for RPP.}
1653 \end{center}\end{figure}
1654
1655 \textbf{Description:}
1656
1657 This demo will toggle all LEDs connected to the LOUT port. Even outputs pins will be negated.
1658 Toggle will happen each second. The timing is driven by Simulink model step configuration that
1659 is set to 1 second. All blocks ErrFlags are aggregated into one global ErrFlag.
1660
1661 \subsection{Log analog input}
1662 \begin{figure}[H]\begin{center}
1663 \noindent
1664 \includegraphics[width=450px]{images/demo_log_analog_input.png}
1665 \caption{Log Analog Input Simulink demo for RPP.}
1666 \end{center}\end{figure}
1667
1668 \textbf{Description:}
1669
1670 This demo will log once per second the value read on the analog input 1. User can read the log
1671 using the SCI logging integrated command processor (9600-8-N-1). Logging block ID set to 1. The
1672 timing is driven by Simulink model step configuration that is set to 1 second.
1673
1674 \subsection{Power toggle}
1675 \begin{figure}[H]\begin{center}
1676 \noindent
1677 \includegraphics[width=300px]{images/demo_power_toggle.png}
1678 \caption{Power Toggle Simulink demo for RPP.}
1679 \end{center}\end{figure}
1680
1681 \textbf{Description:}
1682
1683 This demo will toggle the power output once per second. If an error is detected on at least one of
1684 the outputs a generic error message is printed to the serial line. The timing is driven by Simulink
1685 model step configuration that is set to 1 second. Power outputs can drive a load up to 2A, so please
1686 take into account required safety considerations.
1687
1688 \subsection{Simulink Demo board}
1689 Model for demo board has 6 subsystems. Every subsystem will be described separately.
1690 \begin{figure}[H]\begin{center}
1691 \noindent
1692 \includegraphics[width=0.8\textwidth]{images/demo_board-connection_scheme.pdf}
1693 \caption{Demo board connection and usage scheme.}
1694 \end{center}\end{figure}
1695
1696 \subsubsection{Potentiometer regulation of motor speed}
1697 This is example of driving motor with input signal. Motor can be rotated in various speed in both directions and stopping motor means setting potentiometer to half of its range. Potentiometer value is also transmitted through CAN.
1698
1699 \subsubsection{Color music}
1700 This is showing abilities of RPP board to generate analog signals. Bargraphs on demo board are showing value of analog outputs. Speed of change can be changed with potentiometer and in one case is used motor 2 IRC. There are five different modes. Three of them are derived from sinus and rest of them are counter value and direct control. Modes can be changed with black button. First mod selected after board start is fifth.
1701 \begin{enumerate}
1702 \item Sinus signal is sequential delayed by 10 steps for second and third bargraph.
1703 \item Sinus signal on second bargraph is shifted by 120° and on third one is shifted by 240°.
1704 \item Sinus signal for second and third bargraphs are shifted same as in previous mode, but as counter value is used IRC value with appropriate divider no potentiometer value.
1705 \item Visualizing counter value which speed is changed with potentiometer.
1706 \item Potentiometer value is passed to all bargraphs with appropriate multiplier.
1707 \end{enumerate}
1708
1709 \subsubsection{Buttons and LEDs}
1710 This is example of digital input/output. LEDs on demo board can be driven with four different subprograms. These subprograms can be changed with red button and are influenced with green and blue buttons.
1711 \begin{enumerate}
1712 \item One LED is always ON and others are OFF. Every 0.1 sec is neighborhood LED switched on and previous one is switched off. With buttons you can change direction.
1713 \item Same as previous mode, but change is not done after 0.1 sec but only when button is pressed.
1714 \item In this mode you can record message in Morse code (max 64 chars including spaces) and after delay it is repetitively replayed. To record message use green button as dash and blue button as dot.
1715 \item Simple game in which you must determine if light is moving left or right and press green or blue button according to it. Speed of movement is increasing and in case of wrong answer or long delay is game ends with lights flashing.
1716 \end{enumerate}
1717
1718 \subsubsection{IRC to CAN}
1719 IRC value from Motor 2 is sent every tenth step via CAN2 with message ID 0x4.
1720
1721 \subsubsection{CAN receive -- Button press emulation}
1722 You can simulate press of all four buttons by sending message through CAN2 to board with message ID 0x0 and value according to button number.
1723
1724 \subsubsection{Configuration and error handling}
1725 RPP supports some basic runtime error handling. Every block can set its error flag, all these error flags are joined in this demo together and when some problem is detected CAN2 message of ID 0x10 is transmitted. Also in case of board overrun (exhaustion of time quanta) is transmitted message through CAN2 with ID 0x11.\\
1726 When model is build without external mode, errors are also printed to SCI.
1727
1728 \subsubsection{Full list of CAN communication}
1729 The board produces CAN frames with the following IDs:
1730 \begin{itemize}
1731 \item 0x05: Potentiometer 1 value.
1732 \item 0x06: Potentiometer 2 value.
1733 \item 0x08: Selected mod of color music.
1734 \item 0x09: Active subprogram of buttons and LEDs.
1735 \item 0x10: Transmitted only in case of error flag of some block, error code.
1736 \item 0x11: Transmitted only in case of board overrun, no data.
1737 \end{itemize}
1738 The board reacts to CAN frames with following IDs:
1739 \begin{itemize}
1740 \item 0x00: Simulate button press, accepts value 1--4.
1741 \end{itemize}
1742
1743 \chapter{Command line testing tool}
1744 \label{chap-rpp-test-software}
1745 The \textsc{rpp-test-suite} is a RPP application developed testing and direct control of the RPP hardware. The test suite implements a command processor, which is listening for a commands and prints some output related to the commands on the serial interface. The command processor is modular and each peripheral has its commands in a separated module.
1746
1747 The command processor is implemented in <rpp-test-sw>/cmdproc and commands modules are implemented in <rpp-test-sw>/commands directory.
1748
1749 The application enables a command processor using the SCI at \textbf{115200-8-N-1}. When the software starts, the received welcome message and prompt should look like:
1750
1751 \begin{verbatim}
1752 TODO: FILL
1753 \end{verbatim}
1754
1755 Type in command help for a complete list of available command, or help command for a description of concrete command.
1756
1757 \section{Commands description}
1758
1759 % Generated by html2tex: Version 2.7 of February 6, 2012.
1760 % Written by F.J. Faase.  http://www.iwriteiam.nl/
1761
1762 % html: Beginning of file: `doc.html'
1763
1764 \subsection{adcread}
1765
1766 \label{f0}
1767 Read values from ADC inputs
1768
1769 \subsubsection{Command syntax}
1770
1771 \begin{verbatim}  adcread\end{verbatim}
1772
1773 \subsubsection{Description}
1774
1775
1776 This command reads values corresponding to analog voltages on ADC inputs 1-12 and prints them as decimal numbers as well as converted to Volts.
1777
1778 \subsubsection{Example}
1779
1780 \begin{verbatim}  --> adcread
1781  ADC1  2332 lsb ~ 11.66 V
1782  ADC2   107 lsb ~  0.54 V
1783  ADC3   108 lsb ~  0.54 V
1784  ADC4   107 lsb ~  0.54 V
1785  ADC5   108 lsb ~  0.54 V
1786  ADC6   111 lsb ~  0.56 V
1787  ADC7   110 lsb ~  0.55 V
1788  ADC8   109 lsb ~  0.55 V
1789  ADC9   107 lsb ~  0.54 V
1790  ADC10  107 lsb ~  0.54 V
1791  ADC11  110 lsb ~  0.55 V
1792  ADC12  108 lsb ~  0.54 V\end{verbatim}
1793
1794 \subsection{adcread*}
1795
1796
1797 Read a value from a single ADC input
1798
1799 \subsubsection{Command syntax}
1800
1801 \begin{verbatim} adcread<PIN>\end{verbatim}
1802
1803 where \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1 - 12.
1804
1805 \subsubsection{Description}
1806
1807
1808 This command reads the value corresponding to analog voltage on an ADC input and prints it as decimal numbers as well as converted to Volts.
1809
1810 \subsubsection{Example}
1811
1812 \begin{verbatim} --> adcread1
1813 ADC1  2331 lsb ~ 11.66 V\end{verbatim}
1814
1815 \subsection{adcwatch}
1816
1817
1818 Watch the values from ADC inputs
1819
1820 \subsubsection{Command syntax}
1821
1822 \begin{verbatim} adcwatch\end{verbatim}
1823
1824 \subsubsection{Description}
1825
1826
1827 This command reads values corresponding to analog voltages on ADC inputs 1-12 10 times per second and prints them as decimal numbers (in lsb units) as well as converted to Volts. The command is ended by any key.
1828
1829 \subsubsection{Example}
1830
1831 \begin{verbatim} --> adcwatch
1832 ADC Inputs Test [1-12]:
1833 =======================================================================
1834     1     2     3     4     5     6     7     8     9    10    11    12
1835  2331   107   108   106   107   110   110   109   107   107   110   109 lsb
1836 11.66  0.54  0.54  0.53  0.54  0.55  0.55  0.55  0.54  0.54  0.55  0.55 V\end{verbatim}
1837
1838 \subsection{canbaudrate\#}
1839
1840
1841 Change baudrate of CAN controller
1842
1843 \subsubsection{Command syntax}
1844
1845 \begin{verbatim} canbaudrate<CONTROLLER>?
1846 canbaudrate<CONTROLLER>:<BAUDRATE>\end{verbatim}
1847
1848 where \texttt{\mbox{$<$}CONTROLLER\mbox{$>$}} is number in range 1-3 and BAUDRATE is number in range 1000-10000000 specifying the baudrate in bits per second.
1849
1850 \subsubsection{Description}
1851
1852
1853 This command is used to set or show the baudrate of a CAN controller. The baudrate shown is the one which will be used by next invocation of the caninit command. The baudrate specified by the command is used to automatic calculation of the CAN controller timing. If you want to specify the timing manually, please use the command cantiming. The automatic calculation might not work properly for some baudrates. In this case you should calculate the timing manually and specify it by the command cantiming.
1854
1855 \subsubsection{Examples}
1856
1857 \begin{verbatim} --> canbaudrate2?
1858 canbaudrate2=500000
1859
1860 --> canbaudrate2:100000\end{verbatim}
1861
1862 \subsection{candump}
1863
1864
1865 Dump all messages received over CAN
1866
1867 \subsubsection{Command syntax}
1868
1869 \begin{verbatim} candump <CONTROLLER>\end{verbatim}
1870
1871 where \texttt{\mbox{$<$}CONTROLLER\mbox{$>$}} is a number in range 1-3.
1872
1873 \subsubsection{Description}
1874
1875
1876 This command prints out all CAN messages received via the specified controller.
1877
1878 IDs are zero-filled to length 3 if a message in the standard frame format is received and to 8 for extended frame format messages.
1879
1880 caninit must be called before using this command.
1881
1882 \subsubsection{Example}
1883
1884 \begin{verbatim} --> candump 2\end{verbatim}
1885
1886 can2 0000FADE \mbox{$[$}2\mbox{$]$} 12 34
1887
1888 \subsection{caninit}
1889
1890
1891 Initialize CAN controllers
1892
1893 \subsubsection{Command syntax}
1894
1895 \begin{verbatim} caninit\end{verbatim}
1896
1897 \subsubsection{Description}
1898
1899
1900 This command (re-)initializes all CAN controllers using current CAN configuration. This configuration can be changed using canbaudrate command.
1901
1902 In the default configuration the baudrate of all CAN controllers i set to 500 kbit/s.
1903
1904 \subsubsection{Example}
1905
1906
1907 --\mbox{$>$} caninit
1908
1909 \subsection{canrpptest}
1910
1911
1912 Test the CAN functions from the RPP library
1913
1914 \subsubsection{Command syntax}
1915
1916 \begin{verbatim} canrpptest\end{verbatim}
1917
1918 \subsubsection{Description}
1919
1920
1921 This command tests all CAN functions in the RPP library. It does those particular tests:
1922
1923 1) Test of the rpp\emph{can}init(), rpp\emph{can}write() and rpp\emph{can}read() functions. At the beginning, the CAN bus is initialized with manually specified and verified CAN bit timing parameters. Then a message is sent on the CAN1 and is received on the CAN2. Finally the received message is compared with the sent one. If the transmissions fails, reception exceeds a timeout or the sent and received messages do not match, the command prints the appropriate error code.2) Test of the CAN bit timing parameters calculation. This test subsequently initializes the CAN bus to a baudrates 125k, 250k and 500k. For each one of them a message is sent on CAN1 and received on CAN2. Finally the received message is compared with the sent one like in a test (1). If the initialization, transmission, reception or comparison fails or if the reception timeout is reached, an appropriate error code is printed. 3) Test of the behavior of transmission request overwriting. The CAN bus is initialized like in the test (1). A message A transmission request is posted on CAN1 by calling rpp\emph{can}write() and right after that another message B transmission request is posted on CAN1 by another call of the rpp\emph{can}write(). A message B is received on CAN2, because the second request came so quickly, that it overwrote the first one. The sent and received messages are compared to verify that the transmission was correct. If the initialization, transmission, reception or comparison fails or if the reception timeout is reached, an appropriate error code is printed. 4) Test of the TX request pending flag detection. The CAN bus is initialized like in the test (1). A message is transmitted on the CAN1 and the test waits for the TX pending flag to be set, which signalizes that there is a message transmission request pending. After the flag has been set, the test waits for its clearance, which means that the message has been sent. The test measures, how many flag test cycles passed, until the flag has been cleared. This value is then presented as a time. At the end, the message is received on the CAN2 and is compared with the sent message for verification. If the initialization, transmission, reception or comparison fails or if timeout is reached while waiting for the flag set/clear or receive timeout is reached, an appropriate error code is printed. 5) Test of the message received (RX) indicator. The CAN bus is initialized like in the test (1). A message is transmitted on the CAN1. The test then waits for the RX indicator to be set, which indicates that a message has been received. The message is picked up by the rpp\emph{can}read(). This should clear the indicator, which is tested. Finally the received messages is compared with the sent one. If the initialization, transmission, reception, message comparison or indicator test fails or if timeout is reached while waiting for the flag set, the appropriate error code is printed.
1924
1925 At the end the CAN bus is reset and left with the configuration from test (1). Those tests assumes the CAN1 and CAN2 to be connected in HW loopback. Any previous configuration is canceled, but is not deleted, so any following call of caninit command will restore the CAN bus to previous configuration.
1926
1927 For error codes description refer please the API documentation for the rpp-test-sw.
1928
1929 \subsubsection{Example}
1930
1931 \begin{verbatim} --> canrpptest\end{verbatim}
1932
1933 This is a test for RPP CAN library functions:Test of simple message transmission and reception. CAN bus Initialization...OK Transmission and reception...OK---Test od automatic CAN bit timing calculation. Baudrate: 125000: OK Baudrate: 250000: OK Baudrate: 500000: OK---Test of transmission request rewritting. CAN bus Initialization...OK TX request rewritting...OK---Test of TX request pending flag detection. CAN bus Initialization...OK TX request pending flag behavioral: OK, time: 256 cycles.---Test of RX indicator. CAN bus Initialization...OK RX indicator behavioral:OK, time: 0 cycles.---Reset the CAN bus. CAN bus Initialization...OK\#\# cansend \#\# Test sending message over CAN
1934
1935 \subsubsection{Command syntax}
1936
1937 \begin{verbatim} cansend <CONTROLLER> <ID> <DATA>\end{verbatim}
1938
1939 where \texttt{\mbox{$<$}CONTROLLER\mbox{$>$}} is number in range 1-3, \texttt{\mbox{$<$}ID\mbox{$>$}} is a valid CAN ID and \texttt{\mbox{$<$}DATA\mbox{$>$}} is 0-8 bytes of data in hexadecimal representation. There may be any number of spaces between the data bytes. \texttt{\mbox{$<$}ID\mbox{$>$}} may be given in octal, decimal or hexadecimal base.
1940
1941 \subsubsection{Description}
1942
1943
1944 This command sends a CAN frame using specified CAN controller.
1945
1946 The caninit command must be called before using this command.
1947
1948 \subsubsection{Example}
1949
1950 \begin{verbatim} --> cansend 2 0x123 DEAD BEEF
1951 Sent: can2      123     [4]     DE AD BE EF\end{verbatim}
1952
1953 \subsection{cantiming\#}
1954
1955
1956 Change timing of CAN controller manually
1957
1958 \subsubsection{Command syntax}
1959
1960 \begin{verbatim} cantiming<CONTROLLER>?
1961 cantiming<CONTROLLER>:<BRP> <PROP_SEG> <PHASE_SEG1> <PHASE_SEG2> <SJW>\end{verbatim}
1962
1963 where: - \texttt{\mbox{$<$}CONTROLLER\mbox{$>$}} is number in range 1-3 - \texttt{\mbox{$<$}BRP\mbox{$>$}} (baudrate prescaler) is number in range 1-65 - \texttt{\mbox{$<$}PROP\_SEG\mbox{$>$}} (length of propagation segment in tQ) is a number in range 1-8 - \texttt{\mbox{$<$}PHASE\_SEG1\mbox{$>$}} (phase buffer segment 1 in tQ) is a number in range 1-8 - \texttt{\mbox{$<$}PHASE\_SEG2\mbox{$>$}} (phase buffer segment 2 in tQ) is a number in range 1-8 - \texttt{\mbox{$<$}SJW\mbox{$>$}} (synchronization jump width in tQ) is a number in range 1-4
1964
1965 \subsubsection{Description}
1966
1967
1968 This command is used to set or show the timing of a CAN controller. The timing shown is the one which will be used by next invocation of the caninit command. The timing configured by this command defines manually the baudrate of the CAN controller. If you want to calculate the timing automaticaly from a baudrate, please use the command canbaudrate.
1969
1970 \subsubsection{Examples}
1971
1972 \begin{verbatim} --> cantiming2?
1973 brp: 17
1974 prop_seg: 4 tQ
1975 phase_seg1: 5 tQ
1976 phase_seg2: 5 tQ
1977 sjw: 4 tQ
1978 sample_pt: 875 ns
1979 error: 0
1980 tQ: 125 ns
1981
1982 --> cantiming2:5 8 7 4 1\end{verbatim}
1983
1984 \subsection{dacpinenable*}
1985
1986
1987 Enable or disable a DAC pin
1988
1989 \subsubsection{Command syntax}
1990
1991 \begin{verbatim} dacpinenable<PIN> <VALUE>\end{verbatim}
1992
1993 where
1994 \begin{itemize}
1995 \item \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-4
1996 \item \texttt{\mbox{$<$}VALUE\mbox{$>$}} is a number 0 (disable) or 1 (enable)
1997 \end{itemize}
1998
1999 \subsubsection{Description}
2000
2001
2002 Command for enabling or disabling of a DAC pin.
2003
2004 Command always prints the actual state of the selected pin.
2005
2006 \subsubsection{Example}
2007
2008 \begin{verbatim} --> dacpinenable1 1
2009 dacpinenable1=1\end{verbatim}
2010
2011 Enables pin DAC1 and prints its actual state (which will be 1)
2012
2013 \subsection{dacpinval*}
2014
2015
2016 Set raw value of a DAC register
2017
2018 \subsubsection{Command syntax}
2019
2020 \begin{verbatim} dacpinval<PIN> <VALUE>\end{verbatim}
2021
2022 where
2023 \begin{itemize}
2024 \item \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-4
2025 \item \texttt{\mbox{$<$}VALUE\mbox{$>$}} is a number in range 0-4095
2026 \end{itemize}
2027
2028 \subsubsection{Description}
2029
2030
2031 This command writes a raw value to DAC register that controls the DAC output voltage according to the formula described in the datasheet. \texttt{\mbox{$<$}PIN\mbox{$>$}} parameter selects which DAC pin to use.
2032
2033 Command always prints the written raw value of the selected pin. There is no way how to read the value out of the register.
2034
2035 \subsubsection{Example}
2036
2037 \begin{verbatim} --> dacpinval1 4095
2038 dacpinval1 =4095\end{verbatim}
2039
2040 Set pin DAC1 voltage to 12V, and prints the value (4095).
2041
2042 \subsection{dacpinvoltage*}
2043
2044
2045 Set voltage in mV of a DAC pin
2046
2047 \subsubsection{Command syntax}
2048
2049 \begin{verbatim} dacpinvoltage<PIN> <VALUE>\end{verbatim}
2050
2051 where
2052 \begin{itemize}
2053 \item \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-4
2054 \item \texttt{\mbox{$<$}VALUE\mbox{$>$}} is a number in range 0-12000
2055 \end{itemize}
2056
2057 \subsubsection{Description}
2058
2059
2060 This command sets the voltage on a DAC pin.
2061
2062 The command always prints the actually set voltage of selected pin. There is no way how to read the value back out of the pin.
2063
2064 \subsubsection{Example}
2065
2066 \begin{verbatim} --> dacpinvoltage1 8000
2067 dacpinvoltage1 =8000\end{verbatim}
2068
2069 Sets pin DAC1 to 8V, prints the actual voltage (8000)
2070 \begin{verbatim} --> dacpinvoltage2 500
2071 dacpinvoltage2 =500\end{verbatim}
2072
2073 Sets pin DAC2 to 500mV, prints actual voltage (500)
2074
2075 \subsection{demomotctrl}
2076
2077
2078 Run motor control demo - reads input and sends it
2079
2080 \subsubsection{Command syntax}
2081
2082 \begin{verbatim} demomotctrl\end{verbatim}
2083
2084 \subsubsection{Description}
2085
2086
2087 This command creates a FlexRay node and starts to read buttons (connected to DIN0 and DIN1) and a potentiometer (ADC1) from a control panel. The read data are sent via FlexRay to the second node, created by running demomotdrive command.
2088
2089 The purpose of this pair of commands is to demonstrate functionality of the FlexRay, ADC, DIN and HBR peripherals.
2090
2091 \subsection{demomotdrive}
2092
2093
2094 Run motor control demo - drives the DC motor
2095
2096 \subsubsection{Command syntax}
2097
2098 \begin{verbatim} demomotdrive\end{verbatim}
2099
2100 \subsubsection{Description}
2101
2102
2103 This command creates a FlexRay node and starts to receive the data from another node created by command demomotctrl. The received data are applied to HBR to control the DC motor.
2104
2105 The purpose of this pair of commands is to demonstrate functionality of the FlexRay, ADC, DIN and HBR peripherals.
2106
2107 \subsection{dinget*}
2108
2109
2110 Read the open/close status of a DIN pin (with the default treshold)
2111
2112 \subsubsection{Command syntax}
2113
2114 \begin{verbatim} dinget<PIN>\end{verbatim}
2115
2116 where PIN is a number in range 0-15
2117
2118 \subsubsection{Description}
2119
2120
2121 The command reads and prints the status of the DIN pin. Value 0 means switch is open, value 1 means switch is closed. The mapping between the DIN voltage and the open/close status depends on the setup of the pin (see dinsetup command).
2122
2123 \subsubsection{Example}
2124
2125 \begin{verbatim} --> dinget1
2126 dinget1 =0\end{verbatim}
2127
2128 DIN1 is in open state.
2129
2130 \subsection{dinsetup*}
2131
2132
2133 Setup DIN pin parameters (Pull up/down, tristate/active, IRQ and wakeup disable/enable)
2134
2135 \subsubsection{Command syntax}
2136
2137 \begin{verbatim} dinsetup<PINS> [A [B [C]]]\end{verbatim}
2138
2139 where
2140 \begin{itemize}
2141 \item PINS is either a number in range 1-16 or a range written as \texttt{\mbox{$<$}min\mbox{$>$}-\mbox{$<$}max\mbox{$>$}}
2142 \item A is an optional value - either 0 (pull down/switch to battery) or 1 (pull up/switch to ground). The default is 1.
2143 \item B is an optional value - either 0 (tri-state) or 1 (active). The default is 0.
2144 \item C is an optional value - either 0 (wake up and IRQ disabled) or 1 (wake up and IRQ disabled enabled). The default is 1.
2145 \end{itemize}
2146
2147 \subsubsection{Description}
2148
2149
2150 The command setups properties of one or more DIN pins as specified by \texttt{\mbox{$<$}PIN\mbox{$>$}}. Pins 0-7 can be set as pull up (switch to ground) or pull down (switch to battery), pins 8-15 are hardcoded as switch to ground. All pins can be set to either tri-state or active state and also can have wake-up function with IRQ activated or not.
2151
2152 The command always prints the final settings of each set pin as ABC. The actual configuration cannot be read out of the pin driver.
2153
2154 \subsubsection{Example}
2155
2156 \begin{verbatim} --> dinsetup1 1 0 0
2157 dinsetup1=100\end{verbatim}
2158
2159 Sets the DIN1 as switch to ground, active and disables IRQ generation.
2160 \begin{verbatim} --> dinsetup2
2161 dinsetup2=101\end{verbatim}
2162
2163 Sets the DIN2 as to the default values i.e. switch to battery, tri-state, wake-up/IRQ enabled.
2164 \begin{verbatim} --> dinsetup0-7 1 1 1
2165 dinsetup0=111
2166 dinsetup1=111
2167 dinsetup2=111
2168 dinsetup3=111
2169 dinsetup4=111
2170 dinsetup5=111
2171 dinsetup6=111
2172 dinsetup7=111\end{verbatim}
2173
2174 Sets the DIN0 through DIN7 as switch to ground, tri-state, wake-up/IRQ enabled.
2175
2176 \subsection{dinwatch}
2177
2178
2179 Watch status of all DIN pins
2180
2181 \subsubsection{Command syntax}
2182
2183 \begin{verbatim} dinwatch\end{verbatim}
2184
2185 \subsubsection{Description}
2186
2187
2188 The command reads and prints the status of DIN pins every 100 milliseconds. Columns 0-15 correspond to open/close status of DIN pins with the default threshold of 4 V, columns A-H represent the logical values of pins DIN8-15 when read with programmable threshold. Pin status (open=0, close=1) depends on the pin setup that can be changed with dinsetup command, programmable threshold can be set with TODO command.
2189
2190 Press any key to end this command.
2191
2192 \subsubsection{Example}
2193
2194 \begin{verbatim} --> dinwatch
2195 Digital Inputs Test [0-15]:
2196 ===========================================================
2197  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15  A  B  C  D  E  F  G  H
2198  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1\end{verbatim}
2199
2200 \subsection{ethbd}
2201
2202
2203 Examine emac buffer descriptors
2204
2205 \subsubsection{Command syntax}
2206
2207 \begin{verbatim} ethbd\end{verbatim}
2208
2209 \subsubsection{Description}
2210
2211
2212 After startup you use keys to control what will be done.
2213 \begin{itemize}
2214 \item q - quit
2215 \item s - general statistics
2216 \item t - transmit channel status
2217 \item r - receive channel status
2218 \item b - after giving address of bd it prints bd content
2219 \item a - checks consistency of buffer descriptors
2220 \end{itemize}
2221
2222 \subsubsection{Example}
2223
2224 \begin{verbatim} --> ethbd\end{verbatim}
2225
2226 \subsection{ethernet}
2227
2228
2229 Temporary command to test Ethernet communication
2230
2231 \subsubsection{Command syntax}
2232
2233 \begin{verbatim} ethernet\end{verbatim}
2234
2235 \subsubsection{Description}
2236
2237
2238 Command tries to send a few ethernet frames. No real connection or meaningful packets are sent. This only tests, if Ethernet is just working.
2239
2240 \subsection{ethinit}
2241
2242
2243 Post OS startup eth initialization
2244
2245 \subsubsection{Command syntax}
2246
2247 \begin{verbatim} ethinit\end{verbatim}
2248
2249 \subsubsection{Description}
2250
2251
2252 This command finishes autonegotiation of PHY and initialize LwIP stack.
2253
2254 \subsubsection{Example}
2255
2256 \begin{verbatim} --> ethinit\end{verbatim}
2257
2258 \subsection{ethip}
2259
2260
2261 Print current IP address of network interface
2262
2263 \subsubsection{Command syntax}
2264
2265 \begin{verbatim} ethip\end{verbatim}
2266
2267 \subsubsection{Description}
2268
2269
2270 This command reads current IP address, netmask and gateway of network interface and prints these to the output.
2271
2272 \subsubsection{Example}
2273
2274 \begin{verbatim} --> ethip
2275 Address: 192.168.247.1
2276 Netmask: 255.255.255.0
2277 Gateway: 192.168.247.255\end{verbatim}
2278
2279 \subsection{ethlinkstat}
2280
2281
2282 Print current status of ethernet interface
2283
2284 \subsubsection{Command syntax}
2285
2286 \begin{verbatim} ethlinkstat\end{verbatim}
2287
2288 \subsubsection{Description}
2289
2290
2291 This command reads PHY link status assigned to ethernet interface and prints interface name and informs about PHY's status to the output.
2292
2293 \subsubsection{Example}
2294
2295 \begin{verbatim} --> ethlinkstat
2296 et0 : UP
2297
2298 --> ethlinkstat
2299 et0 : DOWN\end{verbatim}
2300
2301 \subsection{ethmac}
2302
2303
2304 Print current MAC address of ethernet interface
2305
2306 \subsubsection{Command syntax}
2307
2308 \begin{verbatim} ethmac\end{verbatim}
2309
2310 \subsubsection{Description}
2311
2312
2313 This command obtains MAC address from ethernet interface structure and prints it to the output.
2314
2315 \subsubsection{Example}
2316
2317 \begin{verbatim} --> ethmac
2318 12:34:56:78:9a:bc\end{verbatim}
2319
2320 \subsection{ethnc}
2321
2322
2323 Start very simple netcat
2324
2325 \subsubsection{Command syntax}
2326
2327 \begin{verbatim}  ethnc <IP> <PORT> [-p <PORT>] [-u] [-m [-t] | -d [-t]] [-c]
2328  ethnc -l <PORT> [-u] [-m [-t] | -d [-t]] [-c]\end{verbatim}
2329
2330 \subsubsection{Description}
2331
2332
2333 Netcat is a program which allows to communicate using TCP or UDP protocols. First a connection is established by either:
2334 \begin{itemize}
2335 \item connecting to a specified IP address and PORT (without option -l) or by
2336 \item listening for a new connection on a given PORT (with option -l).
2337 \end{itemize}
2338
2339 When no -u option is specified ethnc command works with TCP connections. With -u option UDP communication is used. Listening for connection on UDP means waiting for reception of any UDP datagram.
2340
2341 Once the connection is established the command works in one of the following modes:
2342 \begin{itemize}
2343 \item interactive mode in which received data are forwarded to serial line and data received on serial line are sent to the connection when either new line is encountered or when internal buffer is full,
2344 \item sending of testing data (increasing ASCII formatted numbers) (option -d),
2345 \item looping of incoming data back to the connection's peer (option -m).
2346 \end{itemize}
2347
2348 Note: When trying to use a same local TCP port number multiple times in a row (-l or -p options) there might be several minutes delay before the port is available after closing the previous connection. This situation is singled with ERROR 31.
2349
2350 Other options:
2351 \begin{itemize}
2352 \item -p specifies local port for outgoing connections.
2353 \item -u use UDP protocol instead of the default TCP.
2354 \item -t send and/or receive data in a background thread (works only with -d or -m options).
2355 \item -c stop all running background tasks
2356 \end{itemize}
2357
2358 \subsubsection{Examples}
2359
2360
2361 Listen for incoming TCP connection on local port 2000: --\mbox{$>$} ethnc -l 2000
2362
2363 Connect using TCP to address 192.168.247.15 to remote port 80 using local port 1500: --\mbox{$>$} ethnc 192.168.247.15 80 -p 1500
2364
2365 Send testing data to the remote node: --\mbox{$>$} ethnc -d 192.168.247.2 1025
2366
2367 Loop back all data coming from remote node's UDP port 1025: --\mbox{$>$} ethnc -m -u 192.168.247.2 1025
2368
2369 Wait for a TCP connection on local port 30000 and loop all incoming data back: --\mbox{$>$} ethnc -l 30000 -m
2370
2371 \subsection{fraytestA}
2372
2373
2374 Run the FlexRay test as A node
2375
2376 \subsubsection{Command syntax}
2377
2378 \begin{verbatim} fraytestA [<COUNT>]\end{verbatim}
2379
2380 where \texttt{\mbox{$<$}COUNT\mbox{$>$}} is an optional number of messages to send. The default is 100.
2381
2382 \subsubsection{Description}
2383
2384
2385 The commands creates FlexRay node A and starts sending a message approximately every communication cycle. COUNT messages are sent for the test of the connection. The command should be run with two devices connected by a FlexRay bus and the second device should be running the fraytestB command (it is necessary to run both commands shortly after each other).
2386
2387 When the command transmits a message a character is printed. O means that the message was transmitted correctly, X signals a transmission error. The number of TX errors and successfully transmitted messages is maintained during the test and printed at the end.
2388
2389 \subsection{fraytestB}
2390
2391
2392 Run the FlexRay test as B node
2393
2394 \subsubsection{Command syntax}
2395
2396 \begin{verbatim} fraytestB [<COUNT>]\end{verbatim}
2397
2398 where \texttt{\mbox{$<$}COUNT\mbox{$>$}} is an optional number of messages to receive. The default is 100.
2399
2400 \subsubsection{Description}
2401
2402
2403 The commands creates FlexRay node B and starts receiving a messages. 100 messages should be received. The command should be run with two devices connected by a FlexRay bus and the second device should be running the fraytestA command (it is necessary to run both commands shortly after each other).
2404
2405 When the command receives a message a character is printed. O means that the message was received correctly, X signals an error in data, T means timeout (i.e. no message was received within 63 cycles). The number of RX errors and successfully received messages is maintained during the test and printed at the end.
2406
2407 \subsection{frayxcvrstat\#}
2408
2409
2410 Get the status of a FlexRay transceiver in a human readable form
2411
2412 \subsubsection{Command syntax}
2413
2414 \begin{verbatim} frayxcvrstat<CHN>\end{verbatim}
2415
2416 where CHN is a number in range 1-2
2417
2418 \subsubsection{Description}
2419
2420
2421 The command receives response from a FlexRay transceiver via SPI, and prints in the form of attribute-value table.
2422
2423 \subsubsection{Example}
2424
2425 \begin{verbatim} --> frayxcvrstat1\end{verbatim}
2426
2427 Prints the status of FRAY1 transceiver.
2428
2429 \subsection{frbtabort}
2430
2431
2432 Abort FlexRay communication immediately
2433
2434 \subsubsection{Command syntax}
2435
2436 \begin{verbatim} frbtabort\end{verbatim}
2437
2438 \subsubsection{Description}
2439
2440
2441 The command stands for Fr\_AbortCommunication function from the Autosar specification. The command invokes the FlexRay POC command FREEZE, which means that the communication is stopped immediately. On the opposite side there is a frbthalt command, which stops the communication after the end of the actual communication cycle. To restart the communication, the frbtinit and frbtstart commands have to be called.
2442
2443 \subsubsection{Example}
2444
2445 \begin{verbatim} --> frbtabort
2446 FlexRay node communication aborted.\end{verbatim}
2447
2448 \subsection{frbtallslots}
2449
2450
2451 Enables communication for all frames
2452
2453 \subsubsection{Command syntax}
2454
2455 \begin{verbatim} frbtallslots\end{verbatim}
2456
2457 \subsubsection{Description}
2458
2459
2460 The command stands for Fr\_AllSlots function from the Autosar specification.
2461
2462 The node can be configured to communicate only on key frames by default (as in the case of frbtinitA/B). This command can be used to allow the communication on all configured frames. The command invokes the FlexRay POC command ALL\_SLOTS which enables the communication on all frames. The command can be called after the controller initialization.
2463
2464 \subsubsection{Example}
2465
2466 \begin{verbatim} --> frbtallslots
2467 FlexRay node started communication on all slots.\end{verbatim}
2468
2469 \subsection{frbtcanceltimer*}
2470
2471
2472 Stop the timer
2473
2474 \subsubsection{Command syntax}
2475
2476 \begin{verbatim} frbtcanceltimer<TMID>\end{verbatim}
2477
2478 where \texttt{\mbox{$<$}TMID\mbox{$>$}} is a number (0 or 1) specifying the timer.
2479
2480 \subsubsection{Description}
2481
2482
2483 The command stands for Fr\_CancelAbsoluteTimer function from the Autosar specification. It stops the timer selected by the parameter.
2484
2485 \subsubsection{Example}
2486
2487 \begin{verbatim} --> frbtcanceltimer0
2488 Timer was canceled.\end{verbatim}
2489
2490 \subsection{frbtcanceltx*}
2491
2492
2493 Stop the transmission of the frame
2494
2495 \subsubsection{Command syntax}
2496
2497 \begin{verbatim} frbtcanceltx<FRID>\end{verbatim}
2498
2499 where \texttt{\mbox{$<$}FRID\mbox{$>$}} is a decimal number specifying the ID of the frame for which a buffer has been configured.
2500
2501 \subsubsection{Description}
2502
2503
2504 The command stands for Fr\_CancelTxLPdu function from the Autosar specification. The command finds all buffers assigned to the specified frame ID and reconfigures them to stop transmitting data. The command finishes successfully only if reconfiguration is allowed in message RAM configuration (secureBuffers configuration parameter). Only TX buffers and buffers not used for startup frames can be canceled.
2505
2506 \subsubsection{Example}
2507
2508 \begin{verbatim} --> frbtcanceltx3
2509 Transmission canceled.\end{verbatim}
2510
2511 \subsection{frbtccconfig*}
2512
2513
2514 Print value of a FlexRay cluster and node configuration parameter
2515
2516 \subsubsection{Command syntax}
2517
2518 \begin{verbatim} frbtccconfig<INDEX>\end{verbatim}
2519
2520 where \texttt{\mbox{$<$}INDEX\mbox{$>$}} is an identifier of the parameter.
2521
2522 \subsubsection{Description}
2523
2524
2525 The command stands for Fr\emph{ReadCCConfig function from the Autosar specification. The driver stores the configuration parameters as an array. Each parameter can be indexed and returned by this command. See Autosar specification of the FlexRay driver (http://www.autosar.org/download/R4.1/AUTOSAR}SWS\_FlexRayDriver.pdf), section 8.2.1 for parameter indexes.
2526
2527 \subsubsection{Example}
2528
2529 \begin{verbatim} --> frbtccconfig1
2530 Value = 0x1\end{verbatim}
2531
2532 \subsection{frbtcfgbuf?*}
2533
2534
2535 Configure a message buffer in the user configuration
2536
2537 \subsubsection{Command syntax}
2538
2539 \begin{verbatim} frbtcfgbuf<TYPE><NUM> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\end{verbatim}
2540
2541 where
2542 \begin{itemize}
2543 \item \texttt{\mbox{$<$}TYPE\mbox{$>$}} is 'S' for static segment buffers and 'D' for dynamic segment buffers,
2544 \item \texttt{\mbox{$<$}NUM\mbox{$>$}} is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,
2545 \item \texttt{\mbox{$<$}SLOT\mbox{$>$}} is the number of the slot,
2546 \item \texttt{\mbox{$<$}CHN\mbox{$>$}} is one of 'A', 'B' or 'AB' and identifies the used channel,
2547 \item \texttt{\mbox{$<$}CYC\mbox{$>$}} is the cycle set when to send the buffer,
2548 \item \texttt{\mbox{$<$}RXTX\mbox{$>$}} is either string \"{}rx\"{} or \"{}tx\"{},
2549 \item \texttt{\mbox{$<$}MAX\mbox{$>$}} is the number determining the maximum payload (in hald-words),
2550 \item \texttt{\mbox{$<$}REP\mbox{$>$}} is a string \"{}s\"{} or \"{}single\"{} for single transmission or \"{}c\"{} or \"{}continuous\"{} for continuous transmission,
2551 \item \texttt{\mbox{$<$}PPI\mbox{$>$}} is 0 or 1 determining whether the payload preamble indicator is set,
2552 \item \texttt{\mbox{$<$}INT\mbox{$>$}} is 0 or 1 and is currently ignored.
2553 \end{itemize}
2554
2555 \subsubsection{Description}
2556
2557
2558 The command sets the configuration parameters for static or dynamic buffers in user configuration. The parameters set by this command are applied by the frbtinitU command. Once frbtinit is called, it is no longer possible to change the parameters.
2559
2560 \subsubsection{Example}
2561
2562 \begin{verbatim} --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1
2563 frbtcfgbufS0 slot2 AB cyc0 tx max9  continous ppi0 int1
2564 --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1
2565 frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1
2566 --> frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0
2567 frbtcfgbufD0 slot9  A cyc0 rx max64 single ppi0 int0
2568 --> frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0
2569 frbtcfgbufD1 slot10  A cyc0 tx max64 single ppi0 int0\end{verbatim}
2570
2571 \subsection{frbtcfgfifo*}
2572
2573
2574 Configure a RX FIFO message buffer in the user configuration
2575
2576 \subsubsection{Command syntax}
2577
2578 \begin{verbatim} frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\end{verbatim}
2579
2580 where - \texttt{\mbox{$<$}SLOT\mbox{$>$}} is the number of the slot that will be rejected. If it is 0, no slot will be rejected, - \texttt{\mbox{$<$}MASK\mbox{$>$}} is a number specifying which bits of the \texttt{\mbox{$<$}SLOT\mbox{$>$}} will be ignored,- \texttt{\mbox{$<$}DEPTH\mbox{$>$}} is a number specifying the depth of the FIFO, - \texttt{\mbox{$<$}CHN\mbox{$>$}} is one of 'A', 'B' or 'AB' and identifies the used channel, - \texttt{\mbox{$<$}CYC\mbox{$>$}} is the cycle set when to send the buffer, - \texttt{\mbox{$<$}MAX\mbox{$>$}} is the number determining the maximum payload (in hald-words), - \texttt{\mbox{$<$}REJNULL\mbox{$>$}} is a string \"{}rejnull\"{} for rejecting NULL frames or \"{}accnull\"{} for accepting NULL frames, - \texttt{\mbox{$<$}REJSTAT\mbox{$>$}} is a string \"{}rejstat\"{} for rejecting frames in static segment or \"{}accstat\"{} for accepting frames from static segment,
2581
2582 \subsubsection{Description}
2583
2584
2585 The command sets the configuration parameters for RX FIFO buffer in user configuration. The parameters set by this command are applied by the frbtinitU command. Once frbtinit is called, it is no longer possible to change the parameters. Those messages, which are not accepted by any other buffer and pass the FIFO rejection filter will be stored in the RX FIFO buffer.
2586
2587 \subsubsection{Example}
2588
2589 \begin{verbatim} --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat
2590 frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\end{verbatim}
2591
2592 \subsection{frbtchecktx*}
2593
2594
2595 Print the status of the transmit buffer
2596
2597 \subsubsection{Command syntax}
2598
2599 \begin{verbatim} frbtchecktx<FRID>\end{verbatim}
2600
2601 where \texttt{\mbox{$<$}FRID\mbox{$>$}} is a decimal number specifying the ID of the frame for which a buffer has been configured.
2602
2603 \subsubsection{Description}
2604
2605
2606 The command stands for Fr\_CheckTxLPduStatus function from the Autosar specification. The command finds the first buffer assigned to the specified frame ID, reads its status and prints it. The buffer can be in one of the two states:
2607 \begin{itemize}
2608 \item Message transmission is pending, which means that the buffer has not yet sent its message in single shot mode or that it is in continuous mode.
2609 \item No message transmission is pending, which means that the buffer is in single shot mode and the message has already been sent.
2610 \end{itemize}
2611
2612 \subsubsection{Example}
2613
2614 \begin{verbatim} --> frbtchecktx1
2615 Message transmission is not pending.\end{verbatim}
2616
2617 \subsection{frbtchstat}
2618
2619
2620 Print channel A and B status
2621
2622 \subsubsection{Command syntax}
2623
2624 \begin{verbatim} frbtchstat\end{verbatim}
2625
2626 \subsubsection{Description}
2627
2628
2629 The command stands for Fr\_GetChannelStatus function from the Autosar specification.
2630
2631 \subsubsection{Example}
2632
2633 \begin{verbatim} --> frbtchstat
2634 Channel A status:
2635     aggregated channel status vSS!ValidFrame: TRUE
2636     aggregated channel status vSS!SyntaxError: FALSE
2637     aggregated channel status vSS!ContentError: FALSE
2638     aggregated channel status additional communication: FALSE
2639     aggregated channel status vSS!Bviolation: FALSE
2640     aggregated channel status vSS!TxConflict: FALSE
2641     Not used (0): FALSE
2642     Not used (0): FALSE
2643     symbol window status data vSS!ValidMTS: FALSE
2644     symbol window status data vSS!SyntaxError: FALSE
2645     symbol window status data vSS!Bviolation: FALSE
2646     symbol window status data vSS!TxConflict: FALSE
2647     NIT status data vSS!SyntaxError: FALSE
2648     NIT status data vSS!Bviolation: FALSE
2649     Not used (0): FALSE
2650     Not used (0): FALSE
2651 Channel B status:
2652     aggregated channel status vSS!ValidFrame: TRUE
2653     aggregated channel status vSS!SyntaxError: FALSE
2654     aggregated channel status vSS!ContentError: FALSE
2655     aggregated channel status additional communication: FALSE
2656     aggregated channel status vSS!Bviolation: FALSE
2657     aggregated channel status vSS!TxConflict: FALSE
2658     Not used (0): FALSE
2659     Not used (0): FALSE
2660     symbol window status data vSS!ValidMTS: FALSE
2661     symbol window status data vSS!SyntaxError: FALSE
2662     symbol window status data vSS!Bviolation: FALSE
2663     symbol window status data vSS!TxConflict: FALSE
2664     NIT status data vSS!SyntaxError: FALSE
2665     NIT status data vSS!Bviolation: FALSE
2666     Not used (0): FALSE
2667     Not used (0): FALSE\end{verbatim}
2668
2669 \subsection{frbtclkcor}
2670
2671
2672 Print clock correction (rate and offset)
2673
2674 \subsubsection{Command syntax}
2675
2676 \begin{verbatim} frbtclkcor\end{verbatim}
2677
2678 \subsubsection{Description}
2679
2680
2681 The command stands for Fr\_GetClockCorrection function from the Autosar specification.
2682
2683 \subsubsection{Example}
2684
2685 \begin{verbatim} --> frbtclkcor
2686 Rate correction: 0
2687 Offset correction: 0\end{verbatim}
2688
2689 \subsection{frbtconfig*}
2690
2691
2692 Set the user configuration parameters
2693
2694 \subsubsection{Command syntax}
2695
2696 \begin{verbatim} frbtconfig<TYPE> <PARAMS>\end{verbatim}
2697
2698 where
2699 \begin{itemize}
2700 \item \texttt{\mbox{$<$}TYPE\mbox{$>$}} is a string specifying the type of parameters to be set. It can be: \"{}cluster\"{} or \"{}node\"{}
2701 \item \texttt{\mbox{$<$}PARAMS\mbox{$>$}} is a sequence of numbers separated by spaces. Each number stands for one parameter.
2702 \end{itemize}
2703
2704 \subsubsection{Description}
2705
2706
2707 The command takes the configuration parameters in the form of a string and sets the appropriate type of the FlexRay parameters. It is necessary to configure parameters of at least cluster, and node and one static buffer (see frbtcfgbuf command). The parameters set by this command are applied by the frbtinitU command. Once frbtinit is called, it is no longer possible to change the parameters.
2708
2709 The type of the parameters can be selected by the \texttt{\mbox{$<$}TYPE\mbox{$>$}} selector.
2710
2711 Type \"{}cluster\"{} sets global FlexRay network parameters. It expects a sequence of 25 parameters in this order:
2712 \begin{itemize}
2713 \item 1) gColdStartAttempts
2714 \item 2) gListenNoise
2715 \item 3) gMacroPerCycle
2716 \item 4) gMaxWithoutClockCorrectionFatal
2717 \item 5) gMaxWithoutClockCorrectionPassive
2718 \item 6) gNetworkManagementVectorLength
2719 \item 7) gNumberOfMinislots
2720 \item 8) gNumberOfStaticSlots
2721 \item 9) gOffsetCorrectionStart
2722 \item 10) gPayloadLengthStatic
2723 \item 11) gSyncNodeMax
2724 \item 12) gdActionPointOffset
2725 \item 13) gdCASRxLowMax
2726 \item 14) gdDynamicSlotIdlePhase
2727 \item 15) gdMinislot
2728 \item 16) gdMinislotActionPointOffset
2729 \item 17) gdNIT
2730 \item 18) gdSampleClockPeriod
2731 \item 19) gdStaticSlot
2732 \item 20) gdTSSTransmitter
2733 \item 21) gdWakeupSymbolRxIdle
2734 \item 22) gdWakeupSymbolRxLow
2735 \item 23) gdWakeupSymbolRxWindow
2736 \item 24) gdWakeupSymbolTxIdle
2737 \item 25) gdWakeupSymbolTxLow
2738 \end{itemize}
2739
2740 Type \"{}node\"{} sets local FlexRay network parameters. It expects a sequence of 28 parameters in this order:
2741 \begin{itemize}
2742 \item 1) pAllowHaltDueToClock
2743 \item 2) pAllowPassiveToActive
2744 \item 3) pChannels (0 - A, 1 - B, 2 - AB)
2745 \item 4) pClusterDriftDamping
2746 \item 5) pDelayCompensationA
2747 \item 6) pDelayCompensationB
2748 \item 7) pExternOffsetCorrection
2749 \item 8) pExternRateCorrection
2750 \item 9) pKeySlotUsedForStartup
2751 \item 10) pKeySlotUsedForSync
2752 \item 11) pLatestTx
2753 \item 12) pMacroInitialOffsetA
2754 \item 13) pMacroInitialOffsetB
2755 \item 14) pMicroInitialOffsetA
2756 \item 15) pMicroInitialOffsetB
2757 \item 16) pMicroPerCycle
2758 \item 17) pRateCorrectionOut
2759 \item 18) pOffsetCorrectionOut
2760 \item 19) pSamplesPerMicrotick
2761 \item 20) pSingleSlotEnabled
2762 \item 21) pWakeupChannel (0 - A, 1 - B)
2763 \item 22) pWakeupPattern
2764 \item 23) pdAcceptedStartupRange
2765 \item 24) pdListenTimeout
2766 \item 25) pdMaxDrift
2767 \item 26) pDecodingCorrection
2768 \item 27) syncFramePayloadMultiplexEnabled
2769 \item 28) secureBuffers (0 - FR\emph{SB}RECONFIG\emph{ENABLED, 1 - FR}SB\emph{STAT}REC\emph{DISABLED}STAT\emph{TR}DISABLED, 2 - FR\emph{SB}ALL\emph{REC}DISABLED, 3 - FR\emph{SB}ALL\emph{REC}DISABLED\emph{STAT}TR\_DISABLED)
2770 \end{itemize}
2771
2772 \subsubsection{Example}
2773
2774 \begin{verbatim} --> frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
2775 FlexRay cluster configuration accepted.
2776 --> frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
2777 FlexRay node configuration accepted.\end{verbatim}
2778
2779 \subsection{frbtdisable*}
2780
2781
2782 Disable the buffers assigned to the frame
2783
2784 \subsubsection{Command syntax}
2785
2786 \begin{verbatim} frbtdisable<FRID>\end{verbatim}
2787
2788 where \texttt{\mbox{$<$}FRID\mbox{$>$}} is a decimal number specifying the ID of a frame. The buffers configure for this frame will be disabled.
2789
2790 \subsubsection{Description}
2791
2792
2793 The command stands for Fr\_DisableLPdu function from the Autosar specification. The command finds all buffers assigned to the specified frame ID and disables them. This means that those buffers will be unavailable for the communication until their reconfiguration (which is not yet implemented). Buffers used for startup frames and FIFO RX buffers cannot be disabled.
2794
2795 \subsubsection{Example}
2796
2797 \begin{verbatim} --> frbtdisable3
2798 Buffer disabled.\end{verbatim}
2799
2800 \subsection{frbtgetpocst}
2801
2802
2803 Print FlexRay POC status
2804
2805 \subsubsection{Command syntax}
2806
2807 \begin{verbatim} frbtgetpocst\end{verbatim}
2808
2809 \subsubsection{Description}
2810
2811
2812 The command stands for Fr\_GetPOCStatus function from the Autosar specification. It prints the main FlexRay POC status values in the form of a table. The command should be called after the frbtinit command.
2813
2814 \subsubsection{Example}
2815
2816 \begin{verbatim} --> frbtgetpocst
2817 POC status:
2818 CHIHaltRequest: FALSE
2819 CHIReadyRequest: FALSE
2820 ColdstartNoise: FALSE
2821 Freeze: FALSE
2822 ErrorMode: ACTIVE
2823 SlotMode: ALL
2824 StartupState: UNDEFINED
2825 State: READY
2826 WakeupStatus: UNDEFINED\end{verbatim}
2827
2828 \subsection{frbtgetsyncfrlist*}
2829
2830
2831 Print the list of sync frames transmitted on both channels via the odd and even communication cycle
2832
2833 \subsubsection{Command syntax}
2834
2835 \begin{verbatim} frbtgetsyncfrlist<LENGTH>\end{verbatim}
2836
2837 where \texttt{\mbox{$<$}LENGTH\mbox{$>$}} is a decimal number in range 0 - 15, specifying the length of the list to be printed.
2838
2839 \subsubsection{Description}
2840
2841
2842 The command stands for Fr\_GetSyncFrameList function from the Autosar specification.
2843
2844 \subsubsection{Example}
2845
2846 \begin{verbatim} --> frbtgetsyncfrlist2
2847 | Channel A even | channel B even | channel A odd  | channel B odd  |
2848 |----------------|----------------|----------------|----------------|
2849 | 1              | 1              | 1              | 1              |
2850 | 2              | 2              | 2              | 2              |
2851 |----------------|----------------|----------------|----------------|\end{verbatim}
2852
2853 \subsection{frbtgetwurxstat}
2854
2855
2856 Prints whether the wake up pattern has been or has not been received
2857
2858 \subsubsection{Command syntax}
2859
2860 \begin{verbatim} frbtgetwurxstat\end{verbatim}
2861
2862 \subsubsection{Description}
2863
2864
2865 The command stands for Fr\_GetWakeupRxStatus function from the Autosar specification. The status of the wake up receiving is bitcoded in the controller. This command decodes and prints it in a readable format.
2866
2867 \subsubsection{Example}
2868
2869 \begin{verbatim} --> frbtgetwurxstat
2870 Wake up pattern was not yet received on channel A.
2871 Wake up pattern was not yet received on channel B.\end{verbatim}
2872
2873 \subsection{frbtglobtime}
2874
2875
2876 Print actual global time of the network
2877
2878 \subsubsection{Command syntax}
2879
2880 \begin{verbatim} frbtglobtime\end{verbatim}
2881
2882 \subsubsection{Description}
2883
2884
2885 The command stands for Fr\_GetGlobalTime function from the Autosar specification. The command prints the time as a number of the current cycle and the offset in the cycle in macroticks.
2886
2887 \subsubsection{Example}
2888
2889 \begin{verbatim} --> frbtglobtime
2890 Cycle number: 23
2891 Macrotick number: 6\end{verbatim}
2892
2893 \subsection{frbthalt}
2894
2895
2896 Halt FlexRay communication after the end of the actual communication cycle
2897
2898 \subsubsection{Command syntax}
2899
2900 \begin{verbatim} frbthalt\end{verbatim}
2901
2902 \subsubsection{Description}
2903
2904
2905 The command stands for Fr\_HaltCommunication function from the Autosar specification. The command invokes the FlexRay POC command HALT, which means that communication is stopped after the end of the actual communication cycle. On the opposite side, there is a frbtfreeze command, which stops the communication immediately. To restart the communication, the frbtinit and frbtstart commands have to be called.
2906
2907 \subsubsection{Example}
2908
2909 \begin{verbatim} --> frbthalt
2910 FlexRay node communication halted.\end{verbatim}
2911
2912 \subsection{frbtinit?}
2913
2914
2915 Initialize a FlexRay node
2916
2917 \subsubsection{Command syntax}
2918
2919 \begin{verbatim} frbtinit<CFG>\end{verbatim}
2920
2921 where \texttt{\mbox{$<$}CFG\mbox{$>$}} identifies the configuration to use. It can be one of A, B or U. The A and B are predefined configurations. If U is specified, the user configuration previously set by frbtconfig command is used.
2922
2923 \subsubsection{Description}
2924
2925
2926 The command stands for Fr\emph{Init and Fr}ControllerInit functions from the Autosar specification. It initializes the internal data structures of the driver and then, based on those data, the controller configuration is done. During the controller configuration the parameters of the cluster, node, message RAM and buffers are checked. If anything goes bad, the command returns an error number, which can be decoded by macros defined in driver header file fr\emph{tms570.h with prefix ERR}PARAM. If all parameters are OK, all necessary registers of the controller are initialized according to the specified configuration parameters. At the end of the command, the FlexRay controller is switched into READY state and all buffers are configured to send NULL frames. This command should be called as the very first command, when trying to communicate over the FlexRay bus.
2927
2928 \subsubsection{Example}
2929
2930 \begin{verbatim} --> frbtinitA
2931 FlexRay driver initialized.
2932 FlexRay controller initialized.\end{verbatim}
2933
2934 \subsection{frbtnmvector}
2935
2936
2937 Print network management vector of the node
2938
2939 \subsubsection{Command syntax}
2940
2941 \begin{verbatim} frbtnmvector\end{verbatim}
2942
2943 \subsubsection{Description}
2944
2945
2946 The command stands for Fr\_GetNmVector function from the Autosar specification. It prints the values of the network management vector as hexadecimal numbers.
2947
2948 \subsubsection{Example}
2949
2950 \begin{verbatim} --> frbtnmvector
2951 Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\end{verbatim}
2952
2953 \subsection{frbtnmwatch}
2954
2955
2956 Watch the changes of the network managment vector in real-time
2957
2958 \subsubsection{Command syntax}
2959
2960 \begin{verbatim} frbtnmwatch\end{verbatim}
2961
2962 \subsubsection{Description}
2963
2964
2965 Reads the network management vector every 100 ms and prints it out.
2966
2967 \subsubsection{Example}
2968
2969 \begin{verbatim} --> frbtnmwatch
2970 Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\end{verbatim}
2971
2972 \subsection{frbtreceive*}
2973
2974
2975 Receive a new message
2976
2977 \subsubsection{Command syntax}
2978
2979 \begin{verbatim} frbtreceive<FRID>\end{verbatim}
2980
2981 where \texttt{\mbox{$<$}FRID\mbox{$>$}} is a decimal number specifying the ID of the frame for which a buffer was configured.
2982
2983 \subsubsection{Description}
2984
2985
2986 The command stands for Fr\_ReceiveRxLPdu function from the Autosar specification. The command finds the first buffer assigned to the specified frame ID, determines if a new message has been received and reads it out of the buffer. If no message was received, \"{}No message received\"{} is printed. If a new message was received, all message data are printed as a hexadecimal values. If a new message was retrieved from a FIFO buffer and more messages are available in it, \"{}More messages are still in FIFO\"{} is printed.
2987
2988 \subsubsection{Example}
2989
2990 \begin{verbatim} --> frbtreceive0
2991 More messages are still in FIFO:
2992 Received message (32 B):
2993  ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\end{verbatim}
2994
2995 \subsection{frbtreconfigurebuf*}
2996
2997
2998 Reconfigure a buffer to communicate in another slot
2999
3000 \subsubsection{Command syntax}
3001
3002 \begin{verbatim} frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\end{verbatim}
3003
3004 where
3005 \begin{itemize}
3006 \item \texttt{\mbox{$<$}ID\mbox{$>$}} is a number specifying a slot, where the buffer is currently communicating,
3007 \item \texttt{\mbox{$<$}SLOT\mbox{$>$}} is a number, where buffer will be communicating after the reconfiguration,
3008 \item \texttt{\mbox{$<$}CHN\mbox{$>$}} is one of 'A', 'B' or 'AB' and identifies the used channel,
3009 \item \texttt{\mbox{$<$}CYCS\mbox{$>$}} is the cycle set. It has to be one of 0, 1, 2, 4, 8, 16, 32, 64. It specifies together with \texttt{\mbox{$<$}CYCO\mbox{$>$}} the cycle filtering.
3010 \item \texttt{\mbox{$<$}CYCO\mbox{$>$}} is the cycle offset. It has to be in range 0 - \texttt{\mbox{$<$}CYCS\mbox{$>$}}-1- \texttt{\mbox{$<$}MAX\mbox{$>$}} is the number determining the maximum payload (in hald-words).
3011 \end{itemize}
3012
3013 \subsubsection{Description}
3014
3015
3016 The command stands for Fr\_ReconfigLPDu function from the Autosar specification. It reconfigures specified buffer to communicate in different slot. The reconfiguration must be allowed in node configuration parameter secureBuffers. Buffers used for synchronization or assigned to the FIFO are not reconfigurable. The command can be called any time when the communication is running.
3017
3018 \subsubsection{Example}
3019
3020 \begin{verbatim} --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9
3021 frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\end{verbatim}
3022
3023 \subsection{frbtsettimer*}
3024
3025
3026 Set and start timer
3027
3028 \subsubsection{Command syntax}
3029
3030 \begin{verbatim} frbtsettimer<TMID> <CYCLE> <OFFSET>\end{verbatim}
3031
3032 where
3033 \begin{itemize}
3034 \item \texttt{\mbox{$<$}TMID\mbox{$>$}} is a number (0, 1) specifying the timer.
3035 \item \texttt{\mbox{$<$}CYCLE\mbox{$>$}} is a 7-bit number (0 - 127) specifying the set of cycles, in which timer interrupt should be requested. The first set bit determines the period (1, 2, ..., 64) and the lower bits determine the offset in cycles within the period.
3036 \item \texttt{\mbox{$<$}OFFSET\mbox{$>$}} is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.
3037 \end{itemize}
3038
3039 \subsubsection{Description}
3040
3041
3042 The command is similar to Fr\_SetAbsoluteTimer function from the Autosar specification. The difference is that the command allows to specify a set of cycles, not only one of 64 cycles. It sets the timer selected by the parameter and enables it.
3043
3044 Before using this command, FlexRay communication has to be started (see frbtstart).
3045
3046 \subsubsection{Example}
3047
3048 \begin{verbatim} --> frbtsettimer0 32 50
3049 Timer was set for every 32-th cycle, offset 0, macrotick 50
3050 --> frbtsettimer0 31 50
3051 Timer was set for every 16-th cycle, offset 15, macrotick 50
3052 --> frbtsettimer0 0x42 0
3053 Timer was set for every 64-th cycle, offset 2, macrotick 0\end{verbatim}
3054
3055 \subsection{frbtsetwuch?}
3056
3057
3058 Set wake up channel
3059
3060 \subsubsection{Command syntax}
3061
3062 \begin{verbatim} frbtsetwuch<CHANNEL>\end{verbatim}
3063
3064 where \texttt{\mbox{$<$}CHANNEL\mbox{$>$}} is a character A or B, specifying the channel.
3065
3066 \subsubsection{Description}
3067
3068
3069 The command stands for Fr\_SetWakeupChannel function from the Autosar specification. Wake up channel is the channel, where Wake Up Pattern is sent. The channel can be set after the driver and controller are initialized and before the communication is running. The actual wake-up pattern is sent by the frbtwup command.
3070
3071 \subsubsection{Example}
3072
3073 \begin{verbatim} --> frbtsetwuchA
3074 Wake up channel has been set.\end{verbatim}
3075
3076 \subsection{frbtstart}
3077
3078
3079 Start a new FlexRay network or join to the existing one
3080
3081 \subsubsection{Command syntax}
3082
3083 \begin{verbatim} frbtstart\end{verbatim}
3084
3085 \subsubsection{Description}
3086
3087
3088 The command stands for Fr\_StartCommunication function from the Autosar specification. If the FlexRay node is configured as a coldstarter node (as for example by frbtinitA/B command), then the command first listen on the bus. When it does not detect any existing bus communication, it tries to initiate a new network. If the initiation fails, the FlexRay controller is switched back to the ready state for another attempt (calling frbtstart again). If the FlexRay node is configured as non-coldstarter, it is listening on the bus until some existing communication is detected.
3089
3090 The command should be called after the frbtinit command.
3091
3092 \subsubsection{Example}
3093
3094 \begin{verbatim} --> frbtstart
3095 FlexRay communication is running.\end{verbatim}
3096
3097 \subsection{frbttimerirq*}
3098
3099
3100 Perform selected action on the timer IRQ
3101
3102 \subsubsection{Command syntax}
3103
3104 \begin{verbatim} frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer
3105 frbttimerirq<TMID> - Get timer IRQ status\end{verbatim}
3106
3107 where
3108 \begin{itemize}
3109 \item \texttt{\mbox{$<$}TMID\mbox{$>$}} is a number (0, 1) specifying the timer.
3110 \item where \texttt{\mbox{$<$}ACTION\mbox{$>$}} is a string specifying the action to be performed on the selected timer IRQ.
3111 \end{itemize}
3112
3113 \texttt{\mbox{$<$}ACTIONS\mbox{$>$}} can be one of:
3114 \begin{itemize}
3115 \item EN - Enable the IRQ on the selected timer
3116 \item DIS - Disable the IRQ on the selected timer
3117 \item ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).
3118 \end{itemize}
3119
3120 \subsubsection{Description}
3121
3122
3123 The command stands for Fr\emph{EnableAbsoluteTimerIRQ, Fr}AckAbsoluteTimerIRQ, Fr\emph{DisableAbsoluteTimerIRQ and Fr}GetAbsoluteTimerIRQStatus functions from the Autosar specification. It masks or demasks the IRQ for the timer, or acknowledges the interrupt request. If no action is specified it prints whether the IRQ is pending for the timer.
3124
3125 \subsubsection{Example}
3126
3127 \begin{verbatim} --> frbttimerirq0
3128 IRQ = FALSE
3129
3130 --> frbttimerirq0 EN
3131 OK\end{verbatim}
3132
3133 \subsection{frbttransmit*}
3134
3135
3136 Transmit data in selected frame
3137
3138 \subsubsection{Command syntax}
3139
3140 \begin{verbatim} frbttransmit<FRID> <DATA>\end{verbatim}
3141
3142 where
3143 \begin{itemize}
3144 \item \texttt{\mbox{$<$}FRID\mbox{$>$}} is a decimal number specifying the ID of the frame for which a buffer has been configured.
3145 \item \texttt{\mbox{$<$}DATA\mbox{$>$}} is a sequence of hexadecimal numbers separated by spaces. Each number represents one byte of the message.
3146 \end{itemize}
3147
3148 \subsubsection{Description}
3149
3150
3151 The command stands for Fr\_TransmitTxLPdu function from the Autosar specification. The command finds the first buffer assigned to the specified frame ID and copies the given data into its data section in the message RAM. Transmit request is set after the data are copied, so transmission starts at the next occurrence of the frame in the communication cycle.
3152
3153 \subsubsection{Example}
3154
3155 \begin{verbatim} --> frbttransmit1 12 34 56 AA BB CC
3156 Data were set for transmission.\end{verbatim}
3157
3158 \subsection{frbtversion}
3159
3160
3161 Print FlexRay driver version information
3162
3163 \subsubsection{Command syntax}
3164
3165 \begin{verbatim} frbtversion\end{verbatim}
3166
3167 \subsubsection{Description}
3168
3169
3170 The command stands for Fr\_GetVersionInfo function from the Autosar specification. It reads and prints the information about vendor, module and version of the FlexRay driver
3171
3172 \subsubsection{Example}
3173
3174 \begin{verbatim} --> frbtversion
3175 vendorID: 0xAAAA
3176 moduleID: 0xBBBB
3177 sw_major_version: 0x1
3178 sw_minor_version: 0x2
3179 sw_patch_version: 0x4\end{verbatim}
3180
3181 \subsection{frbtwup}
3182
3183
3184 Initiate the wake up procedure
3185
3186 \subsubsection{Command syntax}
3187
3188 \begin{verbatim} frbtwup\end{verbatim}
3189
3190 \subsubsection{Description}
3191
3192
3193 The command stands for Fr\_SendWUP function from the Autosar specification. It initiates the wake up procedure by switching FlexRay controller state machine to WAKEUP state.
3194
3195 \subsubsection{Example}
3196
3197 \begin{verbatim} --> frbtwup
3198 Wake up pattern has been sent.\end{verbatim}
3199
3200 \subsection{hbrcontrol*}
3201
3202
3203 Set the motor voltage direction and size in percent
3204
3205 \subsubsection{Command syntax}
3206
3207 \begin{verbatim} hbrcontrol<SPEED>\end{verbatim}
3208
3209 where \texttt{\mbox{$<$}SPEED\mbox{$>$}} specifies direction and PWM duty cycle in percent (a number in range -100, 100).
3210
3211 \subsubsection{Description}
3212
3213
3214 The command sets the direction and the size of the voltage at the HBR output.
3215
3216 HBR has to be enabled by the \texttt{hbrenable} command before calling this command.
3217
3218 \subsubsection{Examples}
3219
3220 \begin{verbatim} --> hbrcontrol-25
3221 hbrcontrol =-25\end{verbatim}
3222
3223 Rotates the motor to the left with 25\% duty cycle.
3224 \begin{verbatim} --> hbrcontrol25
3225 hbrcontrol =25\end{verbatim}
3226
3227 Rotates the motor to the right with 25\% duty cycle.
3228 \begin{verbatim} --> hbrcontrol0
3229 hbrcontrol =0\end{verbatim}
3230
3231 Stops the motor, but the H-Bridge output is active (low-side active free wheeling).
3232
3233 \subsection{hbrdisable}
3234
3235
3236 Disable the H-bridge
3237
3238 \subsubsection{Command syntax}
3239
3240 \begin{verbatim} hbrdisable\end{verbatim}
3241
3242 \subsubsection{Description}
3243
3244
3245 The command disables the H-bridge HBR, which means that the PWM is stopped and the enable signal is cleared. The watchdog task is left running, because it is harmless.
3246
3247 After the H-bridge is disabled, it cannot be controlled by any command until it is enabled again by the \texttt{hbrenable} command.
3248
3249 \subsubsection{Example}
3250
3251 \begin{verbatim} --> hbrdisable
3252 hbrdisable=0\end{verbatim}
3253
3254 Stops motor and disables the H-bridge.
3255
3256 \subsection{hbrenable*}
3257
3258
3259 Enable the H-bridge and set its PWM period
3260
3261 \subsubsection{Command syntax}
3262
3263 \begin{verbatim} hbrenable<PER>\end{verbatim}
3264
3265 where \texttt{\mbox{$<$}PER\mbox{$>$}} is PWM period in microseconds.
3266
3267 \subsubsection{Description}
3268
3269
3270 This command enables the H-bridge (HBR pin), i.e. the enable signal the H-bridge chip is set, the watchdog reset task is started and the PWM is configured with the specified period and duty cycle 0\%.
3271
3272 If the period is zero, the default frequency of 18kHz is used instead. Minimum period is 50. This command should be called before any other command starting with hbr is used. If H-bridge is already enabled, an error is printed.
3273
3274 \subsubsection{Example}
3275
3276 \begin{verbatim} --> hbrenable1000
3277 hbrenable =1000\end{verbatim}
3278
3279 Enables HBR with period 1000 microseconds (frequency 1 kHz). HBR output is still inactive, but ready for other commands.
3280
3281 \subsection{help}
3282
3283
3284 Print help for commands
3285
3286 \subsubsection{Syntax}
3287
3288
3289 help \mbox{$[$}command\mbox{$]$}
3290
3291 \subsubsection{Description}
3292
3293
3294 This command without parameter prints the list of all available commands with short help text for each of them. If a parameter is provided, the command prints a long description for given command.
3295
3296 \subsection{houtfail*}
3297
3298
3299 Test if some HOUT pin is in the fault state
3300
3301 \subsubsection{Command syntax}
3302
3303 \begin{verbatim} houtfail<PIN>\end{verbatim}
3304
3305 where \texttt{\mbox{$<$}PIN\mbox{$>$}} is in range 1-6
3306
3307 \subsubsection{Description}
3308
3309
3310 This command tests, if HOUT pin is in a good condition. When the circuit controlling HOUT pin detects some failure, it signals that on HOUT\_DIAG output. This command is supposed to read this output and print its state.
3311
3312 Possible outputs of this command:
3313 \begin{itemize}
3314 \item OK - no failure detected
3315 \item FAIL - a failure detected
3316 \item NOT RUNNING - PWM was set set up and started
3317 \end{itemize}
3318
3319 Note: Before using this command, houtpwmstart and houtpwm commands should be called.
3320
3321 \subsubsection{Example}
3322
3323 \begin{verbatim} --> houtpwm6 1000 25
3324 --> houtpwmstart6
3325 --> houtfail6
3326 OK\end{verbatim}
3327
3328 Detects the state of the HOUT1 and prints OK, FAIL or NOT RUNNING.
3329
3330 \subsection{houtifbk}
3331
3332
3333 Read values from HOUT current feedback
3334
3335 \subsubsection{Command syntax}
3336
3337 \begin{verbatim} houtifbk\end{verbatim}
3338
3339 \subsubsection{Description}
3340
3341
3342 The command reads analog values from HOUT\_IFBK pins and prints them in a table.
3343
3344 \subsubsection{Example}
3345
3346
3347 --\mbox{$>$} houtifbk HOUT1: 0 HOUT2: 134223784 HOUT3: 134223784 HOUT4: 0 HOUT5: 38924 HOUT6: 1342231444
3348
3349 \subsection{houtpwm*}
3350
3351
3352 Set or get actual PWM parameters
3353
3354 \subsubsection{Command syntax}
3355
3356 \begin{verbatim} houtpwm<PIN> <PER> <DUTY>
3357 houtpwm<PIN>\end{verbatim}
3358
3359 where
3360 \begin{itemize}
3361 \item \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-6
3362 \item \texttt{\mbox{$<$}PER\mbox{$>$}} is a length of the PWM period in microseconds
3363 \item \texttt{\mbox{$<$}DUTY\mbox{$>$}} is a the PWM duty cycle in percent (0-100)
3364 \end{itemize}
3365
3366 \subsubsection{Description}
3367
3368
3369 This command can be used to set or get HOUT PWM parameters.
3370
3371 \subsubsection{Example}
3372
3373 \begin{verbatim} --> houtpwm1 1000 25\end{verbatim}
3374
3375 HOUT1 PWM will have the period of 1ms and will be active for 25\% of this period.
3376 \begin{verbatim} --> houtpwm1
3377 houtpwm1_period=1000
3378 houtpwm1_duty=25\end{verbatim}
3379
3380 Prints the actual period of HOUT1 PWM in microseconds and the duty cycle in percents.
3381
3382 \subsection{houtstartpwm*}
3383
3384
3385 Start generating PWM signal on HOUT
3386
3387 \subsubsection{Command syntax}
3388
3389 \begin{verbatim} houtstartpwm<PIN>\end{verbatim}
3390
3391 where \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-6
3392
3393 \subsubsection{Description}
3394
3395
3396 This command starts to generate the PWM signal on the specified HOUT pin. The HOUT PWM has to be previously set by the houtpwm command, otherwise an error is printed.
3397
3398 \subsubsection{Example}
3399
3400 \begin{verbatim} --> houtpwm1 1000 25
3401 --> houtstartpwm1\end{verbatim}
3402
3403 HOUT1 PWM generation will be started.
3404
3405 \subsection{houtstoppwm*}
3406
3407
3408 Stop generating of PWM signal on HOUT
3409
3410 \subsubsection{Command syntax}
3411
3412 \begin{verbatim} houtstoppwm<PIN>\end{verbatim}
3413
3414 where \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-6
3415
3416 \subsubsection{Description}
3417
3418
3419 This command stops generating the PWM signal on the selected pin.
3420
3421 \subsubsection{Example}
3422
3423 \begin{verbatim} --> houtstoppwm1\end{verbatim}
3424
3425 HOUT1 PWM generation will be deactivated.
3426
3427 \subsection{lintest}
3428
3429
3430 Test the digital loopback on LIN
3431
3432 \subsubsection{Command syntax}
3433
3434 \begin{verbatim} lintest\end{verbatim}
3435
3436 \subsubsection{Description}
3437
3438
3439 This command can be used for testing the LIN. The command starts to send a short message on the LIN port and is testing if it is correctly received via an internal loopback.
3440
3441 \subsection{loutdiag*}
3442
3443
3444 Read a diagnostic value from an LOUT pin
3445
3446 \subsubsection{Command syntax}
3447
3448 \begin{verbatim} loutdiag<PIN>\end{verbatim}
3449
3450 where \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-8
3451
3452 \subsubsection{Description}
3453
3454
3455 The command reads a logical value of the LOUT diagnostic signal.
3456
3457 \subsubsection{Example}
3458
3459 \begin{verbatim} --> loutdiag1\end{verbatim}
3460
3461 Reads value of the LOUT1 diagnostic signal.
3462
3463 \subsection{loutset*}
3464
3465
3466 Set a value of the LOUT pin
3467
3468 \subsubsection{Command syntax}
3469
3470 \begin{verbatim} loutset<PIN> <VALUE>\end{verbatim}
3471
3472 where
3473 \begin{itemize}
3474 \item \texttt{\mbox{$<$}PIN\mbox{$>$}} is a number in range 1-8
3475 \item \texttt{\mbox{$<$}VALUE\mbox{$>$}} is a binary value to be set (0 or 1)
3476 \end{itemize}
3477
3478 \subsubsection{Description}
3479
3480
3481 The command sets the digital value on the LOUT pin.
3482
3483 \subsubsection{Example}
3484
3485 \begin{verbatim} --> loutset1 1\end{verbatim}
3486
3487 Sets LOUT1 to 1.
3488 \begin{verbatim} --> loutset2 0\end{verbatim}
3489
3490 Sets LOUT2 to 0.
3491
3492 \subsection{pindir*}
3493
3494
3495 Set the pin direction
3496
3497 \subsubsection{Command syntax}
3498
3499 \begin{verbatim} pindir<NAME> <DIR>
3500 pindir<NAME>\end{verbatim}
3501
3502 where
3503 \begin{itemize}
3504 \item \texttt{\mbox{$<$}NAME\mbox{$>$}} is a string identifying the pin
3505 \item DIR is be either 0 (input) or 1 (output)
3506 \end{itemize}
3507
3508 \subsubsection{Description}
3509
3510
3511 This command is used to set or get direction of the particular pin.
3512
3513 The list of valid pin names can be obtained with pinlist command.
3514
3515 Most of the pins are accessible indirectly via other highlevel commands HBR\_EN is, for example, controlled by the hbrenable command. This command serves as supplement to highlevel commands for testing purpose.
3516
3517 \subsubsection{Example}
3518
3519 \begin{verbatim} --> pindirHBREN 1
3520 pindirHBREN=1\end{verbatim}
3521
3522 Sets the HBR\_EN pin as output.
3523 \begin{verbatim} --> pindirHBREN
3524 pindirHBREN=1\end{verbatim}
3525
3526 Gets the direction of the HBR\_EN pin.
3527
3528 \subsection{pinlist}
3529
3530
3531 Print a list of all defined pins.
3532
3533 \subsubsection{Command syntax}
3534
3535 \begin{verbatim} pinlist\end{verbatim}
3536
3537 \subsubsection{Description}
3538
3539
3540 The command prints a list of all defined pins accessible by pinval and pindir commands.
3541
3542 \subsubsection{Example}
3543
3544 \begin{verbatim} --> pinlist
3545 List of all defined pins. Those names can be used by pinval command.
3546 FANCTRL
3547 ETHRST
3548 VBAT1EN
3549 VBAT2EN
3550 VBAT3EN
3551 VBATEN
3552 SPICSA
3553 SPICSB
3554 MOUT1EN
3555 MOUT2EN
3556 CANNSTB
3557 CANEN
3558 LIN2NSLP
3559 LIN1NSLP
3560 DININT
3561 DIN8
3562 DIN9
3563 DIN10
3564 DIN11
3565 DIN12
3566 DIN13
3567 DIN14
3568 DIN15
3569 MOUT6EN
3570 MOUT5EN
3571 MOUT6IN
3572 MOUT5IN
3573 MOUT4EN
3574 MOUT3EN
3575 MOUT4IN
3576 MOUT3IN
3577 HBREN
3578 HBRDIR
3579 HBRPWM
3580 MOUT1IN
3581 MOUT2IN
3582 HOUT1IN
3583 HOUT1DIAG
3584 HOUT2IN
3585 HOUT2DIAG
3586 HOUT3IN
3587 HOUT3DIAG
3588 HOUT4IN
3589 HOUT4DIAG
3590 HOUT5IN
3591 HOUT5DIAG
3592 HOUT6IN
3593 HOUT6DIAG\end{verbatim}
3594
3595 \subsection{pinval*}
3596
3597
3598 Set or get the pin value
3599
3600 \subsubsection{Command syntax}
3601
3602 \begin{verbatim} pinval<NAME> <VAL>
3603 pinval<NAME>\end{verbatim}
3604
3605 where
3606 \begin{itemize}
3607 \item \texttt{\mbox{$<$}NAME\mbox{$>$}} is a string identifying the pin
3608 \item \texttt{\mbox{$<$}VAL\mbox{$>$}} can be 0 or 1
3609 \end{itemize}
3610
3611 \subsubsection{Description}
3612
3613
3614 This command is sets or gets a value of the particular pin.
3615
3616 The list of valid pin names can be obtained with pinlist command.
3617
3618 Most of the pins are accessible indirectly via other highlevel commands. HBR\_EN is, for example, controlled by the hbrenable command. This command serves as supplement to highlevel commands for testing purpose.
3619
3620 \subsubsection{Example}
3621
3622 \begin{verbatim} --> pinvalHBREN 1
3623 pinvalHBREN=1\end{verbatim}
3624
3625 Sets the HBR\_EN pin to 1.
3626 \begin{verbatim} --> pinvalHBREN
3627 pinvalHBREN=1\end{verbatim}
3628
3629 Gets a value of the HBR\_EN pin.
3630
3631 \subsection{portlist}
3632
3633
3634 Print a list of all port names
3635
3636 \subsubsection{Command syntax}
3637
3638 \begin{verbatim}  portlist\end{verbatim}
3639
3640 \subsubsection{Description}
3641
3642
3643 This command prints the list of all defined ports accessible via the portval command. Each record of the list is a couple of PortName-PortInterface, where PortInterface is SPI, ADC or GPIO. The type of the MCU\mbox{$<$}-\mbox{$>$}port interface slightly modifies the meaning of the portval command.
3644
3645 \subsubsection{Example}
3646
3647 \begin{verbatim}  --> portlist
3648  List of all defined ports with its type. Those names can be used by portval command.
3649  DINMCU, GPIO
3650  DINSPI, SPI
3651  HOUTDIAG, GPIO
3652  HOUTIN, GPIO
3653  HOUTIFBK, ADC
3654  ADC, ADC
3655  LOUT, SPI
3656  DAC12, SPI
3657  DAC34, SPI
3658  DACDREF, SPI
3659  HBR, SPI
3660  FRAY1, SPI
3661  FRAY2, SPI
3662  MOUTEN, GPIO
3663  MOUTIN, GPIO\end{verbatim}
3664
3665 \subsection{portval*}
3666
3667
3668 Read or write values from or to the port
3669
3670 \subsubsection{Command syntax}
3671
3672 \begin{verbatim}  portval<NAME> <VAL>
3673  portval<NAME>\end{verbatim}
3674
3675 where
3676 \begin{itemize}
3677 \item \texttt{\mbox{$<$}NAME\mbox{$>$}} is a string specifying the name of the port
3678 \item \texttt{\mbox{$<$}VAL\mbox{$>$}} is a sequence of hexadecimal numbers, separated by spaces, e.g. 12 AA CD
3679 \end{itemize}
3680
3681 \subsubsection{Description}
3682
3683
3684 This command sets or gets values of all pins on the specified port. If the port is connected to the GPIO interface of the MCU, then when writing the value, the lowest significant bit of the argument is assigned to the first pin, the second bit is assigned to the second pin, etc. The command returns zero. When reading from the port, the command returns values for each pin.
3685
3686 If the port is connected to the SPI interface of the MCU, then it is write only and the argument is interpreted as a command for the port controller. The command returns the response from the port controller. For command examples please refer to the project wiki
3687
3688 If the port is connected to the ADC interface of the MCU, then it is read only and returns values for each ADC pin.
3689
3690 Port names and interface type can be obtained with the portlist command.
3691
3692 NOTE: For successful communication with the HBR, HBR\_EN pin must be set first.
3693
3694 \subsubsection{Example}
3695
3696 \begin{verbatim}  --> portvalMOUTIN 3A
3697  portvalMOUTIN=0
3698  --> portvalMOUTIN
3699  0
3700  1
3701  0
3702  1
3703  1
3704  1\end{verbatim}
3705
3706 This pair of commands sets: MOUT1INMOUT1IN=0 MOUT2IN=1 MOUT3IN=0 MOUT4IN=1 MOUT5IN=1 MOUT6IN=1 Which is shown in getter output
3707
3708 \subsection{poweroff}
3709
3710
3711 Disables VBATEN and VBAT1EN power supply
3712
3713 \subsubsection{Command syntax}
3714
3715 \begin{verbatim} poweroff\end{verbatim}
3716
3717 \subsubsection{Description}
3718
3719
3720 This command turns off VBAT and VBAT1 voltages.
3721
3722 \subsection{poweron}
3723
3724
3725 Enable VBATEN and VBAT1EN power supply by using PWM hack
3726
3727 \subsubsection{Command syntax}
3728
3729 \begin{verbatim} poweron\end{verbatim}
3730
3731 \subsubsection{Description}
3732
3733
3734 This command tries to work around error on VBAT power supply wiring and attempts to switch the power supply on.
3735
3736 It turns on the VBAT voltage by slowly charging the capacitors connected to the VBAT1 signal by using the software-generated PWM signal with increasing duty cycle.
3737
3738 The poweron command has to be launched before any access to any SPI peripherals, otherwise they will not work (or the power supply has to be electrically bypassed).
3739
3740 Please note that parameters for the PWM signal may change from device to device and it might be necessary to tune them (in source code) for each device.
3741
3742 \subsection{sdramlogtest}
3743
3744
3745 Open a command subprocessor for managing SDRAM logging
3746
3747 \subsubsection{Command syntax}
3748
3749 \begin{verbatim} sdramlogtest\end{verbatim}
3750
3751 \subsubsection{Description}
3752
3753
3754 The command opens a subcommand processor, which contains testing commands for logging into SDRAM.
3755
3756 \subsection{sdramtest}
3757
3758
3759 Test if the SDRAM module is connected and if so, measures its capacity
3760
3761 \subsubsection{Command syntax}
3762
3763 \begin{verbatim} sdramtest\end{verbatim}
3764
3765 \subsubsection{Description}
3766
3767
3768 This command tests SDRAM address space by writing and reading a pattern to/from it. It detects the SDRAM capacity.
3769
3770 \subsubsection{Example}
3771
3772 \begin{verbatim} --> sdramtest
3773 SDRAM installed: 64 MB\end{verbatim}
3774
3775 \subsection{sleep}
3776
3777
3778 Sleep the board
3779
3780 \subsubsection{Syntax}
3781
3782
3783 sleep
3784
3785 \subsubsection{Description}
3786
3787
3788 This command configures the LIN and CAN peripherals to enter sleep mode and turn the whole device into sleep mode. External signal on CAN or LIN will wake the device up.
3789
3790 \subsection{spimst*}
3791
3792
3793 Request SPI master communication
3794
3795 \subsubsection{Command syntax}
3796
3797 \begin{verbatim} spimst<SPI> <ADDR> <DATA>\end{verbatim}
3798
3799 where
3800 \begin{itemize}
3801 \item \texttt{\mbox{$<$}SPI\mbox{$>$}} is a number in range 0 - 4
3802 \item \texttt{\mbox{$<$}ADDR\mbox{$>$}} is a number in range 0 - 2
3803 \item \texttt{\mbox{$<$}DATA\mbox{$>$}} is a sequence of hexadecimal numbers, separated by spaces, e.g. 12 AA CD
3804 \end{itemize}
3805
3806 \subsubsection{Description}
3807
3808
3809 The command sends given data to the SPI peripheral and prints the response. The response contains the address and the received data in parentheses.
3810
3811 \subsubsection{Example}
3812
3813 \begin{verbatim} --> spimst1 0 7F 00 00
3814 spirx:0x0(0x3f,0xc0,0xff)\end{verbatim}
3815
3816 Sends reset command (0x7F0000) to the DIN peripheral.
3817
3818 \subsection{spitr*}
3819
3820
3821 Translate response from an SPI peripheral
3822
3823 \subsubsection{Command syntax}
3824
3825 \begin{verbatim} spitr<NAME> <CMD> <RESP>\end{verbatim}
3826
3827 where
3828 \begin{itemize}
3829 \item \texttt{\mbox{$<$}NAME\mbox{$>$}} is a string specifying the name of the peripheral (one of DINSPI, LOUT, DAC12, DAC34, HBR, FRAY1 and FRAY2)
3830 \item \texttt{\mbox{$<$}CMD\mbox{$>$}} is a hexadecimal number in range 0 - FFFFFFFF
3831 \item \texttt{\mbox{$<$}RESP\mbox{$>$}} is a hexadecimal number in range 0 - FFFFFFFF
3832 \end{itemize}
3833
3834 \subsubsection{Description}
3835
3836
3837 This command translates a response from SPI from many different peripherals into a human readable form. The SPI response is in the form of a hexadecimal number, which encodes the information. This commands takes this response, the command which produced this response, the name of the peripheral and translates the response into the attribute-value table.
3838
3839 \subsubsection{Example}
3840
3841 \begin{verbatim} --> portvalDINSPI 7F 00 00
3842 portvalDINSPI=AAC03F
3843 --> spitrDINSPI 7F0000 3FC0AA
3844 Thermal flag    : 0
3845 INT flag    : 0
3846 SP0  - DIN0 : 1
3847 SP1  - DIN1 : 1
3848 SP2  - DIN2 : 1
3849 SP3  - DIN3 : 1
3850 SP4  - DIN4 : 1
3851 SP5  - DIN5 : 1
3852 SP6  - DIN6 : 1
3853 SP7  - DIN7 : 1
3854 SG0  - DIN8 : 0
3855 SG1  - DIN9 : 1
3856 SG2  - DIN10    : 0
3857 SG3  - DIN11    : 1
3858 SG4  - DIN12    : 0
3859 SG5  - DIN13    : 1
3860 SG6  - DIN14    : 0
3861 SG7  - DIN15    : 1
3862 SG8  - NA   : 0
3863 SG9  - NA   : 0
3864 SG10 - NA   : 0
3865 SG11 - NA   : 0
3866 SG12 - NA   : 0
3867 SG13 - NA   : 0
3868 spitrDINSPI=24\end{verbatim}
3869
3870 Translates response 0x3FC0AA returned by command 0x7F0000 into a human readable form. Please notice LSB-\mbox{$>$}MSB conversion of the portval result. The necessity of the conversion depends on the controller of the examined port.
3871
3872 \subsection{version}
3873
3874
3875 Print version of the software
3876
3877 \subsubsection{Syntax}
3878
3879
3880 version
3881
3882 \subsubsection{Description}
3883
3884
3885 This command prints the version of the test software. The version number is the output of 'git describe' command, i.e. it is composed from the last tag in the git repository, the number of commits since the tag and the abbreviated commit hash.
3886
3887 \subsubsection{Example}
3888
3889 \begin{verbatim} --> version
3890 version=v0.2-109-ga81a9dd\end{verbatim}
3891
3892 % html: End of file: `doc.html'
3893 \chapter{Glossary}
3894
3895 \begin{description}
3896 \item[ADC]
3897   \textit{Analog to Digital Converter.} \newline{}
3898   Hardware circuitry that converts a continuous physical quantity (usually voltage) to a
3899   digital number that represents the quantity's amplitude.
3900
3901 \item[AIN]
3902   \textit{Analog Input.} \newline{}
3903   Mnemonic to refer to or something related to the analog input (ADC) hardware module.
3904
3905 \item[AOUT]
3906   \textit{Analog Output.} \newline{}
3907   Mnemonic to refer to or something related to the analog output (DAC) hardware module.
3908
3909 \item[CAN]
3910   \textit{Controller Area Network.} \newline{}
3911   The CAN Bus is a vehicle bus standard designed to allow microcontrollers and devices to
3912   communicate with each other within a vehicle without a host computer.
3913   In this project it is also used as mnemonic to refer to or something related to the CAN
3914   hardware module.
3915
3916 \item[CGT]
3917   \textit{Code Generation Tools.} \newline{}
3918   Name given to the tool set produced by Texas Instruments used to compile, link, optimize,
3919   assemble, archive, among others. In this project is normally used as synonym for
3920   ``Texas Instruments ARM compiler and linker."
3921
3922 \item[DAC]
3923   \textit{Digital to Analog Converter.} \newline{}
3924   Hardware circuitry that converts a digital (usually binary) code to an analog signal
3925   (current, voltage, or electric charge).
3926
3927 \item[DIN]
3928   \textit{Digital Input.} \newline{}
3929   Mnemonic to refer to or something related to the digital input hardware module.
3930
3931 \item[ECU]
3932   \textit{Engine Control Unit.} \newline{}
3933   A type of electronic control unit that controls a series of actuators on an internal combustion
3934   engine to ensure the optimum running.
3935
3936 \item[ETH]
3937   \textit{Ethernet.} \newline{}
3938   Mnemonic to refer to or something related to the Ethernet hardware module.
3939
3940 \item[FR]
3941   \textit{FlexRay.} \newline{}
3942   FlexRay is an automotive network communications protocol developed to govern on-board automotive
3943   computing.
3944   In this project it is also used as mnemonic to refer to or something related to the FlexRay
3945   hardware module.
3946
3947 \item[GPIO]
3948   \textit{General Purpose Input/Output.} \newline{}
3949   Generic pin on a chip whose behavior (including whether it is an input or output pin) can be
3950   controlled (programmed) by the user at run time.
3951
3952 \item[HBR]
3953   \textit{H-Bridge.} \newline{}
3954   Mnemonic to refer to or something related to the H-Bridge hardware module. A H-Bridge is
3955   an electronic circuit that enables a voltage to be applied across a load in either direction.
3956
3957 \item[HOUT]
3958   \textit{High-Power Output.} \newline{}
3959   Mnemonic to refer to or something related to the 10A, PWM, with current sensing, high-power
3960   output hardware module.
3961
3962 \item[IDE]
3963   \textit{Integrated Development Environment.} \newline{}
3964   An IDE is a Software application that provides comprehensive facilities to computer programmers
3965   for software development.
3966
3967 \item[LCT]
3968   \textit{Legacy Code Tool.} \newline{}
3969   Matlab tool that allows to generate source code for S-Functions given the descriptor of a C 
3970   function call.
3971
3972 \item[LIN]
3973   \textit{Local Interconnect Network.} \newline{}
3974   The LIN is a serial network protocol used for communication between components in vehicles.
3975   In this project it is also used as mnemonic to refer to or something related to the LIN
3976   hardware module.
3977
3978 \item[LOUT]
3979   \textit{Logic Output.} \newline{}
3980   Mnemonic to refer to or something related to the digital output hardware module.
3981   It is logic output (100mA), as opposed to power outputs (2A, 10A).
3982
3983 \item[MBD]
3984   \textit{Model-Based Design.} \newline{}
3985   Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated
3986   with designing complex control, signal processing and communication systems.
3987
3988 \item[MEX]
3989   \textit{Matlab Executable.} \newline{}
3990   Type of binary executable that can be called within Matlab. In this document the common term
3991   used is `C MEX S-Function", which means Matlab executable written in C that implements a system
3992   function.
3993
3994 \item[MOUT]
3995   \textit{(Motor) Power Output.} \newline{}
3996   Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
3997
3998 \item[PWM]
3999   \textit{Pulse-width modulation.} \newline{}
4000   Technique for getting analog results with digital means. Digital control is used to create a
4001   square wave, a signal switched between on and off. This on-off pattern can simulate voltages
4002   in between full on and off by changing the portion of the time the signal spends on versus
4003   the time that the signal spends off. The duration of ``on time" is called the pulse width or
4004   \textit{duty cycle}.
4005
4006 \item[RPP]
4007   \textit{Rapid Prototyping Platform.} \newline{}
4008   Name of the automotive hardware board. Also generic term to define something related
4009   to the board, like the RPP Library, RPP Layer, RPP API, etc.
4010
4011 \item[SCI]
4012   \textit{Serial Communication Interface.} \newline{}
4013   Serial Interface for communication through hardware's UART using communication standard RS-232.
4014   In this project it is also used as mnemonic to refer to or something related to the Serial
4015   Communication Interface hardware module.
4016
4017 \item[SDC]
4018   \textit{SD-Card.} \newline{}
4019   Mnemonic to refer to or something related to the SD-Card hardware module.
4020
4021 \item[SDR]
4022   \textit{SD-RAM.} \newline{}
4023   Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
4024
4025 \item[TLC]
4026   \textit{Target Language Compiler.} \newline{}
4027   Technology and language used to generate code in Matlab/Simulink.
4028
4029 \item[UART]
4030   \textit{Universal Asynchronous Receiver/Transmitter.} \newline{}
4031   Hardware circuitry that translates data between parallel and serial forms.
4032 \end{description}
4033
4034
4035 \chapter{References}
4036
4037 \begin{itemize}
4038 \item Horn, M. (2013). \textit{Software obsluhující periferie a flexray na automobilové rídicí jednotce}.
4039   (Unpublished master's thesis, Czech Technical University in Prague, Prague, Czech Republic).
4040
4041 \item \textit{Model-based design}. (n.d.). In Wikipedia. Retrieved March 10, 2013, from \newline{}
4042   \htmladdnormallink{http://en.wikipedia.org/wiki/Model-based\_design}{http://en.wikipedia.org/wiki/Model-based\_design}
4043
4044 \item (2012). \textit{ARM Assembly Language Tools}. Texas Instruments.
4045
4046 \item (2012). \textit{ARM Optimizing C/C++ Compiler}. Texas Instruments.
4047
4048 \item (2013). \textit{Embedded Coder - Reference}. MathWorks.
4049
4050 \item (2013). \textit{Embedded Coder - User's Guide}. MathWorks.
4051
4052 \item Barry, R. (2009). \textit{Using the FreeRTOS real time kernel - A practical guide}.
4053
4054 \item (2013). \textit{Simulink Coder - Reference}. MathWorks.
4055
4056 \item (2013). \textit{Simulink - Target Language Compiler}. MathWorks.
4057
4058 \item (2013). \textit{Simulink Coder - User's Guide}. MathWorks.
4059
4060 \item (2013). \textit{Simulink - Developing S-Functions}. MathWorks.
4061
4062 \item (2012). \textit{TMS570LS31x/21x 16/32-Bit RISC Flash Microcontroller - Technical Reference Manual}.
4063   Texas Instruments.
4064 \end{itemize}
4065
4066 \end{document}
4067
4068 %  LocalWords:  FreeRTOS RPP POSIX