]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blobdiff - rpp/blocks/sfunction_din.c
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_din.c
index 70e50cbac466ee119e2f52a915afb14a537563ef..9889ca319fddba281cd6eb403c855442e4596e62 100644 (file)
@@ -3,10 +3,26 @@
  * 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:
@@ -35,32 +51,34 @@ Outputs:
   - { name: "ErrFlag",       type: "bool" }
 
 Parameters:
-  - { name: "Pin number [0-15]",      type: "uint8"                            }
+  - { 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 is in Markdown mark-up
+# Description and Help is in Markdown mark-up
 Description: |
 
+  Gets the digital value of the specified digital input pin on the RPP board.
+
+  If pin is high the output is 1, 0 if the pin is low.
+
+  If an error is detected while getting the pin, the ErrFlag is set high.
+
+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 
+  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:
-  Tested:
-    - Changing the pin.
-    - Compilation and general use.
-    - Using variable threshold.
-  Untested:
-    - Faulty situation for the ErrFlag to set.
-  Not working:
+Status: Stable
 
 RPP API functions used:
     - rpp_din_setup()
@@ -126,12 +144,12 @@ static void mdlCheckParameters(SimStruct *S)
     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;
@@ -154,10 +172,10 @@ static void mdlSetWorkWidths(SimStruct *S)
 
     /* 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);
 }