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