%% Copyright (C) 2013, 2015 Czech Technical University in Prague %% %% Authors: %% - Carlos Jenkins %% - Michal Horn %% %% 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_gio_in.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_gio_in "C" %include "common.tlc" %% Function: BlockTypeSetup ==================================================== %function BlockTypeSetup(block, system) void %% Ensure required header files are included % % %assign ::rpp_gio_in_present = 1 %endfunction %function BlockInstanceSetup(block, system) void %assign port_par = LibBlockParameterValue(port_type, 0) %assign pin_number_par = LibBlockParameterValue(pin_number, 0) %% Ensure that every pin is configured only once %if EXISTS("::rpp_gio_%_%_present") == 0 %assign ::rpp_gio_%_%_present = 1 %else % on port % has already been configured.")> %endif %endfunction %% Function: Start ============================================================= %function Start(block, system) Output %assign port_par = LibBlockParameterValue(port_type, 0) %assign pin_number_par = LibBlockParameterValue(pin_number, 0) %assign config = LibBlockParameterValue(input_type, 0) %if !SLibCodeGenForSim() %if port_par == 1 %% GIOA %assign pin = "PIN_GIOA%" %elseif port_par == 2 %% GIOB %assign pin = "PIN_GIOB%" %elseif port_par == 3 %% NHET1 %assign pin = "PIN_NHET1%" %else %")> %endif %if config == 1 %% Tri-state rpp_gio_setup(%, RPP_GIO_IN, RPP_GIO_MODE_PULLDIS, FALSE); %elseif config == 2 %% Pull up rpp_gio_setup(%, RPP_GIO_IN, RPP_GIO_MODE_PULLUP, FALSE); %elseif config == 3 %% Pull down rpp_gio_setup(%, RPP_GIO_IN, RPP_GIO_MODE_PULLDOWN, FALSE); %else %% error %")> %endif %endif %endfunction %% Function: Outputs =========================================================== %function Outputs(block, system) Output %if !SLibCodeGenForSim() %assign digital_in = LibBlockOutputSignal(0, "", "", 0) %assign port_par = LibBlockParameterValue(port_type, 0) %assign pin_number_par = LibBlockParameterValue(pin_number, 0) %if port_par == 1 %% GIOA %assign pin = "PIN_GIOA%" %elseif port_par == 2 %% GIOB %assign pin = "PIN_GIOB%" %elseif port_par == 3 %% NHET1 %assign pin = "PIN_NHET1%" %else %")> %endif /% TODO: Handle FAILURE (add error output?) %/ % = rpp_gio_get(%) ? TRUE : FALSE; %endif %endfunction %% [EOF]