]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - doc/reports/report/report.t2t
Improved documentation.
[jenkicar/rpp-simulink.git] / doc / reports / report / report.t2t
1 Final Report
2 Carlos Jenkins
3 %%date(%B, %Y)
4
5 %!target: tex
6 %!style(xhtmls): media/themes/Clean/style.css
7 %!postproc(xhtmls): 'NEWPAGE' ''
8 %!nested(xhtmls): --libs syntaxhighlighter
9 %!options(tex): --enum-title --toc --toc-level 5
10 %!postproc(tex): '\.pdf\.png' '.pdf'
11 %!postproc(tex): 'NEWPAGE' '\\newpage'
12 %!postproc(tex): '-\$>\$' '\\noindent$\\rightarrow$'
13 %!postproc(tex): 'TAB' '\\hspace{1.0em}'
14 %!nested(tex): --docclass {article} --pdf
15
16 %S = Table of contents =[table_of_contents]
17
18 %DONE
19
20 %Table of contents
21 %%toc
22
23 NEWPAGE
24
25 %Table of contents
26 %tex% ''' \listoffigures
27
28 NEWPAGE
29
30 = Introduction =[introduction]
31
32 %DONE
33
34 This document describes the final results of the project ``Code generation for automotive rapid prototyping 
35 platform using Matlab/Simulink".
36
37 The general layout of this document is as follows:
38
39 - Project description, objectives and outcome. This section.
40 - Software and Hardware setup for development, repository layout and programming standards.
41 - A section for each of the four products delivered, with:
42  - Implementation fundamentals.
43  - Repository branch description.
44  - Product specific aspects.
45  - Reference documentation.
46 - Glossary.
47 - References.
48 - Appendices.
49
50
51
52 == Background ==[background]
53
54 %DONE
55
56 Back in the beginning of 2012 a leading automotive company requested the Czech Technical University to 
57 develop a Engine Control Unit (ECU) for automotive applications. Real-Time Systems group at the Department 
58 of Control Engineering from the Faculty of Electrical Engineering developed a hardware and Software 
59 platform to the needs of this industry. The hardware uses Texas Instruments TMS570LS3137 CPU and has was 
60 built with automotive standards and interfaces in mind. It uses a real-time operating system and was 
61 directly programmed in C.
62
63 Nevertheless, in accordance to company policies the Software developed for the engine control unit must be 
64 designed in a safe and auditable way. The company has the policy to implement the Software for their 
65 system using Model-Based Design:
66
67         Model-Based Design (MBD) is a mathematical and visual method of addressing 
68         problems associated with designing complex control, signal processing and 
69         communication systems. It is used in many motion control, industrial equipment, 
70         aerospace, and automotive applications. Model-based design is a methodology 
71         applied in designing embedded software.
72
73 In order to meet this requirement an interaction layer between the platform and the Software the company 
74 uses, Matlab/Simulink, must be implemented. This document describes the implementation of this interaction
75 system.
76
77 NEWPAGE
78
79 == Technologies involved ==[technologies_involved]
80
81 %DONE
82
83 + Matlab/Simulink data flow graphical programming language tool for modeling, simulating and analyzing 
84   multidomain dynamic systems.
85 + Standard ANSI C programming.
86 + FreeRTOS real-time operating system.
87 + Texas Instruments TI Code Generation Tools (CGT).
88 + RPP in-house automotive hardware board using Texas Instruments TMS570LS3137 CPU.
89
90
91 == Objectives ==[objectives]
92
93 %DONE
94
95 Main objectives of this project are:
96
97 + Allow C code generation from Matlab/Simulink models for custom made hardware platform.
98 + Implement model blocks for some of the peripheral units of the board for use in Simulink programming.
99
100
101 At the time of this writing the objectives of this project are considered successfully achieved.
102
103 == Benefits ==[benefits]
104
105 %DONE
106
107 Expected benefits of this project are:
108
109 + Enabling faster implementation and rapid-prototyping of Software components through the use of model-based 
110   programming.
111 + Enabling better and clearer visualization of Software implementations for the hardware board through models.
112 + Improve auditability of Software system for automotive applications.
113
114
115 At the time of this writing the benefits of this project are considered enabled.
116
117 == Final outcome ==[final_outcome]
118
119 %DONE
120
121 The main products generated for this project are:
122
123 - Simulink RPP Target.
124 - RPP Library and API.
125 - Simulink RPP Block Library.
126 - Simulink RPP Demo Library.
127
128
129 Each of this product is described deeply in the following sections.
130
131 = Project setup =[project_setup]
132
133 %DONE
134
135 This sections describes the Software and Hardware aspects required to undertake development for 
136 this project. It considers:
137
138 - Software development environment.
139 - Hardware reference documentation and wiring for development.
140 - Repository's general layout.
141
142
143 == Development environment ==[development_environment]
144
145 %DONE
146
147 This section describes the Software environment setup for development.
148
149 === Operating system ===[operating_system]
150
151 %DONE
152
153 This project was developed on a GNU/Linux operating system. For development it is recommended to use a 
154 Debian based operating system for development as most of the tools are easily available from repositories. 
155 Relevant OS information is:
156
157 - Ubuntu 12.04.2 LTS AMD64.
158 - Kernel 3.2.0-48-generic.
159 - GCC version 4.6.3.
160
161
162 No test for cross-platform interoperability was performed on the code developed. Although care was taken 
163 to try to provide platform independent code and tools this are the elements that are know to be Linux 
164 dependent:
165
166 - LCM1 hardware control tool. @@
167   This tool is both GUI and command line capable, the following just affects the GUI part. 
168   Command line should be usable under Windows systems. @@
169   __Cause__: Serial port search algorithm is Linux dependent and Gtk 3.0 dynamic Python bindings are not 
170   available on Windows operating systems.
171 - TI CGT support file for RPP Simulink Target ``target_tools.mk``. @@
172   __Cause__: Use UNIX path separator ``/``.
173 - Simulink RPP Target download script ``rpp_download.m``. @@
174   __Cause__: Use UNIX path separator ``/``.
175 - Simulink RPP Target install script ``rpp_setup.m``. @@
176   __Cause__: Use UNIX path separator ``/``.
177 - Simulink RPP Block Library block compilation script ``compile_blocks.m``. @@
178   __Cause__: Call Matlab MEX executable with Unix name.
179 - All CCS projects under ``<repo>/rpp/lib/apps/``. @@
180   __Cause__: Paths are configure using UNIX path separator ``/``.
181
182
183
184 === Version Control System ===[version_control_system]
185
186 %DONE
187
188 The version control system used for this project is **git**. The repository of this project contains all 
189 the files produced during development, including documentation, references, code and graphics. Also the 
190 GUI application **giggle** was used to easily review changes. To install both execute on a terminal:
191
192 {{{ bash
193 sudo apt-get install git giggle
194 }}}
195
196 === TI Code Composer Studio ===[ti_code_composer_studio]
197
198 %DONE
199
200 Code Composer Studio (CCS) is the official Integrated Development Environment (IDE) for developing 
201 applications for Texas Instruments embedded processors. CCS is multiplatform Software based on Eclipse 
202 Open Source IDE.
203
204 The version used in this project is the 5.3.0. Download and install CCS for Linux from:
205
206         http://processors.wiki.ti.com/index.php/Category:Code_Composer_Studio_v5
207
208 CCS download requires a valid MyTI account. Tedious. CCS download is about 1.5GB. Once downloaded extract 
209 the content of the ``tar.gz`` archiver and run ``css_setup_<version>.bin`` script as __root__. Installation 
210 must done as root in order to install driver set.
211
212 After installation the application can be executed with:
213
214 {{{ bash
215 cd <ccs>/ccsv5/eclipse/
216 ./ccstudio
217 }}}
218
219 If the application fails to start on 64bits systems is because CCS5 is a 32bits application a thus requires 
220 32bits libraries:
221
222 {{{ bash
223 sudo apt-get install libgtk2.0-0:i386 libxtst6:i386
224 }}}
225
226 If the application crashes with a segmentation fault edit file:
227
228 {{{ bash
229 nano <ccs>/ccsv5/eclipse/plugins/com.ti.ccstudio.branding_<version>/plugin_customization.ini
230 }}}
231
232 And change key ``org.eclipse.ui/showIntro`` to false.
233
234 Choose ``FREE License - for use with XDS100 JTAG Emulators" on the licensing options. Code download for the 
235 board is uses that particular hardware. See [Hardware configuration #hardware_configuration] for more details
236 on this hardware.
237
238 CCS include Texas Instruments Code Generation Tools (CGT) (compiler, linker, etc). Simulink code generation
239 requires the CGT to be available in the system, and thus, even if no library development will be done or the 
240 IDE is not going to be used CCS is still required. See ``<repo>/rpp/rpp/README.txt`` file for more information.
241
242 You can find documentation for CGT compiler in ``<repo>/ref/armcl.pdf`` and for CGT archiver in 
243 ``<repo>/ref/armar.pdf``.
244
245
246 === Matlab/Simulink ===[matlabsimulink]
247
248 %DONE
249
250 Matlab/Simulink version used is R2012b for Linux 64 bits. For in-house development the CVUT should provide a 
251 network licensing server descriptor file.
252
253 === GtkTerm ===[gtkterm]
254
255 %DONE
256
257 Most of the interaction with the board for development is done through a RS-232 serial connection.
258 The terminal Software used for communication is called GtkTerm.
259
260 The default configuration for the board serial communication module is 9600-8-N-1. Note that the RPP
261 Library test suite is setup to 115200-8-N-1.
262
263 To install GtkTerm execute:
264
265 {{{ bash
266 sudo apt-get install gtkterm
267 }}}
268
269
270 === Doxygen ===[doxygen]
271
272 %DONE
273
274 Doxygen is the name of the documentation generator used to generate the RPP API documentation based on the 
275 source code files. The generated API include dependency graphs and thus it also requires Graphviz, a graph 
276 drawing tool. To install both execute:
277
278 {{{ bash
279 sudo apt-get install doxygen graphviz
280 }}}
281
282 See [API generation #api_generation] on how to use Doxygen to generate the API Reference documentation.
283
284 NEWPAGE
285
286 === Nested ===[nested]
287
288 %DONE
289
290 Nested is the documentation editor used to create the document you're reading. It features a plain text 
291 version control friendly simple to read non-cluttered format, WYSIWYM paradigm, divide and conquer document 
292 creation approach, a nested (non-linear) document tree and content/presentation separation scheme and thus 
293 documents can be published to LaTeX, PDF or HTML. Nested is a tool created by the author of this report.
294
295 To install Nested first install dependencies:
296
297 {{{ bash
298 sudo apt-get install python2.7 python-gtk2 python-webkit python-gtkspellcheck texlive-publishers texlive texlive-latex-extra rubber iso-codes subversion
299 }}}
300
301 Then get the latest revision from the stable repository:
302
303 {{{ bash
304 svn checkout svn://svn.code.sf.net/p/nestededitor/code/trunk nested
305 }}}
306
307 Run Nested with:
308
309 {{{ bash
310 cd nested/nested/
311 ./nested
312 }}}
313
314 Nested sources for this document can be found on the repository under ``<repo>/doc/reports/report/``.
315
316 === LMC1 ===[lmc1]
317
318 %DONE
319
320 The LMC1 is a simple script developed for this project written in Python 3 using Gtk+ 3.0 Python dynamic 
321 bindings PyGObject. This script, based on Michal Horn command line only script, allows to set or clear the 
322 outputs of the test board. 
323
324 This script includes both a GUI and command line tool. If no parameters are given to the script the GUI 
325 version is launched:
326
327 %tex% ''' \begin{figure}[H]\begin{center}
328 [350-lmc1.png]
329 %tex% ''' \caption{LMC1 GUI application.}\end{center}\end{figure}
330
331 To run the LMC1 application first install dependencies:
332
333 {{{ bash
334 apt-get install python3 python3-gi python3-serial
335 }}}
336
337 To launch LMC1 GUI version double click file:
338
339 ``<repo>/rpp/lib/apps/lmc1/lmc1.py``
340
341 To launch LMC1 command line version type:
342
343 ``<repo>/rpp/lib/apps/lmc1/lmc1.py --help``
344
345
346 NEWPAGE
347
348 == Hardware reference ==[hardware_reference]
349
350 This section provides reference documentation for the RPP board: 
351
352 - Connectors pinout.
353 - Modules capabilities and features.
354 - Wiring configuration for development and testing.
355
356
357 Please note that although this is a hardware reference documentation this is from a Software 
358 development perspective and __**NOT**__ Hardware development perspective. For full hardware
359 details please refer to schematics and related documentation.
360
361 %tex% ''' \begin{figure}[H]\begin{center}
362 [300-board.png]
363 %tex% ''' \caption{The RPP board (signal connector missing).}\end{center}\end{figure}
364
365 === Connectors pinout ===[connectors_pinout]
366
367 %tex% ''' \begin{figure}[H]\advance\leftskip-1cm
368 [530-pinout.pdf.png]
369 %tex% ''' \caption{The RPP connectors pinout.}\end{figure}
370
371
372 === Modules description ===[modules_description]
373
374
375
376 ==== Logic IO ====[logic_io]
377
378
379
380 ===== 16x digital input (DIN) =====[16x_digital_input_din]
381
382 - Read status via GPIO pin (configurable threshold).
383 - Read status via SPI pin (fixed threshold).
384 - Setting pin programmable via SPI.
385
386
387 ===== 8x digital outputs for loads up to 100 mA (LOUT) =====[8x_digital_outputs_for_loads_up_to_100_ma_lout]
388
389 - Set pin ON.
390 - Set pin OFF.
391 - Reading the SPI status excitation.
392
393 ===== 12x analog-to-digital converter =====[12x_analog_to_digital_converter]
394
395 - Reading values on all channels.
396
397 ===== 4x digital-to-analog converter =====[4x_digital_to_analog_converter]
398
399 - Set the required voltage on all channels.
400
401 ==== Power Output ====[power_output]
402
403
404
405 ===== 1x H-Bridge =====[1x_h_bridge]
406
407 - Setting the direction.
408 - Switch on, off.
409 - Communication with excitation by SPI.
410 - Enable PWM.
411
412
413 ===== 6x outputs for loads up to 2 A (MOUT) =====[6x_outputs_for_loads_up_to_2_a_mout]
414
415 - Set pin ON.
416 - Set pin OFF.
417 - Reading diagnostics values (DIAG).
418
419 ===== 6x output up to 10 A with PWM (HOUT) =====[6x_output_up_to_10_a_with_pwm_hout]
420
421 - Set pin ON.
422 - Set pin OFF.
423 - Reading analog values of current flowing (IFBK).
424 - Reading diagnostics values (DIAG).
425 - Detection of a fault condition.
426 - Turn on the PWM pin.
427
428 ==== Communication ====[communication]
429
430
431
432 ===== 3x CAN High speed =====[3x_can_high_speed]
433
434 - Sending and receiving messages between the CAN bus interfaces.
435 - Recover from error.
436 - Detection of network errors.
437
438 ===== 2x LIN =====[2x_lin]
439
440 - Testing least one LIN using a loop. The second connector is shared with serial interface, which is tested alone communicate with the computer. Detailed testing makes sense to be no support for access to diagnostics unit via Ethernet or other interface.
441
442 ===== 1x FlexRay =====[1x_flexray]
443
444 - Sending and receiving messages between two plates JRVA.
445
446
447 ===== 1x Serial Comm. Interface =====[1x_serial_comm_interface]
448
449
450
451 ===== 1x Ethernet =====[1x_ethernet]
452
453 - To send a packet.
454 - Code for testing Ethernet is the result of this thesis and is therefore not analyzed.
455
456 ==== Data storage/logging ====[data_storagelogging]
457
458
459
460 ===== External Memory SDRAM =====[external_memory_sdram]
461
462 - Determine the total capacity of the module fitted.
463 - Performing a memory test module using the entire address range.
464
465
466 ===== SD Card =====[sd_card]
467
468
469
470 === Development wiring ===[development_wiring]
471
472 How to wire the board for testing.
473
474 === Test wiring ===[test_wiring]
475
476
477
478 == Repository layout ==[repository_layout]
479
480
481 The repository is hosted on the server of the Real-Time Systems group at the Department
482 of Control Engineering
483
484 ```
485 .
486 |-- doc         - Documentation created for this project.
487 |-- refs        - Official reference documentation.
488 `-- rpp
489     |-- blocks  - Simulink RPP Block Library.
490     |-- demos   - Simulink RPP Demo Library.
491     |-- lib     - RPP Library and API.
492     `-- rpp     - Simulink RPP Target.
493 ```
494
495
496
497 == Programming standards ==[programming_standards]
498
499
500 NEWPAGE
501
502 === TLC files ===[tlc_files]
503
504
505
506 === RPP API ===[rpp_api]
507
508
509
510 === S-Functions ===[s_functions]
511
512
513
514 = Simulink RPP Target =[simulink_rpp_target]
515
516 % FALTA
517
518 == Description ==[description]
519
520 The Simulink RPP Target provides support for C source code generation from Simulink models and compilation of 
521 that code on top of the RPP library and the FreeRTOS operating system. This target uses Texas Instrument ARM 
522 compiler (armcl) included in the Code Generation Tools available with Code Composer Studio, and thus it depends 
523 on it for proper functioning.
524
525 This library also provides support for automatically download the compiled machine code to the RPP board.
526
527 === Code generation process ===[code_generation_process]
528
529 %tex% ''' \begin{figure}[H]\advance\leftskip-1cm
530 [530-tlc_process.png]
531 %tex% ''' \caption{TLC code generation process.}\end{figure}
532
533 == Repository branch description ==[repository_branch_description]
534
535 -> ``rpp_setup.m``
536
537 RPP Target install script.
538
539 This script will, among other things, ask the user to provide the location of the armcl parent directory, 
540 infer and save some relevant CCS paths, add paths to Matlab path and build S-Function blocks for
541 user's architecture (using Matlab's mex command line tool).
542
543 - __Reference:__
544  - ``<repo>/refs/rtw_ug.pdf`` p. 1137.
545
546
547 -> ``rpp.tlc``
548
549 Embedded real-time system target file for RPP.
550
551 This file is the system target file (STF), or target manifest file. Functions of the STF include:
552
553 - Making the target visible in the System Target File Browser.
554 - Definition of code generation options for the target (inherited and target-specific).
555 - Providing an entry point for the top-level control of the TLC code generation process.
556
557
558 - __Reference:__
559  - ``<repo>/refs/rtw_ug.pdf`` p. 1129 and __1144__.
560
561
562 -> ``rpp.tmf``
563
564 Embedded Coder Template Makefile.
565
566 This is just standard Embedded Coder Template Makefile, provided by Matlab. It was slightly modified to 
567 support ``armcl`` particularities and added template rules for assembler files (which were included by the
568 ``rpp_lib_support.m`` script, but is no longer the case).
569
570 - __Reference:__
571  - ``<repo>/refs/rtw_ug.pdf`` p. 1130 and __1183__.
572
573
574 -> ``rpp_download.m``
575
576 Code download utility for Simulink RPP Target.
577
578 This function is optionally executed at the end of the build process if it is successful and the user selected 
579 //Download compiled binary to RPP// option on the build configuration panel. This function calls ``loadti.sh`` 
580 script with the generated binary and using configuration for the XDS100v2 JTAG Emulators. The board should be 
581 powered and correctly wired. See [Development wiring #development_wiring].
582
583
584 NEWPAGE
585 -> ``rpp_file_process.tlc``
586
587 Code generation custom file processing template.
588
589 This file should decide which //main// to generate according to configuration, in particular which mode, Single 
590 Tasking or Multitasking, is chosen. The RPP Target ignores this settings because it uses a tasking system based 
591 on tasking features provided by FreeRTOS. In consequence is only a wrapper to the //Single Tasking// main, which
592 clearly is not for single tasking.
593
594 - __Reference:__
595  - ``<repo>/refs/ecoder_ug.pdf`` p. 556.
596  - ``<repo>/refs/ecoder_ref.pdf`` p. 1347.
597
598
599 -> ``rpp_lib_support.m``
600
601 **DEPRECATED**. Simulink support for RPP library and operating system setup.
602
603 This files used to add the source code from the RPP library and operating to the build. This is no longer required 
604 when using the static library. This is left for future reference in case new source code needs to be included to 
605 the build.
606
607 - __Reference:__
608  - ``<repo>/refs/rtw_ug.pdf`` p. 1058.
609  - ``<repo>/refs/rtw_ref.pdf`` p. 56.
610
611
612 -> ``rpp_make_rtw_hook.m``
613
614 Build process hooks file.
615
616 This file is hook file that invoke target-specific functions or executables at specified points in the build process. 
617 In particular, this file handle the copying of required files before the compilation stage.
618
619 - __Reference:__
620  - ``<repo>/refs/rtw_ug.pdf`` p. 1066-1072 and 1131.
621
622
623 -> ``rpp_select_callback_handler.m``
624
625 RPP Target select callback handler.
626
627 This callback function is triggered whenever the user selects the target in the System Target File Browser. Default 
628 values for Simulation and configurations parameters are set. Some options are disabled if it is not allowed to be 
629 changed by user.
630
631 - __Reference:__
632  - ``<repo>/refs/rtw_ug.pdf`` p. 1211.
633
634
635 NEWPAGE
636 -> ``rpp_srmain.tlc``
637
638 Custom file processing to generate a //main// file.
639
640 This file generated the //main// file for the RPP target on top of the RPP library and the FreeRTOS operating system. 
641 The ``sr`` prefix is standard to mark Single Tasking main, which is not the case. See ``rpp_file_process.m`` description 
642 above for more information about this.
643
644 - __Reference:__
645  - Example in ``<matlab>/rtw/c/tlc/mw/bareboard_srmain.tlc``.
646
647
648 -> ``target_tools.mk``
649
650 Makefile for CCS (``armcl``) toolchain support.
651
652 This file set variables to CCS tools to support build for this toolchain. This file is included by ``rpp.tmf`` before 
653 declaring the rules for source code.
654
655 - __Reference:__
656  - "Include a tool specification settings" comment block in ``rpp.tmf``.
657  - Compiler options documentation available in ``armcl.pdf``.
658
659
660 NEWPAGE
661
662 == Installation procedure ==[installation_procedure]
663
664 **1) Download and install CCS for Linux:**
665
666 Details on how to setup CCS are available in section [TI Code Composer Studio #ti_code_composer_studio].
667
668
669 **2) Install RPP Target:**
670
671 Open Matlab and type on command window:
672
673 {{{ plain
674 cd <repo>/rpp/rpp/
675 rpp_setup()
676 }}}
677
678 This will launch the RPP setup script. This script will ask the user to provide the path to the CCS compiler 
679 root directory (the directory where armcl binary is located), normally:
680
681 ```
682 <ccs>/tools/compiler/arm_5.X.X/
683 ```
684
685 This script will, among other things, ask the user to provide the location of the armcl parent directory, 
686 infer and save some relevant CCS paths, add paths to Matlab path and build S-Function blocks for user's 
687 architecture (using Matlab's mex command line tool).
688
689
690 **3) Create a new model or load a demo:**
691
692 Demos are located on <repo>/rpp/demo or you can start a new model and configure target to RPP. For new models see
693 [Target Reference #target_reference] section below.
694
695 NEWPAGE
696
697 == Target Reference ==[target_reference]
698
699 This section describes the options required or available for running a Simulink model with the RPP Target.
700
701 === Simulink model options ===[simulink_model_options]
702
703 The Simulink model needs to be configured in the following way:
704
705 - Solver: 
706  - //fixed-step discrete//.
707  - Tasking mode set to //SingleTasking//. @@
708 [400-simulink_solver.png]
709 NEWPAGE
710 - Diagnostics - Sample Time:
711  - Disable warning source block specifies -1 sampling time. It's ok for the source blocks to run once per tick. @@
712 [400-simulink_diagnostics.png]
713 - Code generation:
714  - Set to ``rpp.tlc``. @@
715 [400-simulink_code.png]
716
717
718 Note: Single Tasking is the only currently supported mode. If multitasking is required to be implemented in the 
719       future create a new file ``rpp_mrmain.tlc`` in ``<repo>/rpp/rpp/`` and edit ``rpp_file_process.tlc`` to use
720       that file instead when multitasking is selected.
721
722
723 === RPP Target options ===[rpp_target_options]
724
725 The RPP Target include the following configuration options, all of them configurable per model under 
726 ``Code Generation`` -> ``RPP Options``:
727
728 - **C system stack size**: this parameter is passed directly to the linker for the allocation of the stack. 
729   Note that this is the stack for the application when running outside a FreeRTOS task, normally before 
730   the scheduler has started and for system routines. Default value is 4096.
731 - **C system heap size**: this parameter is passed directly to the linker for the allocation of the heap.
732   See [Appendix A: Notes on FreeRTOS memory management #appendix_a_notes_on_freertos_memory_management]
733   for an important overview of memory management and why this parameter is one of the most important in
734   memory management.
735 - **Model step task stack size**: this parameter will be passed to the ``xTaskCreate()`` that creates the 
736   task for the model to run. In a Simulink model there is always two tasks: 
737  - The worker task. This task is the one that executes the model step. This task requires enough stack 
738    memory to execute the step. Take into account for example than only a single call to 
739    ``rpp_sci_printf()`` requires, with current configuration, 128 bytes from the stack. This value should
740    be minor than the C system heap and leaving enough heap for the system tasks. 
741    See [Appendix A: Notes on FreeRTOS memory management #appendix_a_notes_on_freertos_memory_management]
742    for more information.
743  - The control task. This task controls when the worker task should execute and controls overruns.
744 - **Download compiled binary to RPP**: if set, this option will download the generated binary to the board after
745   the model is successfully built. Note that this option is unaware of the option //Generate code only// in
746   the //Code Generation// options panel, so it will try to upload even if only source code has being generated,
747   failing graciously or uploading an old binary laying around in the build directory. This option calls the
748   ``rpp_download.m`` script, which is in turn a wrapper on the ``loadti.sh`` script. More information on the 
749   ``loadti.sh`` script can be found in:
750 ```
751 <css>/ccs_base/scripting/examples/loadti/readme.txt
752 http://processors.wiki.ti.com/index.php/Loadti
753 ```
754   The ``loadti.sh`` script will close after the download of the generated program and in consequence the execution 
755   of the loaded program will stop (because it work as the CCS debug server). In order to test the loaded model a 
756   manual reset of the board is always required after a successful download.
757 - **Print model metadata to SCI at start**: if set this option will print a message to the Serial Communication
758   Interface when the model start execution on the board. This is very helpful to identify the model running on the
759   board. The message is in the form:
760 ```
761 `model_name' - generated_date (TLC tlc_version)
762 ```
763   For example:
764 ```
765 `hbridge_analog_control' - Wed Jun 19 14:10:44 2013 (TLC 8.3 (Jul 20 2012))
766 ```
767
768 NEWPAGE
769
770 = RPP Library and API =[rpp_library_and_api]
771
772 %DONE
773
774 == Description ==[description]
775
776 %DONE
777 The RPP Library is the support library used by Simulink models. It is designed from the board user 
778 perspective and exposes a simplified high-level API to handle the board's peripheral modules in a safe 
779 manner.
780
781 The library as a concept and as a functional unit was introduced by this project. At the beginning of this
782 project the RPP board had just one application developed for. This application intended for board testing
783 allows the user to issue low-level commands to control and test the peripherals of the board. This application
784 was created using a combination of custom code, contributed drivers and generated code from TI tool HalCoGen.
785 Library functionality, like drivers and hardware access, and application logic, like command processor and test 
786 routines, was largely merged in a single layer, 166 source code files long highly coupled application.
787 In order to develop independent applications for the RPP board, as it was expected to be each Simulink model, 
788 the library logic needed to be separated from the application logic. This work implied a heavy refactoring on 
789 the testing application in order extract from it the library functionality. Because the application files were 
790 highly coupled in a single layer the refactoring and testing of the library implied roughly 70% of the work done 
791 on this project.
792
793 %tex% ''' \begin{figure}[H]\advance\leftskip-1cm
794 [500-adc_dep_before.png]
795 %tex% ''' \caption{Dependency graph of the ADC driver before refactoring.}\end{figure}
796
797 The above graph shows the dependencies of the ADC driver before the refactoring. Please note the dependency on 
798 ``cmdproc_io_tisci.h`` and ``cmdproc.h``, both application level modules. Also, note the indirect dependency on 
799 the Operating System is being resolved through the application modules.
800
801 %tex% ''' \begin{figure}[H]\begin{center}
802 [150-adc_dep_after.png]
803 %tex% ''' \caption{Dependency graph of the ADC driver after refactoring.}\end{center}\end{figure}
804
805 The above graph shows the current dependencies for the ADC driver in the RPP Library. Please note that it 
806 dependents only on the system layer low-level driver and that the Operating System indirect dependency is resolved 
807 through the library foundations ``base.h``.
808
809 Some other relevant changes introduced with the refactoring are:
810
811 - ADC driver was completely rewritten.
812 - MOUT driver was implemented.
813 - DIN driver was slightly modified and extended.
814 - DAC driver was slightly modified.
815 - HBR driver was largely modified (in particular watchdog functionality).
816 - SCI driver was refactored and extended.
817 - SDR driver was implemented.
818
819
820 Also, once the library functionality could be isolated, the resulting API was too low-level to be used by 
821 applications, in consequence one of the contributions of this projects was the implementation of a high-level 
822 API on top of this low level API: the RPP Layer.
823
824
825 NEWPAGE
826
827 === Architecture ===[architecture]
828
829 %DONE
830 The RPP library was structured into 5 layers with the following guidelines:
831
832 - Top-down dependency only. No lower layer depends on anything from upper layers.
833 - 1-1 layer dependency only. The top layer depends exclusively on the bottom layer, not on any
834   lower level layer (except for a couple of exceptions).
835 - Each layer should provide a unified layer interface (``rpp.h``, ``drv.h``, ``hal.h``, ``sys.h`` and 
836   ``os.h``), so top layers depends on that layer interface and not on individual elements from that layer.
837
838
839 %tex% ''' \begin{figure}[H]\begin{center}
840 [250-layers.pdf.png]
841 %tex% ''' \caption{The RPP library layers.}\end{center}\end{figure}
842
843
844 As a consequence of this division the source code files and interface files are now placed on private directories
845 so the previous prefix based inclusion ``drv_din.h`` is replaced by ``drv/din.h``. With this organization user 
846 applications only needs to include the top layer interface file (``rpp/rpp.h``) to be able to use the library API.
847
848 Please note the sublayer uLut, which is used only by the SPI driver in order to use thread safe queue mechanisms. 
849 Because the FreeRTOS already provides thread safe queues and in order to match the order parts of the system it 
850 would be advisable to drop this dependency in the future.
851
852 NEWPAGE
853
854 === RPP Layer Modules ===[rpp_layer_modules]
855
856 %DONE
857 The RPP Layer was structured into 14 different modules from 4 different categories that match the hardware 
858 modules on the board:
859
860 || Category      | Description                        | MNEMONIC 
861  | Logic IO      | Digital Input                      | ``[DIN ]``   |
862  |               | Digital (Logic) Output             | ``[LOUT]``   |
863  |               | Analog Input                       | ``[AIN ]``   |
864  |               | Analog Output                      | ``[AOUT]``   |
865  | Power output  | H-Bridge output                    | ``[HBR ]``   |
866  |               | Power output (12V, 2A)             | ``[MOUT]``   |
867  |               | High-Power output (12V, 10A)       | ``[HOUT]``   |
868  | Communication | CAN Bus                            | ``[CAN ]``   |
869  |               | LIN (Local Interconnect Network)   | ``[LIN ]``   |
870  |               | FlexRay                            | ``[FR  ]``   |
871  |               | Serial Communication Interface     | ``[SCI ]``   |
872  |               | Ethernet                           | ``[ETH ]``   |
873  | Logging       | SD Card                            | ``[SDC ]``   |
874  |               | SD-RAM                             | ``[SDR ]``   |
875
876
877 Please note the mnemonic of each module, as they are constantly used on the Software and documentation. 
878 Also note that only the following modules where implemented as part of this project:
879
880 %tex% ''' \begin{multicols}{2}
881 - DIN.
882 - LOUT.
883 - AIN.
884 - AOUT.
885 - HBR.
886 - MOUT.
887 - SCI.
888 - SDR.
889
890
891 %tex% ''' \end{multicols}
892
893 Modules for which there is a low-level API available on the library but no high-level module was implemented:
894
895 %tex% ''' \begin{multicols}{2}
896 - CAN.
897 - LIN.
898 - FR.
899
900
901 %tex% ''' \end{multicols}
902
903 Modules that are not yet available on the library at all:
904
905 %tex% ''' \begin{multicols}{2}
906 - ETH (in the works).
907 - SDC.
908 - HOUT (partial).
909
910
911 %tex% ''' \end{multicols}
912
913 The following graphic shows the library modules and the connectors on the hardware they map to.
914
915 %tex% ''' \begin{figure}[H]\advance\leftskip-1cm
916 [500-blocks.pdf.png]
917 %tex% ''' \caption{The RPP Library modules.}\end{figure}
918
919 NEWPAGE
920
921 === OS interchangeable layer ===[os_interchangeable_layer]
922
923 %DONE
924 The OS Layer is composed by the FreeRTOS source code files. Because the FreeRTOS exposes an stable
925 API the OS layer can be changed in order to upgrade the Operating System or use a different port of the
926 OS, without changing the upper layers source code. The OS Layers currently available for the RPP Library
927 at ``<repo>/rpp/lib/os/`` at the time of this writing are:
928
929 - Version 6.0.4 using POSIX port. This layer is the one that should be used when compiling a program for
930   x86(_64) simulation. The port uses the ``pthread`` library and because of this the port is not true 
931   real time and this is considered a simulator.
932 - Version 7.0.2 using HalCoGen port for TMS570. This layer is the one currently supported and tested. It was
933   originally included in the testing application and was generated by an older version of TI code generation
934   tool HalCoGen.
935 - Version 7.4.0 using HalCoGen port for TMS570. This layer was extracted from a newly generated project using
936   a newer version of HalCoGen. This layer is untested but //should// work out of the box.
937 - Version 7.4.2 using ARM Cortex R4 official port for CCS. This layer was created from vanilla FreeRTOS 7.4.2 
938   release. It is tested but non-working. Ticks are proved to be executed in time but applications using this 
939   kernel runs at full-speed. The reason if this is currently unknown.
940
941
942 The general layout of all the layers are as following:
943
944 - Common source code (kernel):
945
946 ```
947     src/os/croutine.c (Optional)
948     src/os/list.c
949     src/os/queue.c
950     src/os/tasks.c
951     src/os/timers.c (Optional)
952 ```
953
954 Originally found in vanilla distribution in: ``<FreeRTOSRoot>/FreeRTOS/Source``
955
956 - Common interface files:
957
958 ```
959     include/os/croutine.h
960     include/os/FreeRTOS.h
961     include/os/list.h
962     include/os/mpu_wrappers.h
963     include/os/portable.h (with minor editions)
964     include/os/projdefs.h
965     include/os/queue.h
966     include/os/semphr.h
967     include/os/StackMacros.h
968     include/os/task.h
969     include/os/timers.h
970 ```
971
972 Originally found in vanilla distribution in: ``<FreeRTOSRoot>/FreeRTOS/Source/include``
973
974 - Memory management file:
975
976 ```
977     src/os/heap.c (One of 4 version available, see Appendix A).
978 ```
979
980 Originally found in vanilla distribution in: ``<FreeRTOSRoot>/FreeRTOS/Source/portable/MemMang``
981
982 - Port specific files:
983
984 ```
985     src/os/port.c
986     src/os/portASM.asm
987     include/os/portmacro.h
988     include/os/FreeRTOSConfig.h
989 ```
990
991 This depend of the port. In the case of the 7.4.2 TMS570 / ARM Cortex R4 for CCS port:
992
993  - First three files can be found in vanilla distribution in ``<FreeRTOSRoot>/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4``.
994  - Last file in ``<FreeRTOSRoot>/FreeRTOS/Demo/CORTEX_R4_RM48_TMS570_CCS5``.
995
996
997 In general, the following changes were applied to the source code base of all kernels:
998
999 - Replaced include directives to adapt to RPP library standard:
1000
1001 ``#include "`` with ``#include "os/``
1002
1003 - Line ending character set to UNIX '\n' and tabs replaced by 4 spaces.
1004
1005
1006 NEWPAGE
1007
1008 === API development guidelines ===[api_development_guidelines]
1009
1010 %DONE
1011 The following are the development guidelines use for developing the RPP API:
1012
1013 - User documentation should be placed in header files, not in source code, and should be Doxygen formatted 
1014   using autobrief. Documentation for each function present is mandatory.
1015 - Function declarations on the headers files is for public functions only. Do not declare local/static/private
1016   functions on the header.
1017 - Documentation on source code files should be non-doxygen formatted and intended for developers, not users.
1018   Documentation here is optional.
1019 - Always use standard data types for IO when possible. Use custom structs as very last resort.
1020 - Use prefix based functions names to avoid clash. The prefix is of the form ``[layer]_[module]_``, for example
1021   ``rpp_din_update()`` for the update function of the DIN module in the RPP Layer.
1022 - To be very careful about symbol export. Because it is used as a static library the modules should not export
1023   any symbol that is not intended to be used (function) or externed (variable) from application. As a rule of
1024   thumb declare all global variables as static.
1025
1026
1027
1028 === Further improvements ===[further_improvements]
1029
1030 %DONE
1031 The following are recommendations for future improvements of the library:
1032
1033 - General code revision to remove local-only methods and variables from being exported.
1034 - General code revision and refactoring to normalize the functions naming scheme. Normalize DRV and HAL 
1035   to use prefix based scheme, not all the functions and exported variables do. Refactor the SYS layer, 
1036   most of it generated by HalCoGen and that uses ``thisNamingScheme`` to use library standards (see 
1037   [RPP API #rpp_api] programming standards).
1038 - Simplify doxygen documentation on the SYS layer, because is clunky, doesn't add any value and is 
1039   repetitive. Move it the header files.
1040 - The HAL layer currently two elements:
1041  - CPU and chips abstractions. This should stay.
1042  - Command descriptors. This is remaining elements from the testing applications and should be moved to 
1043    application layer.
1044
1045
1046 Recommendations for changes on the electrical diagrams:
1047
1048 - Change name of GPIO MOUT1_EN to MOUT1_DIAG. 
1049 - Change name of GPIO MOUT1_IN to MOUT1_EN.
1050
1051
1052 This are misleading.
1053
1054 %S == Repository branch description ==[repository_branch_description]
1055
1056
1057 -> ``apps/``
1058
1059 Applications related to the RPP library. This include .
1060
1061
1062
1063 Library file layout:
1064
1065     -> include/rpp/rpp.h
1066
1067         Main library header file.
1068
1069         To use this library just include this file and this file only. Also,
1070         before using any library function please call rpp_init() function for
1071         hardware initialization.
1072
1073
1074     -> include/rpp/RppConfig.h
1075
1076         Library configuration file.
1077
1078         Please refer to the API documentation and header file comments for
1079         specific documentation for each configuration parameter.
1080
1081
1082     -> include/rpp/rpp_{mnemonic}.h
1083
1084         Header file for {mnemonic} module.
1085
1086         This files includes function definitions, pin definitions, etc, specific
1087         to {mnemonic} module. The inclusion of this header can be configured
1088         in RppConfig.h using rppCONFIG_INCLUDE_{MNEMONIC} directive.
1089
1090
1091     -> src/rpp/rpp_{mnemonic}.c
1092
1093         Module implementation.
1094
1095         Implementation of rpp_{mnemonic}.h's functions on top of the DRV
1096         library.
1097
1098
1099     -> src/rpp/rpp.c
1100
1101         Implementation of library-wide functions.
1102
1103
1104     -> doc/doxygen.conf
1105
1106         Configuration file for Doxygen code documentation generation tool.
1107
1108
1109
1110 NEWPAGE
1111
1112 == Test Suite ==[test_suite]
1113
1114 %DONE
1115 The ``rpp-test-suite`` is a RPP application developed as part of this project that includes a series of
1116 test tasks or test commands to verify the correct behavior and functionality of the RPP layer modules.
1117 There is one command per module, and the command use the same mnemonic that the module.
1118
1119 This test suite can be found in ``<repo>/rpp/lib/apps/rpp-test-suite`` for the ARM version and in 
1120 ``<repo>/rpp/lib/apps/rpp-test-suite_posix`` for the simulated version.
1121
1122 The application enables a command processor using the SCI at **115200-8-N-1**:
1123
1124 ```
1125 RPP Library Test Suite.
1126 ===========================================================
1127 [Type a module to test or 'help']
1128 --> help
1129 Available commands:
1130         help - Display this help.
1131         ain  - Test Analog Input.
1132         aout - Test Analog Output.
1133         can  - Test CAN communication.
1134         din  - Test Digital Inputs.
1135         eth  - Test Ethernet communication.
1136         fr   - Test Frame Relay communication.
1137         hbr  - Test H-Bridge.
1138         hout - Test High Power Output.
1139         lin  - Test LIN communication.
1140         lout - Test Digital Outputs.
1141         mout - Test Power Outputs.
1142         sci  - Test Serial Communication Interface.
1143         sdc  - Test SD-Card.
1144         sdr  - Test SD-RAM.
1145 ```
1146
1147 Current modules with tests implemented are:
1148
1149 %tex% ''' \begin{multicols}{2}
1150 - AIN.
1151 - AOUT.
1152 - DIN.
1153 - HBR.
1154 - LOUT.
1155 - MOUT.
1156 - SCI. (the test-suite itself)
1157 - SDR.
1158
1159
1160 %tex% ''' \end{multicols}
1161
1162 NEWPAGE
1163
1164 === AIN test description ===[ain_test_description]
1165
1166 %DONE
1167 This test will read all the analog inputs at a rate of 100 times per second and print the result.
1168
1169 ```
1170 --> ain
1171 Analog Inputs Test [1-12]:
1172 ===========================================================
1173    1    2    3    4    5    6    7    8    9   10   11   12
1174    0    0    0    0    0    0    0    0    0    0    0    0
1175 ```
1176
1177 Status: **PASSED** for channels 1-5. 6-12 remain untested but they //should// work.
1178
1179 === AOUT test description ===[aout_test_description]
1180
1181 %DONE
1182 This test will generate a 10Hz sinus wave on all the analog outputs with a sampling rate of 1kHz. 
1183 The sinus wave of each analog output channel is sifted by (1/4)pi.
1184
1185 ```
1186 --> aout
1187 Analog Output Test at 10 Hz:
1188 ===========================================================
1189 Samples: 7331
1190 ```
1191
1192 Status: **PASSED**.
1193
1194 === DIN test description ===[din_test_description]
1195
1196 %DONE
1197 This test will read all 16 + 8 the digital inputs at a rate of 100 times per second, using both low speed 
1198 SPI chip and variable threshold high-speed inputs.
1199
1200 ```
1201 --> din
1202 Digital Inputs Test [1-16]:
1203 ===========================================================
1204  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16  A  B  C  D  E  F  G  H
1205  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
1206 ```
1207
1208 Status: 
1209  - Low speed fixed threshold [1-16]: **PASSED**.
1210  - High speed variable threshold [A-H]: **FAILED**.
1211
1212 === HBR test description ===[hbr_test_description]
1213
1214 %DONE
1215 This test will generate a sinus wave to control the H-Bridge of one period per 20 seconds (0.05Hz) at a 
1216 sampling rate of 20Hz.
1217
1218 ```
1219 --> hbr
1220 H-Bridge Test at 0.05 Hz:
1221 ===========================================================
1222 Samples: 72
1223 ```
1224
1225 Status: **PASSED**.
1226
1227 === LOUT test description ===[lout_test_description]
1228
1229 %DONE
1230 This test will show in the digital outputs the value in binary of a counter, incrementing the counter
1231 once per second. The counter is 8 bits, the same as the outputs, so 255 seconds are required for an
1232 overflow/restart of the counting.
1233
1234 ```
1235 --> lout
1236 Digital Output Test:
1237 ===========================================================
1238 Counter:   40 
1239 ```
1240
1241 Status: **PASSED**.
1242
1243 === MOUT test description ===[mout_test_description]
1244
1245 %DONE
1246 This test will toggle the power outputs one by one per second, then wait 10 seconds in that state while
1247 constantly verifying the diagnostics.
1248
1249 ```
1250 --> mout
1251 Power Output Test:
1252 ===========================================================
1253 1     2     3     4     5     6
1254 1: OK 1: OK 1: OK 1: OK 1: OK 1: OK 
1255 ```
1256
1257 Status: **PASSED**.
1258
1259 === SCI test description ===[sci_test_description]
1260
1261 %DONE
1262 A more comprehensive test is not implemented. The very use of this test-suite implies the correct function
1263 of the SCI module. Nevertheless, as a future improvement, a test that will verify run-time baud rate changes
1264 and test some other RPP SCI functions is desirable.
1265
1266 ```
1267 --> sci
1268 You're using the SCI, reading this and typing this command.
1269 Press any key to continue...
1270 ```
1271
1272 Status: **PASSED**.
1273
1274 === SDR test description ===[sdr_test_description]
1275
1276 %DONE
1277 This test will launch a noise generator task that will log noise and then start the library included SD-RAM 
1278 logging command processor, allowing the user to see and handle the log on the SD-RAM.
1279
1280 ```
1281 --> sdr
1282 Log control: 1024kB available.
1283 ===========================================================
1284 --> log
1285 [   1239864] This is the noise generator at iteration 1 putting some noise value 279735017.
1286 [   1240779] This is the noise generator at iteration 2 putting some noise value 1943579783.
1287
1288 --> available
1289 1023 kB of 1024 kB available.
1290
1291 --> clear
1292 Done.
1293
1294 --> exit
1295 ```
1296
1297 Status: **PASSED**.
1298
1299 NEWPAGE
1300
1301 == Static libraries ==[static_libraries]
1302
1303 %DONE
1304 The RPP Library can be compiled as a static library for ARM using TI CGT and for x86(_64) using GCC. CCS 
1305 projects ``rpp-lib`` and ``rpp-lib_posix`` in ``<repo>/rpp/lib/apps/`` allows to generate the static 
1306 libraries. After compilation, as part of the build process, both projects will automatically update the 
1307 version-controlled static libraries in ``<repo>/rpp/lib/``:
1308
1309 - ``rpp-lib.lib``, static library for ARM using TI naming scheme.
1310 - ``librpp.a``, static library for x86(_64) using standard Linux naming scheme.
1311
1312
1313 One future improvement would be the creation of a Makefile for each compilation scheme in order to not depend 
1314 on CCS managed build system. For ARM manual compilation or makefile creation using Texas CGT see the 
1315 ``target_tools.mk`` file under the Simulink RPP Target folder. The relevant aspects for compiling and linking 
1316 an application using the static libraries are:
1317
1318 **ARM compilation using CCS for the RPP board:**
1319
1320 - Include headers files of the OS for which the library was compiled against. At the time of this writing the OS 
1321   is FreeRTOS 7.0.2. See [OS interchangeable layer #os_interchangeable_layer] section above.
1322 - Include header files for the RPP library.
1323 - Add library ``rpp-lib.lib`` to the linker libraries. The RPP library **MUST** be looked for before Texas 
1324   Instruments support library ``rtsv7R4_T_be_v3D16_eabi.lib``.
1325 - Configure linker to retain ``.intvecs`` section from RPP Library:@@
1326   ``--retain="rpp-lib.lib<sys_intvecs.obj>(.intvecs)"``
1327 - Use the provided linker command file ``TMS570LS313xFlashLnk.cmd``.
1328
1329
1330 **x86(_64) compilation using GCC for Simulation:**
1331
1332 - Include headers files of the OS for Simulation. At the time of this writing the OS is POSIX FreeRTOS 6.0.4.
1333 - Include header files for the RPP library.
1334 - Create a ``RppConfig.h`` override file and drop DRV layer dependency: ``rppCONFIG_DRV 0``.
1335 - Includes must be configured in a way that the ``RppConfig.h`` taken under consideration is the override and not 
1336   the library one.
1337 - Add library ``librpp.a`` to the linker libraries.
1338 - Add ``pthread`` to the linker libraries.
1339
1340
1341 As an important note, all the models compiled using Simulink will link against ``rpp-lib.lib``. When compiling a
1342 Simulink model, Simulink, and then ``make``, will not update the generated binary if the model hasn't changed, and 
1343 then if the source code hasn't changed. Static libraries changes are not considered for re-compilation and 
1344 re-linking. If library development is being done and static library is updated, in order for the Simulink model
1345 to generate a newly linked version of the binary the whole code generation folder needs to be deleted in order to
1346 force code generation, compilation and linking with the new static library.
1347
1348
1349 NEWPAGE
1350
1351 == Base application ==[base_application]
1352
1353 %DONE
1354 In ``<repo>/rpp/lib/apps/`` there is two RPP base applications, ``base`` and ``base_posix``, that
1355 already configured for the RPP Library. It is advised that new applications uses this projects a foundations. 
1356
1357 To create a new application copy this directory and rename it. Now open files ``.project``, ``.cproject`` and 
1358 ``.ccsproject`` (if available) and change any occurrence of the work ``base`` with the name of your project. 
1359 Use only lower case ASCII letters and underscores.
1360
1361 **Steps to configure a new CCS (ARM, using CGT) RPP application:**
1362
1363 + Create a new CCS project.@@
1364 [400-base_1.png]
1365 + Create a normal folder ``include``.
1366 + Create a source folder ``src``.
1367 + Add common ``.gitignore`` to the root of that project:
1368 {{{ plain
1369 Debug
1370 Release
1371 .settings/*
1372 }}}
1373 NEWPAGE
1374 + Add new variable ``RPP_LIB_ROOT`` and point to this repository branch root.@@
1375 [400-base_2.png]
1376 + Add ``rpp-lib.lib`` static library to linker libraries and add ``RPP_LIB_ROOT`` to the library search path.@@
1377 [400-base_3.png]
1378 NEWPAGE
1379 + Configure linker to retain ``.intvecs`` from RPP static library.@@
1380 [350-base_4.png]
1381 + Configure compiler to include local includes, OS includes for TMS570 and RPP includes, in that order.@@
1382 [350-base_5.png]
1383 NEWPAGE
1384 + Configure compiler to allow GCC extensions.@@
1385 [400-base_6.png]
1386 + Import and link (__do not copy!__) linker file and board upload descriptor.@@
1387 [200-base_7.png]
1388
1389
1390 **Steps to configure a new GCC (x86(_64)) RPP simulated application:**
1391
1392 + Create a new managed C project that uses Linux GCC toolchain.
1393 + Create a source folder ``src``. Link all files from original CCS application to this folder.
1394 + Create a normal folder ``include``. Create a folder ``rpp`` inside of it.
1395 + Add common ``.gitignore`` to the root of that project:
1396 {{{ plain
1397 Debug
1398 Release
1399 .settings/*
1400 }}}
1401 NEWPAGE
1402 + Add new variable ``RPP_LIB_ROOT`` and point to this repository branch root.@@
1403 [400-base_posix_1.png]
1404 + Configure compiler to include local includes, CCS application includes, OS includes for POSIX and 
1405   RPP includes, in that order.@@
1406 [400-base_posix_2.png]
1407 NEWPAGE
1408 + Add ``rpp`` and ``pthread``to linker libraries and add ``RPP_LIB_ROOT`` to the library search path.@@
1409 [400-base_posix_3.png]
1410 + Copy ``RppConfig.h`` from RPP Library to a new folder ``include/rpp`` and configure it drop DRV layer 
1411   dependency: ``rppCONFIG_DRV 0``.@@
1412 [200-base_posix_4.png]
1413
1414
1415 **In general any RPP application uses the layout/template:**
1416
1417 + Include RPP library header file.
1418 {{{ cpp
1419 #include "rpp/rpp.h"
1420 }}}
1421
1422 NEWPAGE
1423 + Create one or as many FreeRTOS task function definitions as required. Those
1424   tasks should use functions from this library.
1425 {{{ cpp
1426 void my_task(void* p)
1427 {
1428     static const portTickType freq_ticks = 1000 / portTICK_RATE_MS;
1429     portTickType last_wake_time = xTaskGetTickCount();
1430     while(TRUE) {
1431         /* Wait until next step */
1432         vTaskDelayUntil(&last_wake_time, freq_ticks);
1433         rpp_sci_printf((const char*)"Hello RPP.\r\n");
1434     }
1435 }
1436 }}}
1437
1438 + Create the main function that will:
1439  - Initialize the RPP board.
1440  - Spawn the tasks the application requires. Refer to FreeRTOS API for
1441    details.
1442  - Start the FreeRTOS Scheduler. Refer to FreeRTOS API for details.
1443  - Catch if idle task could not be created.
1444 +
1445 {{{ cpp
1446 void main(void)
1447 {
1448     /* Initialize RPP board */
1449     rpp_init();
1450
1451     /* Spawn tasks */
1452     if(xTaskCreate(my_task, (const signed char*)"my_task",
1453             512, NULL, 0, NULL) != pdPASS) {
1454         #ifdef DEBUG
1455         rpp_sci_printf((const char*)
1456             "ERROR: Cannot spawn control task.\r\n"
1457         );
1458         #endif
1459         while(TRUE) { asm(" nop"); }
1460     }
1461
1462     /* Start the FreeRTOS Scheduler */
1463     vTaskStartScheduler();
1464
1465     /* Catch scheduler start error */
1466     #ifdef DEBUG
1467     rpp_sci_printf((const char*)
1468             "ERROR: Problem allocating memory for idle task.\r\n"
1469         );
1470     #endif
1471     while(TRUE) { asm(" nop"); }
1472 }
1473 }}}
1474
1475 + Create hook functions for FreeRTOS:
1476  - ``vApplicationMallocFailedHook()`` allows to catch memory allocation errors.
1477  - ``vApplicationStackOverflowHook()`` allows to catch if a task overflows it's
1478    stack.
1479 +
1480 {{{ cpp
1481 #if configUSE_MALLOC_FAILED_HOOK == 1
1482 /**
1483  * FreeRTOS malloc() failed hook.
1484  */
1485 void vApplicationMallocFailedHook(void) {
1486     #ifdef DEBUG
1487     rpp_sci_printf((const char*)
1488             "ERROR: manual memory allocation failed.\r\n"
1489         );
1490     #endif
1491 }
1492 #endif
1493
1494
1495 #if configCHECK_FOR_STACK_OVERFLOW > 0
1496 /**
1497  * FreeRTOS stack overflow hook.
1498  */
1499 void vApplicationStackOverflowHook(xTaskHandle xTask,
1500                                    signed portCHAR *pcTaskName) {
1501     #ifdef DEBUG
1502     rpp_sci_printf((const char*)
1503             "ERROR: Stack overflow : \"%s\".\r\n", pcTaskName
1504         );
1505     #endif
1506 }
1507 #endif
1508 }}}
1509
1510 NEWPAGE
1511
1512
1513 == API generation ==[api_generation]
1514
1515 %DONE
1516 The RPP Layer is formatted using Doxygen documentation generator. This allows to generate a high quality 
1517 API reference. To generate the API reference do in a terminal:
1518
1519 {{{ bash
1520 cd <repo>/rpp/lib/rpp/doc/api
1521 doxygen doxygen.conf
1522 xdg-open html/index.html
1523 }}}
1524
1525 The files under ``<repo>/rpp/lib/rpp/doc/api/content`` are used for the API reference generation are their
1526 name is self-explanatory:
1527
1528 ```
1529 blocks_map.html
1530 blocks.png
1531 cvut.png
1532 footer.html
1533 main_page.dox
1534 ```
1535
1536 To install Doxygen see [Development environment #development_environment] section.
1537
1538 == API Reference ==[api_reference]
1539
1540 %DONE
1541 For the complete API reference please generate the HTML version using the above section instructions.
1542 Here is listed the index of functions of each module and their brief.
1543
1544 Please note that not all modules were implemented as part of this project. See 
1545 [RPP Layer Modules #rpp_layer_modules] for a list of the modules implemented.
1546
1547 NEWPAGE
1548
1549 === DIN API Reference ===[din_api_reference]
1550
1551 %DONE
1552 ``int8_t rpp_din_init();`` @@ -> DIN module initialization. @@ @@
1553 ``int8_t rpp_din_ref(uint16_t refA, uint16_t refB);`` @@ -> Configure voltage reference levels for digital inputs using variable reference threshold. @@ @@
1554 ``int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type, boolean_t active, boolean_t can_wake);`` @@ -> Configure given pin. @@ @@
1555 ``int8_t rpp_din_get(uint8_t pin, boolean_t var_thr);`` @@ -> Get the current cached value of the given pin. @@ @@
1556 ``int8_t rpp_din_diag(uint8_t pin);`` @@ -> Get the diagnostic cached value for given pin. @@ @@
1557 ``int8_t rpp_din_update();`` @@ -> Read and update cached values and diagnostic values of all pins. Also commit configuration changes.
1558
1559 === LOUT API Reference ===[lout_api_reference]
1560
1561 %DONE
1562 ``int8_t rpp_lout_init();`` @@ -> LOUT module initialization. @@ @@
1563 ``int8_t rpp_lout_set(uint8_t pin, uint8_t val);`` @@ -> Set the output cache of given pin to given value. @@ @@
1564 ``int8_t rpp_lout_diag(uint8_t pin);`` @@ -> Get the diagnostic cached value for given pin. @@ @@
1565 ``int8_t rpp_lout_update();`` @@ -> Flush cached output values and read back diagnostic values of all pins.
1566
1567 === AIN API Reference ===[ain_api_reference]
1568
1569 %DONE
1570 ``int8_t rpp_ain_init();`` @@ -> AIN module initialization. @@ @@
1571 ``int16_t rpp_ain_get(uint8_t pin);`` @@ -> Get the current analog value on the given pin. @@ @@
1572 ``int8_t rpp_ain_update();`` @@ -> Read and update analog cached values.
1573
1574
1575 === AOUT API Reference ===[aout_api_reference]
1576
1577 %DONE
1578 ``#define RPP_DAC_OA   5.6`` @@ -> DAC output operational amplifier multiplication constant. @@ @@
1579 ``#define RPP_DAC_VREF 2.5`` @@ -> DAC hardware reference voltage. @@ @@
1580 ``int8_t rpp_aout_init();`` @@ -> AOUT module initialization. @@ @@
1581 ``int8_t rpp_aout_setup(uint8_t pin, boolean_t enabled);`` @@ -> Configure enabled/disabled state for given pin. @@ @@
1582 ``int8_t rpp_aout_set(uint8_t pin, uint16_t val);`` @@ -> Set the output cache of given pin to given value. @@ @@
1583 ``int8_t rpp_aout_set_voltage(uint8_t pin, uint16_t mv);`` @@ -> Set output to given voltage. @@ @@
1584 ``int8_t rpp_aout_update();`` @@ -> Flush cached output values and configuration changes.
1585
1586 === HBR API Reference ===[hbr_api_reference]
1587
1588 %DONE
1589 ``int8_t rpp_hbr_init();`` @@ -> HBR module initialization. @@ @@
1590 ``int8_t rpp_hbr_enable(int32_t period);`` @@ -> Enable the H-Bridge for control. @@ @@
1591 ``int8_t rpp_hbr_control(double cmd);`` @@ -> Control the H-Bridge direction, enabled/disabled and PWM. @@ @@
1592 ``int8_t rpp_hbr_disable();`` @@ -> Disable the H-Bridge.
1593
1594 NEWPAGE
1595
1596 === MOUT API Reference ===[mout_api_reference]
1597
1598 %DONE
1599 ``int8_t rpp_hbr_init();`` @@ -> HBR module initialization. @@ @@
1600 ``int8_t rpp_mout_init();`` @@ -> MOUT module initialization. @@ @@
1601 ``int8_t rpp_mout_set(uint8_t pin, uint8_t val);`` @@ -> Set the output of given pin to given value. @@ @@
1602 ``int8_t rpp_mout_get(uint8_t pin);`` @@ -> Get the cached value of the given pin set by rpp_mout_set(). @@ @@
1603 ``int8_t rpp_mout_diag(uint8_t pin);`` @@ -> Reads the value on the given diagnostic pin.
1604
1605 === HOUT API Reference ===[hout_api_reference]
1606
1607 %DONE
1608 ``int8_t rpp_hout_init();`` @@ -> HOUT module initialization.
1609
1610 === CAN API Reference ===[can_api_reference]
1611
1612 %DONE
1613 ``int8_t rpp_can_init();`` @@ -> CAN module initialization.
1614
1615 === LIN API Reference ===[lin_api_reference]
1616
1617 %DONE
1618 ``int8_t rpp_lin_init();`` @@ -> LIN module initialization.
1619
1620 === FR API Reference ===[fr_api_reference]
1621
1622 %DONE
1623 ``int8_t rpp_fr_init();`` @@ -> FR module initialization.
1624
1625 NEWPAGE
1626
1627 === SCI API Reference ===[sci_api_reference]
1628
1629 %DONE
1630 ``int8_t rpp_sci_init();`` @@ -> SCI module initialization. @@ @@
1631 ``boolean_t rpp_sci_setup(uint32_t baud);`` @@ -> SCI module setup. @@ @@
1632 ``uint16_t rpp_sci_available();`` @@ -> Number of bytes available on input buffer. @@ @@
1633 ``int8_t rpp_sci_read(uint32_t amount, uint8_t* buffer);`` @@ -> Read n number of bytes from input buffer. @@ @@
1634 ``int8_t rpp_sci_read_nb(uint32_t amount, uint8_t* buffer);`` @@ -> Read n number of bytes from input buffer if possible. @@ @@
1635 ``int8_t rpp_sci_write(uint32_t amount, uint8_t* data);`` @@ -> Write n number of bytes to the output buffer. @@ @@
1636 ``int8_t rpp_sci_write_nb(uint32_t amount, uint8_t* data);`` @@ -> Write n number of bytes to the output buffer if possible. @@ @@
1637 ``int8_t rpp_sci_flush(boolean_t buff);`` @@ -> Flush incomming or outgoing buffers. @@ @@
1638 ``int32_t rpp_sci_printf(const char* format, ...);`` @@ -> C style printf using RPP SCI module. @@ @@
1639 ``int8_t rpp_sci_putc(uint8_t byte);`` @@ -> C style putc (put character) using RPP SCI module. @@ @@
1640 ``int16_t rpp_sci_getc();`` @@ -> C style getc (get character) using RPP SCI module.
1641
1642 === ETH API Reference ===[eth_api_reference]
1643
1644 %DONE
1645 ``int8_t rpp_eth_init();`` @@ -> ETH module initialization.
1646
1647 === SDC API Reference ===[sdc_api_reference]
1648
1649 %DONE
1650 ``int8_t rpp_sdc_init();`` @@ -> SDC module initialization.
1651
1652 === SDR API Reference ===[sdr_api_reference]
1653
1654 %DONE
1655 ``#define RPP_SDR_ADDR_START 0x80000000U`` @@ -> SDRAM start address on RPP board. @@ @@
1656 ``#define RPP_SDR_ADDR_END   0x83FFFFFFU`` @@ -> SDRAM end address on RPP board. @@ @@
1657 ``int8_t rpp_sdr_init();`` @@ -> SDR module initialization. @@ @@
1658 ``int8_t rpp_sdr_setup(boolean_t enable);`` @@ -> Configure SD-RAM logging. @@ @@
1659 ``uint32_t rpp_sdr_available();`` @@ -> Query for the amount of space free on the SD-RAM. @@ @@
1660 ``int32_t rpp_sdr_printf(const char* format, ...);`` @@ -> Store a formatted user string on the log, if logging is enabled. @@ @@
1661 ``int8_t rpp_sdr_clear();`` @@ -> Clear log. @@ @@
1662 ``int8_t rpp_sdr_show(boolean_t start);`` @@ -> Start/Stop the task that sends the log to the SCI.
1663
1664 NEWPAGE
1665
1666 = Simulink RPP Block Library =[simulink_rpp_block_library]
1667
1668
1669
1670 == Description ==[description]
1671
1672 The Simulink RPP Block Library is the ideal set of blocks that should be implemented for the RPP board.
1673 As part of this project this ideal set was defined, but not all blocks were implemented. The following
1674 table shows the current status of the block library.
1675
1676 || CATEGORY                | NAME                           | STATUS*  | MNEMONIC    | LRH* 
1677  | System blocks           | Configuration block            | ``X``    | ``[CONF]``  | ``RppConfig.h``  |
1678  | Logic IO blocks         | Digital Input block            | ``T``    | ``[DIN ]``  | ``rpp_din.h``    |
1679  |                         | Digital Output block           | ``T``    | ``[LOUT]``  | ``rpp_lout.h``   |
1680  |                         | Analog Input block             | ``T``    | ``[AIN ]``  | ``rpp_ain.h``    |
1681  |                         | Analog Output block            | ``T``    | ``[AOUT]``  | ``rpp_aout.h``   |
1682  | Power output blocks     | H-Bridge Control block         | ``T``    | ``[HBR ]``  | ``rpp_hbr.h``    |
1683  |                         | Power output block             | ``T``    | ``[MOUT]``  | ``rpp_mout.h``   |
1684  |                         | High-Power output block        | ``X``    | ``[HOUT]``  | ``rpp_hout.h``   |
1685  | Communication blocks    | CAN Bus receive block          | ``X``    | ``[CANR]``  | ``rpp_can.h``    |
1686  |                         | CAN Bus send msg block         | ``X``    | ``[CANS]``  | - Idem -         |
1687  |                         | LIN receive block              | ``X``    | ``[LINR]``  | ``rpp_lin.h``    |
1688  |                         | LIN send msg block             | ``X``    | ``[LINS]``  | - Idem -         |
1689  |                         | FlexRay receive block          | ``X``    | ``[FRR ]``  | ``rpp_fr.h``     |
1690  |                         | FlexRay send msg block         | ``X``    | ``[FRS ]``  | - Idem -         |
1691  |                         | SCI receive block              | ``T``    | ``[SCIR]``  | ``rpp_sci.h``    |
1692  |                         | SCI send msg block             | ``T``    | ``[SCIS]``  | - Idem -         |
1693  |                         | SCI configure block            | ``T``    | ``[SCIC]``  | - Idem -         |
1694  |                         | Ethernet receive block         | ``X``    | ``[ETHR]``  | ``rpp_eth.h``    |
1695  |                         | Ethernet send msg block        | ``X``    | ``[ETHS]``  | - Idem -         |
1696  | Logging/Storage blocks  | SD Card write block            | ``T``    | ``[SDCW]``  | ``rpp_sdc.h``    |
1697  |                         | SDRAM write block              | ``X``    | ``[SDRW]``  | ``rpp_sdr.h``    |
1698  | Trigger blocks          | Overrun detected block         | ``X``    | ``[TROR]``  | - None -         |
1699  |                         | Stack overflow detected block  | ``X``    | ``[TRSO]``  | - None -         |
1700  |                         | Malloc Failed detected block   | ``X``    | ``[TRMF]``  | - None -         |
1701
1702 **Legend:**
1703 - *LRH    : Library Reference Header.
1704 - *STATUS : 
1705  - ``X`` - Unimplemented. Files non present.
1706  - ``P`` - Unimplemented. Files present.
1707  - ``W`` - Work in progress.
1708  - ``I`` - Implemented.
1709  - ``T`` - Implemented and tested.
1710
1711
1712 __Notes__: Each block that can detect fault condition should have a trigger output.
1713            High-power output provides current flow as an input to the model.
1714
1715
1716
1717 === C MEX S-Functions ===[c_mex_s_functions]
1718
1719 All of the blocks are implemented as a C Mex S-Function coded by hand. In the this section this approach is 
1720 explained.
1721
1722 Anatomy
1723 Compilation
1724
1725 === Target Language Compiler files ===[target_language_compiler_files]
1726
1727 Anatomy
1728
1729
1730 NEWPAGE
1731
1732 == Repository branch description ==[repository_branch_description]
1733
1734 -> ``header.c`` and ``trailer.c``
1735
1736 RPP framework for simple S-Functions.
1737
1738 This files are included at the head and tail of each S-Function file. They include refactored and 
1739 commonly repeated structures that pollute S-Functions implementations. They include basic includes, 
1740 required definitions, macro definitions, common functions implementations and documentation on 
1741 optional functions and commented prototypes for optional model calls/hooks.
1742
1743 - __Reference:__
1744  - None.
1745
1746
1747 -> ``sfunction_{mnemonic}.c``
1748
1749 C-MEX S-Function implementation for {mnemonic} block.
1750
1751 This file implements the {mnemonic} block using C-MEX S-Function API. See the reference for information 
1752 about the S-Function API.
1753
1754 - __Reference:__
1755  - ``<repo>/refs/sfunctions.pdf``
1756
1757
1758 -> ``tlc_c/sfunction_{mnemonic}.tlc``
1759
1760 Target Language Compiler (TLC) file for {mnemonic} block.
1761
1762 This file implements the C code inlining for {mnemonic} block. See the reference for information about 
1763 the TLC API.
1764
1765 - __Reference:__
1766  - ``<repo>/refs/rtw_tlc.pdf``
1767
1768
1769 -> ``tlc_c/common.tlc``
1770
1771 Common TLC functions.
1772
1773 This file implements common TLC functions used by all the blocks.
1774
1775 - __Reference:__
1776  - None.
1777
1778
1779 -> ``slblocks.m``
1780
1781 Simulink library control file.
1782
1783 This file allows a group of blocks to be integrated into the Simulink Library and Simulink Library 
1784 Browser. This file is required by Simulink in order to interpret this folder as a block library. 
1785 For information about this file see the references.
1786
1787 - __Reference:__
1788  - ``<repo>/refs/rtw_ug.pdf`` p. 1127
1789
1790
1791 -> ``rpp_lib.slx``
1792
1793 RPP Simulink block library.
1794
1795 Simulink block library that includes all the blocks. This file is referenced by ``slblocks.m``
1796
1797 - __Reference:__
1798  - None.
1799
1800
1801 -> compile_blocks.m
1802
1803 Blocks compilation script.
1804
1805 This script compiles all the sfunction blocks to MEX executables. This script is called by the 
1806 ``rpp_setup()`` function in order make all the blocks available to the Simulink environment or it 
1807 can be called independently when developing S-Functions.
1808
1809 - __Reference:__
1810  - None.
1811
1812
1813 NEWPAGE
1814
1815 == Block Library Reference ==[block_library_reference]
1816
1817 This section describes each one of the Simulink blocks implements as part of this project:
1818
1819 %tex% ''' \begin{figure}[H]\advance\leftskip-1cm
1820 [530-block_library.png]
1821 %tex% ''' \caption{Simulink RPP Block Library.}\end{figure}
1822
1823 NEWPAGE
1824
1825 === DIN Digital Input block ===[din_digital_input_block]
1826
1827 ```
1828     Inputs      : 0
1829         None
1830
1831     Outputs     : 2
1832         bool    Digital Input
1833         bool    ErrFlag
1834
1835     Parameters  : 2
1836         uint8   Pin number [1-16]
1837         bool    Use variable threshold
1838 ```
1839
1840 This block allows to read the digital inputs on the RPP board. The variable threshold check change the read
1841 mode of the pin (from the block size this is working, library call is not working though). The ErrFlag should
1842 raise if ``rpp_din_update()`` or ``rpp_din_get()`` returns error. ``rpp_din_update()`` is called just by the
1843 first DIN block in the model and thus only the first block could raise the flag because of this. In case an 
1844 errors occurs the return value will always be LOW (0). Because the ErrFlag should never set, once set the
1845 following steps will never clear it back.
1846
1847
1848 %tex% ''' \begin{multicols}{3}
1849 - **Tested**:
1850  - Changing the pin.
1851  - Compilation and general use.
1852
1853
1854 %tex% ''' \vfill\columnbreak
1855 - **Untested**:
1856  - Faulty situation for the ErrFlag to set.
1857
1858
1859 %tex% ''' \vfill\columnbreak
1860 - **Not working**:
1861  - Using variable threshold.
1862
1863
1864 %tex% ''' \end{multicols}
1865
1866
1867 **RPP API functions used:**
1868 - ``rpp_din_setup()``.
1869 - ``rpp_din_update()``.
1870 - ``rpp_din_get()``.
1871
1872
1873 **Relevant demos:**
1874 - ``digital_passthrough``.
1875 - ``hbridge_digital_control``.
1876
1877
1878 NEWPAGE
1879
1880 === LOUT Digital Output block ===[lout_digital_output_block]
1881
1882 ```
1883     Inputs      : 1
1884         bool    Digital Output
1885
1886     Outputs     : 1
1887         bool    ErrFlag
1888
1889     Parameters  : 1
1890         uint8   Pin number [1-8]
1891 ```
1892
1893 This block allows to write to the digital outputs on the RPP board. The ErrFlag should raise if ``rpp_lout_set()`` 
1894 or ``rpp_lout_update()`` returns error. Because the ErrFlag should never set, once set the following steps will 
1895 never clear it back. ``rpp_lout_update()`` is called on each block, which is not the most efficient but guaranties 
1896 consistent behavior.
1897
1898
1899 **Status:**
1900 %tex% ''' \begin{multicols}{3}
1901 - **Tested**:
1902  - Changing the pin.
1903  - Compilation and general use.
1904
1905
1906 %tex% ''' \vfill\columnbreak
1907 - **Untested**:
1908  - Faulty situation for the ErrFlag to set.
1909
1910
1911 %tex% ''' \vfill\columnbreak
1912 - **Not working**:
1913
1914
1915 %tex% ''' \end{multicols}
1916
1917
1918 **RPP API functions used:**
1919 - ``rpp_lout_set()``.
1920 - ``rpp_lout_update()``.
1921
1922
1923 **Relevant demos:**
1924 - ``digital_passthrough``.
1925 - ``led_blink_all``.
1926 - ``led_blink``.
1927
1928
1929 NEWPAGE
1930
1931 === AIN Analog Input block ===[ain_analog_input_block]
1932
1933 ```
1934     Inputs      : 0
1935         None
1936
1937     Outputs     : 2
1938         uint16  Analog Input
1939         bool    ErrFlag
1940
1941     Parameters  : 1
1942         uint8   Pin number [1-12]
1943 ```
1944
1945 This block allows to read the analog inputs on the RPP board. The ErrFlag should if raise ``rpp_ain_update()`` 
1946 or ``rpp_ain_get()`` returns error. ``rpp_ain_update()`` is called just by the first DIN block in the model and 
1947 thus only the first block could raise the flag because of this. In case an errors occurs the return value will 
1948 always be 0. Because the ErrFlag should never set, once set the following steps will never clear it back.
1949
1950
1951 **Status:**
1952 %tex% ''' \begin{multicols}{3}
1953 - **Tested**:
1954  - Changing the pin.
1955  - Compilation and general use.
1956
1957
1958 %tex% ''' \vfill\columnbreak
1959 - **Untested**:
1960  - Faulty situation for the ErrFlag to set.
1961
1962
1963 %tex% ''' \vfill\columnbreak
1964 - **Not working**:
1965
1966
1967 %tex% ''' \end{multicols}
1968
1969
1970 **RPP API functions used:**
1971 - ``rpp_ain_update()``.
1972 - ``rpp_ain_get()``.
1973
1974
1975 **Relevant demos:**
1976 - ``analog_passthrough``.
1977 - ``hbridge_analog_control``.
1978 - ``log_analog_input``.
1979
1980
1981 NEWPAGE
1982
1983 === AOUT Analog Output block ===[aout_analog_output_block]
1984
1985 ```
1986     Inputs      : 1
1987         uint16  Analog Output
1988
1989     Outputs     : 1
1990         bool    ErrFlag
1991
1992     Parameters  : 1
1993         uint8   Pin number [1-4]
1994         bool    UseVoltage
1995 ```
1996
1997 This block allows to write to the analog outputs on the RPP board. The UseVoltage flag allows the user to
1998 configure if block inputs should be interpreted as raw DAC value or millivolts. The ErrFlag should raise 
1999 if ``rpp_aout_update()`` or ``rpp_aout_set()`` (or ``rpp_aout_set_voltage()`` depending on block configuration) 
2000 returns error. Because the ErrFlag should never set, once set the following steps will never clear it back.
2001
2002 ``rpp_aout_update()`` is called on each block but the implementation provides this to be efficient.
2003
2004 There is a know bug on the RPP Library, check ``rpp_aout_update()`` on the RPP API for details. Because of this, 
2005 the outputs of the DACs are initialized on the first step of the model and not on the model initialization.
2006
2007
2008 **Status:**
2009 %tex% ''' \begin{multicols}{3}
2010 - **Tested**:
2011  - Changing the pin.
2012  - Changing voltage/value flag.
2013  - Compilation and general use.
2014
2015
2016 %tex% ''' \vfill\columnbreak
2017 - **Untested**:
2018  - Faulty situation for the ErrFlag to set.
2019
2020
2021 %tex% ''' \vfill\columnbreak
2022 - **Not working**:
2023  - Initializing DACs on model's initialization.
2024
2025
2026 %tex% ''' \end{multicols}
2027
2028
2029 **RPP API functions used:**
2030 - ``rpp_aout_setup()``.
2031 - ``rpp_aout_set()``, or
2032 - ``rpp_aout_set_voltage()``.
2033 - ``rpp_aout_update()``.
2034
2035
2036 **Relevant demos:**
2037 - ``analog_passthrough``.
2038 - ``analog_sinewave``.
2039
2040
2041 NEWPAGE
2042
2043 === HBR H-Bridge Control block ===[hbr_h_bridge_control_block]
2044
2045 ```
2046     Inputs      : 1
2047         double  Control
2048
2049     Outputs     : 1
2050         bool    ErrFlag
2051
2052     Parameters  : 0
2053         None
2054 ```
2055
2056 This block allows to control the H-Bridge on the RPP board. The ErrFlag should raise only if 
2057 ``rpp_hbr_control()`` returns error. The H-Bridge is initialized with the default frequency (~18kHz). 
2058 A future improvement could include a parameter to set the frequency. Because the ErrFlag should never
2059 set, once set the following steps will never clear it back.
2060
2061
2062 **Status:**
2063 %tex% ''' \begin{multicols}{3}
2064 - **Tested**:
2065  - Compilation and general use.
2066
2067
2068 %tex% ''' \vfill\columnbreak
2069 - **Untested**:
2070  - Faulty situation for the ErrFlag to set.
2071
2072
2073 %tex% ''' \vfill\columnbreak
2074 - **Not working**:
2075
2076
2077 %tex% ''' \end{multicols}
2078
2079
2080 **RPP API functions used:**
2081 - ``rpp_hbr_enable()``.
2082 - ``rpp_hbr_control()``.
2083
2084
2085 **Relevant demos:**
2086 - ``hbridge_analog_control``.
2087 - ``hbridge_digital_control``.
2088 - ``hbridge_sinewave_control``.
2089
2090
2091 NEWPAGE
2092
2093 === MOUT Power Output block ===[mout_power_output_block]
2094
2095 ```
2096     Inputs      : 1
2097         bool    Power Output
2098
2099     Outputs     : 1
2100         bool    ErrFlag
2101
2102     Parameters  : 1
2103         uint8   Pin number [1-6]
2104 ```
2105
2106 This block allows to write the power outputs (2A) on the RPP board. The ErrFlag should raise only if 
2107 ``rpp_mout_set()``returns error. Note that ``rpp_mout_set()`` returns error only if some bad parameter
2108 or in case it could detect a faulty condition on the pin in a very very short period of time after 
2109 setting the value, see the function API for details. If the faulty condition persist on the next step
2110 the call will successfully detect the faulty condition and ErrFlag should set. Because the ErrFlag should 
2111 never set, once set the following steps will never clear it back.
2112
2113
2114 **Status:**
2115 %tex% ''' \begin{multicols}{3}
2116 - **Tested**:
2117  - Changing the pin.
2118  - Compilation and general use.
2119
2120
2121 %tex% ''' \vfill\columnbreak
2122 - **Untested**:
2123  - Faulty situation for the ErrFlag to set.
2124
2125
2126 %tex% ''' \vfill\columnbreak
2127 - **Not working**:
2128
2129
2130 %tex% ''' \end{multicols}
2131
2132
2133 **RPP API functions used:**
2134 - ``rpp_mout_set()``.
2135
2136
2137 **Relevant demos:**
2138 - ``power_toggle``.
2139
2140
2141 NEWPAGE
2142
2143 === SCIR Serial Comm. Interface Receive ===[scir_serial_comm_interface_receive]
2144
2145 ```
2146     Inputs      : 0
2147         None
2148
2149     Outputs     : 2
2150         uint8   Data
2151         bool    ErrFlag
2152
2153     Parameters  : 0
2154         None
2155 ```
2156
2157 This block allows to receive a byte from the SCI. The ErrFlag should raise if ``rpp_sci_read_nb()`` 
2158 doesn't succeed. The behavior of the ErrFlag is different from others blocks in that this block will 
2159 set or clear the flag if the call fails of success at each step. Note that this block uses the 
2160 non-blocking call to read the SCI and thus will never cause an overrun.
2161
2162
2163 **Status:**
2164 %tex% ''' \begin{multicols}{3}
2165 - **Tested**:
2166  - Receiving data.
2167  - Compilation and general use.
2168  - Faulty situation for the ErrFlag to set.
2169
2170
2171 %tex% ''' \vfill\columnbreak
2172 - **Untested**:
2173
2174
2175 %tex% ''' \vfill\columnbreak
2176 - **Not working**:
2177
2178
2179 %tex% ''' \end{multicols}
2180
2181
2182 **RPP API functions used:**
2183 - ``rpp_sci_read_nb()``.
2184
2185
2186 **Relevant demos:**
2187 - ``echo_char``.
2188
2189
2190 NEWPAGE
2191
2192 === SCIS Serial Comm. Interface Send ===[scis_serial_comm_interface_send]
2193
2194 ```
2195     Inputs      : 1
2196         uint8   Data
2197
2198     Outputs     : 1
2199         bool    ErrFlag
2200
2201     Parameters  : 2
2202         bool    UsePrintf
2203         string  PrintFormat [SETTING]
2204 ```
2205
2206 This block allows to send a byte to the SCI or to print a formatted string that uses that byte. The 
2207 UsePrintf flag allows to user to select ``rpp_sci_write_nb()`` (raw send) or ``rpp_sci_printf()`` 
2208 (formatted print) as the function the block should use on code generation. If UsePrintf is set the 
2209 PrintFormat string parameters SETTING is used as the format specifier. Note that this value is 
2210 inserted raw between quotes on code generation and thus there is no validation on it. User should
2211 always put any valid integer specifier for the value on the input of the block.
2212
2213 The behavior of this block depends if UsePrintf is set or not. If set, the call ``rpp_sci_printf()``
2214 (a blocking call) could potentially overrun the step. Also, the ErrFlag will set only if 
2215 ``rpp_sci_printf()`` returns an error, and because it should never set, once set it will never
2216 clear back. On the contrary, if UsePrintf is clear, the call ``rpp_sci_write_nb()`` (non-blocking) 
2217 is used and thus the step cannot be overrun, but because is a best-effort call it cannot guarantee that 
2218 all the data will be sent. In the case that not all data could be sent, the ErrFlag will set, but it
2219 will clear back if the next step is able to send all it's data (which with the current implementation
2220 is just one byte).
2221
2222 A possible future improvement for this block is to allow input to be non-scalar so user can print a whole
2223 string in one step using raw non-blocking write. This is currently possible if input configuration is 
2224 adapted in S-Function and TLC. The problem this could pose is is that for printf user should include
2225 specifiers for all the cells in the non-scalar input, and if unknown, then printf cannot be used.
2226
2227
2228 **Status:**
2229 %tex% ''' \begin{multicols}{3}
2230 - **Tested**:
2231  - Sending data.
2232  - Compilation and general use.
2233
2234
2235 %tex% ''' \vfill\columnbreak
2236 - **Untested**:
2237  - Faulty situation for the ErrFlag to set.
2238
2239
2240 %tex% ''' \vfill\columnbreak
2241 - **Not working**:
2242
2243
2244 %tex% ''' \end{multicols}
2245
2246
2247 **RPP API functions used:**
2248 - ``rpp_sci_write_nb()``, or ``rpp_sci_printf()``.
2249
2250
2251 **Relevant demos:**
2252 - ``echo_char`` and ``hello_world``.
2253
2254
2255 NEWPAGE
2256
2257 === SCIC Serial Comm. Interface Configure ===[scic_serial_comm_interface_configure]
2258
2259 ```
2260     Inputs      : 0
2261         None
2262
2263     Outputs     : 0
2264         None
2265
2266     Parameters  : 1
2267         uint32  Baud rate
2268 ```
2269
2270 This block allows to configure the baud rate of the SCI. There should only one block of this type per
2271 model, and this requirement is not validated, but the inclusion of several blocks is harmless and will
2272 just produce the baud rate to be changed several times, being the final baud rate to be the one of the 
2273 last executed block. This block just executes on model initialization and not on each step.
2274
2275
2276 **Status:**
2277 %tex% ''' \begin{multicols}{3}
2278 - **Tested**:
2279  - Changing baud rate.
2280  - Compilation and general use.
2281
2282
2283 %tex% ''' \vfill\columnbreak
2284 - **Untested**:
2285  - Using more than one block in a model.
2286
2287
2288 %tex% ''' \vfill\columnbreak
2289 - **Not working**:
2290
2291
2292 %tex% ''' \end{multicols}
2293
2294
2295 **RPP API functions used:**
2296 - ``rpp_sci_setup()``.
2297
2298
2299 **Relevant demos:**
2300 - ``echo_char``.
2301 - ``hello_world``.
2302
2303
2304 NEWPAGE
2305
2306 === SDRW SD-RAM Write ===[sdrw_sd_ram_write]
2307
2308 ```
2309     Inputs      : 1
2310         double  Data
2311
2312     Outputs     : 1
2313         bool    ErrFlag
2314
2315     Parameters  : 2
2316         uint8   Block ID
2317         string  PrintFormat [SETTING]
2318 ```
2319
2320 This block allows to log a double value to the SD-RAM. User needs to provide a valid PrintFormat string to
2321 format and register the double value on the log. The PrintFormat string should include two specifiers:
2322
2323 - For the block ID. Any valid integer specifier.
2324 - For the value to log. Any valid double specifier.
2325
2326
2327 Note that the value of PrintFormat is inserted raw between quotes on code generation and thus there is no 
2328 validation on it. Error to provide a valid PrintFormat could generate compilation errors on even run-time 
2329 errors (normally this generates a warning on compile time). Note that the function for logging used is
2330 ``rpp_sdr_printf()``, which is a blocking call, and can potentially overrun the step. The ErrFlag will set
2331 if ``rpp_sdr_printf()`` returns an error (for example out of memory), but will clear back if the next step 
2332 the call to this function is successful.
2333
2334
2335 **Status:**
2336 %tex% ''' \begin{multicols}{3}
2337 - **Tested**:
2338  - Logging data.
2339  - Compilation and general use.
2340
2341
2342 %tex% ''' \vfill\columnbreak
2343 - **Untested**:
2344  - Faulty situation for the ErrFlag to set.
2345
2346
2347 %tex% ''' \vfill\columnbreak
2348 - **Not working**:
2349
2350
2351 %tex% ''' \end{multicols}
2352
2353
2354 **RPP API functions used:**
2355 - ``rpp_sdr_printf()``.
2356
2357
2358 **Relevant demos:**
2359 - ``log_analog_input``.
2360
2361
2362 NEWPAGE
2363
2364 = Simulink RPP Demo Library =[simulink_rpp_demo_library]
2365
2366
2367
2368 == Description ==[description]
2369
2370 The Simulink RPP Demo Library is a set of Simulink models that use blocks in the Simulink RPP Block Library
2371 and generates code using the Simulink RPP Target. It is used as a test suite for the Simulink RPP Block Library 
2372 but they are also intended to show basic programs built using it, because of this the demos try to use more than 
2373 one type of block and more than one block per block type.
2374
2375 The following table shows the current status of the demos:
2376
2377 || Name                         | Implemented | Tested    
2378  | analog_passthrough           | YES         | SUCCESS   | 
2379  | analog_sinewave              | YES         | SUCCESS   | 
2380  | digital_passthrough          | YES         | SUCCESS   | 
2381  | echo_char                    | YES         | SUCCESS   | 
2382  | hbridge_analog_control       | YES         | SUCCESS   | 
2383  | hbridge_digital_control      | YES         | SUCCESS   | 
2384  | hbridge_sinewave_control     | YES         | SUCCESS   | 
2385  | hello_world                  | YES         | SUCCESS   | 
2386  | led_blink_all                | YES         | SUCCESS   | 
2387  | led_blink                    | YES         | SUCCESS   | 
2388  | log_analog_input             | YES         | SUCCESS   | 
2389  | power_toggle                 | YES         | SUCCESS   | 
2390
2391 In the reference below you can find a complete description for each of the demos.
2392
2393 == Repository branch description ==[repository_branch_description]
2394
2395
2396 NEWPAGE
2397
2398 == Demos Reference ==[demos_reference]
2399
2400 This section describes the demos implemented as part of this project that uses the Simulink RRP Block 
2401 Library and generates code using the RPP Simulink Target.
2402
2403 === analog_passthrough ===[analog_passthrough]
2404
2405 %tex% ''' \begin{figure}[H]\begin{center}
2406 [450-demo_analog_passthrough.png]
2407 %tex% ''' \caption{Analog Passthrough Simulink RPP demo.}\end{center}\end{figure}
2408
2409 **Description:**
2410
2411 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2412 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2413 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2414 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2415
2416 NEWPAGE
2417
2418 === analog_sinewave ===[analog_sinewave]
2419
2420 %tex% ''' \begin{figure}[H]\begin{center}
2421 [350-demo_analog_sinewave.png]
2422 %tex% ''' \caption{Analog Sinewave Simulink RPP demo.}\end{center}\end{figure}
2423
2424 **Description:**
2425
2426 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2427 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2428 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2429 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2430
2431 NEWPAGE
2432
2433 === digital_passthrough ===[digital_passthrough]
2434
2435 %tex% ''' \begin{figure}[H]\begin{center}
2436 [350-demo_digital_passthrough.png]
2437 %tex% ''' \caption{Digital Pass-through Simulink RPP demo.}\end{center}\end{figure}
2438
2439 **Description:**
2440
2441 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2442 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2443 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2444 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2445
2446 NEWPAGE
2447
2448 === echo_char ===[echo_char]
2449
2450 %tex% ''' \begin{figure}[H]\begin{center}
2451 [450-demo_echo_char.png]
2452 %tex% ''' \caption{Echo Character Simulink RPP demo.}\end{center}\end{figure}
2453
2454 **Description:**
2455
2456 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2457 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2458 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2459 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2460
2461 NEWPAGE
2462
2463 === hbridge_analog_control ===[hbridge_analog_control]
2464
2465 %tex% ''' \begin{figure}[H]\begin{center}
2466 [450-demo_hbridge_analog_control.png]
2467 %tex% ''' \caption{H-Bridge Analog Control Simulink RPP demo.}\end{center}\end{figure}
2468
2469 **Description:**
2470
2471 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2472 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2473 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2474 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2475
2476 NEWPAGE
2477
2478 === hbridge_digital_control ===[hbridge_digital_control]
2479
2480 %tex% ''' \begin{figure}[H]\begin{center}
2481 [450-demo_hbridge_digital_control.png]
2482 %tex% ''' \caption{H-Bridge Digital Control Simulink RPP demo.}\end{center}\end{figure}
2483
2484 **Description:**
2485
2486 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2487 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2488 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2489 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2490
2491 NEWPAGE
2492
2493 === hbridge_sinewave_control ===[hbridge_sinewave_control]
2494
2495 %tex% ''' \begin{figure}[H]\begin{center}
2496 [450-demo_hbridge_sinewave_control.png]
2497 %tex% ''' \caption{H-Bridge Sinewave Control Simulink RPP demo.}\end{center}\end{figure}
2498
2499 **Description:**
2500
2501 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2502 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2503 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2504 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2505
2506 NEWPAGE
2507
2508 === hello_world ===[hello_world]
2509
2510 %tex% ''' \begin{figure}[H]\begin{center}
2511 [350-demo_hello_world.png]
2512 %tex% ''' \caption{Hello World Simulink RPP demo.}\end{center}\end{figure}
2513
2514 **Description:**
2515
2516 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2517 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2518 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2519 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2520
2521 NEWPAGE
2522
2523 === led_blink_all ===[led_blink_all]
2524
2525 %tex% ''' \begin{figure}[H]\begin{center}
2526 [350-demo_led_blink_all.png]
2527 %tex% ''' \caption{LED Blink All Simulink RPP demo.}\end{center}\end{figure}
2528
2529 **Description:**
2530
2531 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2532 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2533 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2534 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2535
2536 NEWPAGE
2537
2538 === led_blink ===[led_blink]
2539
2540 %tex% ''' \begin{figure}[H]\begin{center}
2541 [300-demo_led_blink.png]
2542 %tex% ''' \caption{LED Blink Simulink RPP demo.}\end{center}\end{figure}
2543
2544 **Description:**
2545
2546 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2547 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2548 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2549 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2550
2551 NEWPAGE
2552
2553 === log_analog_input ===[log_analog_input]
2554
2555 %tex% ''' \begin{figure}[H]\begin{center}
2556 [450-demo_log_analog_input.png]
2557 %tex% ''' \caption{Log Analog Input Simulink RPP demo.}\end{center}\end{figure}
2558
2559 **Description:**
2560
2561 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2562 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2563 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2564 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2565
2566 NEWPAGE
2567
2568 === power_toggle ===[power_toggle]
2569
2570 %tex% ''' \begin{figure}[H]\begin{center}
2571 [300-demo_power_toggle.png]
2572 %tex% ''' \caption{Power Toggle Simulink RPP demo.}\end{center}\end{figure}
2573
2574 **Description:**
2575
2576 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2577 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2578 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM
2579 LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM LORENS IPSUM 
2580
2581 NEWPAGE
2582
2583 = Glossary =[glossary]
2584
2585 : ADC
2586   //Analog to Digital Converter.//
2587   Hardware circuitry that converts a continuous physical quantity (usually voltage) to a
2588   digital number that represents the quantity's amplitude.
2589
2590 : AIN
2591   //Analog Input.//
2592   Mnemonic to refer to or something related to the analog input (ADC) hardware module.
2593
2594 : AOUT
2595   //Analog Output.//
2596   Mnemonic to refer to or something related to the analog output (DAC) hardware module.
2597
2598 : CAN
2599   //Controller Area Network.//
2600   The CAN Bus is a vehicle bus standard designed to allow microcontrollers and devices to
2601   communicate with each other within a vehicle without a host computer.
2602   In this project it is also used as mnemonic to refer to or something related to the CAN
2603   hardware module.
2604
2605 : CGT
2606   //Code Generation Tools.//
2607   Name given to the tool set produced by Texas Instruments used to compile, link, optimize,
2608   assemble, archive, among others. In this project is normally used as synonym for 
2609   ``Texas Instruments ARM compiler and linker."
2610
2611 : DAC
2612   //Digital to Analog Converter.//
2613   Hardware circuitry that converts a digital (usually binary) code to an analog signal
2614   (current, voltage, or electric charge).
2615
2616 : DIN
2617   //Digital Input.//
2618   Mnemonic to refer to or something related to the digital input hardware module.
2619
2620 : ECU
2621   //Engine Control Unit.//
2622   A type of electronic control unit that controls a series of actuators on an internal combustion 
2623   engine to ensure the optimum running.
2624
2625 : ETH
2626   //Ethernet.//
2627   Mnemonic to refer to or something related to the Ethernet hardware module.
2628
2629 : FR
2630   //FlexRay.//
2631   FlexRay is an automotive network communications protocol developed to govern on-board automotive
2632   computing.
2633   In this project it is also used as mnemonic to refer to or something related to the FlexRay
2634   hardware module.
2635
2636 : HBR
2637   //H-Bridge.//
2638   Mnemonic to refer to or something related to the H-Bridge hardware module. A H-Bridge is
2639   an electronic circuit that enables a voltage to be applied across a load in either direction.
2640
2641 : HOUT
2642   //High-Power Output.//
2643   Mnemonic to refer to or something related to the 10A, PWM, with current sensing, high-power
2644   output hardware module.
2645
2646 : IDE
2647   //Integrated Development Environment.//
2648   An IDE is a Software application that provides comprehensive facilities to computer programmers 
2649   for software development.
2650
2651 : LIN
2652   //Local Interconnect Network.//
2653   The LIN is a serial network protocol used for communication between components in vehicles.
2654   In this project it is also used as mnemonic to refer to or something related to the LIN
2655   hardware module.
2656
2657 : LOUT
2658   //Logic Output.//
2659   Mnemonic to refer to or something related to the digital output hardware module.
2660   It is logic output (100mA), as opposed to power outputs (2A, 10A).
2661
2662 : MBD
2663   //Model-Based Design.//
2664   Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated 
2665   with designing complex control, signal processing and communication systems.
2666
2667 : MEX
2668   //Matlab Executable.//
2669   Type of binary executable that can be called within Matlab. In this document the common term
2670   used is `C MEX S-Function", which means Matlab executable written in C that implements a system 
2671   function.
2672
2673 : MOUT
2674   //(Motor) Power Output.//
2675   Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
2676
2677 : RPP
2678   //Rapid Prototyping Platform//.
2679   Name of the automotive hardware board. Also generic term to define something related
2680   to the board, like the RPP Library, RPP Layer, RPP API, etc.
2681
2682 : SCI
2683   //Serial Communication Interface.//
2684   Serial Interface for communication through hardware's UART using communication standard RS-232.
2685   In this project it is also used as mnemonic to refer to or something related to the Serial
2686   Communication Interface hardware module.
2687
2688 : SDC
2689   //SD-Card.//
2690   Mnemonic to refer to or something related to the SD-Card hardware module.
2691
2692 : SDR
2693   //SD-RAM.//
2694   Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
2695
2696 : TLC
2697   //Target Language Compiler.//
2698   Technology and language used to generate code in Matlab/Simulink.
2699
2700 : UART
2701   //Universal Asynchronous Receiver/Transmitter.//
2702   Hardware circuitry that translates data between parallel and serial forms.
2703
2704
2705
2706 NEWPAGE
2707
2708 = References =[references]
2709
2710 - Horn, M. (2013). //Software obsluhující periferie a flexray na automobilové rídicí jednotce//.
2711   (Unpublished master's thesis, Czech Technical University in Prague, Prague, Czech Republic).
2712
2713 - //Model-based design//. (n.d.). In Wikipedia. 
2714   Retrieved March 10, 2013, from http://en.wikipedia.org/wiki/Model-based_design
2715
2716
2717 NEWPAGE
2718
2719 = Appendix A: Notes on FreeRTOS memory management =[appendix_a_notes_on_freertos_memory_management]
2720
2721 Write about heap implementation, FreeRTOSConfig.h heap size, C heap size, C stack size, Simulink memory, among others.
2722