How kurokesu/sce2-grbl works
Main Components
• MCU / Hardware Platform: At the center, show the STM32F10x microcontroller, since all firmware components run on this hardware.
• Core Firmware / GRBL Engine: Illustrate this as a central block that encompasses:
• G-code parsing and protocol handling (files such as src/gcode.c, src/protocol.c, inc/gcode.h, inc/protocol.h)
• Motion planning and control (src/motion_control.c, src/planner.c, inc/motion_control.h, inc/planner.h)
• Stepper motor control (src/stepper.c, inc/stepper.h)
• Auxiliary functionalities like coolant control, limits, probe, jog (the corresponding modules in inc and src)
• USB Communication Stack:
• USB interface unit by showing two layers:
▪ The USB FS Library module (from stm_usb_fs_lib and usb directories), including configurations and ISR handling.
▪ The mapping between the physical USB hardware and the firmware’s serial/USB routines.
• Hardware Abstraction / Middleware:
• CMSIS Libraries and STM32F10x Standard Peripheral Driver: Group these libraries (found under Libraries/CMSIS and Libraries/STM32F10x_StdPeriph_Driver) as the peripheral abstraction layer that bridges the raw hardware with the firmware.
• Configuration & Build Infrastructure:
• Configuration files (inc/config.h, other header files, and linker scripts like stm32_flash.ld) and startup routines (e.g., src/startup_stm32f10x_md.s).
• Debug/Build Artifacts:
• That there is a Debug folder containing the compiled binaries and associated build files. (This is less critical for data flow but might be useful in a complete architecture document.)
Relationships and Interactions
• Data Flow from USB to Controller:
• Internal Processing:
• From the GRBL Engine, include flows to lower-level drivers (e.g., motion control and stepper motor control) to represent the sequencing of commands and pulse generation.
• Hardware Abstraction:
• Dependencies flowing from the GRBL Engine to the peripheral libraries (CMSIS, StdPeriph_Driver) which handle the actual hardware control such as GPIO, timers, and interrupts.
• Configuration & System Initialization:
• A separate block should illustrate the role of initialization/startup routines and configuration settings that prepare the MCU and the firmware.
Architectural Patterns and Design Principles
• Embedded Application Pattern:
• That the entire design is tightly coupled with the microcontroller’s hardware and the firmware is designed for real-time control.
• Layered Architecture:
• Distinct layers where the top represents application-specific logic (g-code, motion, stepper control) and the bottom layer represents hardware abstraction (CMSIS, peripheral drivers).
• Modular Design:
• Each major functionality (e.g., coolant control, spindle control, USB communication) is implemented in its own source and header files – indicate these as separate modules within the GRBL engine block.
Relevant Technologies & Libraries
• Microcontroller: STM32F10x
• USB Stack: Custom USB library from stm_usb_fs_lib and various USB modules in the usb directory
• Peripheral Libraries: CMSIS and STM32F10x Standard Peripheral Driver Libraries
• Build System: Managed via makefiles (as seen in the Debug folder) and project files (.cproject, .project)