]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
doc: fix typos, add missing links and labels
authorMichal Horn <hornmich@fel.cvut.cz>
Tue, 2 Dec 2014 22:54:40 +0000 (23:54 +0100)
committerMichal Horn <hornmich@fel.cvut.cz>
Tue, 2 Dec 2014 22:54:40 +0000 (23:54 +0100)
doc/rpp_simulink.tex

index d0761f55c41b84cbe4c7e035ea9847cc9012af53..df0e334917627170a050e011d0c8c561869b0ea4 100644 (file)
@@ -126,7 +126,7 @@ Michal \textsc{Sojka}\\[\baselineskip]
 
 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 to a
+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.
 
@@ -135,9 +135,9 @@ provides an overall description of the hardware design and architecture of its c
 
 The Rapid Prototyping Platform is an ECU (Electronic Control Unit) designed for use in Automotive, thus requirements for Automotive communication interfaces, durable IO ports and analog-digital converters were applied.
 
-The ECU is controlled by TMS570LS5137ZWT MCU, which is an ARM Cortex R4 based microcontroller developed by Texas Instruments. This MCU contains several protective mechanisms (Two cores in lockstep, error correction mechanisms for SRAM and Flash memory, voltage monitoring...) to fulfill the requirements for safety critical applications.  TODO: add ref to Ti Reference
+The ECU is controlled by TMS570LS5137ZWT MCU, which is an ARM Cortex R4 based microcontroller developed by Texas Instruments. This MCU contains several protective mechanisms (two cores in lockstep, error correction mechanisms for SRAM and Flash memory, voltage monitoring...) to fulfill the requirements for safety critical applications. TODO: add ref to Ti Reference
 
-Besides the right MCU, an operating system is necessary for nontrivial applications. The RPP board runs FreeRTOS, which is opensource operating system with real-time kernel not only for embedded systems. The FreeRTOS provides an API for creation and managing multiple tasks, scheduler, memory manager, semaphores, queues, mutexes, timers and lots of other features that can be used in the applications.     TODO: add ref to FreeRTOS pages
+Besides the right MCU, an operating system is necessary for nontrivial applications. The RPP board runs FreeRTOS, which is an opensource operating system with real-time kernel, aimed not only on embedded systems. The FreeRTOS provides an API for creation and managing multiple tasks, scheduler, memory manager, semaphores, queues, mutexes, timers and lots of other features wich can be used in the applications. TODO: add ref to FreeRTOS pages
 
 Even with the operating system it is quite hard and non-intuitive to control the hardware directly. That is the point when abstraction comes in the play. RPP software is made of several layers implementing from the bottom to the top driver to the hardware itself, hardware abstraction for common functionality on different hardware and final API which is easy for the user to use. The whole thing, the operating system and the control software, can be compiled as a library and easily used in any project. More details about the library can be found in Chapter \ref{chap-c-support-library}.
 
@@ -165,7 +165,7 @@ The RPP control software, also called RPP library, is structured into 5 layers,
 \end{center}
 \end{figure}
 
-As a consequence of this division the source code files and interface files are now placed on
+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.
 
@@ -185,34 +185,34 @@ Following FreeRTOS versions are distributed:
 
 \subsection{System Layer} 
 \label{sec-system-layer}
-This layer contains system files with data types definitions, clock definitions, interrupts mapping, MCU startup sequence, MCU selftests, and other low level code for controlling some of the MCU peripherals. The source files can be found in <lib-root>/rpp/src/sys, the header files can be found in <lib-root>/rpp/include/sys folder.
+This layer contains system files with data types definitions, clock definitions, interrupts mapping, MCU startup sequence, MCU selftests, and other low level code for controlling some of the MCU peripherals. The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/sys}, the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/sys} folder.
 
 \subsection{HAL abstraction layer}
 \label{sec-hal-abstraction-layer}
-Hardware Abstraction Layer (HAL) creates an abstraction over the real hardware. For example imagine an IO port with 8 pins. First four pins are connected to the MCU directly to GPIO pins, another four pins are connected to an external integrated circuit, communicating with the MCU via SPI. It would be annoying to have to remember which group is which and to have two sets of control functions for one peripheral. This layer maps every pin of the port to a control function from the System Layer, groups and names the pins in a unified style and provides common read, write and configure functions.
+Hardware Abstraction Layer (HAL) creates an abstraction over the real hardware. For example imagine an IO port with 8 pins. First four pins are connected to the MCU directly to GPIO pins, another four pins are connected to an external integrated circuit, communicating with the MCU via SPI. It would be annoying to have to remember which group is which and to have two sets of control functions for one peripheral. This layer maps every pin of the port to a control function from the System Layer, groups the pins together, names them in a unified style and provides common read, write and configure functions.
 
 As a result, the higher layers do not have to know anything about the wiring of the peripherals, they can just call read, write or configure function with a pin name as a parameter and the HAL handles all the details.
 
-The source files can be found in <library-root>/rpp/src/hal and the header files can be found in <library-root>/rpp/include/hal folder.
+The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/hal} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/hal} folder.
 
 \subsection{Drivers layer} 
 \label{sec-drivers-layer}
-The Drivers layer contains code for controlling the RPP peripherals. The layer benefits from the lower layers thus it is not too low level, but still there are some peripherals like ADC or H-bridge, which needs some special procedure for initialization and running, which would not be very intuitive for the user. For example the H-bridge need a watchdog reset task to be started before the bridge is enabled.
+The Drivers layer contains code for controlling the RPP peripherals. The layer benefits from the lower layers thus it is not too low level, but still there are some peripherals like ADC or H-bridge, which needs some special procedure for initialization and running, that would not be very intuitive for the user. For example the H-bridge needs a watchdog reset task to be started before the bridge is enabled.
 
-The source files can be found in <library-root>/rpp/src/drv and the header files can be found in <library-root>/rpp/include/drv folder.
+The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/drv} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/drv} folder.
 
-\subsection{RPP Layer} 
-The RPP Layer is the highest layer of the control software. This layer provides the easiest set of functions for every peripheral and requires only basic knowledge about them. For example the H-bridge again from the previous section. The user can call just rpp\_hbr\_init() function to enable the H-bridge and the function calls a sequence of Drivers layer functions to start the Watchdog and configure the peripheral.
+\subsection{RPP Layer}
 \label{sec-rpp-layer} 
+The RPP Layer is the highest layer of the control software. This layer provides the easiest set of functions for every peripheral and requires only basic knowledge about them. For example the H-bridge again from the previous section. The user can call just \textsc{rpp\_hbr\_init()} function to enable the H-bridge and the function calls a sequence of Drivers layer functions to start the Watchdog and configure the peripheral.
 
-The source files can be found in <library-root>/rpp/src/rpp and the header files can be found in <library-root>/rpp/include/rpp folder.
+The source files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/src/rpp} and the header files can be found in \textsc{$\langle$rpp\_lib\_root$\rangle$/rpp/include/rpp}.
 
 \section{Hardware description}
 \label{sec-hardware-description}
 
 This section provides reference documentation for the RPP board:
 
-TODO: operating conditions?
+%%TODO: operating conditions as a reference to the Ti documentation
 
 \begin{compactitem}
 \item Layout description.
@@ -236,7 +236,7 @@ As can be seen on Figure \ref{board_photo}, the high power output logic is place
 
 \subsection{Connectors pinout}
 \label{sec-connector-pinout}
-The pinout of the board, described by the Figure \ref{pinout}, follows the layout. The side connectors for communication (24 pins), signals (56 pins) and power (24 pins) are automotive approved humidity resistant connectors.
+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
@@ -259,6 +259,7 @@ This section enumerates the capabilities of the hardware modules from Software p
 
 \subsubsection{Logic IO}
 \label{sec-logic-io}
+
 \paragraph{Digital Inputs (DIN)}
 \label{par-digital-inputs}
 \begin{compactitem}
@@ -409,7 +410,8 @@ The RPP software stack was developed to be functional on both platforms Windows
        \item GtkTerm 0.99.7-rc1
        \item Ti Code Composer Studio 5.5.0.00077
        \item Matlab 2013b 64b
-       \item doxygen 1.8.4 (optionaly, see API Generation)
+       \item Doxygen 1.8.4 (optionaly, see Section \ref{sec-compiling-api-documentation})
+       \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation}).
 \end{itemize}
 
 \subsection{Windows environment}
@@ -420,7 +422,8 @@ The RPP software stack was developed to be functional on both platforms Windows
        \item Bray Terminal v1.9b
        \item Ti Code Composer Studio 5.5.0.00077
        \item Matlab 2013b 64b
-       \item doxygen 1.8.4 (optionaly, see API Generation)
+       \item Doxygen 1.8.4 (optionaly, see Section \ref{sec-compiling-api-documentation})
+       \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation}).
 \end{itemize}
 
 \section{Software and tools} 
@@ -428,17 +431,15 @@ The RPP software stack was developed to be functional on both platforms Windows
 
 \subsection{TI Code Composer Studio}
 \label{sec-ti-ccs}
-
-
 Code Composer Studio (CCS) is the official Integrated Development Environment (IDE) for developing
 applications for Texas Instruments embedded processors. CCS is multiplatform Software based on
 Eclipse Open Source IDE.
 
-CCS include Texas Instruments Code Generation Tools (CGT) (compiler, linker, etc). Simulink code
+CCS includes Texas Instruments Code Generation Tools (CGT) (compiler, linker, etc). Simulink code
 generation requires the CGT to be available in the system, and thus, even if no library development
 will be done or the IDE is not going to be used CCS is still required.
 
-TODO: Zjistit podminky pro distribuci dokumentu
+%% TODO: Zjistit podminky pro distribuci dokumentu
 You can find documentation for CGT compiler in \textsc{\repo/ref/armcl.pdf} and for CGT archiver in
 \textsc{\repo/ref/armar.pdf}.
 
@@ -446,14 +447,19 @@ The version used in this project is the 5.5.0.00077.
 
 \subsubsection{Installation on Linux} 
 \label{sec-installation-on-linux}
-
 Download CCS for Linux from:
 
        \begin{quotation}
 \url{http://processors.wiki.ti.com/index.php/Category:Code\_Composer\_Studio\_v5}
        \end{quotation}
 
-Once downloaded, extract the content of the \textsc{tar.gz} archiver and run \textsc{css\_setup\_$\langle$version$\rangle$.bin} script as \underline{root}. Installation must be done as root in order to install a driver set.
+Once downloaded, add executable permission to the installation file and launch the installation by executing it. Installation must be done as root in order to install a driver set.
+
+\lstset{language=bash}
+\begin{lstlisting}
+chmod +x ccs_setup_5.5.0.00077.bin
+sudo ./ccs_setup_5.5.0.00077.bin
+\end{lstlisting}
 
 After installation the application can be executed with:
 
@@ -493,19 +499,15 @@ Once downloaded run the ccs\_setup\_5.5.0.00077.exe and install the CCS.
 
 \subsubsection{ First launch } 
 \label{sec-first-launch}
-
-If another licence is not available, Choose ``FREE License - for use with XDS100 JTAG Emulators" on the licensing options. Code download
-for the board is using that particular hardware.
+If another licence is not available, choose ``FREE License - for use with XDS100 JTAG Emulators" from the licensing options. Code download for the board is using that particular hardware.
 
 \subsection{Matlab/Simulink}
 \label{sec-matlab-simulink}
-
 Matlab Simulink is a set of tools, runtime environment and development environment for Model-Based applications development, simulations and generation code for target platforms.
-Supported Matlab/Simulink version is R2013b for 64 bits Linux and Windows.
+Supported Matlab Simulink version is R2013b for 64 bits Linux and Windows.
 
 \subsection{GtkTerm and Bray Terminal}
 \label{sec-gtkterm-bray-terminal}
-
 Most of the interaction with the board is done through a RS-232 serial connection. The terminal Software used for communication is called GtkTerm for Linux and Bray terminal for Windows.
 
 To install GtkTerm execute:
@@ -525,7 +527,7 @@ The Bray Terminal does not require any installation and the executable file is a
 \label{sec-c-compiler}
 In order to be able to compile Matlab Simulink blocks S-functions a C language compiler has to be available on the development system.
 
-For Linux a GCC 4.8.1 compiler is recommended and can be installed with command
+For Linux a GCC 4.8.1 compiler is recommended and can be installed with command
 
 \lstset{language=bash}
 \begin{lstlisting}
@@ -547,28 +549,28 @@ The project opening procedure is similar to standard Eclipse project opening.
 
 \begin{enumerate}
        \item Launch Code Composer Studio
-       \item Select File->Import
-       \item In the dialog window select Code Composer Studio -> Existing CCS Eclipse project as an import source as depicted in Figure \ref{fig-import-project}.
-       \item In the next dialog window click on Browse button and find the root directory of the project.
-       \item Select the requested project in the Discovered project section so that the result looks like in Figure \ref{fig-select-project}.
-       \item Click on Finish button.
+       \item Select \textsc{File$\rightarrow$Import}
+       \item In the dialog window select \textsc{Code Composer Studio$\rightarrow$Existing CCS Eclipse project} as an import source as depicted in Figure \ref{fig-import-project}.
+       \item In the next dialog window click on \textsc{Browse} button and find the root directory of the project.
+       \item Select the requested project in the \textsc{Discovered project} section so that the result looks like in Figure \ref{fig-select-project}.
+       \item Click on \textsc{Finish} button.
 \end{enumerate}
 
 \begin{center}
-       \includegraphics[scale=1.00]{images/import_project.png}
+       \includegraphics[width=350px]{images/import_project.png}
        \captionof{figure}{Import project dialog}
        \label{fig-import-project}
 \end{center}
 
 \begin{center}
-       \includegraphics[scale=1.00]{images/select_project.png}
+       \includegraphics[width=350px]{images/select_project.png}
        \captionof{figure}{Select project dialog}
        \label{fig-select-project}
 \end{center}
 
 \subsection{Creating new project}
 \label{sec-creating-new-project}
-In \textsc{\repo/rpp/lib/apps/} there are two RPP base
+In \textsc{\repo/rpp/lib/apps/} there are two RPP based
 applications, \textsc{helloworld} and \textsc{helloworld\_posix}, that are
 already configured for the RPP Library. It is advised that new applications use this project as a
 foundation.
@@ -765,58 +767,58 @@ void vApplicationStackOverflowHook(xTaskHandle xTask,
 \label{sec-running-software-on-hw}
 \subsubsection{Code Composer Studio Project}
 \label{sec-ccs-run-project}
-When the application is distributed as a CCS project, you have to open the project in the CCS as following the procedure in Section. Once the project is opened and build, it can be easily downloaded to the target hardware with the following procedure;
+When the application is distributed as a CCS project, you have to open the project in the CCS as described in the Section \ref{sec-openning-of-existing-project}. Once the project is opened and built, it can be easily downloaded to the target hardware with the following procedure:
 
 \begin{enumerate}
-       \item Connect the Texas Instruments XDS100v2 USB JTAG emulator to the JTAG port (see Figure \ref{pinout}, port 1).
+       \item Connect the Texas Instruments XDS100v2 USB emulator to the JTAG port (see Figure \ref{pinout}, port 1).
        \item Connect a USB cable to the XDS100v2 USB emulator and the development computer.
        \item Plug in the power supply.
-       \item In the Code Composer Studio click on the Run$\rightarrow$Debug. The project will optionally build and the download process will start. The Code Composer Studio will switch into debug mode, when the download is finished.
-       \item Run the program by clicking on the Run button, with the green arrow.
+       \item In the Code Composer Studio click on the \textsc{Run$\rightarrow$Debug}. The project will  be optionaly built and the download process will start. The Code Composer Studio will switch into debug mode, when the download is finished.
+       \item Run the program by clicking on the \textsc{Run} button, with the green arrow.
 \end{enumerate}
 
 \subsubsection{Binary File}
 \label{sec-binary-file}
-If tha application is distributed as a binary file, without source codes and CCS project files, you can download and run just the binary file by creating a new empty CCS project and configuring the debug session according the following procedure:
+If the application is distributed as a binary file, without source codes and CCS project files, you can download and run just the binary file by creating a new empty CCS project and configuring the debug session according the following procedure:
 
 \begin{enumerate}
-       \item In Code Composer Studio click on File$\rightarrow$New$\rightarrow$CCS Project.
-       \item In the dialog window, type in a project name, for example myBinaryLoad, Select Device variant (ARM, Cortex R, TMS570LS3137, Texas Instruments XDS100v2 USB Emulator) and select project template to Empty Project. The filled dialog should look like on the Figure \ref{fig-new-empty-project}
-       \item Click on the Finish button and new empty project will be created.
-       \item In the Project Explorer click on the project with a right mouse button and in the context menu select Debug as$\rightarrow$Debug configuration.
-       \item Click on a button New launch configuration
+       \item In Code Composer Studio click on \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) 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 created.
+       \item In the \textsc{Project Explorer} click on the project with a right mouse button and in the context menu select \textsc{Debug as$\rightarrow$Debug configurations}.
+       \item Click on a button \textsc{New launch configuration}
        \item Rename the New\_configuration, for example to myConfiguration.
-       \item Select configuration target file by clicking the File System button, finding and selecting the TMS5703137.ccxml file. The result should look like on the Figure \ref{fig-debug-conf-main-diag}.
-       \item On the program pane select the binary file you want to download to the board. Click on the File System button, find and select the binary file. rpp-test-sw.out for example. The result should look like on the Figure \ref{fig-debug-conf-program-diag}.
-       \item You may also tune the target configuration like in the Section TODO: fill link to the section.
-       \item Finish the configuration by clickiing on the Apply button and download the code by clicking on the Debug button. You can later invoke the download also from the Run$\rightarrow$Debug CCS menu. You may not need to create more Debug configurations and CCS empty project as you can easily change the binary file in the Debug configuration to load different binary file.
-\end{enumerate}
-
-\subsubsection{Target configuration}
-\label{sec-target-configuration}
-Default target configuration erases the whole Flash memory, before downloading the code. This is however not needed in most cases. You may disable this feature by the following procedure:
-\begin{enumerate}
-       \item Right click on the project name ini the Project Browser
-       \item Select Debug as$\rightarrow$Debug Configurations
-       \item In the dialog window select Targe pane.
-       \item In the Flash Settings, Erase Options select Necessary sectors only.
-       \item Save the configuration by clicking on the Apply button and close the dialog.
+       \item Select configuration target file by clicking the \textsc{File System} button, finding and selecting the TMS5703137.ccxml file. The result should look like on the Figure \ref{fig-debug-conf-main-diag}.
+       \item On the \textsc{program} pane select the binary file you want to download to the board. Click on the \textsc{File System} button, find and select the binary file. Rpp-test-sw.out for example. The result should look like on the Figure \ref{fig-debug-conf-program-diag}.
+       \item You may also tune the target configuration like in the Section \ref{sec-target-configuration}.
+       \item Finish the configuration by clicking on the \textsc{Apply} button and download the code by clicking on the \textsc{Debug} button. You can later invoke the download also from the \textsc{Run$\rightarrow$Debug} CCS menu. You may not need to create more Debug configurations and CCS empty project as you can easily change the binary file in the Debug configuration to load different binary file.
 \end{enumerate}
 
 \begin{center}
-       \includegraphics[scale=0.66]{images/new_empty_project.png}
+       \includegraphics[width=350px]{images/new_empty_project.png}
        \captionof{figure}{New empty project dialog}
        \label{fig-new-empty-project}
 \end{center}
 
 \begin{center}
-       \includegraphics[scale=0.66]{images/debug_configuration_main.png}
+       \includegraphics[width=350px]{images/debug_configuration_main.png}
        \captionof{figure}{Debug Configuration Main dialog}
        \label{fig-debug-conf-main-diag}
 \end{center}
 
+\subsubsection{Target configuration}
+\label{sec-target-configuration}
+Default target configuration erases the whole Flash memory, before downloading the code. This is however not needed in most cases. You may disable this feature by the following procedure:
+\begin{enumerate}
+       \item Right click on the project name in the \textsc{Project Browser}
+       \item Select \textsc{Debug as$\rightarrow$Debug Configurations}
+       \item In the dialog window select \textsc{Target} pane.
+       \item In the \textsc{Flash Settings}, \textsc{Erase Options} select \textsc{Necessary sectors only}.
+       \item Save the configuration by clicking on the \textsc{Apply} button and close the dialog.
+\end{enumerate}
+
 \begin{center}
-       \includegraphics[scale=0.66]{images/debug_configuration_program.png}
+       \includegraphics[width=350px]{images/debug_configuration_program.png}
        \captionof{figure}{Debug Configuration Program dialog}
        \label{fig-debug-conf-program-diag}
 \end{center}
@@ -826,11 +828,10 @@ Default target configuration erases the whole Flash memory, before downloading t
 
 \subsection{Configuring Simulink for RPP}
 \label{sec-configuration-simulink-for-rpp}
-
 \begin{enumerate}
 \item Download and install CCS for Linux:
 
-Details on how to setup CCS are available in section .
+Details on how to setup CCS are available in Section \ref{sec-ti-ccs}.
 
 \item Install RPP Target:
 
@@ -862,21 +863,21 @@ For new models see \htmladdnormallink{Target Reference}{\#target\_reference} sec
 
 \subsection{Working with demo models}
 \label{sec-openning-demo-models}
-The demo models are available from the directory $\langle$rpp-simulink-root$\rangle$/rpp/demos. To asscess the demo models for reference or for downloading to the RPP board you have only to change the directoru to the one, containig the desired demo. For example to open the cantransmit demo you have to type these commands into the Matlab command line:
+The demo models are available from the directory \textsc{\repo/rpp/demos}. To access the demo models for reference or for downloading to the RPP board you have to change the directory to the one, containing the desired demo. For example to open the cantransmit demo you have to type these commands into the Matlab command line:
 
-\begin{verbatim}
+\begin{lstlisting}[language=Matlab]
 cd <rpp-simulink-root>/rpp/demos
 open('cantransmit.slx')
-\end{verbatim}
+\end{lstlisting}
 
-The same procedure can be used to openning any other models.
+The same procedure can be used to open any other models.
 
 \subsection{Creating new model}
 \label{sec-crating-new-model}
 \begin{enumerate}
 \item Open or create a model you want to generate code from.
-\item Make sure that the model is configured (Simulation $\rightarrow$
-  Model Configuration Parameters) as described in Section .
+\item Make sure that the model is configured (\textsc{Simulation $\rightarrow$
+  Model Configuration Parameters}) as described later in this section.
 \item From Matlab command window change the current directory to where
   you want your generated code to appear, e.g.:
 \begin{lstlisting}[language=Matlab]
@@ -885,23 +886,16 @@ cd /tmp/my-code
   The code will be generated in a subdirectory of that directory. The
   name of the subdirectory will be \textsc{<model>\_rpp}, where
   \textsc{model} is the name of the Simulink model.
-\item Generate the code by choosing ``Code $\rightarrow$ C/C++ Code
-  $\rightarrow$ Build Model''.
-\item If \emph{Download compiled binary to RPP} was selected in
-  \emph{RPP Options} pane (see Section \ref{sec-rpp-target-options}),
-  the compiled binary will be downloaded to the to the board. The program
-  will start running right after the loading is finished.
-
-  Note: You should end the Code Composer Studio debug session before
-  downloading the generated code to the RPP board. Otherwise the
-  download fails.
+\item Generate the code by choosing \textsc{Code $\rightarrow$ C/C++ 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}.
 
 The new Simulink model needs to be configured in the following way:
 
 \begin{compactitem}
-\item Solver (Figure~\ref{fig:solver}):
+\item Solver (Figure \ref{fig-solver}):
  \begin{compactitem}
  \item Options: \emph{Fixed-step, discrete}
  \item Tasking mode set to \textit{SingleTasking}.
@@ -909,10 +903,10 @@ The new Simulink model needs to be configured in the following way:
      \centering
      \includegraphics[width=400px]{images/simulink_solver.png}
      \caption{Solver settings}
\label{fig:solver}
       \label{fig-solver}
 \end{figure}
  \end{compactitem}
-\item Diagnostics $\rightarrow$ Sample Time (Figure~\ref{fig:sample-time-settings}):
+\item Diagnostics $\rightarrow$ Sample Time (Figure~\ref{fig-sample-time-settings}):
  \begin{compactitem}
  \item Disable warning source block specifies -1 sampling time. It's ok for the source blocks to run
    once per tick.
@@ -920,19 +914,19 @@ The new Simulink model needs to be configured in the following way:
      \centering
      \includegraphics[width=400px]{images/simulink_diagnostics.png}
      \caption{Sample Time settings}
\label{fig:sample-time-settings}
       \label{fig-sample-time-settings}
 \end{figure}
- \end{compactitem}
-\item Code generation (Figure~\ref{fig:code-gen-settings}):
+\end{compactitem}
+\item Code generation (Figure~\ref{fig-code-gen-settings}):
  \begin{compactitem}
  \item Set to \textsc{rpp.tlc}.
    \begin{figure}
      \centering
      \includegraphics[width=400px]{images/simulink_code.png}
      \caption{Code Generation settings}
\label{fig:code-gen-settings}
       \label{fig-code-gen-settings}
 \end{figure}
- \end{compactitem}
+\end{compactitem}
 \end{compactitem}
 
 
@@ -941,9 +935,9 @@ The new Simulink model needs to be configured in the following way:
 To run the model on the target RPP hardware you have to enable the download feature and build the model by following this procedure:
 \begin{enumerate}
        \item Open the model you want to run (See Section \ref{sec-openning-demo-models}.)
-       \item Click on Simulation$\rightarrow$Model Configuration Parameters.
-       \item In the Code Generation$\rightarrow$RPP Options pane check Download compiled binary to RPP checkbox.
-       \item Click on OK button, connect the target HW to the computer like in the Section \ref{sec-ccs-run-project} and build the model. If the build ends with a success, the download process will start and once the downloading is finished, the application will run immediatelly.
+       \item Click on \textsc{Simulation$\rightarrow$Model Configuration 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 ends with a success, the download process will start and once the downloading is finished, the application will run immediatelly.
 \end{enumerate}
 
 The code downloading is supported for Windows and Linux development systems. If you are using Linux, you may also try to use the OpenOCD by checking Use OpenOCD to download the compiled binary checkbox in addition. Refer 
@@ -952,6 +946,11 @@ The code downloading is supported for Windows and Linux development systems. If
 http://rtime.felk.cvut.cz/hw/index.php/TMS570LS3137#OpenOCD_setup_and_Flashing
 \end{verbatim}
 fore more information about the OpenOCD configuration.
+
+  Note: You should end the Code Composer Studio debug session before
+  downloading the generated code to the RPP board. Otherwise the
+  download fails.
+
  
 \section{Configuring serial interface}
 \label{sec-configuration-serial-interface}
@@ -964,12 +963,12 @@ The main interface for communicating with the RPP board is the serial interface.
        \item Flow control: none
 \end{itemize}
 
-Use GtkTerm in Linux or Bray Terminal for accessing the serial interface. See Section for referenc about the position of the serial interface connector on the RPP board.
+Use GtkTerm in Linux or Bray Terminal for accessing the serial interface. See Section \ref{sec-hardware-description} for reference about the position of the serial interface connector on the RPP board.
 
 \section{Bug reporting}
 \label{sec-bug-reporting}
 
-TODO: implement
+TODO: implement
 
 \chapter{C Support Library}
 \label{chap-c-support-library}
@@ -979,11 +978,9 @@ insight for future development.
 
 \section{Description}
 \label{sec-description}
-TODO create links to chapters
-The RPP C Support Library (also called RPP library) defines the API for communication with the board. It includes drivers and operating system. This support library is used in modules described in Chapter X and X. It is designed from the board user perspective and exposes a simplified high-level API to handle the board's peripheral modules in a safe manner. The library is compiled as a static library with the name rpp-lib.lib and can be found in <library-root>.
+The RPP C Support Library (also called RPP library) defines the API for communication with the board. It includes drivers and operating system and is designed from the board user perspective and exposes a simplified high-level API to handle the board's peripheral modules in a safe manner. The library is compiled as a static library with the name rpp-lib.lib and can be found in \textsc{\repo/rpp/lib}.
 
-The RPP library can be used in any project, where the RPP hardware support is required and is also used in two modules, described later in this document. The Command line testing tool, described in Chapter and Simulink Coder target, described in Chapter.
-TODO: Doplnit odkazy na kapitoly
+The RPP library can be used in any project, where the RPP hardware support is required and is also used in two modules, described later in this document. The Command line testing tool, described in Chapter \ref{chap-rpp-test-software} and Simulink Coder target, described in Chapter \ref{chap-simulink-coder-target}.
 
 For details about the library architecture, refer the Section \ref{sec-software-architecture} in Chapter \ref{chap-introduction}  
 
@@ -1010,9 +1007,9 @@ The following are the development guidelines used for developing the RPP API:
 
 \section{Coding style}
 \label{sec-coding-style}
-In order to keep the code as clean as possible, a unified coding style should be followed by any contributor to the code. The rpp-lib project is prepared for a usage of a program named Uncrustify.
+In order to keep the code as clean as possible, a unified coding style should be followed by any contributor to the code. The RPP library project is prepared for a usage of a program named Uncrustify.
 
-The Uncrustify program checks the code and fixes those lines that does not match the coding style. However keep in mind that the program is not perfect and sometimes some lines can be modified even when they were following the suggestions. This does not causes problems as long as the contributor follows the committing procedure described in next paragraph.
+The Uncrustify program checks the code and fixes those lines that does not match the coding style. However keep in mind that the program is not perfect and sometimes some lines can be modified even when the suggested coding style has been followed. This does not causes problems as long as the contributor follows the committing procedure described in next paragraph.
 
 When contributing to the code, the contributor should learn the current coding style from the existing code. When a new feature is implemented, before committing to the repository, a command :
 \lstset{language=bash}
@@ -1030,10 +1027,10 @@ The first one is for POSIX simulation, the second one for Simulink models and ot
 
        \item[apps/] Demo applications related to the RPP library.
 
-This include the CCS studio project for generation of the static library and the a test suite. The test suit in this directory does not match the test suite mentioned later in Chapter 5 and those two suits are gong 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.
+This include the CCS studio project for generation of the static library and the a test suite. The test suit in this directory does not match the test suite mentioned later in Chapter 5 and those two suits are going to be merged in the future. Also other demo Hello World like applications are included as a reference about how to create a TMS570 application.
        \item[os/] OS layers directory. See OS interchangeable layer for more information.
        \item[rpp/] Main directory for the RPP Library.
-       \item[rpp/doc/] Documentation directory for the RPP Library. See \htmladdnormallink{API generation}{\#api\_generation} for more information.
+       \item[rpp/doc/] Documentation directory for the RPP Library.
        \item[rpp/TMS570LS3137.ccxml] Descriptor for code download.
 
 This file is used by all the projects including the Simulink RPP Target for code download. It is
@@ -1043,20 +1040,20 @@ configured to use the Texas Instruments XDS100v2 USB Emulator.
 This file is used by all applications linked for the board, including the Simulink models, static
 library and test suite. It includes instructions for the CGT Linker on where to place sections
 and size of some sections.
-       \item[rpp/include/\{layer\} and rpp/src/\{layer\}] Interface files and implementations files for given \textsc{\{layer\}}. See Section in Chapter for details on the RPP Layer.
+       \item[rpp/include/\{layer\} and rpp/src/\{layer\}] Interface files and implementations files for given \textsc{\{layer\}}. See Section \ref{sec-software-architecture} in Chapter \ref{chap-introduction} for details on the RPP Layer.
        \item[rpp/include/rpp/rpp.h] Main library header file.
 
 To use this library with all its modules, just include this file and this file only. Also, before using any library function please call \textsc{rpp\_init()} function for hardware initialization.
 
        \item[rpp/include/rpp/rpp\_\{mnemonic\}.h] Header file for \textsc{\{mnemonic\}} module.
 
-This files includes function definitions, pin definitions, etc, specific to \{mnemonic\} module. See \htmladdnormallink{API development guidelines}{\#api\_development\_guidelines}.
+This files includes function definitions, pin definitions, etc, specific to \{mnemonic\} module. See Section \ref{sec-api-development-guidlines}.
 
 You may include only selected rpp\_\{mnemonic\}.h header files and call the specific rpp\_\{mnemonic\}\_init functions, instead of the rpp.h and rpp\_init function, if you want to use only a subset of the library functions.
 
        \item[rpp/src/rpp/rpp\_\{mnemonic\}.c] Module implementation.
 
-Implementation of \textsc{rpp\_\{mnemonic\}.h}'s functions on top of the DRV library. See Section for more details.
+Implementation of \textsc{rpp\_\{mnemonic\}.h}'s functions on top of the DRV library.
        \item[rpp/src/rpp/rpp.c] Implementation of library-wide functions.
 
 \end{description}
@@ -1064,9 +1061,9 @@ Implementation of \textsc{rpp\_\{mnemonic\}.h}'s functions on top of the DRV lib
 \section{Compilation}
 \label{sec-compilation}
 
-The RPP Library can be compiled as a static library for ARM using TI CGT and for x86(\_64) using GCC. The library can be compiled for ARM under Linux and Windows using a Code Composer Studio project. The POSIX version is available for Linux and can be compiled in Linux system using an Eclipse project. After the compilation, as part of the build process, both procedures will automatically update the version-controlled static libraries in the library root.
+The RPP Library can be compiled as a static library for ARM using a Code Composer Studio project or for x86 Linux using an Eclipse project. After the compilation, as part of the build process, both procedures will automatically update the version-controlled static libraries in the library root.
 
-For the compilation of the library as a static library open the Code Composer studio project for the rpp-lib (see Section) and build the project. As a result of the build process, if successful, a rpp-lib. lib file will appear in the library root directory.
+For the compilation of the library as a static library open the Code Composer studio project for the rpp-lib (see Section \ref{sec-openning-of-existing-project}) and build the project. As a result of the build process, if successful, a \textsc{rpp-lib.lib} file will appear in the library root directory.
 
 \begin{compactitem}
 \item \textsc{rpp-lib.lib}, static library for ARM using TI naming scheme.
@@ -1092,8 +1089,7 @@ The relevant aspects for compiling and linking an application using the static l
        \item \textbf{ARM compilation using CCS for the RPP board:}
        \begin{compactitem}
                \item Include headers files of the OS for which the library was compiled against. At the time of this
-         writing the OS is FreeRTOS 7.0.2. See \htmladdnormallink{OS interchangeable layer}{\#os\_interchangeable\_layer}
-         section above.
+         writing the OS is FreeRTOS 7.0.2. See Section \ref{sec-software-architecture}
                \item Include header files for the RPP library or for modules you want to use rpp\_can.h for CAN module for example.
                \item Add library \textsc{rpp-lib.lib} to the linker libraries. The RPP library \textbf{MUST} be looked for
          before Texas Instruments support library \textsc{rtsv7R4\_T\_be\_v3D16\_eabi.lib}.
@@ -1120,11 +1116,10 @@ static library is updated, in order for the Simulink model to generate a newly l
 the binary the whole code generation folder needs to be deleted in order to force code generation,
 compilation and linking with the new static library.
 
-\hypertarget{api_generation}{}
 \section{Compiling API documentation}
-
+\label{sec-compiling-api-documentation}
 The RPP Layer is formatted using Doxygen documentation generator. This allows to generate a high
-quality API reference. To generate the API reference do in a Linux terminal:
+quality API reference. To generate the API reference run in a Linux terminal:
 
 \lstset{language=bash}
 \begin{lstlisting}
@@ -1150,13 +1145,12 @@ main_page.dox
 The Simulink Coder Target allows to convert Simulink models to C code,
 compile it and download to the board.
 
-\hypertarget{description}{}
 \section{Introduction}
 \label{sec-introduction}
 
 The Simulink RPP Target provides support for C source code generation from Simulink models and
 compilation of that code on top of the RPP library and the FreeRTOS operating system. This target
-uses Texas Instruments ARM compiler (\textsc{armcl}) included in the Code Generation Tools available with
+uses Texas Instruments ARM compiler (\textsc{armcl}) included in the Code Generation Tools distributed with
 Code Composer Studio, and thus it depends on it for proper functioning.
 
 This target also provides support for automatic download of the compiled binary to the RPP
@@ -1172,9 +1166,9 @@ board.
 \label{sec-features}
 
 \begin{itemize}
-\item Support only single tasking.  If multitasking is required, it has to be implemented in a new file \textsc{rpp\_mrmain.tlc} in \textsc{\repo/rpp/rpp/} and \textsc{rpp\_file\_process.tlc} has to be edited to use that file, when multitasking is selected.
+\item Supports only single tasking.  If multitasking is required, it has to be implemented in a new file \textsc{rpp\_mrmain.tlc} in \textsc{\repo/rpp/rpp/} and \textsc{rpp\_file\_process.tlc} has to be edited to use that file, when multitasking is selected.
 \item No External mode support
-\item Custom compiler options, available via OPTS variable in \emph{Make command} at \emph{Code Generation} tab (see Figure ). For example \textsc{make\_rtw OPTS="-O0 -g"}.
+\item Custom compiler options, available via OPTS variable in \emph{Make command} at \emph{Code Generation} tab (see Figure \ref{fig-code-gen-settings}). For example \textsc{make\_rtw OPTS="-O0 -g"}.
 
 \end{itemize}
 
@@ -1253,13 +1247,13 @@ This section describes the directories of the Simulink Coder. If you are interes
 \begin{description}
        \item[doc/] Contains the sources of the documentation, you are now reading.
        \item[refs/] Contains third party references, which license allows the distribution.
-       \item[rpp/blocks] Contains the TLC files, which defines the blocks for the Matlab Simulink and rpp\_lib.slx, which is the library of the RPP Matlab Simulink blocks.
+       \item[rpp/blocks] Contains the TLC files, which defines the blocks for the Matlab Simulink and \textsc{rpp\_lib.slx}, which is the Simulink RPP Library, containing all the Simulink blocks for RPP.
        \item[rpp/blocks/tlc\_c]Contains the templates for C code generation from the Matlab Simulink model.
        \item[rpp/demos] Contains demo models, which purpose is to serve as a reference for the usage and for testing.
-       \item[rpp/lib] Contains the C Support Library. See Chapter .
+       \item[rpp/lib] Contains the C Support Library. See Chapter \ref{chap-c-support-library}.
        \item[rpp/loadopenocd] Contains download scripts for Linux support of the OpenOCD, for code downloading to the target.
        \item[rpp/loadti] Contains download scripts for Linux and Windows support for code downloading to the target, using Texas Instruments CCS code downloader.
-       \item[rpp/rpp] Contains set of support script for Code Generator.
+       \item[rpp/rpp] Contains set of support script for the Code Generator.
 \end{description}
 
 \section{Block Library Overview}
@@ -1306,12 +1300,13 @@ A complete list of callbacks can be found in:
 \htmladdnormallink{http://www.mathworks.com/help/simulink/create-cc-s-functions.html}{http://www.mathworks.com/help/simulink/create-cc-s-functions.html}
        \end{quotation}
 
-The way a C-MEX S-Function participates in a Simulink simulation is shown by the following diagram:
+The way a C-MEX S-Function participates in a Simulink simulation is shown on the diagram \ref{fig-sfunctions-process}:
 
 \begin{figure}[H]\begin{center}
 \noindent
 \includegraphics[width=250px]{images/sfunctions_process.png}
 \caption{Simulation cycle of a S-Function.}
+\label{fig-sfunctions-process}
 \end{center}\end{figure}
 
 In general, the S-Function can perform calculations, inputs and outputs for simulation. Because 
@@ -1322,7 +1317,7 @@ The implementation of the S-Functions in the RPP project has following layout:
 
 \begin{itemize}
 \item Define S-Function name \textsc{S\_FUNCTION\_NAME}.
-\item Include header file \textsc{header.c}, which in connection with \textsc{trailer.c} create a mini framework for writing S-Functions.
+\item Include header file \textsc{header.c}, which in connection with \textsc{trailer.c} creates a miniframework for writing S-Functions.
 \item In \textsc{mdlInitializeSizes} define:
        \begin{itemize}
        \item Number of \textit{dialog} parameter.
@@ -1373,8 +1368,8 @@ compile_blocks()
 \subsubsection{Target Language Compiler files}
 \label{sec-target-language-compiler-files}
 
-In order to generate code for each one of those functions each S-Function implements a TLC file
-for \textit{inlining} the S-Function on the generated code. The TLC files are files that describe how to 
+In order to generate code for each one of the S-Functions, every S-Function implements a TLC file
+for \textit{inlining} the S-Function on the generated code. The TLC files describe how to 
 generate code for a specific C-MEX S-Function block. They are programmed using TLC own language and 
 include C code within TLC instructions, just like LaTeX files include normal text in between LaTeX 
 macros.
@@ -1402,7 +1397,7 @@ The general layout of the TLC files implemented for this project are:
 \begin{itemize}
 \item In \textsc{BlockTypeSetup}: \newline{}
   Call common function \textsc{\%$<$RppCommonBlockTypeSetup(block, system)$>$} that will include the 
-  \textsc{rpp/rpp.h} header file (can be called multiple times but header is included only once).
+  \textsc{rpp/rpp\i\_mnemonic.h} header file (can be called multiple times but header is included only once).
 \item \textsc{Start}: \newline{}
   Call setup routines from RPP Layer for the specific block type, like HBR enable, DIN pin setup, 
   DAC value initialization, SCI baud rate setup, among others.
@@ -1442,6 +1437,7 @@ This section describes each one of the Simulink blocks present in the Simulink R
 \end{figure}
 
 % Include automatically generated documentation
+% TODO: the block_desc is badly generated
 \input{block_desc.tex}
 
 \section{Demos}
@@ -1745,7 +1741,7 @@ The board reacts to CAN frames with following IDs:
 \end{itemize}
 
 \chapter{Command line testing tool}
-\label{sec:rpp-test-software}
+\label{chap-rpp-test-software}
 The \textsc{rpp-test-suite} is a RPP application developed testing and direct control of the RPP hardware. The test suite implements a command processor, which is listening for a commands and prints some output related to the commands on the serial interface. The command processor is modular and each peripheral has its commands in a separated module.
 
 The command processor is implemented in <rpp-test-sw>/cmdproc and commands modules are implemented in <rpp-test-sw>/commands directory.