FU68xx_5_MDU.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /********************************************************************************
  2. **** Copyright (C), 2019, Fortior Technology Co., Ltd. ****
  3. ********************************************************************************
  4. * File Name : FU68xx_4_MDU.h
  5. * Author : Bruce HW&RD
  6. * Date : 2019-03-27
  7. * Description : .C file function description
  8. * Version : 1.0
  9. * Function List :
  10. *
  11. * Record :
  12. * 1.Date : 2019-03-27
  13. * Author : Bruce HW&RD
  14. * Modification: Created file
  15. ********************************************************************************/
  16. #ifndef __FU68XX_5_MDU_H__
  17. #define __FU68XX_5_MDU_H__
  18. /**************************************************************************************************///Including Header Files
  19. #include <FU68xx_5_MCU.h>
  20. /**************************************************************************************************///Define Macro
  21. /**
  22. * @brief 运行SMDU且不等待运行结束
  23. *
  24. * @param stan (0-3) 要启动的计算单元编号
  25. * @param mode (0-7) 指定计算单元的模式, 可使用@see ETypeSMDUMode 作为计算模式的设置\n
  26. * @ref S1MUL 有符号乘法, 计算结果左移1位 \n
  27. * @ref SMUL 有符号乘法 \n
  28. * @ref UMUL 无符号乘法 \n
  29. * @ref DIV 32/16无符号除法 \n
  30. * @ref SIN_COS Sin/Cos \n
  31. * @ref ATAN ATan \n
  32. * @ref LPF 低通 \n
  33. * @ref PI PI \n
  34. */
  35. typedef enum
  36. {
  37. S1MUL = 0, /**< 有符号乘法, 计算结果左移1位 */
  38. SMUL = 1, /**< 有符号乘法 */
  39. UMUL = 2, /**< 无符号乘法 */
  40. DIV = 3, /**< 32/16无符号除法 */
  41. SIN_COS = 4, /**< Sin/Cos */
  42. ATAN = 5, /**< ATan */
  43. LPF = 6, /**< 低通滤波 */
  44. PI = 7 /**< PI */
  45. } ETypeSMDUMode;
  46. #define SMDU_RunNoBlock(stan, mode) do \
  47. { \
  48. MDU_CR = MDUSTA0 << stan | (unsigned char)mode; \
  49. } while (0)
  50. /**
  51. * @brief 运行SMDU且等待运行结束
  52. *
  53. * @param stan (0-3) 要启动的计算单元编号
  54. * @param mode (0-7) 指定计算单元的模式, 可使用@see ETypeSMDUMode 作为计算模式的设置\n
  55. * @ref S1MUL 有符号乘法, 计算结果左移1位 \n
  56. * @ref SMUL 有符号乘法 \n
  57. * @ref UMUL 无符号乘法 \n
  58. * @ref DIV 32/16无符号除法 \n
  59. * @ref SIN_COS Sin/Cos \n
  60. * @ref ATAN ATan \n
  61. * @ref LPF 低通 \n
  62. * @ref PI PI \n
  63. */
  64. #define SMDU_RunBlock(stan, mode) do \
  65. { \
  66. SMDU_RunNoBlock(stan, mode); \
  67. while ((MDU_CR & MDUBSY) == MDUBSY); \
  68. } while (0);
  69. #define MuiltS1_H_MDU(iA, iB, iCh) do \
  70. { \
  71. MUL0_MA = iA;MUL0_MB = iB; SMDU_RunBlock(0 , 0); iCh = MUL0_MCH; \
  72. } while (0);
  73. #define SinCos_MDU(iCos0, iTheta, iSin0, iCos, iSin) do \
  74. { \
  75. SCAT2_COS = iCos0;\
  76. SCAT2_THE = iTheta;\
  77. SCAT2_SIN = 0; \
  78. SMDU_RunBlock(2,4);\
  79. iSin = SCAT2_RES2 ;\
  80. iCos = SCAT2_RES1;\
  81. } while (0);
  82. //
  83. #define LPF_MDU(iX, ucK, iYh, iYl) do { \
  84. LPF3_K = ucK;\
  85. LPF3_X = iX;\
  86. LPF3_YH = iYh;\
  87. LPF3_YL = iYl;\
  88. SMDU_RunBlock(3,6);\
  89. iYh = LPF3_YH;\
  90. iYl = LPF3_YL;\
  91. } while (0) ;
  92. #define SqrtI_alpbet(i_alp, i_bet, is) do { \
  93. SCAT0_COS = i_alp; \
  94. SCAT0_SIN = i_bet; \
  95. SMDU_RunBlock(0,5); \
  96. is = SCAT0_RES1; \
  97. } while (0) ;
  98. #define SqrtU_alpbet(u_alp, u_bet, us) do{ \
  99. SCAT1_COS = u_alp; \
  100. SCAT1_SIN = u_bet; \
  101. SMDU_RunBlock(1,5); \
  102. us = SCAT1_RES1; \
  103. } while (0) ;
  104. #endif
  105. // #define MuiltS1_H_MDU(iA, iB, iCh) do {
  106. //// MUL0_MA = iA;
  107. //// MUL0_MB = iB;
  108. //// SMDU_RunBlock(0 , 2);//无符号乘法
  109. //// iCh = MUL0_MCL;
  110. ////
  111. ////// MDU_CR = MDUDONE;
  112. //
  113. // } while (0) ;
  114. //#endif