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_aout.tlc
13 %% TLC file for inlining RPP analog output block.
16 %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
17 %% Start() : refs/rtw_tlc.pdf p. 279
18 %% Outputs() : refs/rtw_tlc.pdf p. 281
21 %implements sfunction_aout "C"
26 %% Function: BlockTypeSetup ====================================================
27 %function BlockTypeSetup(block, system) void
29 %% Ensure required header files are included
30 %<RppCommonBlockTypeSetup(block, system)>
31 %<LibAddToCommonIncludes("rpp/rpp.h")>
32 %assign ::rpp_aout_present=1
37 %% Function: Start =============================================================
38 %function Start(block, system) Output
40 %if !SLibCodeGenForSim()
41 %assign pin_num = LibBlockParameterValue(p1, 0)
42 rpp_dac_setup(%<pin_num>, TRUE);
43 rpp_dac_set(%<pin_num>, 0);
45 * Warning! This should be the correct way to initialize DAC.
46 * Nevertheless rpp_dac_update() has a known bug that if it is called
47 * before starting the FreeRTOS Scheduler the application will freeze.
48 * Check the RPP API documentation for more information.
49 * Not updating now is harmless though.
51 /* rpp_dac_update(); */
57 %% Function: Outputs ===========================================================
58 %function Outputs(block, system) Output
60 %if !SLibCodeGenForSim()
63 %assign pin_num = LibBlockParameterValue(p1, 0)
64 %assign use_voltage = LibBlockParameterValue(p2, 0)
67 %assign analog_out = LibBlockInputSignal(0, "", "", 0)
68 %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
71 if (rpp_dac_set_voltage(%<pin_num>, %<analog_out>) != SUCCESS) {
73 if (rpp_dac_set(%<pin_num>, %<analog_out>) != SUCCESS) {
79 %% The call is smart enought to commit only the changed outputs
80 %% so it is efficient to call this at the end of each block.
81 if (rpp_dac_update() != SUCCESS) {