forked from gary/BCU
2
0
Fork 0
BCU/library/drv_stm32f4xx/drv_dma.h

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_BIT_MASK_32(0) //数据方向 外设到内存
#define DMA_CFG_DATA_DIR_M2P KIT_BIT_MASK_32(1)
#define DMA_CFG_DATA_DIR_M2M KIT_BIT_MASK_32(2)
#define DMA_CFG_CYCLE_NONE KIT_BIT_MASK_32(3) //循环模式 不循环
#define DMA_CFG_CYCLE_EXE KIT_BIT_MASK_32(4)
#define DMA_CFG_DATA_M_N KIT_BIT_MASK_32(5) //数据地址增长 内存不增长 外设不增长
#define DMA_CFG_DATA_M_I KIT_BIT_MASK_32(6) //数据地址增长 内存不增长 外设增长
#define DMA_CFG_DATA_P_N KIT_BIT_MASK_32(7)
#define DMA_CFG_DATA_P_I KIT_BIT_MASK_32(8)
#define DMA_CFG_DATA_LEN_1B KIT_BIT_MASK_32(9) //数据长度 1字节
#define DMA_CFG_DATA_LEN_2B KIT_BIT_MASK_32(10)
#define DMA_CFG_DATA_LEN_4B KIT_BIT_MASK_32(11)
kit_ret_e 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, UintArgFunCall 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);
kit_ret_e 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);
kit_ret_e 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);
kit_ret_e drv_dma_send(DmaStream dma_tx_ch, uint8_t *tx_buf, uint16_t tx_len);
kit_ret_e drv_dma_receive(DmaStream dma_rx_ch, DmaStream dma_tx_ch, uint8_t *rx_buf, uint16_t rx_len);
#ifdef __cplusplus
}
#endif
#endif