typedefine.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: typedefine.h
  4. Partner Filename: N/A
  5. Description: Data type define
  6. Complier: IAR Embedded Workbench for ARM 7.80.4
  7. CPU TYPE : GD32F1x0
  8. *************************************************************************
  9. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  10. All rights reserved.
  11. *************************************************************************
  12. *************************************************************************
  13. Revising History (ECL of this file):
  14. ************************************************************************/
  15. /************************************************************************
  16. Beginning of File, do not put anything above here except notes
  17. Compiler Directives
  18. *************************************************************************/
  19. #ifndef TYPEDEFINE_H
  20. #define TYPEDEFINE_H
  21. /************************************************************************
  22. Definitions & Macros (N/A)
  23. ************************************************************************/
  24. /************************************************************************
  25. Typedefs & Structures Defines
  26. ************************************************************************/
  27. typedef signed char _SBYTE;
  28. typedef unsigned char _UBYTE;
  29. typedef signed short _SWORD;
  30. typedef unsigned short _UWORD;
  31. typedef signed int _SINT;
  32. typedef unsigned int _UINT;
  33. typedef signed long _SLONG;
  34. typedef unsigned long _ULONG;
  35. typedef signed long long _SQWORD;
  36. typedef unsigned long long _UQWORD;
  37. typedef void VOID;
  38. typedef unsigned char UBYTE; // One byte unsigned
  39. typedef signed char SBYTE; // One byte signed
  40. typedef unsigned short UWORD; // Two bytes unsigned
  41. typedef signed short SWORD; // Two bytes signed
  42. typedef unsigned long ULONG; // Four bytes unsigned
  43. typedef signed long SLONG; // Four bytes signed
  44. typedef signed long long SQWORD;
  45. typedef unsigned long long UQWORD;
  46. #define _IQ30(A) (SLONG)(A * 1073741824L) // Q15
  47. #define _IQ21(A) (SLONG)(A * 2097152L) // Q15
  48. #define _IQ20(A) (SLONG)(A * 1048576L) // Q14
  49. #define _IQ19(A) (SLONG)(A * 524288L) // Q13
  50. #define _IQ18(A) (SLONG)(A * 262144L) // Q12
  51. #define _IQ17(A) (SLONG)(A * 131072L) // Q11
  52. #define _IQ16(A) (SLONG)(A * 65536L) // Q10
  53. #define _IQ15(A) (SLONG)(A * 32768L) // Q15
  54. #define _IQ14(A) (SLONG)(A * 16384L) // Q14
  55. #define _IQ13(A) (SLONG)(A * 8192L) // Q13
  56. #define _IQ12(A) (SLONG)(A * 4096L) // Q12
  57. #define _IQ11(A) (SLONG)(A * 2048L) // Q11
  58. #define _IQ10(A) (SLONG)(A * 1024L) // Q10
  59. #define _IQ9(A) (SLONG)(A * 512L) // Q9
  60. #define _IQ8(A) (SLONG)(A * 256L) // Q8
  61. #define _IQ7(A) (SLONG)(A * 128L) // Q7
  62. #define _IQ6(A) (SLONG)(A * 64L) // Q6
  63. #define _IQ5(A) (SLONG)(A * 32L) // Q5
  64. #define _IQ4(A) (SLONG)(A * 16L) // Q4
  65. #define _IQ3(A) (SLONG)(A * 8L) // Q3
  66. #define _IQ2(A) (SLONG)(A * 4L) // Q2
  67. #define _IQ1(A) (SLONG)(A * 2L) // Q1
  68. #define _IQ0(A) (SLONG)(A * 1L) // Q0
  69. #define _IQ(A) _IQ14(A) // Global IQ
  70. typedef enum
  71. {
  72. FALSE = 0,
  73. TRUE = !FALSE
  74. } BOOL;
  75. #ifndef NULL /* set null ((void *)0) */
  76. #define NULL (void *)0
  77. #endif
  78. /*---------------------------------------------------------------------*/
  79. typedef union
  80. {
  81. struct
  82. {
  83. UBYTE low;
  84. SBYTE hi;
  85. } sb;
  86. SWORD sw;
  87. } SWORD_UNION;
  88. /*---------------------------------------------------------------------*/
  89. typedef union
  90. {
  91. struct
  92. {
  93. UWORD low;
  94. SWORD hi;
  95. } sw;
  96. SLONG sl;
  97. } SLONG_UNION;
  98. /*---------------------------------------------------------------------*/
  99. typedef union
  100. {
  101. struct
  102. {
  103. UWORD low;
  104. UWORD hi;
  105. } uw;
  106. ULONG ul;
  107. } ULONG_UNION;
  108. /*---------------------------------------------------------------------*/
  109. typedef union
  110. {
  111. struct
  112. {
  113. UBYTE b0 : 1;
  114. UBYTE b1 : 1;
  115. UBYTE b2 : 1;
  116. UBYTE b3 : 1;
  117. UBYTE b4 : 1;
  118. UBYTE b5 : 1;
  119. UBYTE b6 : 1;
  120. UBYTE b7 : 1;
  121. } bit;
  122. UBYTE ub;
  123. } UBYTE_UNION;
  124. /*---------------------------------------------------------------------*/
  125. typedef union
  126. {
  127. struct
  128. {
  129. UWORD b0 : 1;
  130. UWORD b1 : 1;
  131. UWORD b2 : 1;
  132. UWORD b3 : 1;
  133. UWORD b4 : 1;
  134. UWORD b5 : 1;
  135. UWORD b6 : 1;
  136. UWORD b7 : 1;
  137. UWORD b8 : 1;
  138. UWORD b9 : 1;
  139. UWORD b10 : 1;
  140. UWORD b11 : 1;
  141. UWORD b12 : 1;
  142. UWORD b13 : 1;
  143. UWORD b14 : 1;
  144. UWORD b15 : 1;
  145. } bit;
  146. struct
  147. {
  148. UBYTE low;
  149. UBYTE hi;
  150. } ub;
  151. UWORD uw;
  152. } UWORD_UNION;
  153. typedef union
  154. {
  155. struct
  156. {
  157. ULONG low;
  158. ULONG hi;
  159. } ul;
  160. UQWORD uq;
  161. } UQWORD_UNION;
  162. /************************************************************************
  163. Exported Variables (N/A)
  164. ************************************************************************/
  165. /************************************************************************
  166. Ram Allocation (N/A)
  167. ************************************************************************/
  168. /************************************************************************
  169. Exported Function Call Prototypes (N/A)
  170. ************************************************************************/
  171. /************************************************************************
  172. Local Function Call Prototypes (N/A)
  173. ************************************************************************/
  174. /************************************************************************
  175. Flag Define (N/A)
  176. ************************************************************************/
  177. #endif
  178. /************************************************************************
  179. Copyright (c) 2017 Welling Motor Technology(Shanghai) Co. Ltd.
  180. All rights reserved.
  181. *************************************************************************
  182. End of this File (EOF)!
  183. Do not put anything after this part!
  184. ************************************************************************/