xref: /aosp_15_r20/external/pigweed/pw_dma_mcuxpresso/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1.. _module-pw_dma_mcuxpresso:
2
3=================
4pw_dma_mcuxpresso
5=================
6.. pigweed-module::
7   :name: pw_dma_mcuxpresso
8
9``pw_dma_mcuxpresso`` provides helper classes for working with an MCUXpresso DMA
10controller. The API is specific to MCUXpresso and doesn't implement any generic
11DMA API at this time.
12
13-------------
14API reference
15-------------
16The following classes make up the public API:
17
18``McuxpressoDmaController``
19===========================
20Represents a DMA Controller. Supports ``constinit`` initialization.
21
22
23``McuxpressoDmaChannel``
24========================
25Represents a single channel of a DMA controller.
26
27NOTE: Because the SDK maintains a permanent reference to this class's
28members, these objects must have static lifetime at the time Init() is
29called and ever after. The destructor will intentionally crash.
30
31------
32Guides
33------
34Example code to use a DMA channel:
35
36.. code-block:: cpp
37
38   #include "pw_dma_mcuxpresso/dma.h"
39   #include "pw_status/try.h"
40
41   constinit pw::dma::McuxpressoDmaController dma(DMA0_BASE);
42
43   // McuxpressoDmaChannel must have static lifetime
44   pw::dma::McuxpressoDmaChannel tx_dma = dma.GetChannel(kTxDmaChannel);
45
46   pw::Status Init() {
47     // Initialize the DMA controller
48     PW_TRY(dma.Init());
49
50     tx_dma.Init();
51     tx_dma.SetPriority(kTxDmaChannelPriority);
52     tx_dma.Enable();
53     tx_dma.EnableInterrupts();
54
55     // Pass handle to driver that needs a dma_handle_t*.
56     dma_handle_t* handle = tx_dma.handle();
57   }
58