%% Copyright (C) 2013 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_%_%_present") == 0 %assign ::rpp_%_%_present = 1 %else % on port % has already been configred.")> %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() %openfile buffer uint32_t* din_%_%_desc = NULL; %closefile buffer % uint32_t din_%_%_cfg = PORT_CONF_FNC_GPIO|PORT_CONF_DIR_IN; %if port_par == 1 %% GIOA %assign name = "GIOA%" %elseif port_par == 2 %% GIOB %assign name = "GIOB%" %elseif port_par == 3 %% NHET1 %assign name = "NHET1%" %else %")> %endif din_%_%_desc = hal_gpio_pin_get_dsc("%", -1); %if config == 1 %% Tri-state din_%_%_cfg |= PORT_CONF_MODE_PDIS|PORT_CONF_OD_ON; %elseif config == 2 %% Pull up din_%_%_cfg |= PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF|PORT_CONF_MODE_PU; %elseif config == 3 %% Pull down din_%_%_cfg |= PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF|PORT_CONF_MODE_PD; %else %% error %")> %endif hal_gpio_pin_conf_set(*din_%_%_desc, din_%_%_cfg); %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) uint32_t din_%_%_val = hal_gpio_pin_get_value(*din_%_%_desc); % = din_%_%_val; %endif %endfunction %% [EOF]