* Authors:
* - Carlos Jenkins <carlos@jenkins.co.cr>
*
- * 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.
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*
* File : sfunction_din.c
* Abstract:
/*
%YAML 1.2
---
-Name: xxx
-Category: Xxxx
-Header: xxx.h
-Mnemonic: XXX
+Name: Digital Input
+Category: IO blocks
+Header: rpp/din.h
+Mnemonic: DIN
Inputs:
Outputs:
+ - { name: "Digital Input", type: "bool" }
+ - { name: "ErrFlag", type: "bool" }
Parameters:
+ - { name: "Pin number", type: "uint8", range: "[0-15]" }
+ - { name: "Use variable threshold", type: "bool" }
+ - { name: "Pull", type: "Choice from Pull-down or Pull-up" }
+ - { name: "Active", type: "Choice from Active or Tri-stated" }
+
+# Description and Help is in Markdown mark-up
+Description: |
+
+ Gets the digital value of the specified digital input pin on the RPP board.
-# Description is in Markdown mark-up
-Description: >
+ If pin is high the output is 1, 0 if the pin is low.
- This block ...
+ If an error is detected while getting the pin, the ErrFlag is set high.
-Status:
- Tested:
- Untested:
- Not working:
+Help: |
+
+ This block allows to read the digital inputs on the RPP board. For pins number 0-7 is not
+ relevant and not visible parameter 'Use variable threshold' and only one block for each pin
+ can be in model. And oppositely for other pins (8-15) are not relevant and visible parameters
+ of names 'Pull' and 'Active'. The variable threshold check change the read mode of the pin. For
+ setting it see Digital Input Configure block.
+
+ The ErrFlag should raise if `rpp_din_update()` or `rpp_din_get()` returns error. `rpp_din_update()`
+ is called just by the first DIN block in the model and thus only the first block could raise the
+ flag because of this. In case an errors occurs the return value will always be LOW (0). Because the
+ ErrFlag should never set, once set the following steps will never clear it back.
+
+Status: Stable
RPP API functions used:
+ - rpp_din_setup()
+ - rpp_din_update()
+ - rpp_din_get()
Relevant demos:
+ - digital_passthrough
+ - hbridge_digital_control
...
*/
* Configure parameters: 1
* - Pin number: [1-16]
* - Use variable threshold: [true|false]
+ * - Pull: [Pull-up|Pull-down]
+ * - Active: [Active|Tristate]
*/
- if (!rppSetNumParams(S, 2)) {
+ if (!rppSetNumParams(S, 4)) {
return;
}
if (!rppValidParamBoolean(S, 1)) {
return;
}
+
+ /* Check the parameter 3 */
+ if (!rppValidParamRange(S, 2, 0, 2)) {
+ return;
+ }
+
+ /* Check the parameter 4 */
+ if (!rppValidParamRange(S, 3, 0, 2)) {
+ return;
+ }
}
#endif
static void mdlSetWorkWidths(SimStruct *S)
{
/* Set number of run-time parameters */
- if (!ssSetNumRunTimeParams(S, 2)) {
+ if (!ssSetNumRunTimeParams(S, 4)) {
return;
}
/* Register the run-time parameter 1 */
- ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
+ ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_INT8);
/* Register the run-time parameter 2 */
ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", SS_BOOLEAN);
+
+ /* Register the run-time parameter 3 */
+ ssRegDlgParamAsRunTimeParam(S, 2, 2, "p3", SS_UINT8);
+
+ /* Register the run-time parameter 4 */
+ ssRegDlgParamAsRunTimeParam(S, 3, 3, "p4", SS_UINT8);
}
#endif