This repository has been archived on 2024-05-28. You can view files and clone it, but cannot push or open issues or pull requests.
2023-11-14 16:25:09 -05:00

40 lines
1.2 KiB
C++
Executable File

#ifndef DMA_HPP
#define DMA_HPP
#include "global_variable.h"
#include "reg_dma.h"
#include "reg_gpdma_gen.h"
#include "reg_nvic.h"
#include "reg_rcc.h"
#include "stm32u575xx.h"
#define LINK_LIST_SIZE 32
// 65kb * 32 = 2MB, the max size of link list is 2MB
class Dma {
private:
DMA_TypeDef *dma = nullptr;
DMA_Channel_TypeDef *dma_channel = nullptr;
reg_gpdma_ch_t *reg_ch = nullptr;
reg_gpdma_t *reg_dma = nullptr;
list_node_s link_list_p[LINK_LIST_SIZE] = {0};
bool initialized = false;
uint32_t (*user_tc_cb)() = nullptr;
uint32_t (*user_err_cb)() = nullptr;
public:
Dma(DMA_TypeDef *_dma, DMA_Channel_TypeDef *_dma_channel);
hal_status_e start(uint32_t src, uint32_t dst, uint32_t size, uint32_t (*tc_cb)() = nullptr,
uint32_t (*err_cb)() = nullptr);
hal_status_e init(uint8_t request_source, dma_data_width_e src_width,
dma_data_width_e dst_width, ll_state_e src_inc, ll_state_e dst_inc,
dma_type_e src_type, dma_type_e dst_type, uint32_t max_transfer_size);
hal_status_e stop();
hal_status_e reset();
void interrupt();
uint32_t get_dst_addr();
};
#endif