]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/lib/rpp/doc/api/content/main_page.dox
171f3ad9b5ec33e17ff1f8037c91c0febc051ce2
[pes-rpp/rpp-simulink.git] / rpp / lib / rpp / doc / api / content / main_page.dox
1 /**
2 \mainpage Library description
3
4 The RPP library is a high-level API that allows user to control the RPP
5 hardware. It is designed from the board user perspective and exposes a
6 simplified API to handle the board's peripheral modules in a safe manner.
7
8 If you're using Simulink, the block set is implemented on top of this API.
9
10 This library works on top of the DRV layer (RPP driver library). For advanced
11 use, configuration and low-level access of the board please refers to the DRV
12 library.
13
14
15 \section blocks Block diagram:
16
17 The RPP library is divided into modules, one module per hardware peripheral.
18
19 Click on a block in the following diagram to see the API for that module.
20
21 \htmlonly
22 <div style="float: right;">
23 \endhtmlonly
24 \verbatim
25 CATEGORY            NAME                                MNEMONIC
26 ----------------------------------------------------------------
27
28 Logic IO
29                     Digital Input                       [DIN ]
30                     Digital (Logic) Output              [LOUT]
31                     Analog Input                        [AIN ]
32                     Analog Output                       [AOUT]
33
34 Power output
35                     H-Bridge output                     [HBR ]
36                     Power output (12V, 2A)              [MOUT]
37                     High-Power output (12V, 10A)        [HOUT]
38
39 Communication
40                     CAN Bus                             [CAN ]
41                     LIN (Local Interconnect Network)    [LIN ]
42                     FlexRay                             [FR  ]
43                     Serial Communication Interface      [SCI ]
44                     Ethernet                            [ETHR]
45
46 Logging
47                     SD Card                             [SDC ]
48                     SD-RAM                              [SDR ]
49 \endverbatim
50 \htmlonly
51 </div>
52 \endhtmlonly
53
54 \htmlinclude blocks_map.html
55
56
57 \section example Base application:
58
59 \subsection ex_layout Application Layout
60
61 A base RPP application is structured in the following manner:
62
63 - Include RPP library header file.
64 \code
65 #include "rpp/rpp.h"
66 \endcode
67
68 - Create one or as many FreeRTOS task function definitions as required. Those
69   tasks should use functions from this library.
70 \code
71 void my_task(void* p)
72 {
73     static const portTickType freq_ticks = 1000 / portTICK_RATE_MS;
74     portTickType last_wake_time = xTaskGetTickCount();
75
76     while(TRUE) {
77
78         /* Wait until next step */
79         vTaskDelayUntil(&last_wake_time, freq_ticks);
80         rpp_sci_printf((const char*)"Hello RPP.\r\n");
81
82     }
83 }
84 \endcode
85
86 - Create the main function that will:
87  - Initialize the RPP board.
88  - Spawn the tasks the application requires. Refer to FreeRTOS API for
89    details.
90  - Start the FreeRTOS Scheduler. Refer to FreeRTOS API for details.
91  - Catch if idle task could not be created.
92 -
93 \code
94 void main(void)
95 {
96     /* Initialize RPP board */
97     rpp_init();
98
99     /* Spawn tasks */
100     if(xTaskCreate(my_task, (const signed char*)"my_task",
101             512, NULL, CONTROL_PRIORITY, NULL) != pdPASS) {
102         #ifdef DEBUG
103         rpp_sci_printf((const char*)
104             "ERROR: cannot spawn control task.\r\n"
105         );
106         #endif
107         while(TRUE) {
108             asm("nop");
109         }
110     }
111
112     /* Start the FreeRTOS Scheduler */
113     vTaskStartScheduler();
114
115     /* Catch scheduler start error */
116     #ifdef DEBUG
117     rpp_sci_printf((const char*)
118             "ERROR: Problem allocating memory for idle task.\r\n"
119         );
120     #endif
121     while(TRUE) {
122         asm("nop");
123     }
124 }
125 \endcode
126
127
128 \subsection ex_make Compilation
129
130 TODO
131 \note If using the RPP Static Library, rpp-lib.lib, make sure the linker is
132       retaining the .intvecs sections, and that the startup symbol is resolved
133       to the library and not to the support ABI.
134
135 */