1 %% Copyright (C) 2013, 2014 Czech Technical University in Prague
6 %% Permission is hereby granted, free of charge, to any person
7 %% obtaining a copy of this software and associated documentation
8 %% files (the "Software"), to deal in the Software without
9 %% restriction, including without limitation the rights to use,
10 %% copy, modify, merge, publish, distribute, sublicense, and/or sell
11 %% copies of the Software, and to permit persons to whom the
12 %% Software is furnished to do so, subject to the following
15 %% The above copyright notice and this permission notice shall be
16 %% included in all copies or substantial portions of the Software.
18 %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 %% OTHER DEALINGS IN THE SOFTWARE.
27 %% File : sfunction_irc.tlc
29 %% TLC file for inlining RPP IRC input block.
32 %% BlockTypeSetup() : rtw_tlc.pdf p. 277
33 %% Start() : rtw_tlc.pdf p. 279
34 %% Outputs() : rtw_tlc.pdf p. 281
37 %implements sfunction_irc "C"
42 %% Function: BlockInstanceSetup ================================================
43 %function BlockInstanceSetup(block, system) void
44 %assign irc_num = LibBlockParameterValue(p1, 0)
48 %if EXISTS("rpp_din_10_11_used") == 1
49 %<LibBlockReportError(block, "Either IRC1 or Digital Input pin 10 and 11 blocks are allowed in one model, not both.")>
51 %assign ::rpp_irc_1_used = 1
55 %if EXISTS("rpp_din_14_15_used") == 1
56 %<LibBlockReportError(block, "Either IRC2 or Digital Input pin 14 and 15 blocks are allowed in one model, not both.")>
58 %assign ::rpp_irc_2_used = 1
64 %% Function: BlockTypeSetup ====================================================
65 %function BlockTypeSetup(block, system) void
67 %% Ensure required header files are included
68 %<RppCommonBlockTypeSetup(block, system)>
69 %<LibAddToCommonIncludes("rpp/rpp.h")>
70 %assign ::rpp_irc_present=1
75 %% Function: Start =============================================================
76 %function Start(block, system) Output
78 %if !SLibCodeGenForSim()
79 %assign irc_num = LibBlockParameterValue(p1, 0)
80 rpp_irc_enable(%<irc_num>);
86 %% Function: Outputs ===========================================================
87 %function Outputs(block, system) Output
89 %if !SLibCodeGenForSim()
92 %assign err_flag = LibBlockOutputSignal(1, "", "", 0)
95 %assign irc_num = LibBlockParameterValue(p1, 0)
97 %% Control if irc running
98 if (rpp_irc_status(%<irc_num>) != 1) {
102 %assign irc_val = LibBlockOutputSignal(0, "", "", 0)
103 %<irc_val> = rpp_irc_get(%<irc_num>);