# grblhal/imxrt1062 architecture

> Architecture diagram of the GitHub repository grblhal/imxrt1062, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grblhal/imxrt1062
- Repository: https://github.com/grblhal/imxrt1062

## Overview

This is an embedded grblHAL hardware driver for Teensy 4.x/i.MXRT1062 CNC controllers. The principal workflow is host commands entering through a serial or network stream, grblHAL interpreting them, and the driver translating motion and spindle control into board-specific signals for the machine. Board maps select pin assignments and capabilities; optional networking, SD-card, and peripheral/plugin features extend the controller. The startup call and selected driver paths are sampled; several feature directories are represented from the README and tree, so their internal wiring is not shown.

Main entry points: [`grblHAL_Teensy4/src/driver.c`](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/driver.c) (Hardware driver), [`grblHAL_Teensy4/src/grbl`](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/grbl) (grblHAL core), [`grblHAL_Teensy4/src/uart.c`](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/uart.c) (UART streams), [`grblHAL_Teensy4/src/usb_serial_pjrc.c`](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/usb_serial_pjrc.c) (USB serial)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_startup["Startup<br/>[main.c]"]
  node_core["grblHAL core"]
end

subgraph group_motion["Motion hardware"]
  node_driver["Hardware driver<br/>[driver.c]"]
  node_boardmap["Board maps"]
  node_spindle["Spindle control<br/>[driver.c]"]
end

subgraph group_connectivity["Connectivity"]
  node_uart["UART streams<br/>[uart.c]"]
  node_usb["USB serial<br/>[usb_serial_pjrc.c]"]
  node_ethernet["Ethernet glue<br/>[enet.c]"]
  node_network["Network services"]
end

subgraph group_features["Storage and peripherals"]
  node_sd["SD-card plugin"]
  node_eeprom["EEPROM support"]
  node_keypad["I2C keypad"]
  node_i2c["I2C driver<br/>[i2c.c]"]
  node_encoders["Encoder plugin"]
  node_io["Digital and analog I/O<br/>[ioports.c]"]
  node_littlefs["Littlefs<br/>[lfs.c]"]
  node_filesystem_hal["Filesystem HAL<br/>[littlefs_hal.c]"]
end

node_host(("CNC host"))
node_machine(("CNC machine"))
node_network_peer(("Network peer"))
node_sdcard[("SD card")]

node_startup -->|"enters"| node_core
node_host -->|"sends commands"| node_uart
node_host -->|"sends commands"| node_usb
node_uart -->|"streams input"| node_core
node_usb -->|"streams input"| node_core
node_network_peer -.->|"sends commands"| node_network
node_network -.->|"uses glue"| node_ethernet
node_ethernet -.->|"provides network interface"| node_core
node_core -->|"uses hardware HAL"| node_driver
node_boardmap -->|"defines pin mapping"| node_driver
node_driver -->|"drives motion signals"| node_machine
node_spindle -->|"controls spindle"| node_machine
node_core -.->|"optional file access"| node_sd
node_sd -.->|"reads and writes"| node_sdcard
node_driver -.->|"optional settings storage"| node_eeprom
node_driver -.->|"uses bus"| node_i2c
node_keypad -.->|"uses bus"| node_i2c
node_driver -.->|"optional feedback"| node_encoders
node_driver -->|"registers I/O"| node_io
node_filesystem_hal -.->|"adapts filesystem"| node_littlefs

click node_startup "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/main.c"
click node_core "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/grbl"
click node_driver "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/driver.c"
click node_boardmap "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/boards"
click node_spindle "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/driver.c"
click node_uart "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/uart.c"
click node_usb "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/usb_serial_pjrc.c"
click node_ethernet "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/enet.c"
click node_network "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/networking"
click node_sd "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/sdcard"
click node_eeprom "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/eeprom"
click node_keypad "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/keypad"
click node_i2c "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/i2c.c"
click node_encoders "https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/encoder"
click node_io "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/ioports.c"
click node_littlefs "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/littlefs/lfs.c"
click node_filesystem_hal "https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/littlefs_hal.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_core toneBlue
class node_driver,node_boardmap,node_spindle,node_sdcard toneAmber
class node_uart,node_usb,node_ethernet,node_network toneMint
class node_sd,node_eeprom,node_keypad,node_i2c,node_encoders,node_io,node_littlefs,node_filesystem_hal toneRose
class node_host,node_machine,node_network_peer toneIndigo
```

## Components

### Firmware runtime

- [Startup](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/main.c): `grblHAL_Teensy4/src/main.c`
- [grblHAL core](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/grbl): `grblHAL_Teensy4/src/grbl`

### Motion hardware

- [Hardware driver](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/driver.c): `grblHAL_Teensy4/src/driver.c`
- [Board maps](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/boards): `grblHAL_Teensy4/src/boards`
- [Spindle control](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/driver.c): `grblHAL_Teensy4/src/driver.c`

### Connectivity

- [UART streams](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/uart.c): `grblHAL_Teensy4/src/uart.c`
- [USB serial](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/usb_serial_pjrc.c): `grblHAL_Teensy4/src/usb_serial_pjrc.c`
- [Ethernet glue](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/enet.c): `grblHAL_Teensy4/src/enet.c`
- [Network services](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/networking): `grblHAL_Teensy4/src/networking`

### Storage and peripherals

- [SD-card plugin](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/sdcard): `grblHAL_Teensy4/src/sdcard`
- [EEPROM support](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/eeprom): `grblHAL_Teensy4/src/eeprom`
- [I2C keypad](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/keypad): `grblHAL_Teensy4/src/keypad`
- [I2C driver](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/i2c.c): `grblHAL_Teensy4/src/i2c.c`
- [Encoder plugin](https://github.com/grblhal/imxrt1062/tree/master/grblHAL_Teensy4/src/encoder): `grblHAL_Teensy4/src/encoder`
- [Digital and analog I/O](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/ioports.c): `grblHAL_Teensy4/src/ioports.c`
- [Littlefs](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/littlefs/lfs.c): `grblHAL_Teensy4/src/littlefs/lfs.c`
- [Filesystem HAL](https://github.com/grblhal/imxrt1062/blob/master/grblHAL_Teensy4/src/littlefs_hal.c): `grblHAL_Teensy4/src/littlefs_hal.c`

### Other components

- **CNC host**
- **CNC machine**
- **Network peer**
- **SD card**

## Connections

- Startup → grblHAL core: enters
- CNC host → UART streams: sends commands
- CNC host → USB serial: sends commands
- UART streams → grblHAL core: streams input
- USB serial → grblHAL core: streams input
- Network peer → Network services: sends commands
- Network services → Ethernet glue: uses glue
- Ethernet glue → grblHAL core: provides network interface
- grblHAL core → Hardware driver: uses hardware HAL
- Board maps → Hardware driver: defines pin mapping
- Hardware driver → CNC machine: drives motion signals
- Spindle control → CNC machine: controls spindle
- grblHAL core → SD-card plugin: optional file access
- SD-card plugin → SD card: reads and writes
- Hardware driver → EEPROM support: optional settings storage
- Hardware driver → I2C driver: uses bus
- I2C keypad → I2C driver: uses bus
- Hardware driver → Encoder plugin: optional feedback
- Hardware driver → Digital and analog I/O: registers I/O
- Filesystem HAL → Littlefs: adapts filesystem
