82 lines
2.4 KiB
C
82 lines
2.4 KiB
C
|
#ifndef _BSP_DMA_H_
|
||
|
#define _BSP_DMA_H_
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#include "kit_macro.h"
|
||
|
|
||
|
|
||
|
typedef enum
|
||
|
{
|
||
|
kDmaDev_1,
|
||
|
kDmaDev_2,
|
||
|
kDmaDev_End,
|
||
|
}DmaDev;
|
||
|
|
||
|
typedef enum
|
||
|
{
|
||
|
kDma1Stream_0 = 0,
|
||
|
kDma1Stream_1,
|
||
|
kDma1Stream_2,
|
||
|
kDma1Stream_3,
|
||
|
kDma1Stream_4,
|
||
|
kDma1Stream_5,
|
||
|
kDma1Stream_6,
|
||
|
kDma1Stream_7,
|
||
|
kDma2Stream_0,
|
||
|
kDma2Stream_1,
|
||
|
kDma2Stream_2,
|
||
|
kDma2Stream_3,
|
||
|
kDma2Stream_4,
|
||
|
kDma2Stream_5,
|
||
|
kDma2Stream_6,
|
||
|
kDma2Stream_7,
|
||
|
kDmaStream_End,
|
||
|
}DmaStream;
|
||
|
|
||
|
typedef enum
|
||
|
{
|
||
|
kDmaChannel_0 = 0,
|
||
|
kDmaChannel_1,
|
||
|
kDmaChannel_2,
|
||
|
kDmaChannel_3,
|
||
|
kDmaChannel_4,
|
||
|
kDmaChannel_5,
|
||
|
kDmaChannel_6,
|
||
|
kDmaChannel_7,
|
||
|
kDmaChannel_End,
|
||
|
}DmaChannel;
|
||
|
|
||
|
|
||
|
#define DMA_CFG_DATA_DIR_P2M KIT_CREAT_BIT(0) //数据方向 外设到内存
|
||
|
#define DMA_CFG_DATA_DIR_M2P KIT_CREAT_BIT(1)
|
||
|
#define DMA_CFG_DATA_DIR_M2M KIT_CREAT_BIT(2)
|
||
|
#define DMA_CFG_CYCLE_NONE KIT_CREAT_BIT(3) //循环模式 不循环
|
||
|
#define DMA_CFG_CYCLE_EXE KIT_CREAT_BIT(4)
|
||
|
#define DMA_CFG_DATA_M_N KIT_CREAT_BIT(5) //数据地址增长 内存不增长 外设不增长
|
||
|
#define DMA_CFG_DATA_M_I KIT_CREAT_BIT(6) //数据地址增长 内存不增长 外设增长
|
||
|
#define DMA_CFG_DATA_P_N KIT_CREAT_BIT(7)
|
||
|
#define DMA_CFG_DATA_P_I KIT_CREAT_BIT(8)
|
||
|
#define DMA_CFG_DATA_LEN_1B KIT_CREAT_BIT(9) //数据长度 1字节
|
||
|
#define DMA_CFG_DATA_LEN_2B KIT_CREAT_BIT(10)
|
||
|
#define DMA_CFG_DATA_LEN_4B KIT_CREAT_BIT(11)
|
||
|
|
||
|
|
||
|
|
||
|
KitResult drv_dma_init(DmaStream stream_idx, DmaChannel channel, uint32_t dma_config, uint32_t addr);
|
||
|
void drv_dma_set_buf_with_call(DmaStream ch_idx,uint8_t* buf, uint16_t len, UintArgCall call);
|
||
|
void drv_dma_set_interrupt(DmaStream ch_idx, uint8_t priority, KitIrqCall call);
|
||
|
void drv_dma_set_buf(DmaStream ch_idx,uint8_t* buf, uint16_t len);
|
||
|
KitResult drv_dma_rx_tx(DmaStream dma_rx_ch, DmaStream dma_tx_ch, uint8_t *tx_buf, uint16_t tx_len, uint8_t *rx_buf, uint16_t rx_len, uint16_t timeout);
|
||
|
KitResult drv_dma_async_rx_tx(DmaStream dma_rx_ch, DmaStream dma_tx_ch, uint8_t *tx_buf, uint16_t tx_len, uint8_t *rx_buf, uint16_t rx_len);
|
||
|
KitResult drv_dma_send(DmaStream dma_tx_ch, uint8_t *tx_buf, uint16_t tx_len);
|
||
|
KitResult drv_dma_receive(DmaStream dma_rx_ch, DmaStream dma_tx_ch, uint8_t *rx_buf, uint16_t rx_len);
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif
|
||
|
|