• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _module-pw_clock_tree_mcuxpresso:
2
3===========================
4pw_clock_tree_mcuxpresso
5===========================
6.. pigweed-module::
7   :name: pw_clock_tree_mcuxpresso
8
9``pw_clock_tree_mcuxpresso`` implements the ``pw_clock_tree`` interface using the
10NXP MCUXpresso SDK. It provides class implementations for the following clock tree elements
11that can be directly instantiated:
12
13.. inclusive-language: disable
14
15* Free-Running Oscillator (FRO)
16* 32 kHz RTC Oscillator
17* Low-power Oscillator
18* Master Clock
19* External Clock Input as clock source for SYSOSCBYPASS clock selector to generate OSC_CLK
20* Fractional Rate Generator (FRG) for Flexcomm Interfaces
21* Clock Source Selector
22* Clock Divider
23* Audio PLL
24
25.. inclusive-language: enable
26
27Other clock tree components such as PLLs can be instantiated by deriving custom class implementations
28from the abstract class `DependentElement` and overwriting `DoEnable` and `DoDisable` methods.
29
30Examples
31========
32
33----------------------------------------
34End-to-end Mcuxpresso clock tree example
35----------------------------------------
36
37Definition of clock tree elements:
38
39.. mermaid::
40
41    flowchart LR
42          A(fro_div_4) -->B(frg_0)
43          B-->C(flexcomm_selector_0)
44          style A fill:#0f0,stroke:#333,stroke-width:2px
45          style B fill:#0f0,stroke:#333,stroke-width:2px
46          style C fill:#0f0,stroke:#333,stroke-width:2px
47
48.. literalinclude:: examples.cc
49   :language: cpp
50   :linenos:
51   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-Flexcomm0]
52   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-Flexcomm0]
53
54.. mermaid::
55
56    flowchart LR
57          D(fro_div_8)--> E(i3c_selector)
58          E --> F(i3c_divider)
59          style D fill:#f0f,stroke:#333,stroke-width:2px
60          style E fill:#f0f,stroke:#333,stroke-width:2px
61          style F fill:#f0f,stroke:#333,stroke-width:2px
62
63.. literalinclude:: examples.cc
64   :language: cpp
65   :linenos:
66   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-i3c0]
67   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-i3c0]
68
69.. mermaid::
70
71    flowchart LR
72          G(mclk) --> H(ctimer_0)
73          style G fill:#0ff,stroke:#333,stroke-width:2px
74          style H fill:#0ff,stroke:#333,stroke-width:2px
75
76.. literalinclude:: examples.cc
77   :language: cpp
78   :linenos:
79   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-ClockSourceNoOp]
80   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-ClockSourceNoOp]
81
82.. literalinclude:: examples.cc
83   :language: cpp
84   :linenos:
85   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-Ctimer0]
86   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-Ctimer0]
87
88.. mermaid::
89
90    flowchart LR
91          I(lposc)
92          style I fill:#ff0,stroke:#333,stroke-width:2px
93
94.. literalinclude:: examples.cc
95   :language: cpp
96   :linenos:
97   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-LpOsc]
98   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-LpOsc]
99
100Definition of clock tree:
101
102.. literalinclude:: examples.cc
103   :language: cpp
104   :linenos:
105   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeDef]
106   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeDef]
107
108Example usage of ``clock_tree`` APIs:
109
110.. literalinclude:: examples.cc
111   :language: cpp
112   :linenos:
113   :start-after: [pw_clock_tree_mcuxpresso-examples-UseExample]
114   :end-before: [pw_clock_tree_mcuxpresso-examples-UseExample]
115
116------------------
117Audio PLL examples
118------------------
119
120.. cpp:namespace-push:: pw::clock_tree
121
122The :cpp:class:`ClockMcuxpressoAudioPll` can be configured in two different ways,
123either it can be configured where the audio PLL gets enabled, or it can be
124configured in bypass mode.
125
126The first example shows where :cpp:class:`ClockMcuxpressoAudioPll` enables the audio PLL
127and uses the ClkIn pin clock source as OSC clock source that feeds into the audio PLL logic.
128
129.. mermaid::
130
131    flowchart LR
132          subgraph PLL [Audio PLL logic]
133          B(audio_pll_selctor) -.-> C(PLL)
134          C -.-> D(Phase Fraction divider)
135          end
136          A(clk_in) -->|as osc_clk| PLL
137          PLL --> E(audio_pfd_bypass_selector)
138
139          style A fill:#f0f,stroke:#333,stroke-width:2px
140          style E fill:#f0f,stroke:#333,stroke-width:2px
141
142.. literalinclude:: examples.cc
143   :language: cpp
144   :linenos:
145   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-ClockSourceNoOp]
146   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-ClockSourceNoOp]
147
148.. literalinclude:: examples.cc
149   :language: cpp
150   :linenos:
151   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-AudioPll]
152   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-AudioPll]
153
154The second example shows where :cpp:class:`ClockMcuxpressoAudioPll` bypasses the audio PLL
155and uses ``FRO_DIV_8 pin`` clock source.
156
157.. cpp:namespace-pop::
158
159.. mermaid::
160
161    flowchart LR
162          A(fro_div_8) --> B(audio_pfd_bypass_selector)
163          style A fill:#0ff,stroke:#333,stroke-width:2px
164          style B fill:#0ff,stroke:#333,stroke-width:2px
165
166.. literalinclude:: examples.cc
167   :language: cpp
168   :linenos:
169   :start-after: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-AudioPllBypass]
170   :end-before: [pw_clock_tree_mcuxpresso-examples-ClockTreeElementDefs-AudioPllBypass]
171
172APIs
173====
174
175------------------
176ClockMcuxpressoFro
177------------------
178.. doxygenclass:: pw::clock_tree::ClockMcuxpressoFro
179   :members:
180
181--------------------
182ClockMcuxpressoLpOsc
183--------------------
184.. doxygenclass:: pw::clock_tree::ClockMcuxpressoLpOsc
185   :members:
186
187-------------------
188ClockMcuxpressoMclk
189-------------------
190.. doxygenclass:: pw::clock_tree::ClockMcuxpressoMclk
191   :members:
192
193--------------------
194ClockMcuxpressoClkIn
195--------------------
196.. doxygenclass:: pw::clock_tree::ClockMcuxpressoClkIn
197   :members:
198
199------------------
200ClockMcuxpressoFrg
201------------------
202.. doxygenclass:: pw::clock_tree::ClockMcuxpressoFrg
203   :members:
204
205-----------------------
206ClockMcuxpressoSelector
207-----------------------
208.. doxygenclass:: pw::clock_tree::ClockMcuxpressoSelector
209   :members:
210
211----------------------
212ClockMcuxpressoDivider
213----------------------
214.. doxygenclass:: pw::clock_tree::ClockMcuxpressoDivider
215   :members:
216
217-----------------------
218ClockMcuxpressoAudioPll
219-----------------------
220.. doxygenclass:: pw::clock_tree::ClockMcuxpressoAudioPll
221   :members:
222