1 %% Copyright (C) 2013 Czech Technical University in Prague
4 %% - Carlos Jenkins <carlos@jenkins.co.cr>
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.
11 %% File : sfunction_din.tlc
13 %% TLC file for inlining RPP digital input block.
16 %% BlockTypeSetup() : rtw_tlc.pdf p. 277
17 %% Start() : rtw_tlc.pdf p. 279
18 %% Outputs() : rtw_tlc.pdf p. 281
21 %implements sfunction_din "C"
26 %% Function: BlockTypeSetup ====================================================
27 %function BlockTypeSetup(block, system) void
29 %% Ensure required header files are included
30 %<RppCommonBlockTypeSetup(block, system)>
35 %% Function: Start =============================================================
36 %function Start(block, system) Output
38 %if !SLibCodeGenForSim()
39 %assign pin_num = LibBlockParameterValue(p1, 0)
40 rpp_din_setup(%<pin_num>, FALSE, TRUE, FALSE);
46 %% Function: Outputs ===========================================================
47 %function Outputs(block, system) Output
49 %if !SLibCodeGenForSim()
51 %% Declare temporal variables
52 %if EXISTS("_RPP_DIN_TMP_VARS_") == 0
53 %assign ::_RPP_DIN_TMP_VARS_ = 1
58 %assign err_flag = LibBlockOutputSignal(1, "", "", 0)
60 %% First executed block must update cached values
61 %if EXISTS("_RPP_DIN_UPDATE_") == 0
62 %assign ::_RPP_DIN_UPDATE_ = 1
63 if (rpp_din_update() != SUCCESS) {
68 %% Get pin number and if to use variable threshold
69 %assign pin_num = LibBlockParameterValue(p1, 0)
70 %assign var_thr = LibBlockParameterValue(p2, 0)
74 din_tmp = rpp_din_get(%<pin_num>);
76 din_tmp = rpp_din_get_tr(%<pin_num>);
84 %assign digital_in = LibBlockOutputSignal(0, "", "", 0)
85 %<digital_in> = din_tmp;