FU68xx_5_DMA.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __FU68XX_5_DMA_H__
  2. #define __FU68XX_5_DMA_H__
  3. #include <FU68xx_5_MCU.h>
  4. // DMA管道参数表
  5. #define DMA_PIPE (DMACFG2 | DMACFG1 | DMACFG0)
  6. #define UART1_XDATA (0x00)
  7. #define XDATA_UART1 (DMACFG0)
  8. #define I2C_XDATA (DMACFG1)
  9. #define XDATA_I2C (DMACFG0 | DMACFG1)
  10. #define SPI_XDATA (DMACFG2)
  11. #define XDATA_SPI (DMACFG2 | DMACFG0)
  12. #define UART2_XDATA (DMACFG2 | DMACFG1)
  13. #define XDATA_UART2 (DMACFG2 | DMACFG1 | DMACFG0)
  14. // DMA中断控制
  15. #define DMA_IE_EN DMAIE
  16. #define DMA_IE_DIS 0x00
  17. // DMA传输顺序
  18. #define DMA_FHSB ENDIAN
  19. #define DMA_FLSB 0x00
  20. // DMA状态
  21. #define DMA_BSY (DMABSY)
  22. #define DMA_IRQ (DMAIF)
  23. // DMA中断优先级配置
  24. #define DMA_IRQ_L1 (0)
  25. #define DMA_IRQ_L2 (PDMA0)
  26. #define DMA_IRQ_L3 (PDMA1)
  27. #define DMA_IRQ_L4 (PDMA0 | PDMA1)
  28. // DMA操作函数
  29. #define Wait_DMA(a) while (ReadBit(*(&DMA0_CR0 + a), DMABSY))
  30. #define Switch_DMA(a) SetBit(*(&DMA0_CR0 + a), DMAEN | DMABSY)
  31. // DMA配置函数
  32. void Set_IRQ_DMA(uint8_t DMA_IRQ_Priority);
  33. void Conf_DMA(uint8_t DMAx, uint8_t DMAPipe, uint16_t DMAAddr, uint8_t DMALen);
  34. void Set_DMA_Pipe(uint8_t DMAx,uint8_t DMAPipe);
  35. void Start_DMA(uint8_t DMAx);
  36. bool Get_DMA_Status(uint8_t DMAx,uint8_t DMAStatus);
  37. void Set_DMA_Data_Package(uint8_t DMAx, uint16_t ulAddr, uint8_t cLen);
  38. #endif