grblHAL core  20261015
probe.h
Go to the documentation of this file.
1 /*
2  probe.h - An embedded CNC Controller with rs274/ngc (g-code) support
3 
4  Part of grblHAL
5 
6  Copyright (c) 2020-2025 Terje Io
7 
8  grblHAL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  grblHAL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef _PROBE_H_
23 #define _PROBE_H_
24 
25 #include "crossbar.h"
26 
27 #define N_PROBE_MAX 3
28 
29 // Values that define the probing state machine.
30 
31 typedef bool (*get_probe_input_ptr)(void *input);
32 
33 typedef enum {
37 
38 typedef enum {
41  Probe_2
43 
44 typedef union {
45  uint8_t flags;
46  struct {
47  uint8_t probe_triggered :1,
50  aquired :1;
51  };
53 
54 typedef union {
55  uint16_t value;
56  struct {
57  uint16_t triggered :1,
58  connected :1,
59  inverted :1,
63  irq_mode :5,
64  unused :3,
65  probe_id :2;
66  };
68 
69 typedef union {
70  uint8_t value;
71  struct {
72  uint8_t available :1,
73  connected :1,
74  latchable :1,
75  watchable :1,
76  guarded :1,
78  };
80 
81 void probe_connected_event (void *data);
82 bool probe_add (probe_id_t probe_id, uint8_t port, pin_irq_mode_t irq_mode, void *input, get_probe_input_ptr get_input);
84 
85 #endif // _PROBE_H_
pin_irq_mode_t
Pin interrupt modes, may be or'ed when reporting pin capability.
Definition: crossbar.h:697
probe_id_t
Definition: probe.h:38
@ Probe_Toolsetter
1
Definition: probe.h:40
@ Probe_2
2
Definition: probe.h:41
@ Probe_Default
0
Definition: probe.h:39
bool probe_add(probe_id_t probe_id, uint8_t port, pin_irq_mode_t irq_mode, void *input, get_probe_input_ptr get_input)
Definition: probe.c:161
void probe_connected_event(void *data)
Definition: probe.c:233
bool(* get_probe_input_ptr)(void *input)
Definition: probe.h:31
probe_states_t probes_get_state(void)
Definition: probe.c:215
probing_state_t
Definition: probe.h:33
@ Probing_Off
0
Definition: probe.h:34
@ Probing_Active
1
Definition: probe.h:35
Definition: probe.h:69
uint8_t watchable
Set to true when probe input supports change interrupt.
Definition: probe.h:75
uint8_t unassigned
Definition: probe.h:77
uint8_t latchable
Set to true when probe input supports change rising/falling.
Definition: probe.h:74
uint8_t value
Definition: probe.h:70
uint8_t connected
Set to true when probe is connected. Always set to true if the driver does not have a probe connected...
Definition: probe.h:73
uint8_t guarded
Set to true when probe protection is enabled.
Definition: probe.h:76
uint8_t available
Set to true when probe input is available.
Definition: probe.h:72
Definition: probe.h:54
uint16_t irq_mode
pin_irq_mode_t - for driver use
Definition: probe.h:63
uint16_t connected
Set to true when probe is connected. Always set to true if the driver does not have a probe connected...
Definition: probe.h:58
uint16_t is_probing
For driver use.
Definition: probe.h:60
uint16_t triggered
Set to true when probe or toolsetter is triggered.
Definition: probe.h:57
uint16_t unused
Definition: probe.h:64
uint16_t irq_enabled
For driver use.
Definition: probe.h:62
uint16_t value
Definition: probe.h:55
uint16_t was_probing
For driver use.
Definition: probe.h:61
uint16_t inverted
For driver use.
Definition: probe.h:59
uint16_t probe_id
Id of active probe (for now).
Definition: probe.h:65
Definition: probe.h:44
uint8_t probe_triggered
Definition: probe.h:47
uint8_t aquired
Definition: probe.h:50
uint8_t flags
Definition: probe.h:45
uint8_t probe2_triggered
Definition: probe.h:49
uint8_t toolsetter_triggered
Definition: probe.h:48