C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
hw_dma.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include "hardware/dma.h"
15#include "hardware/irq.h"
16#include "hw/spi/hw_spi.h"
17#include "hw/i2c/hw_i2c.h"
18#include "FreeRTOS.h"
19#include "task.h"
20#include "semphr.h"
21#include "queue.h"
22
24#define I2C_BURST_SIZE 16
25
26
31class HW_DMA
32{
33private:
34
35public:
37 irq_num_t irq_number;
39 uint channel;
41 SemaphoreHandle_t end_of_xfer;
42
46 HW_DMA(irq_num_t irq_number = DMA_IRQ_0, irq_handler_t dma_irq_handler = NULL);
47
49 ~HW_DMA();
50
58 int xfer_mem2mem(uint32_t number_of_transfer,
59 dma_channel_transfer_size_t transfer_size,
60 volatile void *destination_address,
61 volatile void *source_address,
62 bool start);
63
66
68 void start_dma();
69};
~HW_DMA()
Destructor of the class, free the allocated DMA channel.
Definition hw_dma.cpp:23
SemaphoreHandle_t end_of_xfer
semaphore to signal the end of a DMA transfer
Definition hw_dma.h:41
irq_num_t irq_number
the IRQ number for the DMA channel, can be DMA_IRQ_0 or DMA_IRQ_1
Definition hw_dma.h:37
int xfer_mem2mem(uint32_t number_of_transfer, dma_channel_transfer_size_t transfer_size, volatile void *destination_address, volatile void *source_address, bool start)
the function member used to move data from memory to memory
Definition hw_dma.cpp:28
void start_dma()
start the DMA transfer
Definition hw_dma.cpp:58
uint channel
the DMA channel number allocated
Definition hw_dma.h:39
HW_DMA(irq_num_t irq_number=DMA_IRQ_0, irq_handler_t dma_irq_handler=NULL)
constructor of the DMA class
Definition hw_dma.cpp:3
void cleanup_and_free_dma_channel()
clean up and free the allocated DMA channel
Definition hw_dma.cpp:52