-Subproject commit 99da95a0f981210ad545f53cd0de67e7af24fae3
+Subproject commit 84955c1eb7121d0841cfc8b68a34be4894a4ab83
-%% Copyright (C) 2013 Czech Technical University in Prague
+%% Copyright (C) 2013, 2015 Czech Technical University in Prague
%%
%% Authors:
%% - Carlos Jenkins <carlos@jenkins.co.cr>
%assign pin_number_par = LibBlockParameterValue(pin_number, 0)
%% Ensure that every pin is configured only once
- %if EXISTS("::rpp_%<port_par>_%<pin_number_par>_present") == 0
- %assign ::rpp_%<port_par>_%<pin_number_par>_present = 1
+ %if EXISTS("::rpp_gio_%<port_par>_%<pin_number_par>_present") == 0
+ %assign ::rpp_gio_%<port_par>_%<pin_number_par>_present = 1
%else
- %<LibBlockReportError(block, "GPIO pin %<pin_number_par> on port %<port_par> has already been configred.")>
+ %<LibBlockReportError(block, "GIO pin %<pin_number_par> on port %<port_par> has already been configured.")>
%endif
%endfunction
%assign config = LibBlockParameterValue(input_type, 0)
%if !SLibCodeGenForSim()
- %openfile buffer
- uint32_t* din_%<port_par>_%<pin_number_par>_desc = NULL;
- %closefile buffer
- %<LibSetSourceFileSection(LibGetModelDotCFile(), "Declarations", buffer)>
-
- uint32_t din_%<port_par>_%<pin_number_par>_cfg = PORT_CONF_FNC_GPIO|PORT_CONF_DIR_IN;
%if port_par == 1 %% GIOA
- %assign name = "GIOA%<pin_number_par>"
+ %assign pin = "PIN_GIOA%<pin_number_par>"
%elseif port_par == 2 %% GIOB
- %assign name = "GIOB%<pin_number_par>"
+ %assign pin = "PIN_GIOB%<pin_number_par>"
%elseif port_par == 3 %% NHET1
- %assign name = "NHET1%<pin_number_par>"
+ %assign pin = "PIN_NHET1%<pin_number_par>"
%else
%<LibBlockReportError(block, "Bad port identifier: %<port_par>")>
%endif
- din_%<port_par>_%<pin_number_par>_desc = hal_gpio_pin_get_dsc("%<name>", -1);
-
%if config == 1 %% Tri-state
- din_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_MODE_PDIS|PORT_CONF_OD_ON;
+ rpp_gio_setup(%<pin>, RPP_GIO_IN, RPP_GIO_MODE_PULLDIS, FALSE);
%elseif config == 2 %% Pull up
- din_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF|PORT_CONF_MODE_PU;
+ rpp_gio_setup(%<pin>, RPP_GIO_IN, RPP_GIO_MODE_PULLUP, FALSE);
%elseif config == 3 %% Pull down
- din_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF|PORT_CONF_MODE_PD;
+ rpp_gio_setup(%<pin>, RPP_GIO_IN, RPP_GIO_MODE_PULLDOWN, FALSE);
%else %% error
%<LibBlockReportError(block, "Bad configuration value: %<config>")>
%endif
-
- hal_gpio_pin_conf_set(*din_%<port_par>_%<pin_number_par>_desc, din_%<port_par>_%<pin_number_par>_cfg);
-
%endif
%endfunction
%assign digital_in = LibBlockOutputSignal(0, "", "", 0)
%assign port_par = LibBlockParameterValue(port_type, 0)
%assign pin_number_par = LibBlockParameterValue(pin_number, 0)
- uint32_t din_%<port_par>_%<pin_number_par>_val = hal_gpio_pin_get_value(*din_%<port_par>_%<pin_number_par>_desc);
- %<digital_in> = din_%<port_par>_%<pin_number_par>_val;
+ %if port_par == 1 %% GIOA
+ %assign pin = "PIN_GIOA%<pin_number_par>"
+ %elseif port_par == 2 %% GIOB
+ %assign pin = "PIN_GIOB%<pin_number_par>"
+ %elseif port_par == 3 %% NHET1
+ %assign pin = "PIN_NHET1%<pin_number_par>"
+ %else
+ %<LibBlockReportError(block, "Bad port identifier: %<port_par>")>
+ %endif
+ /% TODO: Handle FAILURE (add error output?) %/
+ %<digital_in> = rpp_gio_get(%<pin>) ? TRUE : FALSE;
%endif
%endfunction
-%% Copyright (C) 2013 Czech Technical University in Prague
+%% Copyright (C) 2013, 2015 Czech Technical University in Prague
%%
%% Authors:
%% - Carlos Jenkins <carlos@jenkins.co.cr>
%assign pin_number_par = LibBlockParameterValue(pin_number, 0)
%% Ensure that every pin is configured only once
- %if EXISTS("::rpp_%<port_par>_%<pin_number_par>_present") == 0
- %assign ::rpp_%<port_par>_%<pin_number_par>_present = 1
+ %if EXISTS("::rpp_gio_%<port_par>_%<pin_number_par>_present") == 0
+ %assign ::rpp_gio_%<port_par>_%<pin_number_par>_present = 1
%else
- %<LibBlockReportError(block, "GPIO pin %<pin_number_par> on port %<port_par> has already been configred.")>
+ %<LibBlockReportError(block, "GIO pin %<pin_number_par> on port %<port_par> has already been configred.")>
%endif
%endfunction
%assign init_val = LibBlockParameterValue(default_output, 0)
%if !SLibCodeGenForSim()
- %openfile buffer
- uint32_t* dout_%<port_par>_%<pin_number_par>_desc = NULL;
- %closefile buffer
- %<LibSetSourceFileSection(LibGetModelDotCFile(), "Declarations", buffer)>
-
-
-
- uint32_t dout_%<port_par>_%<pin_number_par>_cfg = PORT_CONF_FNC_GPIO|PORT_CONF_DIR_OUT;
%if port_par == 1 %% GIOA
- %assign name = "GIOA%<pin_number_par>"
+ %assign pin = "PIN_GIOA%<pin_number_par>"
%elseif port_par == 2 %% GIOB
- %assign name = "GIOB%<pin_number_par>"
+ %assign pin = "PIN_GIOB%<pin_number_par>"
%elseif port_par == 3 %% NHET1
- %assign name = "NHET1%<pin_number_par>"
+ %assign pin = "PIN_NHET1%<pin_number_par>"
%else
%<LibBlockReportError(block, "Bad port identifier: %<port_par>")>
%endif
- dout_%<port_par>_%<pin_number_par>_desc = hal_gpio_pin_get_dsc("%<name>", -1);
-
- %if init_val == 0
- dout_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_INIT_LOW | PORT_CONF_MODE_PD;
- %elseif init_val == 1
- dout_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_INIT_HIGH | PORT_CONF_MODE_PU;
- %else
- %<LibBlockReportError(block, "Bad init output value: %<init_val>")>
- %endif
-
%if config == 1 %% Open drain
- dout_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_MODE_PDIS|PORT_CONF_OD_ON;
+ rpp_gio_setup(%<pin>, RPP_GIO_OUT, RPP_GIO_MODE_PULLDIS, TRUE);
%elseif config == 2 %% push/pull
- dout_%<port_par>_%<pin_number_par>_cfg |= PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF;
+ rpp_gio_setup(%<pin>, RPP_GIO_OUT, RPP_GIO_MODE_PULLDIS, FALSE);
%else %% error
%<LibBlockReportError(block, "Bad configuration value: %<config>")>
%endif
-
- hal_gpio_pin_conf_set(*dout_%<port_par>_%<pin_number_par>_desc, dout_%<port_par>_%<pin_number_par>_cfg);
-
+ %if init_val == 0
+ rpp_gio_set(%<pin>, FALSE);
+ %elseif init_val == 1
+ rpp_gio_set(%<pin>, TRUE);
+ %else
+ %<LibBlockReportError(block, "Bad init output value: %<init_val>")>
+ %endif
%endif
%endfunction
%assign digital_out = LibBlockInputSignal(0, "", "", 0)
%assign port_par = LibBlockParameterValue(port_type, 0)
%assign pin_number_par = LibBlockParameterValue(pin_number, 0)
- hal_gpio_pin_set_value(*dout_%<port_par>_%<pin_number_par>_desc, (uint32_t) %<digital_out>);
+
+ %if port_par == 1 %% GIOA
+ %assign pin = "PIN_GIOA%<pin_number_par>"
+ %elseif port_par == 2 %% GIOB
+ %assign pin = "PIN_GIOB%<pin_number_par>"
+ %elseif port_par == 3 %% NHET1
+ %assign pin = "PIN_NHET1%<pin_number_par>"
+ %else
+ %<LibBlockReportError(block, "Bad port identifier: %<port_par>")>
+ %endif
+
+ rpp_gio_set(%<pin>, %<digital_out>);
%endif
%endfunction
-Subproject commit 431c0b06c0dee19050a859c5df020c44ac605072
+Subproject commit a51911e6286f0aa67562634cab9db68620e7cc89