grblHAL core  20241107
plugins.h
Go to the documentation of this file.
1 /*
2  plugins.h - An embedded CNC Controller with rs274/ngc (g-code) support
3 
4  Some data structures and function declarations for plugins that require driver code
5 
6  These are NOT referenced in the core grbl code
7 
8  Part of grblHAL
9 
10  Copyright (c) 2020-2024 Terje Io
11 
12  grblHAL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  grblHAL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #ifndef _PLUGINS_H_
27 #define _PLUGINS_H_
28 
29 #include <stdint.h>
30 #include <stdbool.h>
31 
32 #include "nvs.h"
33 
34 // Jogging
35 
36 typedef struct {
37  float fast_speed;
38  float slow_speed;
39  float step_speed;
44 
45 // Networking
46 
47 typedef enum {
52 
53 typedef union {
54  uint8_t mask;
55  struct {
56  uint8_t telnet :1,
58  http :1,
59  ftp :1,
60  dns :1,
61  mdns :1,
62  ssdp :1,
63  webdav :1;
64  };
66 
67 typedef char ssid_t[65];
68 typedef uint8_t bssid_t[6];
69 typedef char username_t[33];
70 typedef char password_t[33];
71 typedef char hostname_t[33];
72 typedef char uri_t[65];
73 
74 typedef struct {
75  char ip[16];
76  uint16_t port;
80 
81 typedef struct {
82  char ip[16];
83  char gateway[16];
84  char mask[16];
86  uint16_t telnet_port;
87  uint16_t websocket_port;
88  uint16_t http_port;
89  uint16_t ftp_port;
92 #if MQTT_ENABLE
93  mqtt_settings_t mqtt;
94 #endif
95 #if defined(_WIZCHIP_) || defined(HAS_MAC_SETTING)
96  uint8_t mac[6];
97 #endif
99 
100 typedef enum {
106 
107 typedef struct {
109  bool link_up;
110  uint16_t mbps;
111  char mac[18];
112  char mqtt_client_id[18];
116 
117 typedef struct {
121  char country[4];
122  uint8_t channel;
125 
126 typedef struct {
131 
132 typedef struct {
133  char device_name[33];
134  char service_name[33];
136 
137 typedef struct {
138  uint32_t baud_rate;
139  uint32_t rx_timeout;
141 
142 #define MODBUS_TCP_SETTINGS_INCREMENT 5
143 
144 typedef enum {
147  Setting_ModbusId = 2
149 
150 typedef struct {
151  char ip[16];
152  uint16_t port;
153  uint8_t id;
155 
156 // Quadrature encoder interface
157 
158 typedef enum {
172 
173 typedef enum {
179 
180 typedef union {
181  uint8_t events;
182  struct {
183  uint8_t position_changed :1,
185  click :1,
189  unused :2;
190  };
192 
193 typedef union {
194  uint8_t flags;
195  uint8_t value;
196  struct {
198  };
200 
201 typedef struct {
203  uint32_t cpr;
204  uint32_t cpd;
205  uint32_t dbl_click_window;
208 
209 typedef struct {
211  uint_fast8_t id;
212  uint_fast8_t axis;
213  int32_t position;
214  uint32_t velocity;
217 } encoder_t;
218 
219 // EEPROM/FRAM interface
220 
221 typedef struct {
222  uint8_t address;
224  uint16_t word_addr;
225  volatile uint_fast16_t count;
227  uint8_t checksum;
228  uint8_t *data;
230 
232 
233 // I2C interface
234 
235 typedef void (*keycode_callback_ptr)(const char c);
236 
237 extern bool i2c_probe (uint_fast16_t i2c_address);
238 extern bool i2c_send (uint_fast16_t i2c_address, uint8_t *data, size_t size, bool block);
239 extern void i2c_get_keycode (uint_fast16_t i2c_address, keycode_callback_ptr callback);
240 
241 #endif
nvs_transfer_result_t
Definition: nvs.h:79
bool i2c_send(uint_fast16_t i2c_address, uint8_t *data, size_t size, bool block)
char hostname_t[33]
Definition: plugins.h:71
char password_t[33]
Definition: plugins.h:70
char uri_t[65]
Definition: plugins.h:72
uint8_t bssid_t[6]
Definition: plugins.h:68
ip_mode_t
Definition: plugins.h:47
@ IpMode_Static
Definition: plugins.h:48
@ IpMode_DHCP
Definition: plugins.h:49
@ IpMode_AutoIP
Definition: plugins.h:50
encoder_setting_id_t
Definition: plugins.h:173
@ Setting_EncoderCPR
Count Per Revolution.
Definition: plugins.h:175
@ Setting_EncoderCPD
Count Per Detent.
Definition: plugins.h:176
@ Setting_EncoderMode
Definition: plugins.h:174
@ Setting_EncoderDblClickWindow
Definition: plugins.h:177
grbl_wifi_mode_t
Definition: plugins.h:100
@ WiFiMode_APSTA
Definition: plugins.h:104
@ WiFiMode_STA
Definition: plugins.h:102
@ WiFiMode_AP
Definition: plugins.h:103
@ WiFiMode_NULL
Definition: plugins.h:101
char username_t[33]
Definition: plugins.h:69
bool i2c_probe(uint_fast16_t i2c_address)
encoder_mode_t
Definition: plugins.h:158
@ Encoder_MPG_A
Definition: plugins.h:167
@ Encoder_MPG_Z
Definition: plugins.h:166
@ Encoder_MPG
Definition: plugins.h:163
@ Encoder_MPG_Y
Definition: plugins.h:165
@ Encoder_MPG_C
Definition: plugins.h:169
@ Encoder_MPG_X
Definition: plugins.h:164
@ Encoder_FeedRate
Definition: plugins.h:160
@ Encoder_Universal
Definition: plugins.h:159
@ Encoder_RapidRate
Definition: plugins.h:161
@ Encoder_Spindle_Position
Definition: plugins.h:170
@ Encoder_MPG_B
Definition: plugins.h:168
@ Encoder_Spindle_RPM
Definition: plugins.h:162
void(* keycode_callback_ptr)(const char c)
Definition: plugins.h:235
char ssid_t[65]
Definition: plugins.h:67
void i2c_get_keycode(uint_fast16_t i2c_address, keycode_callback_ptr callback)
nvs_transfer_result_t i2c_nvs_transfer(nvs_transfer_t *i2c, bool read)
modbus_tcp_setting_id_t
Definition: plugins.h:144
@ Setting_ModbusId
Definition: plugins.h:147
@ Setting_ModbusPort
Definition: plugins.h:146
@ Setting_ModbusIpAddress
Definition: plugins.h:145
Definition: plugins.h:132
Definition: plugins.h:201
uint32_t dbl_click_window
ms.
Definition: plugins.h:205
uint32_t cpr
Count per revolution.
Definition: plugins.h:203
uint32_t cpd
Count per detent.
Definition: plugins.h:204
encoder_mode_t mode
Definition: plugins.h:202
encoder_flags_t flags
Definition: plugins.h:206
Definition: plugins.h:209
encoder_mode_t mode
Definition: plugins.h:210
uint_fast8_t id
Definition: plugins.h:211
int32_t position
Definition: plugins.h:213
encoder_event_t event
Definition: plugins.h:215
uint_fast8_t axis
Axis index for MPG encoders, 0xFF for others.
Definition: plugins.h:212
uint32_t velocity
Definition: plugins.h:214
encoder_settings_t * settings
Definition: plugins.h:216
Definition: plugins.h:36
float step_speed
Definition: plugins.h:39
float fast_distance
Definition: plugins.h:40
float step_distance
Definition: plugins.h:42
float slow_speed
Definition: plugins.h:38
float slow_distance
Definition: plugins.h:41
float fast_speed
Definition: plugins.h:37
Definition: plugins.h:137
uint32_t baud_rate
Definition: plugins.h:138
uint32_t rx_timeout
Definition: plugins.h:139
Definition: plugins.h:150
uint8_t id
Definition: plugins.h:153
uint16_t port
Definition: plugins.h:152
Definition: plugins.h:74
uint16_t port
Definition: plugins.h:76
username_t user
Definition: plugins.h:77
password_t password
Definition: plugins.h:78
Definition: plugins.h:107
network_settings_t status
Definition: plugins.h:114
bool link_up
Definition: plugins.h:109
uint16_t mbps
Definition: plugins.h:110
bool is_ethernet
Definition: plugins.h:108
grbl_wifi_mode_t wifi_mode
Definition: plugins.h:113
Definition: plugins.h:81
hostname_t hostname
Definition: plugins.h:85
uint16_t websocket_port
Definition: plugins.h:87
uint16_t telnet_port
Definition: plugins.h:86
uint16_t ftp_port
Definition: plugins.h:89
ip_mode_t ip_mode
Definition: plugins.h:90
network_services_t services
Definition: plugins.h:91
uint16_t http_port
Definition: plugins.h:88
Definition: plugins.h:221
uint8_t word_addr_bytes
Definition: plugins.h:223
uint8_t checksum
Definition: plugins.h:227
bool add_checksum
Definition: plugins.h:226
uint16_t word_addr
Definition: plugins.h:224
uint8_t * data
Definition: plugins.h:228
volatile uint_fast16_t count
Definition: plugins.h:225
uint8_t address
Definition: plugins.h:222
Definition: plugins.h:117
ssid_t ssid
Definition: plugins.h:118
uint8_t channel
Definition: plugins.h:122
bssid_t bssid
Definition: plugins.h:119
password_t password
Definition: plugins.h:120
network_settings_t network
Definition: plugins.h:123
Definition: plugins.h:126
ssid_t ssid
Definition: plugins.h:127
password_t password
Definition: plugins.h:128
network_settings_t network
Definition: plugins.h:129
Definition: plugins.h:180
uint8_t direction_changed
Definition: plugins.h:184
uint8_t index_pulse
Definition: plugins.h:188
uint8_t click
Definition: plugins.h:185
uint8_t long_click
Definition: plugins.h:187
uint8_t position_changed
Definition: plugins.h:183
uint8_t events
Definition: plugins.h:181
uint8_t dbl_click
Definition: plugins.h:186
uint8_t unused
Definition: plugins.h:189
Definition: plugins.h:193
uint8_t value
Definition: plugins.h:195
uint8_t single_count_per_detent
Definition: plugins.h:197
uint8_t flags
Definition: plugins.h:194
Definition: plugins.h:53
uint8_t mdns
Definition: plugins.h:61
uint8_t ftp
Definition: plugins.h:59
uint8_t telnet
Definition: plugins.h:56
uint8_t websocket
Definition: plugins.h:57
uint8_t dns
Definition: plugins.h:60
uint8_t mask
Definition: plugins.h:54
uint8_t http
Definition: plugins.h:58
uint8_t webdav
Definition: plugins.h:63
uint8_t ssdp
Definition: plugins.h:62