]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/tlc_c/sfunction_hbr.tlc
Coding style: Add space after if, for and while
[pes-rpp/rpp-simulink.git] / rpp / blocks / tlc_c / sfunction_hbr.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_hbr.tlc
12 %% Abstract:
13 %%     TLC file for inlining RPP H-Bridge control 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_hbr "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
32 %endfunction
33
34
35 %% Function: Start =============================================================
36 %function Start(block, system) Output
37
38     %if !SLibCodeGenForSim()
39         rpp_hbr_enable(-1);
40     %endif
41
42 %endfunction
43
44
45 %% Function: Outputs ===========================================================
46 %function Outputs(block, system) Output
47
48     %if !SLibCodeGenForSim()
49
50         %% Get IO signals
51         %assign enable = LibBlockInputSignal(0, "", "", 0)
52         %assign control = LibBlockInputSignal(1, "", "", 0)
53         %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
54
55         if (%<enable>) {
56             rpp_hbr_enable(-1); %% enable if not enabled
57             if (rpp_hbr_control(%<control>) != SUCCESS) {
58                 %<err_flag> = TRUE;
59             }
60         } else {
61             rpp_hbr_disable(); %% disable if not disabled
62         }
63
64     %endif
65
66 %endfunction
67
68 %% [EOF]