]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/tlc_c/sfunction_hbr.tlc
Simulink blocks tlc files tuned to reflect changes in rpp library
[jenkicar/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     %<LibAddToCommonIncludes("rpp/hbr.h")>
32     %assign ::rpp_hbr_present=1
33
34 %endfunction
35
36
37 %% Function: Start =============================================================
38 %function Start(block, system) Output
39
40     %if !SLibCodeGenForSim()
41         rpp_hbr_enable(-1);
42     %endif
43
44 %endfunction
45
46
47 %% Function: Outputs ===========================================================
48 %function Outputs(block, system) Output
49
50     %if !SLibCodeGenForSim()
51
52         %% Get IO signals
53         %assign enable = LibBlockInputSignal(0, "", "", 0)
54         %assign control = LibBlockInputSignal(1, "", "", 0)
55         %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
56
57         if (%<enable>) {
58             rpp_hbr_enable(-1); %% enable if not enabled
59             if (rpp_hbr_control(%<control>) != SUCCESS) {
60                 %<err_flag> = TRUE;
61             }
62         } else {
63             rpp_hbr_disable(); %% disable if not disabled
64         }
65
66     %endif
67
68 %endfunction
69
70 %% [EOF]