-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreset.comp
69 lines (68 loc) · 2.87 KB
/
reset.comp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/******************************************************************************
*
* Copyright (C) 2015 Alexander Rössler
*
*
* This module resets a IO signal
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* THE AUTHORS OF THIS PROGRAM ACCEPT ABSOLUTELY NO LIABILITY FOR
* ANY HARM OR LOSS RESULTING FROM ITS USE. IT IS _EXTREMELY_ UNWISE
* TO RELY ON SOFTWARE ALONE FOR SAFETY. Any machinery capable of
* harming persons must have provisions for completely removing power
* from all motors, etc, before persons enter any danger area. All
* machinery must be designed to comply with local and national safety
* codes, and the authors of this software can not, and do not, take
* any responsibility for such compliance.
*
* This code was written as part of the LinuxCNC project. For more
* information, go to www.linuxcnc.org.
*
******************************************************************************/
component reset "Resets a IO signal";
pin in bit trigger "Trigger input";
pin io u32 out_u32 = 0 "Unsigned 32 bit integer output value";
pin in u32 reset_u32 = 0 "Unsigned 32 bit integer reset value";
pin io s32 out_s32 = 0 "Signed 32 bit integer output value";
pin in s32 reset_s32 = 0 "Signed 32 bit integer reset value";
pin io float out_float = 0.0 "Float output value";
pin in float reset_float = 0.0 "Float reset value";
pin io bit out_bit = 0 "Bit integer output value";
pin in bit reset_bit = 0 "Bit reset value";
pin in bit retriggerable = 1 "Allow additional edges to reset";
pin in bit rising = 1 "Trigger on rising edge";
pin in bit falling = 0 "Trigger on falling edge";
function _ fp "Update the output value";
description """
Component to reset IO signals.
""";
license "GPL";
variable hal_bit_t last_trigger = 0;
;;
FUNCTION(_) {
if (((rising && (trigger == 1)) || (falling && (trigger == 0)))
&& (trigger != last_trigger))
{
out_u32 = reset_u32;
out_s32 = reset_s32;
out_float = reset_float;
out_bit = reset_bit;
}
last_trigger = trigger;
}