Type state encodes a peripheral’s configuration in its Rust type. A HAL can then expose only the operations valid for that state, making some hardware misuse a compile-time error. section 1.4.3
In GPIO and clock setup, type state makes configuration transitions explicit:
- Converting a pin consumes it and creates a new type for its configured mode, so input-only and output-only operations are restricted accordingly. section 5.3.4
- Constrain and freeze move clock peripherals into managed states; the resulting Clocks value can configure timing-dependent peripherals and SysTick delays. section 5.3.4
UART receive pin
A pin configured for UART reception can implement receiving traits such as Read. Attempting to use it for an SPI-specific operation fails to compile; changing its function requires explicit reconfiguration. section 1.4.3
Figure 1.4 Type state pattern applied to MCU pins
Illustrates type state applied to microcontroller pins. section 1.4.3


