Expand description
§Clock Module
For the MCX-A, we separate clock and peripheral control into two main stages:
- At startup, e.g. when
embassy_mcxa::init()is called, we configure the core system clocks, including external and internal oscillators. This configuration is then largely static for the duration of the program. - When HAL drivers are created, e.g.
Lpuart::new()is called, the driver is responsible for two main things:- Ensuring that any required “upstream” core system clocks necessary for clocking the peripheral is active and configured to a reasonable value
- Enabling the clock gates for that peripheral, and resetting the peripheral
From a user perspective, only step 1 is visible. Step 2 is automatically handled by HAL drivers, using interfaces defined in this module.
It is also possible to view the state of the clock configuration after init()
has been called, using the with_clocks() function, which provides a view of the
Clocks structure.
§For HAL driver implementors
The majority of peripherals in the MCXA chip are fed from either a “hard-coded” or
configurable clock source, e.g. selecting the FROM12M or clk_1m as a source. This
selection, as well as often any pre-scaler division from that source clock, is made
through MRCC registers.
Any peripheral that is controlled through the MRCC register can automatically implement
the necessary APIs using the impl_cc_gate! macro in this module. You will also need
to define the configuration surface and steps necessary to fully configure that peripheral
from a clocks perspective by:
- Defining a configuration type in the
periph_helpersmodule that contains any selects or divisions available to the HAL driver - Implementing the
periph_helpers::SPConfHelpertrait, which should check that the necessary input clocks are reasonable
Modules§
- config
- Clock Configuration
- periph_
helpers - Peripheral Helpers
Structs§
- Clock
- Information regarding a system clock
- Clocks
- The
Clocksstructure contains the initialized state of the core system clocks
Enums§
- Clock
Error ClockErroris the main error returned when configuring or checking clock state- Powered
Clock - The power state of a given clock.
Traits§
- Gate
- Trait describing an AHB clock gate that can be toggled through MRCC.
Functions§
- assert_
reset ⚠ - Assert a reset line for the given peripheral set.
- disable⚠
- Disable the clock gate for the given peripheral.
- enable⚠
- Enable the clock gate for the given peripheral.
- enable_
and_ ⚠reset - This is the primary helper method HAL drivers are expected to call when creating an instance of the peripheral.
- init
- Initialize the core system clocks with the given
ClocksConfig. - is_
clock_ enabled - Check whether a gate is currently enabled.
- is_
reset_ ⚠released - Check whether the peripheral is held in reset.
- pulse_
reset ⚠ - Pulse a reset line (assert then release) with a short delay.
- release_
reset ⚠ - Release a reset line for the given peripheral set.
- with_
clocks - Obtain the full clocks structure, calling the given closure in a critical section.