grblHAL core  20260206
alarms.h
Go to the documentation of this file.
1 /*
2  alarms.h -
3 
4  Part of grblHAL
5 
6  Copyright (c) 2017-2025 Terje Io
7  Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
8  Copyright (c) 2009-2011 Simen Svale Skogsrud
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _ALARMS_H_
25 #define _ALARMS_H_
26 
27 // Alarm codes. Valid values (1-255). Zero is reserved.
28 // Code 0 - 9 is equal to legacy Grbl codes, 15 equals to legacy Grbl code 10
29 typedef enum {
30  Alarm_None = 0,
40  Alarm_EStop = 10,
53 } __attribute__ ((__packed__)) alarm_code_t;
54 
55 typedef struct {
57  const char *description;
59 
60 typedef struct alarm_details {
61  const uint16_t n_alarms;
65 
66 typedef alarm_details_t *(*on_get_alarms_ptr)(void);
67 
69 const char *alarms_get_description (alarm_code_t id);
70 void alarms_register (alarm_details_t *details);
71 
72 static inline bool alarm_is_critical (alarm_code_t alarm)
73 {
74  return alarm == Alarm_HardLimit ||
75  alarm == Alarm_SoftLimit ||
76  alarm == Alarm_EStop ||
77  alarm == Alarm_MotorFault ||
78  alarm == Alarm_ExpanderException;
79 }
80 
81 #endif
struct alarm_details alarm_details_t
const char * alarms_get_description(alarm_code_t id)
Definition: alarms.c:71
void alarms_register(alarm_details_t *details)
Definition: alarms.c:60
alarm_code_t
Definition: alarms.h:29
@ Alarm_LimitsEngaged
12
Definition: alarms.h:42
@ Alarm_HardLimit
1
Definition: alarms.h:31
@ Alarm_ProbeFailContact
5
Definition: alarms.h:35
@ Alarm_SoftLimit
2
Definition: alarms.h:32
@ Alarm_SelftestFailed
16
Definition: alarms.h:46
@ Alarm_HomingFailDoor
7
Definition: alarms.h:37
@ Alarm_ProbeProtect
13
Definition: alarms.h:43
@ Alarm_AlarmMax
Definition: alarms.h:52
@ Alarm_None
0
Definition: alarms.h:30
@ Alarm_AbortCycle
3
Definition: alarms.h:33
@ Alarm_Spindle
14
Definition: alarms.h:44
@ Alarm_FailPulloff
8
Definition: alarms.h:38
@ Alarm_EStop
10
Definition: alarms.h:40
@ Alarm_HomingFailApproach
9
Definition: alarms.h:39
@ Alarm_ProbeFailInitial
4
Definition: alarms.h:34
@ Alarm_HomingRequired
11
Definition: alarms.h:41
@ Alarm_HomingFailAutoSquaringApproach
15
Definition: alarms.h:45
@ Alarm_HomingFail
18
Definition: alarms.h:48
@ Alarm_HomingFailReset
6
Definition: alarms.h:36
@ Alarm_NVS_Failed
21
Definition: alarms.h:51
@ Alarm_ExpanderException
20
Definition: alarms.h:50
@ Alarm_MotorFault
17
Definition: alarms.h:47
@ Alarm_ModbusException
19
Definition: alarms.h:49
alarm_details_t * alarms_get_details(void)
Definition: alarms.c:66
Definition: alarms.h:55
const char * description
Definition: alarms.h:57
alarm_code_t id
Definition: alarms.h:56
Definition: alarms.h:60
const uint16_t n_alarms
Definition: alarms.h:61
const alarm_detail_t * alarms
Definition: alarms.h:62
struct alarm_details * next
Definition: alarms.h:63