Skip to content

Hardware Abstraction Layer (HAL) developer reference

Terje Io edited this page Jun 17, 2021 · 5 revisions

grblHAL, HAL driver interface

There is only one fixed entry point into the driver, driver_init(), that is used for enabling the serial stream, nonvolatile storage and initializing the required function pointers. Please note that the grbl core can, and will, only access the driver via this function call and the published HAL entries. The driver, however, is free to call the public functions and reference data structures in the grbl core as it sees fit.

NOTE: this is an incomplete in details, preliminary and pretty terse documentation.

Startup sequence:

The main() function should call , or start grbl as a task, grbl_enter() as the last call. This will never return.

This in turn:

  • clears the HAL structure
  • sets the HAL version number
  • calls driver_init() which then:
    • verifies that the HAL version number matches.
    • initializes serial stream.
    • initializes nonvolatile storage if available.
    • sets up the HAL function pointers (into the driver).
    • sets up the driver capabilities.
    • returns true if everything went well
  • sets up the HAL callback function pointers (into grbl).
  • optionally initializes the EEPROM emulation (requires heap memory, will fail if not enough available).
  • loads the settings.
  • calls hal.driver_setup so that the driver can configure the hardware.
  • sets up internal variables and starts the main protocol loop.

A switch to generated documentation is underway, its temporary home is here.

For convenience, this is a direct link to the HAL structure.

Please note that it will take some time to complete it.


2021-06-17