1 %% Copyright (C) 2013, 2015 Czech Technical University in Prague
4 %% - Carlos Jenkins <carlos@jenkins.co.cr>
5 %% - Michal Horn <hornmich@fel.cvut.cz>
7 %% This document contains proprietary information belonging to Czech
8 %% Technical University in Prague. Passing on and copying of this
9 %% document, and communication of its contents is not permitted
10 %% without prior written authorization.
12 %% File : sfunction_gio_out.tlc
14 %% TLC file for inlining RPP digital output block.
17 %% BlockTypeSetup() : rtw_tlc.pdf p. 277
18 %% Start() : rtw_tlc.pdf p. 279
19 %% Outputs() : rtw_tlc.pdf p. 281
22 %implements sfunction_gio_out "C"
27 %% Function: BlockTypeSetup ====================================================
28 %function BlockTypeSetup(block, system) void
30 %% Ensure required header files are included
31 %<RppCommonBlockTypeSetup(block, system)>
32 %<LibAddToCommonIncludes("rpp/rpp.h")>
33 %assign ::rpp_gio_out_present = 1
37 %function BlockInstanceSetup(block, system) void
38 %assign pin_name = SFcnParamSettings.PinName
40 %% Ensure that every pin is configured only once
41 %if EXISTS("::rpp_gio_%<pin_name>_present") == 0
42 %assign ::rpp_gio_%<pin_name>_present = 1
44 %<LibBlockReportError(block, "GIO pin %<pin_name> has already been configured.")>
48 %% Function: Start =============================================================
49 %function Start(block, system) Output
50 %assign pin_name = SFcnParamSettings.PinName
51 %assign config = SFcnParamSettings.OutType
52 %assign init_val = SFcnParamSettings.DefOut
54 %if !SLibCodeGenForSim()
55 %if config == 1 %% Open drain
56 rpp_gio_setup(PIN_%<pin_name>, RPP_GIO_OUT, RPP_GIO_MODE_PULLDIS, TRUE);
57 %elseif config == 2 %% push/pull
58 rpp_gio_setup(PIN_%<pin_name>, RPP_GIO_OUT, RPP_GIO_MODE_PULLDIS, FALSE);
60 %<LibBlockReportError(block, "Bad configuration value: %<config>")>
63 rpp_gio_set(PIN_%<pin_name>, FALSE);
65 rpp_gio_set(PIN_%<pin_name>, TRUE);
67 %<LibBlockReportError(block, "Bad init output value: %<init_val>")>
74 %% Function: Outputs ===========================================================
75 %function Outputs(block, system) Output
76 %if !SLibCodeGenForSim()
77 %assign pin_name = SFcnParamSettings.PinName
78 %assign digital_out = LibBlockInputSignal(0, "", "", 0)
79 rpp_gio_set(PIN_%<pin_name>, %<digital_out>);