]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Merge branch 'maint-rm48' into rm48/master
authorMichal Horn <hornmich@fel.cvut.cz>
Wed, 10 Dec 2014 09:29:12 +0000 (10:29 +0100)
committerMichal Horn <hornmich@fel.cvut.cz>
Wed, 10 Dec 2014 09:29:12 +0000 (10:29 +0100)
Conflicts:
doc/rpp_simulink.tex
doc/test-sw

1  2 
Makefile
doc/rpp_simulink.tex
doc/test-sw
rpp/lib

diff --combined Makefile
index f2e76c72f78e07220ef4edb3b1ece7288d6bc665,acfb799e7d58e22f5e2a98a3236aa8ed695378a2..aa471265fa55ac79969ec27334533f4ffb106762
+++ b/Makefile
@@@ -10,8 -10,14 +10,12 @@@ release: $(RELEASE_BASENAME).zi
        cp doc/rpp_simulink.pdf rpp_simulink-$(RELEASE_VERSION).pdf
  
  $(RELEASE_BASENAME):: lib
-       mkdir -p $@
+       mkdir -p $@/rpp/lib/rpp
+       mkdir -p $@/rpp/lib/os/7.0.2_tms570
 -      mkdir -p $@/rpp/lib/lwip/src
        cp --parents rpp/lib/rpp-lib.lib $@/
 -      cp -r rpp/lib/lwip/src/include $@/rpp/lib/lwip/src/include
+       cp -r rpp/lib/rpp/include $@/rpp/lib/rpp/include
+       cp rpp/lib/rpp/TMS570LS313xFlashLnk.cmd $@/rpp/lib/rpp/TMS570LS313xFlashLnk.cmd
+       cp -r rpp/lib/os/7.0.2_tms570/include $@/rpp/lib/os/7.0.2_tms570/include
        $(MAKE) -C doc
        mkdir -p $@/doc
        cp doc/rpp_simulink.pdf $@/doc
diff --combined doc/rpp_simulink.tex
index 5c83a1b018f0fdf799e3c65169182b2d26adf8f4,e5178c30ef5471b85ccbc9f421f24f48d75088dc..afd659050d7410b4e4c335e09fdeabe2da673399
  \begin{center}
  
  % Upper part of the page
 -\includegraphics[width=0.70\textwidth]{images/logos.png}\\[1cm]
 -\textsc{\LARGE Costa Rica Institute of Technology}\\[0.5cm]
 +\includegraphics[width=0.40\textwidth]{images/logo_ctu.pdf}\\[1cm]
  \textsc{\LARGE Czech Technical University in Prague}\\[1.5cm]
  
  
  % Document title
 -\HRule \\[0.4cm]
 -{ \huge \bfseries Code generation for automotive rapid prototyping platform using Matlab/Simulink}\\[0.4cm]
 +\HRule
 +\vspace{0.4cm}
 +{\huge \bfseries Simulink code generation target for Texas~Instruments
 +  RM48 platform\par}
 +\vspace{0.4cm}
  \HRule \\[1.5cm]
  
  
@@@ -128,21 -126,13 +128,21 @@@ Michal \textsc{Sojka}\\[\baselineskip
  \chapter{Introduction}
  \label{chap-introduction}
  
 -This text is a documentation for a Rapid Prototyping Platform (RPP) project. It
 -may serve as a guideline for development tools installation, Simulink Coder
 -configuration, creation of new models as well as downloading the resulting
 -firmware to the hardware. It can also be used as a reference for a testing tool,
 -Matlab Simulink blocks and RPP Matlab Simulink Code generator. The document also
 -provides an overall description of the hardware design and architecture of its
 -control software.
 +This text serves as a documentation for the Rapid Prototyping Platform
 +(RPP) project based on Texas Instruments RM48 safety microcontroller.
 +Originally, the RPP project was created for TMS570 microcontroller and
 +the port to RM48 was derived from it under a contract with Eaton
 +Corporation. As this document is still in beta version, some
 +references to the original TMS570-based RPP remain in it.
 +
 +
 +The document contains step-by-step instructions for installation of
 +development tools, information about Simulink Coder configuration,
 +describes how to create new models as well as how to download the
 +resulting firmware to the hardware. It can also be used as a reference
 +for a testing tool, Matlab Simulink blocks and RPP Matlab Simulink
 +Code generator. The document also provides an overall description of
 +the hardware design and architecture of its control software.
  
  \section{Background}
  \label{sec-background}
@@@ -155,7 -145,7 +155,7 @@@ The ECU is controlled by TMS570LS5137ZW
  microcontroller developed by Texas Instruments. This MCU contains several
  protective mechanisms (two cores in lockstep, error correction mechanisms for
  SRAM and Flash memory, voltage monitoring, etc.) to fulfill the requirements for
 -safety critical applications. See~\cite{tms570ls31xtechnicalreferencemanual2012}
 +safety critical applications. See~\cite{rm48xtechnicalreferencemanual2013}
  for details.
  
  In order to develop non-trivial applications for the RPP, an operating
@@@ -208,9 -198,9 +208,9 @@@ design was driven by the following guid
  \begin{compactitem}
        \item Top-down dependency only. No lower layer depends on anything from
  upper layers.
 -      \item 1-1 layer dependency only. The top layer depends
 -exclusively on the bottom layer, not on any lower level layer (except for a
 -couple of exceptions).
 +%     \item 1-1 layer dependency only. The top layer depends
 +exclusively on the bottom layer, not on any lower level layer (except for a
 +couple of exceptions).
        \item Each layer should provide a unified layer interface
  (\textsc{rpp.h}, \textsc{drv.h}, \textsc {hal.h}, \textsc{sys.h} and
  \textsc{os.h}), so top layers depends on that layer  interface and not on
@@@ -225,10 -215,10 +225,10 @@@ individual elements from that layer.  \
  \end{center}
  \end{figure}
  
- As a consequence of this division the source code files and interface files are placed in
- private directories like \textsc{drv/din.h}. With this organization user
- applications only needs to include the top layer interface files (for example
- \textsc{rpp/rpp\_can.h}) to be able to use the selected library API.
+ As a consequence of this division the source code files and interface files are
+ placed in private directories like \textsc{drv/din.h}. With this organization
+ user applications only needs to include the top layer interface files (for
example \textsc{rpp/rpp\_can.h}) to be able to use the selected library API.
  
  The rest of the section provides basic description of each layer.
  
@@@ -250,7 -240,7 +250,7 @@@ Texas Instruments. This version is in u
  library.
        \item[7.4.0] Newest version distributed by the Texas Instruments.
        \item[7.4.2] Newer version available from FreeRTOS pages. Slightly
 -modified to run on TMS570 MCU.
 +modified to run on RM48 MCU.
  \end{description}
  
  \subsection{System Layer} 
@@@ -322,73 -312,199 +322,73 @@@ This section provides reference documen
        \item Modules capabilities and features.
  \end{compactitem}
  
 -\subsection{Layout description}
 -\label{sec-layout-description}
 -The RPP board has been designed with strict Automotive standards and safety in
 -mind. The components and pins are placed in sections and wires are routed in a
 -way to avoid any significant electromagnetic interference.
 -
 -As can be seen on Figure \ref{board_photo}, the high power output logic is
 -placed in the top left corner, the low power output logic is placed on the
 -bottom left corner, while the communication logic is placed on the top right
 -corner.  In the middle there is the only one button available, the reset button
 -and below it is placed the TMS570 MCU itself. In the bottom right corner there
 -are components of analog inputs.
 +The Rapid Prototyping Platform is based on a TMDSRM48HDK development kit developed and distributed by Texas Instruments. The kit is depicted in Figure \ref{fig-board_photo}.
  
  \begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=300px]{images/board-photo.png}
 -\caption{The RPP board (signal connector missing).}
 -\label{board_photo}
 +      \noindent
 +      \includegraphics[width=300px]{images/board.png}
 +      \caption{The RPP board \cite[p. 8]{rm48hdkusersguide2013}}
 +      \label{fig-board_photo}
  \end{center}\end{figure}
  
 +Only a subset of the peripherals available on the kit is implemented in the control software. A block scheme in Figure \ref{fig-blocks} ilustrates the implemented peripherals and their connection with the MCU, expansion connectors and other components on the development kit.
  
 -\subsection{Connectors pinout}
 -\label{sec-connector-pinout}
 -The pinout of the board, described by the Figure \ref{pinout}, follows the
 -layout described in the previous section. The side connectors for communication
 -(24 pins), signals (56 pins) and power (24 pins) are automotive approved
 -humidity resistant connectors.
 -
 -\begin{figure}[H]
 -\advance\leftskip-1cm
 -\noindent
 -\includegraphics[width=530px]{images/pinout.pdf}
 -\caption{The RPP connectors pinout.}
 -\label{pinout}
 -\end{figure}
 -
 -\subsection{Modules description}
 -\label{sec-modules-description}
 -This section enumerates the capabilities of the hardware modules from Software
 -perspective. The block diagram of the modules can be seen in Figure
 -\ref{blocks}.
 +\begin{figure}[H]\begin{center}
 +      \noindent
 +      \includegraphics[width=400px]{images/blocks.png}
 +      \caption{The peripherals block scheme.}
 +      \label{fig-blocks}
 +\end{center}\end{figure}
  
 -\begin{figure}[H]
 -\advance
 -\leftskip-1cm
 -\noindent
 -\includegraphics[width=500px]{images/blocks.pdf}
 -\caption{The RPP layer modules.}
 -\label{blocks}
 -\end{figure}
 +For pinout description of the implemented peripherals refer the RM48HDK User's Guide \cite{rm48hdkusersguide2013}.
  
 -\subsubsection{Logic IO}
 +\subsection{Logic IO}
  \label{sec-logic-io}
  
 -\paragraph{Digital Inputs (DIN)}
 -\label{par-digital-inputs}
 -\begin{compactitem}
 -      \item 16 pins available on Signal Connector.
 -      \item Pins 8-15 status can be read via GPIO using configurable
 -threshold.  \newline{} Pins 8-11 use variable threshold B and pins 12-15 use
 -variable threshold A.
 -      \item Variable threshold is a DAC chip MCP4922.
 -      \item All pins are read at once via SPI (fixed threshold) using chip
 -MC33972.
 -      \item 0-7 are programmable pins and can be set to pull-up or
 -pull-down. 8-15 are pull-down only.
 -      \item All pins can be set to be active or tri-stated.
 -      \item All pins can be set to trigger interrupt.
 -      \item On-line diagnostic of broken wire.
 -\end{compactitem}
 -
 -\paragraph{Digital Outputs (LOUT)}
 -\label{par-digital-outputs}
 -\begin{compactitem}
 -      \item 8 pins available on Signal Connector.
 -      \item Pins for logic output only, up to 100mA.
 -      \item All pins are set at once using a chip through SPI.
 -\end{compactitem}
 +\subsubsection{Digital Inputs and Outputs (DIN and DOUT)}
 +\label{par-digital-inputs-outputs}
 + \begin{compactitem}
 +      \item 46 pins available on Expansion connector J11.
 +      \item 8 pins available on GIOA
 +      \item 8 pins available on GIOB
 +      \item 30 pins available on NHET1. Pins NHET1 6 and NHET1 13 are disabled.
 +      \item All the pins are configurable as inputs and outputs with different modes:
 +       \begin{compactitem}
 +              \item Push/Pull or Open Drain for Output configuration.
 +              \item Pull up, Pull down or tri-stated for Input configuration.
 +       \end{compactitem}
 +      \item Some of the pins are connected to LEDs or to a button. See Figure \ref{fig-blocks} or refer \cite{rm48hdkusersguide2013} for the connection description.
 + \end{compactitem}
  
 -\paragraph{Analog Input (ADC)}
 +\subsubsection{Analog Input (ADC)}
  \label{par-analog-input}
 -\begin{compactitem}
 -      \item 12 channels available.
 -      \item Differential inputs, thus 24 pins available on Signal Connector.
 -      \item Range for 0-20 volts.
 -      \item 12 bits resolution.
 -      \item Using CPU ADC.
 -\end{compactitem}
 -
 -\paragraph{Analog Output (DAC)}
 -\label{par-analog-output}
 -\begin{compactitem}
 -      \item 4 pins available on Signal Connector.
 -      \item Output range is 0-12 volts.
 -      \item Using 2 x MCP4922 DACs controlled using SPI.
 -      \item Resolution is 12 bits. But because of amplification and voltage
 -reference not all range is used.
 -\end{compactitem}
 -
 -\subsubsection{Power Output}
 -\label{sec-power-output}
 -\paragraph{H-Bridge (HBR)}
 -\label{par-hbr}
 -\begin{compactitem}
 -      \item 1 port (2 pins) available on Power Connector.
 -      \item Communication is done through SPI.
 -      \item H-Bridge can be enabled or disabled.
 -      \item Current direction can be set.
 -      \item PWM control with 1\% resolution change of the duty cycle.
 -      \item Port can drive load up to 10A.
 -\end{compactitem}
 -
 -\paragraph{Power Output (MOUT)}
 -\label{par-power-output}
 -\begin{compactitem}
 -      \item 6 pins available on Power Connector.
 -      \item Pins can drive a load up to 2A. Push/Pull.
 -      \item Pins are set using 6 CPU output GPIOs. Diagnostic are read using 6
 -externally pulled-up open-drain input GPIOs.
 -      \item On-line diagnostics. Driver chip will pull-down the corresponding
 -diagnostic pin on the CPU.  
 -\end{compactitem}
 -
 -\paragraph{High-Power Output (HOUT)}
 -\label{par-high-power-output}
 -\begin{compactitem}
 -      \item 6 pins available on Power Connector.
 -      \item Pins can be set ON/OFF.
 -      \item Pins can drive a load up to 10A with PWM.
 -      \item System can read analog values of current flowing (IFBK).
 -      \item System can read diagnostics values (DIAG). Detection of a fault
 -condition.  
 -\end{compactitem}
 + \begin{compactitem}
 +      \item 16 channels available on the Expansion connector J9.
 +      \item Range for 0-5 volts.
 +      \item 12 bits resolution.
 +      \item Using CPU ADC.
 + \end{compactitem}
  
 -\subsubsection{Communication}
 +\subsection{Communication}
  \label{sec-communication}
 -\paragraph{CAN bus (CAN)}
 +\subsubsection{CAN bus (CAN)}
  \label{par-can}
  \begin{compactitem}
 -      \item 3 ports available (CAN uses differential signaling) thus 6 pins
 -are available on Communication connector.
 +      \item 2 ports available ready for connection to the CAN bus on connector J2 and J3.
 +      \item 3 ports available as an interface for external CAN bus drivers on the Expansion connector J11.
        \item High speed.
        \item Recover from error.
        \item Detection of network errors.
  \end{compactitem}
  
 -\paragraph{Local Interconnect Network (LIN)}
 -\label{par-lin}
 -\begin{compactitem}
 -      \item 2 ports/pins available on Communication Connector.
 -      \item Only first port can be used when using the SCI. Second port is
 -shared with SCI.  
 -\end{compactitem}
 -
 -\paragraph{FlexRay (FR)}
 -\label{par-flexray}
 -\begin{compactitem}
 -      \item 2 ports available. FlexRay uses differential signaling thus 4 pins
 -are available on Communication Connector.
 -\end{compactitem}
 -
 -\paragraph{Serial Comm. Interface (SCI)}
 +\subsubsection{Serial Comm. Interface (SCI)}
  \label{par-sci}
  \begin{compactitem}
 -      \item 1 port available inside the box on SCI connector (4 pins).
 +      \item 1 port available on connector J7.
        \item Variable baud rate. Tested on 9600 and 115200.
        \item RS232 standard compatible.
  \end{compactitem}
  
 -\paragraph{Ethernet (ETH)}
 -\label{par-eth}
 -\begin{compactitem}
 -      \item 1 port available. Standard Ethernet connector available inside box.
 -\end{compactitem}
 -
 -\subsubsection{Data storage/logging}
 -\label{sec-data-storage}
 -\paragraph{External Memory SD-RAM (SDR)}
 -\label{par-external-memory}
 -\begin{compactitem}
 -      \item 64MB (currently installed) external RAM used for logging. Maximal
 -supported capacity is 256MB.
 -      \item Memory test routine available with test
 -Software.
 -\end{compactitem}
 -
 -\paragraph{SD Card (SDC)}
 -\label{par-sd-card}
 -\begin{compactitem}
 -      \item Standard SD-Card connector or microSD connector available inside box.
 -      \item Communication done using SPI.
 -\end{compactitem}
 -
  \section{Document structure}
  \label{sec-document-structure}
  The structure of this document is as follows:
@@@ -564,6 -680,91 +564,91 @@@ file is available a
  \url{http://www.microsoft.com/en-us/download/details.aspx?id=8279}
  \end{quotation}
  
+ \section{Project Installation}
+ \label{sec-project-installation}
+ The RPP project is distributed in three packages and a standalone pdf file,
+ containing this documentation. Every package is named like
+ \textsc{package\_name-version.zip}. The three packages are: 
+ \begin{description}
+       \item[rpp-lib] The package contains the source codes of the RPP Library,
+ described in Chapter \ref{chap-c-support-library}. If you want to make any
+ changes in the drivers or RPP API, this library has to be compiled and linked
+ with the other two applications in the other two packages. The compile procedure
+ can be found in Section \ref{sec-compilation}.  
+       \item[rpp-simulink] Contains the distributed binary, header files and
+ linker script of the RPP Library static library, source codes of the Matlab
+ Simulink blocks, demo models and scripts for downloading the resulting firmware
+ to the target. Details can be found in Chapter \ref{chap-simulink-coder-target} 
+       \item[rpp-test-sw]  Contains the distributed binary, header files and
+ linker script of the RPP Library static library and source codes of a Command
+ line testing tool. This application is designed for direct cotroling of the
+ target over Serial Interface. More details can be found in Chapter
+ \ref{chap-rpp-test-software}.
+ \end{description}
+ \subsection{rpp-lib}
+ \label{sec-rpp-lib-installation}
+ You may not need to deal with this package at all as the compiled library is
+ distributed with the applications. But in case of contributions or further
+ development done by your team, this subsection describes how to open the project
+ in development environment and how to use the resulting static library in an
+ application.
+ \begin{enumerate}
+       \item Unzip the \textsc{rpp-lib-version.zip} file.
+       \item Open the Code Composer Studio (see Section \ref{sec-ti-ccs}).
+       \item Follow the procedure for openning the projects in CCS in Section
+ \ref{sec-openning-of-existing-project} and open the rpp-lib project.  \item
+ Compile the static library using a procedure in Section \ref{sec-compilation}.
+ The binary file will appear in the project root directory.
+       \item Copy the binary file to the application, where you want to test
+ and use the new library version.  
+       \begin{itemize}
+               \item In the rpp-simulink application the library binary file is
+ present at \textsc{rpp/lib} folder. 
+               \item In the rpp-test-sw application the library binary file is
+ present at \textsc{rpp-lib} folder.  
+       \end{itemize}
+ \end{enumerate}
+ \subsection{rpp-simulink}
+ \label{sec-rpp-simulink-installation}
+ If you want to access the demos, build your own models using the RPP blocks, if
+ you want to generate a C code, build a firmware for the RPP board and download
+ it to the real hardware, you have to install this application.
+ \begin{enumerate}
+       \item Unzip the \textsc{rpp-simulink-version.zip} file.
+       \item Follow the procedure in Section
+ \ref{sec-configuration-simulink-for-rpp} for configuring the Matlab Simulink for
+ the RPP project.  
+       \item Follow the procedure in Section \ref{sec-crating-new-model} for
+ instruction about creating your own model which will be using the RPP Simulink
+ blocks or follow the instructions in Section \ref{sec-running-model-on-hw}
+ for download the firmware to the real RPP hardware.
+ \end{enumerate}
+ \subsection{rpp-test-sw}
+ \label{sec-test-sw-installation}
+ If you want a direct controll over the hardware for example to test your
+ modifications in the RPP Library follow this procedure for the rpp-test-sw
+ application installation.
+ \begin{enumerate}
+       \item Unzip the \textsc{rpp-test-sw-version.zip} file.
+       \item Open the Code Composer Studio (see Section \ref{sec-ti-ccs}).
+       \item Follow the procedure for openning the projects in CCS in Section
+ \ref{sec-openning-of-existing-project} and open both, the \textsc{rpp-lib} and
+ the \textsc{rpp-test-sw} project.  
+       \item Right click on the \textsc{rpp-test-sw} project in the
+ \textsc{Project Explorer} and select \textsc{Build Project}. Ignore any errors
+ in the \textsc{rpp-lib} project.  
+       \item Follow the instructions in Section
+ \ref{sec-running-software-on-hw} to download, debug and run the software on the
+ target hardware.  
+ \end{enumerate}
  \section{Code Composer Studio usage}
  \label{sec-code-composerpstudio-usage}
  
@@@ -584,17 -785,17 +669,17 @@@ section so that the result looks like i
        \item Click on \textsc{Finish} button.
  \end{enumerate}
  
- \begin{center}
+ \begin{figure}[H]\begin{center}
        \includegraphics[width=350px]{images/import_project.png}
-       \captionof{figure}{Import project dialog}
+       \caption{Import project dialog}
        \label{fig-import-project}
- \end{center}
+ \end{center}\end{figure}
  
- \begin{center}
+ \begin{figure}[H]\begin{center}
        \includegraphics[width=350px]{images/select_project.png}
-       \captionof{figure}{Select project dialog}
+       \caption{Select project dialog}
        \label{fig-select-project}
- \end{center}
+ \end{center}\end{figure}
  
  \subsection{Creating new project}
  \label{sec-creating-new-project}
@@@ -633,7 -834,8 +718,7 @@@ add \textsc{RPP\_LIB\_ROOT} to the libr
        \item Configure linker to retain \textsc{.intvecs} from RPP static
  library.\newline{} \noindent\includegraphics[width=350px]{images/base_4.png}
        \item Configure compiler to include local includes, OS includes for
 -TMS570 and RPP includes, in that order\todo{Add lwip include paths as
 -well}.\newline{}
 +RM48 and RPP includes, in that order.\newline{}
  \noindent\includegraphics[width=350px]{images/base_5.png}
  \newpage
        \item Configure compiler to allow GCC extensions.\newline{}
@@@ -812,7 -1014,7 +897,7 @@@ can be easily downloaded to the target 
  
  \begin{enumerate}
        \item Connect the Texas Instruments XDS100v2 USB emulator to the JTAG
 -port (see Figure \ref{pinout}, port 1).  
 +port.  
        \item Connect a USB cable to the XDS100v2 USB emulator and the
  development computer.
        \item Plug in the power supply.  
@@@ -836,7 -1038,7 +921,7 @@@ procedure
  \textsc{File$\rightarrow$New$\rightarrow$CCS Project}.  
        \item In the dialog window, type in a project name, for example
  myBinaryLoad, Select \textsc{Device
 -variant} (ARM, Cortex R, TMS570LS3137, Texas Instruments XDS100v2 USB Emulator)
 +variant} (ARM, Cortex R, RM48L952, Texas Instruments XDS100v2 USB Emulator)
  and select project template to \textsc{Empty Project}. The filled dialog should
  look like on the Figure \ref{fig-new-empty-project}
        \item Click on the \textsc{Finish} button and new empty project will be
@@@ -864,17 -1066,17 +949,17 @@@ can easily change the binary file in th
  binary file.  
  \end{enumerate}
  
- \begin{center}
+ \begin{figure}[H]\begin{center}
        \includegraphics[width=350px]{images/new_empty_project.png}
-       \captionof{figure}{New empty project dialog}
+       \caption{New empty project dialog}
        \label{fig-new-empty-project}
- \end{center}
+ \end{center}\end{figure}
  
- \begin{center}
+ \begin{figure}[H]\begin{center}
        \includegraphics[width=350px]{images/debug_configuration_main.png}
-       \captionof{figure}{Debug Configuration Main dialog}
+       \caption{Debug Configuration Main dialog}
        \label{fig-debug-conf-main-diag}
- \end{center}
+ \end{center}\end{figure}
  
  \subsubsection{Target configuration}
  \label{sec-target-configuration}
@@@ -891,11 -1093,11 +976,11 @@@ by the following procedure
  and close the dialog.
  \end{enumerate}
  
- \begin{center}
+ \begin{figure}[H]\begin{center}
        \includegraphics[width=350px]{images/debug_configuration_program.png}
-       \captionof{figure}{Debug Configuration Program dialog}
+       \caption{Configuration Program dialog}
        \label{fig-debug-conf-program-diag}
- \end{center}
+ \end{center}\end{figure}
  
  \section{Matlab Simulink usage}
  \label{sec-matlab-simulink-usage}
@@@ -913,7 -1115,7 +998,7 @@@ Open Matlab and type on command window
  
  \lstset{language=Matlab}
  \begin{lstlisting}
- cd <repo>/rpp/rpp/
+ cd <rpp-simulink>/rpp/rpp/
  rpp_setup
  \end{lstlisting}
  
@@@ -947,7 -1149,7 +1032,7 @@@ example to open the cantransmit demo yo
  Matlab command line:
  
  \begin{lstlisting}[language=Matlab]
- cd <rpp-simulink-root>/rpp/demos
+ cd <rpp-simulink>/rpp/demos
  open cantransmit.slx
  \end{lstlisting}
  
@@@ -968,7 -1170,8 +1053,8 @@@ cd /tmp/my-cod
  the subdirectory will be \textsc{<model>\_rpp}, where \textsc{model} is the name
  of the Simulink model.
        \item Generate the code by choosing \textsc{Code $\rightarrow$ C/C++
- Code  $\rightarrow$ Build Model}.  \end{enumerate}
+ Code  $\rightarrow$ Build Model}.
+ \end{enumerate}
  
  If you want to run the model on the RPP board, see Section
  \ref{sec-running-model-on-hw}.
@@@ -1022,7 -1225,8 +1108,8 @@@ Parameters}
        \item In the \textsc{Code Generation$\rightarrow$RPP Options} pane
  check \textsc{Download compiled binary to RPP} checkbox.
        \item Click on \textsc{OK} button, connect the target HW to the computer
- like in the Section \ref{sec-ccs-run-project} and build the model. If the build
+ like in the Section \ref{sec-ccs-run-project} and build the model by \textsc{Code $\rightarrow$ C/C++
+ Code  $\rightarrow$ Build Model}. If the build
  ends with a success, the download process will start and once the downloading is
  finished, the application will run immediatelly.
  \end{enumerate}
@@@ -1062,11 -1266,7 +1149,11 @@@ serial interface connector on the RPP b
  \section{Bug reporting}
  \label{sec-bug-reporting}
  
 -% TODO: implement
 +Please report any problems at CTU's bug tracking system at
 +\url{https://redmine.felk.cvut.cz/projects/eaton-rm48}. New users have
 +to register in the system and notify Michal Sojka about their
 +registration via $\langle{}sojkam1@fel.cvut.cz\rangle{}$ email
 +address.
  
  \chapter{C Support Library}
  \label{chap-c-support-library}
@@@ -1152,12 -1352,12 +1239,12 @@@ in a Linux terminal should be called. T
  errors. After that all changes can be committed.
  
  \section{Subdirectory content description}
- \label{sec-subdirectory-content-description}
+ \label{sec-rpp-lib-subdirectory-content-description}
  \begin{description}
  \item[librpp.a and rpp-lib.lib] static RPP libraries.
  
  The first one is for POSIX simulation, the second one for Simulink models and
 -other ARM/TMS570 applications. This files are placed here by the Makefile, when
 +other ARM/RM48 applications. This files are placed here by the Makefile, when
  the library is built.
  
        \item[apps/] Demo applications related to the RPP library.
@@@ -1166,7 -1366,7 +1253,7 @@@ This include the CCS studio project fo
  a test suite. The test suit in this directory does not match the test suite
  mentioned later in Chapter 5 and those two suits are going to be merged in the
  future. Also other demo Hello World like applications are included as a
 -reference about how to create a TMS570 application.
 +reference about how to create a RM48 application.
        \item[os/] OS layers directory. See OS interchangeable layer for more
  information.  
        \item[rpp/] Main directory for the RPP Library.
@@@ -1423,7 -1623,7 +1510,7 @@@ the board. The message is in the form
  \end{itemize}
  
  \section{Subdirectory  content description}
- \label{sec-subdirectory-content-description}
+ \label{sec-simulink-subdirectory-content-description}
  This section describes the directories of the Simulink Coder. If you are
  interested in particular file, refer the description at the beginning of the
  file.
@@@ -1629,10 -1829,8 +1716,10 @@@ The file \textsc{$\langle$modelname$\ra
  This section describes each one of the Simulink blocks present in the Simulink
  RPP block library, shown in Figure \ref{fig-block-library}.
  
 -\begin{figure}
 -\includegraphics[width=\textwidth]{images/block_library.png}
 +\begin{figure}[h]
 +  \begin{center}
 +    \includegraphics[width=\textwidth]{images/block_library.png}
 +  \end{center}
  \caption{Simulink RPP Block Library.}
  \label{fig-block-library}
  \end{figure}
@@@ -1650,30 -1848,39 +1737,30 @@@ type of block and more than one block p
  
  In the reference below you can find a complete description for each of the demos.
  
 -\subsection{Analog pass-through}
 +\subsection{ADC demo}
  \begin{figure}[H]\begin{center}
  \noindent
 -\includegraphics[width=450px]{images/demo_analog_passthrough.png}
 -\caption{Analog Passthrough Simulink demo for RPP.}
 +\includegraphics[width=450px]{images/demo_adc.png}
 +\caption{Example of the usage of the Analog Input blocks for RPP.}
  \end{center}\end{figure}
  
  \textbf{Description:}
 -This demo will read analog input 1 and write it to analog output 1.
 -
 -In laboratory the minimum read value for analog input a 0 volts is 107. The maximum read at 12
 -volts is 2478. The map subsystem will map the input domain (ADC)\textsc{[110, 2400]} to the output domain
 -(DAC)\textsc{[0, 4095]}.
  
 +Demostrates how to use Analog Input blocks in order to measure voltage. This demo
 +measures voltage on every available Analog Input and prints the values on the
 +Serial Interface.
  
 -\subsection{Analog sinewave}
 +\subsection{Simple CAN demo}
  \begin{figure}[H]\begin{center}
  \noindent
 -\includegraphics[width=450px]{images/demo_analog_sinewave.png}
 -\caption{Analog Sinewave Simulink demo for RPP.}
 +\includegraphics[width=450px]{images/demo_simple_can.png}
 +\caption{The simplest CAN demonstration.}
  \end{center}\end{figure}
  
  \textbf{Description:}
 -This demo will generate a sinewave on analog output 1. The frequency
 -of the sine wave is 10Hz and sampling rate is set to
 -1000Hz (driven from Simulink step of 1ms, same as operating system). Amplitude is set to use DAC
 -full range [0-4095] which means output amplitude will be [0-12] volts.
 -
 -The Software oscilloscope shown should match an external one connected to DAC 1.
 -
 -Note that the driver configuration of the MCP4922 is set to unbuffered (which should eventually
 -be changed to buffered) and thus the last resolution millivolts are lost.
  
 +The simplest possible usage of the CAN bus. This demo is above all designed for
 +testing the CAN configuration and transmission.
  
  \subsection{CAN transmit}
  \begin{figure}[H]\begin{center}
@@@ -1702,25 -1909,31 +1789,25 @@@ Demostrates how to use CAN Receive bloc
  \item Use function-call mechanism to process received messages
  \end{compactenum}
  
 -\subsection{CAN demo}
 -
 +\subsection{Simulink Demo model}
  \begin{figure}[H]\begin{center}
  \noindent
 -\includegraphics[width=450px]{images/demo_can_demo.png}
 -\caption{CAN bus demo for RPP.}
 +\includegraphics[width=450px]{images/demo_board.png}
 +\caption{Model of the complex demonstration of the boards peripherals.}
  \end{center}\end{figure}
  
  \textbf{Description:}
  
 -This demo demonstrates simple processing of received messages.
 +This model demonstrates the usage of RPP Simulink blocks in a complex and interactive
 +application. The Ti HDK kit has eight LEDs placed around the MCU. The application
 +rotates the light around the MCU in one direction. Every time the user presses the button
 +on the HDK, the direction is switched.
  
 -\subsection{Digital pass-through}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=400px]{images/demo_digital_passthrough.png}
 -\caption{Digital Pass-through Simulink demo for RPP.}
 -\end{center}\end{figure}
 +The state of the LEDs is sent on the CAN bus as a message with ID 0x1. The button can
 +be emulated by CAN messages with ID 0x0. The message 0x00000000 simulates button release
 +and the message 0xFFFFFFFF simulates the button press.
  
 -\textbf{Description:}
 -
 -This demo will directly pass the digital values read on DIN [1-8] to LOUT [1-8], and thus acting
 -as a digital pass-through or gateway.
 -
 -Also note that all the ErrFlag are aggregated on a global ErrFlag.
 +Information about the state of the application are printed on the Serial Interface. 
  
  \subsection{Echo char}
  \begin{figure}[H]\begin{center}
  
  \textbf{Description:}
  
 -This demo will echo twice (print back) any character received through the Serial Communication
 -Interface (9600-8-N-1).
 +This demo will echo (print back) any character received through the Serial Communication
 +Interface (115200-8-N-1).
  
  Note that the send subsystem is implemented a as \textit{triggered} subsystem and will execute only
  if data is received, that is, Serial Receive output is non-negative. Negative values are errors.
  
 -
 -\subsection{H-bridge analog control}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=450px]{images/demo_hbridge_analog_control.png}
 -\caption{H-Bridge Analog Control Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo will read values from the analog input, map them, and control the H-Bridge. This allows
 -a motor connected to the H-Bridge to be controlled with a potentiometer connected to Analog Input 1.
 -
 -Setting the potentiometer to output around 6 volts will stop the motor. Less (or greater) than 6
 -volts will trigger the motor in one sense (or in the other sense) and speed proportional with 1\%
 -resolution.
 -
 -In laboratory the minimum read value for analog input is 107 at 0 volts. The maximum read at 12 volts
 -is 2478. The map subsystem will map the input domain (ADC)\textsc{[110, 2400]} to the output domain
 -(HBR)\textsc{[-1.0, 1.0]}.
 -
 -
 -\subsection{H-bridge digital control}
 +\subsection{GIO demo}
  \begin{figure}[H]\begin{center}
  \noindent
 -\includegraphics[width=450px]{images/demo_hbridge_digital_control.png}
 -\caption{H-Bridge Digital Control Simulink demo for RPP.}
 +\includegraphics[width=450px]{images/demo_gio.png}
 +\caption{Demonstration of DIN and DOUT blocks}
  \end{center}\end{figure}
  
  \textbf{Description:}
  
 -This demo toggle the H-Bridge from stop to full speed in one direction using digital input 1.
 -So basically is a ON/OFF switch on DIN 1 for a motor connected on the HBR. Note the data type
 -conversion because the output of the DIN is a boolean and the input to the HBR is a double.
 -
 -\subsection{H-bridge sine wave control}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=300px]{images/demo_hbridge_sinewave_control.png}
 -\caption{H-Bridge Sinewave Control Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo will generate a sine wave to control the H-Bridge. Sine wave is one period per 20
 -seconds or 0.05Hz. Sampling rate is 20Hz or 100 samples per 1/4 of period (for 1\% speed
 -resolution change).
 -
 -Note that the Software oscilloscope should is not the output of the H-Bridge, the H-Bridge will
 -change current sense and the duty cycle of the pulse that drive it (PWM), it does not output
 -analog values. The Software oscilloscope just shows what the input to the HBR block is.
 +The model demonstrates how to use the DIN blocks and DOUT blocks, configured in every mode. The DOUTs
 +are pusched high and low with period 1 second. The DINs are reading inputs and printing the values
 +on the Serial Interface with the same period.
  
  \subsection{Hello world}
  \begin{figure}[H]\begin{center}
  
  \textbf{Description:}
  
 -This demo will print \textsc{"Hello Simulink"} to the Serial Communication Interface (9600-8-N-1) one
 +This demo will print \textsc{"Hello Simulink"} to the Serial Communication Interface (115200-8-N-1) one
  character per second. The output speed is driven by the Simulink model step which is set to one
  second.
  
 -\subsection{IRC input}
 -\begin{figure}[H]\begin{center}
 -
 -\noindent
 -\includegraphics[width=450px]{images/demo_irc_input.png}
 -\caption{LED Blink Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo is printing IRC sensor (connected to DIN10 and DIN11) value to the Serial Communication
 -Interface (115200-8-N-1) with six values to one line.
 -
 -\subsection{LED blink}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=450px]{images/demo_led_blink.png}
 -\caption{LED Blink Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This the simplest demo of all that shows the basics of using the RPP target and blocks. The
 -goal of this demo is to show the configuration of the model (not shown on the picture above),
 -that is, how the RPP Simulink Coder Target is setup, general model setup and step setup.
 -
 -This demo will toggle each second a LED connected on LOUT 1. The timing is set by the Simulink
 -model step which is set to 1 second.
 -
 -\subsection{LED blink all}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=350px]{images/demo_led_blink_all.png}
 -\caption{LED Blink All Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo will toggle all LEDs connected to the LOUT port. Even outputs pins will be negated.
 -Toggle will happen each second. The timing is driven by Simulink model step configuration that
 -is set to 1 second. All blocks ErrFlags are aggregated into one global ErrFlag.
 -
 -\subsection{Log analog input}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=450px]{images/demo_log_analog_input.png}
 -\caption{Log Analog Input Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo will log once per second the value read on the analog input 1. User can read the log
 -using the SCI logging integrated command processor (9600-8-N-1). Logging block ID set to 1. The
 -timing is driven by Simulink model step configuration that is set to 1 second.
 -
 -\subsection{Power toggle}
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=300px]{images/demo_power_toggle.png}
 -\caption{Power Toggle Simulink demo for RPP.}
 -\end{center}\end{figure}
 -
 -\textbf{Description:}
 -
 -This demo will toggle the power output once per second. If an error is detected on at least one of
 -the outputs a generic error message is printed to the serial line. The timing is driven by Simulink
 -model step configuration that is set to 1 second. Power outputs can drive a load up to 2A, so please
 -take into account required safety considerations.
 -
 -\subsection{Simulink Demo board}
 -Model for demo board has 6 subsystems. Every subsystem will be described separately.
 -\begin{figure}[H]\begin{center}
 -\noindent
 -\includegraphics[width=0.8\textwidth]{images/demo_board-connection_scheme.pdf}
 -\caption{Demo board connection and usage scheme.}
 -\end{center}\end{figure}
 -
 -\subsubsection{Potentiometer regulation of motor speed}
 -This is example of driving motor with input signal. Motor can be rotated in
 -various speed in both directions and stopping motor means setting potentiometer
 -to half of its range. Potentiometer value is also transmitted through CAN.
 -
 -\subsubsection{Color music}
 -This is showing abilities of RPP board to generate analog signals. Bargraphs on
 -demo board are showing value of analog outputs. Speed of change can be changed
 -with potentiometer and in one case is used motor 2 IRC. There are five different
 -modes. Three of them are derived from sinus and rest of them are counter value
 -and direct control. Modes can be changed with black button. First mod selected
 -after board start is fifth.  
 -\begin{enumerate}
 -\item Sinus signal is sequential delayed by 10 steps for second and third bargraph.
 -\item Sinus signal on second bargraph is shifted by 120° and on third one is shifted by 240°.
 -\item Sinus signal for second and third bargraphs are shifted same as in
 -previous mode, but as counter value is used IRC value with appropriate divider
 -no potentiometer value.  
 -\item Visualizing counter value which speed is changed
 -with potentiometer.
 -\item Potentiometer value is passed to all bargraphs with appropriate multiplier.
 -\end{enumerate}
 -
 -\subsubsection{Buttons and LEDs}
 -This is example of digital input/output. LEDs on demo board can be driven with
 -four different subprograms. These subprograms can be changed with red button and
 -are influenced with green and blue buttons.  
 -\begin{enumerate}
 -\item One LED is always ON and others are OFF. Every 0.1 sec is neighborhood LED
 -switched on and previous one is switched off. With buttons you can change
 -direction.  
 -\item Same as previous mode, but change is not done after 0.1 sec
 -but only when button is pressed.
 -\item In this mode you can record message in Morse code (max 64 chars including
 -spaces) and after delay it is repetitively replayed. To record message use green
 -button as dash and blue button as dot.  
 -\item Simple game in which you must determine if light is moving left or right
 -and press green or blue button according to it. Speed of movement is increasing
 -and in case of wrong answer or long delay is game ends with lights flashing.
 -\end{enumerate}
 -
 -\subsubsection{IRC to CAN}
 -IRC value from Motor 2 is sent every tenth step via CAN2 with message ID 0x4.
 -
 -\subsubsection{CAN receive -- Button press emulation}
 -You can simulate press of all four buttons by sending message through CAN2 to
 -board with message ID 0x0 and value according to button number.
 -
 -\subsubsection{Configuration and error handling}
 -RPP supports some basic runtime error handling. Every block can set its error
 -flag, all these error flags are joined in this demo together and when some
 -problem is detected CAN2 message of ID 0x10 is transmitted. Also in case of
 -board overrun (exhaustion of time quanta) is transmitted message through CAN2
 -with ID 0x11.\\ When model is build without external mode, errors are also
 -printed to SCI.
 -
 -\subsubsection{Full list of CAN communication}
 -The board produces CAN frames with the following IDs:
 -\begin{itemize}
 -\item 0x05: Potentiometer 1 value.
 -\item 0x06: Potentiometer 2 value.
 -\item 0x08: Selected mod of color music.
 -\item 0x09: Active subprogram of buttons and LEDs.
 -\item 0x10: Transmitted only in case of error flag of some block, error code.
 -\item 0x11: Transmitted only in case of board overrun, no data.
 -\end{itemize}
 -The board reacts to CAN frames with following IDs:
 -\begin{itemize}
 -\item 0x00: Simulate button press, accepts value 1--4.
 -\end{itemize}
 -
  \chapter{Command line testing tool}
  \label{chap-rpp-test-software}
  The \textsc{rpp-test-suite} is a RPP application developed testing and direct
diff --combined doc/test-sw
index bc441c9ebe319c98fba3d75c8b0b47b3f6d1670c,b6361ca5eca38b897e93d821ea4629df21174219..61697a9f72516095f18681eba78ce419e195b21f
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit bc441c9ebe319c98fba3d75c8b0b47b3f6d1670c
 -Subproject commit b6361ca5eca38b897e93d821ea4629df21174219
++Subproject commit 61697a9f72516095f18681eba78ce419e195b21f
diff --combined rpp/lib
index 0a7353c1aaab68397943c876a48fc949d56d0621,b446fb76462cbf0d15f7a26d078613635d9d8ffd..36b02c8c09ce72798db1dc447a5d7ad99da4a582
+++ b/rpp/lib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 0a7353c1aaab68397943c876a48fc949d56d0621
 -Subproject commit b446fb76462cbf0d15f7a26d078613635d9d8ffd
++Subproject commit 36b02c8c09ce72798db1dc447a5d7ad99da4a582