]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/tlc_c/sfunction_scir.tlc
8871081c73b39ad6439a9e92aa5287decedc32cb
[pes-rpp/rpp-simulink.git] / rpp / blocks / tlc_c / sfunction_scir.tlc
1 %% Copyright (C) 2013-2014 Czech Technical University in Prague
2 %%
3 %% Authors:
4 %%     - Carlos Jenkins <carlos@jenkins.co.cr>
5 %%
6 %% This document contains proprietary information belonging to Czech
7 %% Technical University in Prague. Passing on and copying of this
8 %% document, and communication of its contents is not permitted
9 %% without prior written authorization.
10 %%
11 %% File : sfunction_scir.tlc
12 %% Abstract:
13 %%     TLC file for inlining RPP serial communication interface receive block.
14 %%
15 %% References:
16 %%     BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
17 %%     Start()          : refs/rtw_tlc.pdf p. 279
18 %%     Outputs()        : refs/rtw_tlc.pdf p. 281
19
20
21 %implements sfunction_scir "C"
22
23 %include "common.tlc"
24
25
26 %% Function: BlockTypeSetup ====================================================
27 %function BlockTypeSetup(block, system) void
28
29     %% Ensure required header files are included
30     %<RppCommonBlockTypeSetup(block, system)>
31     %<LibAddToCommonIncludes("rpp/rpp.h")>
32
33 %endfunction
34
35
36 %% Function: Start =============================================================
37 %function Start(block, system) Output
38
39     %if !SLibCodeGenForSim()
40         %%No initialization needed for this block
41     %endif
42
43 %endfunction
44
45
46 %% Function: Outputs ===========================================================
47 %function Outputs(block, system) Output
48
49     %if !SLibCodeGenForSim()
50
51         %if extMode
52             %return
53         %endif
54
55         %% Declare temporal variables
56         %if EXISTS("_RPP_SCIR_TMP_VARS_") == 0
57             %assign ::_RPP_SCIR_TMP_VARS_ = 1
58             uint8_t scir_tmp;
59         %endif
60
61         %% Get IO signals
62         %assign data     = LibBlockOutputSignal(0, "", "", 0)
63         %assign err_flag = LibBlockOutputSignal(1, "", "", 0)
64
65         scir_tmp = 0;
66         if (rpp_sci_read_nb(1, &scir_tmp) != SUCCESS) {
67             %<data> = -1;
68             %<err_flag> = TRUE;
69         } else {
70             %<data> = (int16_t)scir_tmp;
71             %<err_flag> = FALSE;
72         }
73
74     %endif
75
76 %endfunction
77
78 %% [EOF]