LAT Hologramm-Software 2.0
Loading...
Searching...
No Matches
probe.c
Go to the documentation of this file.
1/*
2 probe.c - code pertaining to probing methods
3 Part of Grbl
4
5 Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
6
7 Grbl is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 Grbl is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#include "grbl.h"
22
23
24// Inverts the probe pin state depending on user settings and probing cycle mode.
26
27
28// Probe pin initialization routine.
30{
31 PROBE_DDR &= ~(PROBE_MASK); // Configure as input pins
32 #ifdef DISABLE_PROBE_PIN_PULL_UP
33 PROBE_PORT &= ~(PROBE_MASK); // Normal low operation. Requires external pull-down.
34 #else
35 PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation.
36 #endif
37 probe_configure_invert_mask(false); // Initialize invert mask.
38}
39
40
41// Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to
42// appropriately set the pin logic according to setting for normal-high/normal-low operation
43// and the probing cycle modes for toward-workpiece/away-from-workpiece.
44void probe_configure_invert_mask(uint8_t is_probe_away)
45{
46 probe_invert_mask = 0; // Initialize as zero.
48 if (is_probe_away) { probe_invert_mask ^= PROBE_MASK; }
49}
50
51
52// Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
53uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); }
54
55
56// Monitors probe pin state and records the system position when detected. Called by the
57// stepper ISR per ISR tick.
58// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
60{
61 if (probe_get_state()) {
65 }
66}
int32_t sys_position[N_AXIS]
Definition: main.c:27
int32_t sys_probe_position[N_AXIS]
Definition: main.c:28
volatile uint8_t sys_probe_state
Definition: main.c:29
volatile uint8_t sys_rt_exec_state
Definition: main.c:30
#define bit_isfalse(x, mask)
Definition: nuts_bolts.h:65
#define bit_true(x, mask)
Definition: nuts_bolts.h:62
void probe_configure_invert_mask(uint8_t is_probe_away)
Definition: probe.c:44
uint8_t probe_get_state()
Definition: probe.c:53
void probe_init()
Definition: probe.c:29
uint8_t probe_invert_mask
Definition: probe.c:25
void probe_state_monitor()
Definition: probe.c:59
#define PROBE_OFF
Definition: probe.h:25
settings_t settings
Definition: settings.c:24
#define BITFLAG_INVERT_PROBE_PIN
Definition: settings.h:49
uint8_t flags
Definition: settings.h:106
#define EXEC_MOTION_CANCEL
Definition: system.h:37