Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

254 linhas
7.1 KiB

  1. /*******************************************************************************
  2. * *
  3. * Copyright 2010 Rheinmetall Canada Inc. *
  4. * *
  5. * No part of this document may be reproduced, stored in *
  6. * a retrieval system, or transmitted, in any form or by any means, *
  7. * electronic, mechanical, photocopying, recording, or otherwise, *
  8. * without the prior written permission of Rheinmetall Canada Inc. *
  9. * *
  10. *******************************************************************************/
  11. /* ¤Revision:
  12. 000 20100616 HCAM,
  13. Original version.
  14. ,----.. ,----..
  15. / / \ / / \ ,--,
  16. | : : __ ,-. ,---. | : : ,--.'| ,---,
  17. . | ;. / ,' ,'/ /| ' ,'\ .--.--. . | ;. / | |, ,-+-. / |
  18. . ; /--` ' | |' | / / | / / ' . ; /--` `--'_ ,--.'|' |
  19. ; | ; __ | | ,'. ; ,. :| : /`./ ; | ; __ ,' ,'| | | ,"' |
  20. | : |.' .'' : / ' | |: :| : ;_ | : |.' .'' | | | | / | |
  21. . | '_.' :| | ' ' | .; : \ \ `. . | '_.' :| | : | | | | |
  22. ' ; : \ |; : | | : | `----. \ ' ; : \ |' : |__ | | | |/
  23. ' | '/ .'| , ; \ \ / / /`--' / ' | '/ .'| | '.'|| | |--'
  24. | : / ---' `----' '--'. / | : / ; : ;| |/
  25. \ \ .' `--'---' \ \ .' | , / '---'
  26. `---` `---` ---`-'
  27. ### YYYYMMDD Initial, Bug Identification
  28. Change description.
  29. */
  30. /****************************** NOTES ***************************************
  31. -> Timers assignment <-
  32. - Timer1 used by TCP Stack (tick.c)
  33. - Timer2 used by general timer module (timer.c) (see GP_TIMER_USE_TIMER_X definition below)
  34. - timer3 used by input capture to detect PWM
  35. - timer4 used by hall acquisition module (HallAcquisition.c)
  36. - timer5 used by FPGAInterface to time-base SPI the transfer to the FPGA
  37. -> Interrupt priority assignment <-
  38. Priority.SubPriority - Assignment
  39. HIGHEST
  40. 7.3
  41. 7.2
  42. 7.1
  43. 7.0
  44. 6.3
  45. 6.2
  46. 6.1
  47. 6.0
  48. 5.3
  49. 5.2
  50. 5.1
  51. 5.0
  52. 4.3
  53. 4.2
  54. 4.1
  55. 4.0
  56. 3.3
  57. 3.2
  58. 3.1
  59. 3.0 - Wifi chip IRQ (Ext INT 0)
  60. 2.3 - TIMER2 (General purpose timer)
  61. 2.2
  62. 2.1 - Ext Interrupt 1 (Led dimming knob) NOT USED!!!
  63. 1.0
  64. 1.3
  65. 1.2
  66. 1.1
  67. 1.0
  68. LOWEST
  69. *****************************************************************************/
  70. #ifndef DEFINE_H
  71. #define DEFINE_H
  72. /* ************************************************************************** */
  73. /* Includes */
  74. #include <plib.h>
  75. //#include "CUHelperFcns.h"
  76. enum eWiFiState
  77. {
  78. WIFI_MODULE_OFF_STATE = 0,
  79. WIFI_CONNECTED_STATE,
  80. WIFI_DISCONNECTED_STATE,
  81. WIFI_INIT_ERROR_STATE,
  82. WIFI_UNKNOWN_STATE
  83. };
  84. #define WIFI_MODULE_SPI_BAUDRATE 15000000
  85. #define WIFI_CONNECT_TIMEOUT 10000 //The delay we allow the module to establish a connection.
  86. /* ************************************************************************** */
  87. /* Defines */
  88. #define PIN_INPUT 1
  89. #define PIN_OUTPUT 0
  90. #define LED_ON 0
  91. #define LED_OFF 1
  92. #define false 0
  93. #define true 1
  94. #define MSB8(x) ((x >> 8) & 0xFF)
  95. #define LSB8(x) (x & 0xFF)
  96. #define RET_OK true
  97. #define RET_ERROR false
  98. #define bool unsigned int
  99. #define PI 3.1415926536
  100. //#define ENABLE_DEBUG_LOG
  101. #ifdef ENABLE_DEBUG_LOG
  102. #include "util.h"
  103. #endif
  104. ////#define USE_HALL_ACQ_SIMULATOR //Use this switch for development to test hall acquisition traces
  105. //#define USE_ENGINEERING_MODE //Use this switch to disable speed, position and halls traces and traces buffer allocation (all traces !)
  106. ////#define USE_TRACE_SIMULATOR //Use this switch to simulate trace data for development
  107. ////#define USE_SPI_DONGLE_SIMULATOR //Use this switch if you use the CUMUX as a SPI dongle instead of the CS16IS74 dongle.
  108. ////#define USE_PMP_AUTOINCREMENT //Use to speed-up AD2S data transfer
  109. ////#define USE_PWM_DETECTION //Use PWM detection to enable/disable bridge
  110. ////#define USE_AUTO_BRIDGE_CONTROL //Execute drive bridge control
  111. ////#define FORCE_BRIDGE_ON
  112. ////#define DRIVE_BOARD_NOT_INSTALLED
  113. //#define DISABLE_PRINT_FAULT
  114. //#define SPI_FAST
  115. ////#define USE_DMA_WITH_PMP
  116. ////#define USE_RESOLVER_STATEMACHINE
  117. ////#define DISABLE_DRIVE_PARAM_MGMT // uncomment to avoid setting the drive at power-up
  118. #define NO_EXTERNAL_UART
  119. //Choose which timer to use for general purpose timer
  120. #define GP_TIMER_USE_TIMER_1
  121. //#define POLL_UART1_RX
  122. //#define POLL_UART2_RX
  123. //#define NO_WIFI
  124. //Define the com port assignations
  125. //----------------------------
  126. #define NETWORK_UART_PORT UART_1
  127. #define LTE_IF_UART_PORT UART_2
  128. //
  129. //----------------------------
  130. //Enable only one of those 3 options
  131. //#define USE_BLOCKING_PRINTF
  132. //#define USE_UART_PRINTF
  133. #define USE_SYSLOG
  134. #ifdef USE_UART_PRINTF
  135. #ifdef USE_SYSLOG
  136. #error "USE_UART_PRINTF and USE_SYSLOG defined simultaneously"
  137. #endif
  138. #endif
  139. //#error test
  140. #ifdef USE_SYSLOG
  141. #ifdef NO_WIFI
  142. #undef USE_SYSLOG
  143. #error "USE_SYSLOG defined with NO_WIFI"
  144. #endif
  145. #endif
  146. #ifdef USE_UART_PRINTF
  147. #define PRINTF(n, a...) printf(n, ## a)
  148. #elif defined USE_SYSLOG
  149. #define PRINTF(n, a...) printf(n, ## a)
  150. #else
  151. #define PRINTF(n, a...)
  152. #endif
  153. #ifndef NO_WIFI
  154. // #define USE_WIFI_PRINTF
  155. #endif
  156. //#define USE_UART_PRINTF
  157. //#else
  158. //
  159. // #define NO_EXTERNAL_UART
  160. //#endif
  161. //#define CONNECT_DEVICE_TO_NETWORK
  162. //#define TERMINAL_USE_TELNET
  163. //#define TERMINAL_USE_TCP_SERVER
  164. /* ************************************************************************** */
  165. /* Type definitions */
  166. //----- STDINT.H TYPE DEFINITIONS -----
  167. //(Valid for XC16 & XC32 microchip PIC compilers)
  168. #ifndef uint8_t
  169. typedef unsigned char uint8_t;
  170. #endif
  171. #ifndef int8_t
  172. typedef signed char int8_t;
  173. #endif
  174. #ifndef uint16_t
  175. typedef unsigned short uint16_t;
  176. #endif
  177. #ifndef int16_t
  178. typedef signed short int16_t;
  179. #endif
  180. /*
  181. #ifndef uint32_t
  182. typedef unsigned long uint32_t;
  183. #endif
  184. #ifndef int32_t
  185. typedef signed long int32_t;
  186. #endif
  187. */
  188. #ifndef uint64_t
  189. typedef unsigned long long uint64_t;
  190. #endif
  191. #ifndef int64_t
  192. typedef signed long long int64_t;
  193. #endif
  194. #endif
  195. //EOF