%% Copyright (C) 2013 Czech Technical University in Prague %% %% Authors: %% - Carlos Jenkins %% %% This document contains proprietary information belonging to Czech %% Technical University in Prague. Passing on and copying of this %% document, and communication of its contents is not permitted %% without prior written authorization. %% %% File : sfunction_din.tlc %% Abstract: %% TLC file for inlining RPP digital input block. %% %% References: %% BlockTypeSetup() : rtw_tlc.pdf p. 277 %% Start() : rtw_tlc.pdf p. 279 %% Outputs() : rtw_tlc.pdf p. 281 %implements sfunction_din "C" %include "common.tlc" %% Function: BlockInstanceSetup ================================================ %function BlockInstanceSetup(block, system) void %assign pin_num = LibBlockParameterValue(p1, 0) %switch (%) %case 10 %case 11 %if EXISTS("rpp_irc_1_used") == 1 % %else %assign ::rpp_din_10_11_used = 1 %endif %break %case 14 %case 15 %if EXISTS("rpp_irc_2_used") == 1 % %else %assign ::rpp_din_14_15_used = 1 %endif %break %endswitch %endfunction %% Function: BlockTypeSetup ==================================================== %function BlockTypeSetup(block, system) void %% Ensure required header files are included % %endfunction %% Function: Start ============================================================= %function Start(block, system) Output %if !SLibCodeGenForSim() %assign pin_num = LibBlockParameterValue(p1, 0) rpp_din_setup(%, FALSE, TRUE, FALSE); %endif %endfunction %% Function: Outputs =========================================================== %function Outputs(block, system) Output %if !SLibCodeGenForSim() %% Declare temporal variables %if EXISTS("_RPP_DIN_TMP_VARS_") == 0 %assign ::_RPP_DIN_TMP_VARS_ = 1 int8_t din_tmp; %endif %% Error flag %assign err_flag = LibBlockOutputSignal(1, "", "", 0) %% First executed block must update cached values %if EXISTS("_RPP_DIN_UPDATE_") == 0 %assign ::_RPP_DIN_UPDATE_ = 1 if (rpp_din_update() != SUCCESS) { % = TRUE; } %endif %% Get pin number and if to use variable threshold %assign pin_num = LibBlockParameterValue(p1, 0) %assign var_thr = LibBlockParameterValue(p2, 0) %% Get pin value %if var_thr == 0 din_tmp = rpp_din_get(%); %else din_tmp = rpp_din_get_tr(%); %endif if (din_tmp < 0) { % = TRUE; din_tmp = LOW; } %% Return input %assign digital_in = LibBlockOutputSignal(0, "", "", 0) % = din_tmp; %endif %endfunction %% [EOF]