44 #define HAL_VERSION 10
336 volatile uint32_t
ms;
564 void (*set_bits_atomic)(
volatile uint_fast16_t *value, uint_fast16_t bits);
571 uint_fast16_t (*clear_bits_atomic)(
volatile uint_fast16_t *value, uint_fast16_t v);
578 uint_fast16_t (*set_value_atomic)(
volatile uint_fast16_t *value, uint_fast16_t bits);
581 void (*irq_enable)(void);
584 void (*irq_disable)(void);
607 bool (*driver_release)(void);
608 uint32_t (*get_elapsed_ticks)(void);
609 uint64_t (*get_micros)(void);
611 void (*reboot)(void);
619 bool (*get_position)(int32_t (*position)[
N_AXIS]);
622 void (*debug_out)(
bool on);
633 bool (*stream_blocking_callback)(void);
#define N_AXIS
Defines number of axes supported - minimum 3, maximum 8. If more than 3 axes are configured a complia...
Definition: config.h:42
core function pointers and data structures definitions.
bool(* irq_callback_ptr)(uint_fast8_t id, bool level)
Definition: crossbar.h:473
pin_function_t
Definition: crossbar.h:27
pin_group_t
Definition: crossbar.h:413
irq_type_t
Definition: crossbar.h:468
parser_state_t gc_state
Definition: gcode.c:108
user_mcode_t
Definition: gcode.h:221
status_code_t(* tool_change_ptr)(parser_state_t *gc_state)
Pointer to function for executing a tool change.
Definition: hal.h:386
user_mcode_t(* user_mcode_check_ptr)(user_mcode_t mcode)
Pointer to function for checking if user defined M-code is supported.
Definition: hal.h:408
void(* delay_callback_ptr)(void)
Signature of delay callback functions.
Definition: hal.h:332
status_code_t(* user_mcode_validate_ptr)(parser_block_t *gc_block, parameter_words_t *parameter_words)
Pointer to function for validating parameters for a user defined M-code.
Definition: hal.h:428
home_signals_t(* home_get_state_ptr)(void)
Pointer to function for getting home switches state.
Definition: hal.h:174
void(* stepper_disable_motors_ptr)(axes_signals_t axes, squaring_mode_t mode)
Pointer to function for enabling/disabling step signals for individual motors.
Definition: hal.h:262
coolant_state_t(* coolant_get_state_ptr)(void)
Pointer to function for getting the coolant state.
Definition: hal.h:130
void(* probe_connected_toggle_ptr)(void)
Pointer to function for toggling probe connected status.
Definition: hal.h:363
void(* motor_iterator_ptr)(motor_iterator_callback_ptr callback)
Pointer to function for iterating over stepper motor vs. axis mappings.
Definition: hal.h:229
void(* motor_iterator_callback_ptr)(motor_map_t motor)
Signature of the callback function to receive motor vs. axis mappings.
Definition: hal.h:222
void(* pin_info_ptr)(xbar_t *pin, void *data)
Pointer to callback function for pin enumerations.
Definition: hal.h:107
void(* driver_reset_ptr)(void)
Pointer to function to be called when a soft reset occurs.
Definition: hal.h:81
void(* encoder_on_event_ptr)(encoder_t *encoder, int32_t position)
Pointer to callback function to receive encoder events.
Definition: hal.h:468
void(* coolant_set_state_ptr)(coolant_state_t state)
Pointer to function for setting the coolant state.
Definition: hal.h:125
void(* limits_enable_ptr)(bool on, axes_signals_t homing_cycle)
Pointer to function for enabling/disabling limit switches functionality.
Definition: hal.h:147
limit_signals_t(* limits_get_state_ptr)(void)
Pointer to function for getting limit switches state.
Definition: hal.h:152
uint32_t(* get_free_mem_ptr)(void)
Pointer to function for getting free memory (as sum of all free blocks in the heap).
Definition: hal.h:84
bool(* driver_setup_ptr)(settings_t *settings)
Pointer to function called to set up driver peripherals after settings are loaded.
Definition: hal.h:78
void(* stepper_cycles_per_tick_ptr)(uint32_t cycles_per_tick)
Pointer to function for setting the step pulse interrupt rate for the next motion segment.
Definition: hal.h:272
float(* homing_get_feedrate_ptr)(axes_signals_t axes, homing_mode_t mode)
Definition: hal.h:175
void(* stepper_output_step_ptr)(axes_signals_t step_outbits, axes_signals_t dir_outbits)
Pointer to function for outputting a single step pulse and direction signal.
Definition: hal.h:298
void(* pallet_shuttle_ptr)(void)
Pointer to function for performing a pallet shuttle.
Definition: hal.h:514
void(* stepper_interrupt_callback_ptr)(void)
Pointer to callback function for outputting the next direction and step pulse signals....
Definition: hal.h:310
bool(* rtc_get_datetime_ptr)(struct tm *datetime)
Pointer to function for setting the current datetime.
Definition: hal.h:497
void(* tool_select_ptr)(tool_data_t *tool, bool next)
Pointer to function for selecting a tool.
Definition: hal.h:381
control_signals_t(* control_signals_get_state_ptr)(void)
Pointer to function for getting control switches state.
Definition: hal.h:190
void(* stepper_go_idle_ptr)(bool clear_signals)
Pointer to function for disabling the main stepper interrupt.
Definition: hal.h:245
bool(* irq_claim_ptr)(irq_type_t irq, uint_fast8_t id, irq_callback_ptr callback)
Pointer to function for claiming higher level interrupt requests (irq).
Definition: hal.h:486
void(* stepper_enable_ptr)(axes_signals_t enable)
Pointer to function for enabling/disabling stepper motors.
Definition: hal.h:253
void(* control_signals_callback_ptr)(control_signals_t signals)
Pointer to callback function for reporting control switches events (interrupts). Set by the core on s...
Definition: hal.h:195
void(* enumerate_pins_ptr)(bool low_level, pin_info_ptr callback, void *data)
Pointer to function for enumerate pin information.
Definition: hal.h:115
void(* limit_interrupt_callback_ptr)(limit_signals_t state)
Pointer to callback function for reporting limit switches events (interrupts). Set by the core on sta...
Definition: hal.h:157
uint8_t(* encoder_get_n_encoders_ptr)(void)
Pointer to function for getting number of encoders supported.
Definition: hal.h:462
void(* stepper_pulse_start_ptr)(stepper_t *stepper)
Pointer to function for setting up steppers for the next step pulse.
Definition: hal.h:287
void(* set_periph_pin_description_ptr)(const pin_function_t function, const pin_group_t group, const char *description)
Pointer to function for setting pin description for a peripheral pin.
Definition: hal.h:96
void(* probe_configure_ptr)(bool is_probe_away, bool probing)
Pointer to function for setting probe operation mode.
Definition: hal.h:356
grbl_hal_t hal
Global HAL struct.
Definition: grbllib.c:88
probe_state_t(* probe_get_state_ptr)(void)
Pointer to function for getting probe status.
Definition: hal.h:350
void(* register_periph_pin_ptr)(const periph_pin_t *pin)
Pointer to function for registering information about a peripheral pin.
Definition: hal.h:89
bool(* rtc_set_datetime_ptr)(struct tm *datetime)
Pointer to function for setting the current datetime.
Definition: hal.h:503
void(* user_mcode_execute_ptr)(sys_state_t state, parser_block_t *gc_block)
Pointer to function for executing a user defined M-code.
Definition: hal.h:439
void(* stepper_wake_up_ptr)(void)
Pointer to function for enabling all stepper motors and the main stepper interrupt.
Definition: hal.h:236
bool driver_init(void)
Driver main entry point. This will be called once by the core after the HAL structure has been nulled...
void(* encoder_reset_ptr)(uint_fast8_t id)
Pointer to function for resetting encoder data.
Definition: hal.h:473
axes_signals_t(* stepper_get_ganged_ptr)(bool auto_squared)
Pointer to function for getting which axes are configured for auto squaring.
Definition: hal.h:304
homing_mode_t
Definition: machine_limits.h:30
settings_t settings
Definition: settings.c:43
void(* settings_changed_ptr)(settings_t *settings, settings_changed_flags_t changed)
Pointer to callback function to be called when settings are loaded or changed.
Definition: settings.h:946
squaring_mode_t
Definition: stepper.h:29
Control switches handlers.
Definition: hal.h:198
control_signals_get_state_ptr get_state
Handler for getting limit switches status.
Definition: hal.h:199
control_signals_callback_ptr interrupt_callback
Callback for informing about control switches events. _Set by the core at startup.
Definition: hal.h:200
Handlers for coolant support.
Definition: hal.h:133
coolant_get_state_ptr get_state
Handler for getting coolant state.
Definition: hal.h:135
coolant_set_state_ptr set_state
Handler for setting coolant state.
Definition: hal.h:134
Delay struct, currently not used by core - may be used by drivers.
Definition: hal.h:335
volatile uint32_t ms
Definition: hal.h:336
delay_callback_ptr callback
Definition: hal.h:337
encoder_reset_ptr reset
Optional handler for resetting data for an encoder.
Definition: hal.h:478
encoder_get_n_encoders_ptr get_n_encoders
Optional handler for getting number of encoders supported.
Definition: hal.h:476
encoder_on_event_ptr on_event
Optional callback handler for receiving encoder events.
Definition: hal.h:477
Definition: plugins.h:209
HAL structure used for the driver interface.
Definition: hal.h:525
home_signals_t home_cap
Home input signals supported by the driver.
Definition: hal.h:638
uint32_t rx_buffer_size
Input stream buffer size in bytes.
Definition: hal.h:535
char * driver_version
Pointer to driver version date string in YYMMDD format.
Definition: hal.h:528
control_signals_ptrs_t control
Handlers for control switches.
Definition: hal.h:591
encoder_ptrs_t encoder
Optional handlers for encoder support.
Definition: hal.h:614
homing_ptrs_t homing
Handlers for homing switches, used by homing cycle.
Definition: hal.h:590
nvs_io_t nvs
Optional handlers for storing/retrieving settings and data to/from non-volatile storage (NVS).
Definition: hal.h:605
io_stream_t stream
Handlers for stream I/O.
Definition: hal.h:595
uint32_t max_step_rate
Currently unused.
Definition: hal.h:536
spindle_data_ptrs_t spindle_data
Handlers for getting/resetting spindle data (RPM, angular position, ...).
Definition: hal.h:593
char * board
Pointer to optional board name string.
Definition: hal.h:531
uint8_t driver_axis_settings
Currently unused.
Definition: hal.h:537
user_mcode_ptrs_t user_mcode
Optional handlers for user defined M-codes.
Definition: hal.h:613
char * info
Pointer to driver info string, typically name of processor/platform.
Definition: hal.h:527
coolant_ptrs_t coolant
Handlers for coolant.
Definition: hal.h:592
enumerate_pins_ptr enumerate_pins
Optional handler for enumerating pins used by the driver.
Definition: hal.h:606
get_free_mem_ptr get_free_mem
Optional pointer to function for getting free memory (as sum of all free blocks in the heap).
Definition: hal.h:540
periph_port_t periph_port
Optional handlers for peripheral pin registration.
Definition: hal.h:603
limit_signals_t limits_cap
Limit input signals supported by the driver.
Definition: hal.h:637
rtc_ptrs_t rtc
Optional handlers for real time clock (RTC).
Definition: hal.h:599
char * board_url
Pointer to optional URL for the board.
Definition: hal.h:532
limits_ptrs_t limits
Handlers for limit switches.
Definition: hal.h:589
rgb_ptr_t rgb0
Optional handler for RGB output to LEDs (neopixels) or lamps.
Definition: hal.h:601
uint32_t f_step_timer
Frequency of main stepper timer in Hz.
Definition: hal.h:533
settings_changed_ptr settings_changed
Callback handler to be called on settings loaded or settings changed events.
Definition: hal.h:596
stepper_ptrs_t stepper
Handlers for stepper motors.
Definition: hal.h:594
uint32_t f_mcu
Frequency of MCU in MHz.
Definition: hal.h:534
driver_setup_ptr driver_setup
Driver setup handler. Called once by the core after settings has been loaded. The driver should enabl...
Definition: hal.h:547
irq_claim_ptr irq_claim
Optional handler for claiming higher level interrupts. Set to a dummy handler on startup.
Definition: hal.h:587
tool_ptrs_t tool
Optional handlers for tool changes.
Definition: hal.h:598
char * driver_url
Pointer to optional URL for the driver.
Definition: hal.h:530
driver_cap_t driver_cap
Basic driver capabilities flags.
Definition: hal.h:635
driver_reset_ptr driver_reset
Optional handler, called on soft resets. Set to a dummy handler by the core at startup.
Definition: hal.h:604
io_port_t port
Optional handlers for axuillary I/O (adds support for M62-M66).
Definition: hal.h:600
uint32_t version
HAL version, set by the core. Driver should check against this in the driver_init() function.
Definition: hal.h:526
char * driver_options
Pointer to optional comma separated string with driver options.
Definition: hal.h:529
rgb_ptr_t rgb1
Optional handler for RGB output to LEDs (neopixels) or lamps.
Definition: hal.h:602
control_signals_t signals_cap
Control input signals supported by the driver.
Definition: hal.h:636
pallet_shuttle_ptr pallet_shuttle
Optional handler for performing a pallet shuttle on program end (M60).
Definition: hal.h:610
probe_ptrs_t probe
Optional handlers for probe input(s).
Definition: hal.h:597
Home switches struct, consists of two packed axes_signals_t structs.
Definition: nuts_bolts.h:164
Limit switches handler for homing cycle.
Definition: hal.h:178
home_get_state_ptr get_state
Handler for getting homing switches status. Usually read from hal.limits.get_state.
Definition: hal.h:179
homing_get_feedrate_ptr get_feedrate
Definition: hal.h:180
Properties and handlers for auxiliary digital and analog I/O.
Definition: ioports.h:111
Properties and handlers for stream I/O.
Definition: stream.h:229
Limit switches struct, consists of four packed axes_signals_t structs in 32 bits.
Definition: nuts_bolts.h:156
Limit switches handlers.
Definition: hal.h:160
limits_enable_ptr enable
Handler for enabling limits handling mode.
Definition: hal.h:161
limits_get_state_ptr get_state
Handler for getting limit switches status.
Definition: hal.h:162
limit_interrupt_callback_ptr interrupt_callback
Callback for informing about limit switches events. Set by the core at startup.
Definition: hal.h:163
Handler functions and variables for NVS storage of settings and data.
Definition: nvs.h:128
Parser block structure.
Definition: gcode.h:593
Parser state.
Definition: gcode.h:550
Definition: crossbar.h:637
set_periph_pin_description_ptr set_pin_description
Optional handler for setting a description of a peripheral pin.
Definition: hal.h:100
register_periph_pin_ptr register_pin
Opional handler for registering information about a peripheral pin (with the driver).
Definition: hal.h:99
Handlers for probe input(s).
Definition: hal.h:366
probe_configure_ptr configure
Optional handler for setting probe operation mode.
Definition: hal.h:367
probe_connected_toggle_ptr connected_toggle
Optional handler for toggling probe connected status.
Definition: hal.h:369
probe_get_state_ptr get_state
Optional handler for getting probe status. Called from interrupt context.
Definition: hal.h:368
rtc_set_datetime_ptr set_datetime
Optional handler setting the current datetime.
Definition: hal.h:507
rtc_get_datetime_ptr get_datetime
Optional handler getting the current datetime.
Definition: hal.h:506
Definition: settings.h:750
Definition: spindle_control.h:314
Stepper motor handlers.
Definition: hal.h:313
stepper_get_ganged_ptr get_ganged
Optional handler getting which axes are configured for ganging or auto squaring.
Definition: hal.h:321
stepper_enable_ptr enable
Handler for enabling/disabling stepper motor power for individual motors. Called from interrupt conte...
Definition: hal.h:316
stepper_cycles_per_tick_ptr cycles_per_tick
Handler for setting the step pulse rate for the next motion segment. Called from interrupt context.
Definition: hal.h:318
stepper_output_step_ptr output_step
Optional handler for outputting a single step pulse. Experimental. Called from interrupt context.
Definition: hal.h:322
stepper_interrupt_callback_ptr interrupt_callback
Callback for informing about the next step pulse to output. Set by the core at startup.
Definition: hal.h:320
stepper_pulse_start_ptr pulse_start
Handler for starting outputting direction signals and a step pulse. Called from interrupt context.
Definition: hal.h:319
stepper_wake_up_ptr wake_up
Handler for enabling stepper motor power and main stepper interrupt.
Definition: hal.h:314
motor_iterator_ptr motor_iterator
Optional handler iteration over motor vs. axis mappings. Required for the motors plugin (Trinamic dri...
Definition: hal.h:323
stepper_go_idle_ptr go_idle
Handler for disabling main stepper interrupt and optionally reset stepper signals....
Definition: hal.h:315
stepper_disable_motors_ptr disable_motors
Optional handler for enabling/disabling stepper motor step signals for individual motors.
Definition: hal.h:317
Stepper ISR data struct. Contains the running data for the main stepper ISR.
Definition: stepper.h:75
Optional handlers for user defined M-codes.
Definition: hal.h:448
user_mcode_execute_ptr execute
Handler for executing a user defined M-code.
Definition: hal.h:451
user_mcode_validate_ptr validate
Handler for validating parameters for a user defined M-code.
Definition: hal.h:450
user_mcode_check_ptr check
Handler for checking if a user defined M-code is supported.
Definition: hal.h:449
Definition: crossbar.h:622
uint_fast16_t sys_state_t
See sys_state.
Definition: system.h:108
Definition: nuts_bolts.h:130
Definition: coolant_control.h:26
Bitmap flags for driver capabilities, to be set by driver in driver_init(), flags may be cleared afte...
Definition: hal.h:47
uint32_t odometers
Definition: hal.h:69
uint32_t limits_pull_up
Pullup resistors for limit inputs are are supported.
Definition: hal.h:53
uint32_t laser_ppi_mode
Laser PPI (Pulses Per Inch) mode is supported.
Definition: hal.h:66
uint32_t unassigned
Definition: hal.h:72
uint32_t probe_latch
Definition: hal.h:71
uint32_t atc
Automatic tool changer (ATC) is supported.
Definition: hal.h:67
uint32_t bluetooth
Definition: hal.h:61
uint32_t pwm_spindle
Definition: hal.h:70
uint32_t spindle_encoder
Spindle encoder is supported.
Definition: hal.h:57
uint32_t ethernet
Definition: hal.h:62
uint32_t spindle_sync
Spindle synced motion is supported.
Definition: hal.h:58
uint32_t mpg_mode
Definition: hal.h:65
uint32_t software_debounce
Software debounce of input switches signals is supported.
Definition: hal.h:51
uint32_t sd_card
Definition: hal.h:59
uint32_t step_pulse_delay
Stepper step pulse delay is supported.
Definition: hal.h:52
uint32_t wifi
Definition: hal.h:63
uint32_t amass_level
Definition: hal.h:56
uint32_t no_gcode_message_handling
Definition: hal.h:68
uint32_t spindle_pid
Definition: hal.h:64
uint32_t control_pull_up
Pullup resistors for control inputs are supported.
Definition: hal.h:54
uint32_t value
All bitmap flags.
Definition: hal.h:48
uint32_t littlefs
Definition: hal.h:60
uint32_t probe_pull_up
Pullup resistors for probe inputs are supported.
Definition: hal.h:55
uint32_t mist_control
Mist control (M7) is supported.
Definition: hal.h:50
Motor vs. axis mapping NOTE: id and axis values are equal for primary motors, unequal for secondary (...
Definition: hal.h:211
uint32_t axis
Definition: hal.h:215
uint32_t id
Definition: hal.h:214
uint32_t value
Definition: hal.h:212
Parameter words found by parser - do not change order!
Definition: gcode.h:421