FU6522_72_MDU.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * @file FU6522_72_MDU.h
  3. * @version V1.0.0
  4. * @author FortiorTech Hardware Team
  5. * @date 2021-07-15 20:52:58
  6. * @brief This file contains ...
  7. *
  8. * @copyright Copyright(C) 2022, Fortior Technology Co., Ltd. All rights reserved.
  9. */
  10. #ifndef __FU6522_72_MDU_H__
  11. #define __FU6522_72_MDU_H__
  12. // Include external header file.
  13. #include <FU6522_72_MCU.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /**
  18. * @brief SMDU的模式类型
  19. *
  20. * @note 使用@ref SMDU_RunNoBlock时, 其中的mode参数可以直接使用本枚举的内容
  21. * @note 使用@ref SMDU_RunBlock时, 其中的mode参数可以直接使用本枚举的内容
  22. */
  23. typedef enum
  24. {
  25. S1MUL = 0, /**< 有符号乘法, 计算结果左移1位 */
  26. SMUL = 1, /**< 有符号乘法 */
  27. UMUL = 2, /**< 无符号乘法 */
  28. DIV = 3, /**< 32/16无符号除法 */
  29. SIN_COS = 4, /**< Sin/Cos */
  30. ATAN = 5, /**< ATan */
  31. LPF = 6, /**< 低通滤波 */
  32. PI = 7 /**< PI */
  33. } ETypeSMDUMode;
  34. /**
  35. * @brief 运行SMDU且不等待运行结束
  36. *
  37. * @param stan (0-3) 要启动的计算单元编号
  38. * @param mode (0-7) 指定计算单元的模式, 可使用@see ETypeSMDUMode 作为计算模式的设置\n
  39. * @ref S1MUL 有符号乘法, 计算结果左移1位 \n
  40. * @ref SMUL 有符号乘法 \n
  41. * @ref UMUL 无符号乘法 \n
  42. * @ref DIV 32/16无符号除法 \n
  43. * @ref SIN_COS Sin/Cos \n
  44. * @ref ATAN ATan \n
  45. * @ref LPF 低通 \n
  46. * @ref PI PI \n
  47. */
  48. #define SMDU_RunNoBlock(stan, mode) do \
  49. { \
  50. MDU_CR = MDUSTA0 << stan | (unsigned char)mode; \
  51. } while (0)
  52. /**
  53. * @brief 运行SMDU且等待运行结束
  54. *
  55. * @param stan (0-3) 要启动的计算单元编号
  56. * @param mode (0-7) 指定计算单元的模式, 可使用@see ETypeSMDUMode 作为计算模式的设置\n
  57. * @ref S1MUL 有符号乘法, 计算结果左移1位 \n
  58. * @ref SMUL 有符号乘法 \n
  59. * @ref UMUL 无符号乘法 \n
  60. * @ref DIV 32/16无符号除法 \n
  61. * @ref SIN_COS Sin/Cos \n
  62. * @ref ATAN ATan \n
  63. * @ref LPF 低通 \n
  64. * @ref PI PI \n
  65. */
  66. #define SMDU_RunBlock(stan, mode) do \
  67. { \
  68. SMDU_RunNoBlock(stan, mode); \
  69. while ((MDU_CR & MDUBSY) == MDUBSY); \
  70. } while (0);
  71. // SMDU部分函数声明
  72. void HW_Zero_PI_Init(void);
  73. void HW_One_PI_Init(void);
  74. void HW_Two_PI_Init(void);
  75. void HW_Three_PI_Init(void);
  76. int16_t HW_Zero_Calc(int16_t Xn0);
  77. int16_t HW_One_Calc(int16_t Xn0);
  78. int16_t HW_Two_Calc(int16_t Xn0);
  79. int16_t HW_Three_Calc(int16_t Xn0);
  80. int16_t LPF_Zero_Update(int16_t Xn1, int16_t Xn0, int16_t K);
  81. int16_t LPF_One_Update(int16_t Xn1, int16_t Xn0, int16_t K);
  82. int16_t LPF_Two_Update(int16_t Xn1, int16_t Xn0, int16_t K);
  83. int16_t LPF_Three_Update(int16_t Xn1, int16_t Xn0, int16_t K);
  84. int16 Atan_Us_MDU(int16 Xn1, int16 Xn0);
  85. int16 DivQ_L_MDU(uint16 Xn1, uint16 Xn0,uint16 Yn);
  86. int16 MULU_H_MDU(uint16 Xn0, uint16 Xn1);
  87. uint16 Sqrt_alpbet(int16 i_alp, int16 i_bet);
  88. int16 DivQ_L_MDU2(uint16 Xn1, uint16 Xn0, uint16 Yn);
  89. void MULS_H_MDU(int16 Xn0, int16 Xn1,uint16 xdata *lusResult32);
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93. #endif