bsp.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:20k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                     MICIRUM BOARD SUPPORT PACKAGE
  4. *
  5. *                             (c) Copyright 2007; Micrium, Inc.; Weston, FL
  6. *
  7. *               All rights reserved.  Protected by international copyright laws.
  8. *               Knowledge of the source code may NOT be used to develop a similar product.
  9. *               Please help us continue to provide the Embedded community with the finest
  10. *               software available.  Your honesty is greatly appreciated.
  11. *********************************************************************************************************
  12. */
  13. /*
  14. *********************************************************************************************************
  15. *
  16. *                                        BOARD SUPPORT PACKAGE
  17. *
  18. *                                     ST Microelectronics STM32
  19. *                                              with the
  20. *                                   STM3210B-EVAL Evaluation Board
  21. *
  22. * Filename      : bsp.h
  23. * Version       : V1.10
  24. * Programmer(s) : BAN
  25. *********************************************************************************************************
  26. */
  27. /*
  28. *********************************************************************************************************
  29. *                                                 MODULE
  30. *
  31. * Note(s) : (1) This header file is protected from multiple pre-processor inclusion through use of the
  32. *               BSP present pre-processor macro definition.
  33. *********************************************************************************************************
  34. */
  35. #ifndef  BSP_PRESENT
  36. #define  BSP_PRESENT
  37. /*
  38. *********************************************************************************************************
  39. *                                                 EXTERNS
  40. *********************************************************************************************************
  41. */
  42. #ifdef   BSP_MODULE
  43. #define  BSP_EXT
  44. #else
  45. #define  BSP_EXT  extern
  46. #endif
  47. /*
  48. *********************************************************************************************************
  49. *                                              INCLUDE FILES
  50. *********************************************************************************************************
  51. */
  52. #include    <cpu.h>
  53. #include    <lib_def.h>
  54. #include    <lib_mem.h>
  55. #include    <lib_str.h>
  56. #include    <stm32f10x_conf.h>
  57. #include    <stm32f10x_lib.h>
  58. #include    <app_cfg.h>
  59. #include    <bsp.h>
  60. #include  <ucos_ii.h>
  61. /*
  62. *********************************************************************************************************
  63. *                                               INT DEFINES
  64. *********************************************************************************************************
  65. */
  66. #define  BSP_INT_ID_WWDG                                   0    /* Window WatchDog Interrupt                            */
  67. #define  BSP_INT_ID_PVD                                    1    /* PVD through EXTI Line detection Interrupt            */
  68. #define  BSP_INT_ID_TAMPER                                 2    /* Tamper Interrupt                                     */
  69. #define  BSP_INT_ID_RTC                                    3    /* RTC global Interrupt                                 */
  70. #define  BSP_INT_ID_FLASH                                  4    /* FLASH global Interrupt                               */
  71. #define  BSP_INT_ID_RCC                                    5    /* RCC global Interrupt                                 */
  72. #define  BSP_INT_ID_EXTI0                                  6    /* EXTI Line0 Interrupt                                 */
  73. #define  BSP_INT_ID_EXTI1                                  7    /* EXTI Line1 Interrupt                                 */
  74. #define  BSP_INT_ID_EXTI2                                  8    /* EXTI Line2 Interrupt                                 */
  75. #define  BSP_INT_ID_EXTI3                                  9    /* EXTI Line3 Interrupt                                 */
  76. #define  BSP_INT_ID_EXTI4                                 10    /* EXTI Line4 Interrupt                                 */
  77. #define  BSP_INT_ID_DMA1_CH1                              11    /* DMA1 Channel 1 global Interrupt                      */
  78. #define  BSP_INT_ID_DMA1_CH2                              12    /* DMA1 Channel 2 global Interrupt                      */
  79. #define  BSP_INT_ID_DMA1_CH3                              13    /* DMA1 Channel 3 global Interrupt                      */
  80. #define  BSP_INT_ID_DMA1_CH4                              14    /* DMA1 Channel 4 global Interrupt                      */
  81. #define  BSP_INT_ID_DMA1_CH5                              15    /* DMA1 Channel 5 global Interrupt                      */
  82. #define  BSP_INT_ID_DMA1_CH6                              16    /* DMA1 Channel 6 global Interrupt                      */
  83. #define  BSP_INT_ID_DMA1_CH7                              17    /* DMA1 Channel 7 global Interrupt                      */
  84. #define  BSP_INT_ID_ADC1_2                                18    /* ADC1 et ADC2 global Interrupt                        */
  85. #define  BSP_INT_ID_USB_HP_CAN_TX                         19    /* USB High Priority or CAN TX Interrupts               */
  86. #define  BSP_INT_ID_USB_LP_CAN_RX0                        20    /* USB Low Priority or CAN RX0 Interrupts               */
  87. #define  BSP_INT_ID_CAN_RX1                               21    /* CAN RX1 Interrupt                                    */
  88. #define  BSP_INT_ID_CAN_SCE                               22    /* CAN SCE Interrupt                                    */
  89. #define  BSP_INT_ID_EXTI9_5                               23    /* External Line[9:5] Interrupts                        */
  90. #define  BSP_INT_ID_TIM1_BRK                              24    /* TIM1 Break Interrupt                                 */
  91. #define  BSP_INT_ID_TIM1_UP                               25    /* TIM1 Update Interrupt                                */
  92. #define  BSP_INT_ID_TIM1_TRG_COM                          26    /* TIM1 Trigger and Commutation Interrupt               */
  93. #define  BSP_INT_ID_TIM1_CC                               27    /* TIM1 Capture Compare Interrupt                       */
  94. #define  BSP_INT_ID_TIM2                                  28    /* TIM2 global Interrupt                                */
  95. #define  BSP_INT_ID_TIM3                                  29    /* TIM3 global Interrupt                                */
  96. #define  BSP_INT_ID_TIM4                                  30    /* TIM4 global Interrupt                                */
  97. #define  BSP_INT_ID_I2C1_EV                               31    /* I2C1 Event Interrupt                                 */
  98. #define  BSP_INT_ID_I2C1_ER                               32    /* I2C1 Error Interrupt                                 */
  99. #define  BSP_INT_ID_I2C2_EV                               33    /* I2C2 Event Interrupt                                 */
  100. #define  BSP_INT_ID_I2C2_ER                               34    /* I2C2 Error Interrupt                                 */
  101. #define  BSP_INT_ID_SPI1                                  35    /* SPI1 global Interrupt                                */
  102. #define  BSP_INT_ID_SPI2                                  36    /* SPI2 global Interrupt                                */
  103. #define  BSP_INT_ID_USART1                                37    /* USART1 global Interrupt                              */
  104. #define  BSP_INT_ID_USART2                                38    /* USART2 global Interrupt                              */
  105. #define  BSP_INT_ID_USART3                                39    /* USART3 global Interrupt                              */
  106. #define  BSP_INT_ID_EXTI15_10                             40    /* External Line[15:10] Interrupts                      */
  107. #define  BSP_INT_ID_RTCAlarm                              41    /* RTC Alarm through EXTI Line Interrupt                */
  108. #define  BSP_INT_ID_USBWakeUp                             42    /* USB WakeUp from suspend through EXTI Line Interrupt  */
  109. #define  BSP_INT_ID_TIM8_BRK                              43    /* TIM8 Break Interrupt                                 */
  110. #define  BSP_INT_ID_TIM8_UP                               44    /* TIM8 Update Interrupt                                */
  111. #define  BSP_INT_ID_TIM8_TRG_COM                          45    /* TIM8 Trigger and Commutation Interrupt               */
  112. #define  BSP_INT_ID_TIM8_CC                               46    /* TIM8 Capture Compare Interrupt                       */
  113. #define  BSP_INT_ID_ADC3                                  47    /* ADC3 global Interrupt                                */
  114. #define  BSP_INT_ID_FSMC                                  48    /* FSMC global Interrupt                                */
  115. #define  BSP_INT_ID_SDIO                                  49    /* SDIO global Interrupt                                */
  116. #define  BSP_INT_ID_TIM5                                  50    /* TIM5 global Interrupt                                */
  117. #define  BSP_INT_ID_SPI3                                  51    /* SPI3 global Interrupt                                */
  118. #define  BSP_INT_ID_UART4                                 52    /* UART4 global Interrupt                               */
  119. #define  BSP_INT_ID_UART5                                 53    /* UART5 global Interrupt                               */
  120. #define  BSP_INT_ID_TIM6                                  54    /* TIM6 global Interrupt                                */
  121. #define  BSP_INT_ID_TIM7                                  55    /* TIM7 global Interrupt                                */
  122. #define  BSP_INT_ID_DMA2_CH1                              56    /* DMA2 Channel 1 global Interrupt                      */
  123. #define  BSP_INT_ID_DMA2_CH2                              57    /* DMA2 Channel 2 global Interrupt                      */
  124. #define  BSP_INT_ID_DMA2_CH3                              58    /* DMA2 Channel 3 global Interrupt                      */
  125. #define  BSP_INT_ID_DMA2_CH4_5                            59    /* DMA2 Channel 4 and DMA2 Channel 5 global Interrupt   */
  126. /*
  127. *********************************************************************************************************
  128. *                                             PERIPH DEFINES
  129. *********************************************************************************************************
  130. */
  131. #define  BSP_PERIPH_ID_DMA1                                0
  132. #define  BSP_PERIPH_ID_DMA2                                1
  133. #define  BSP_PERIPH_ID_SRAM                                2
  134. #define  BSP_PERIPH_ID_FLITF                               4
  135. #define  BSP_PERIPH_ID_CRC                                 6
  136. #define  BSP_PERIPH_ID_FSMC                                8
  137. #define  BSP_PERIPH_ID_SDIO                               10
  138. #define  BSP_PERIPH_ID_AFIO                               32
  139. #define  BSP_PERIPH_ID_IOPA                               34
  140. #define  BSP_PERIPH_ID_IOPB                               35
  141. #define  BSP_PERIPH_ID_IOPC                               36
  142. #define  BSP_PERIPH_ID_IOPD                               37
  143. #define  BSP_PERIPH_ID_IOPE                               38
  144. #define  BSP_PERIPH_ID_IOPF                               39
  145. #define  BSP_PERIPH_ID_IOPG                               40
  146. #define  BSP_PERIPH_ID_ADC1                               41
  147. #define  BSP_PERIPH_ID_ADC2                               42
  148. #define  BSP_PERIPH_ID_TIM1                               43
  149. #define  BSP_PERIPH_ID_SPI1                               44
  150. #define  BSP_PERIPH_ID_TIM8                               45
  151. #define  BSP_PERIPH_ID_USART1                             46
  152. #define  BSP_PERIPH_ID_ADC3                               47
  153. #define  BSP_PERIPH_ID_TIM2                               64
  154. #define  BSP_PERIPH_ID_TIM3                               65
  155. #define  BSP_PERIPH_ID_TIM4                               66
  156. #define  BSP_PERIPH_ID_TIM5                               67
  157. #define  BSP_PERIPH_ID_TIM6                               68
  158. #define  BSP_PERIPH_ID_TIM7                               69
  159. #define  BSP_PERIPH_ID_WWDG                               75
  160. #define  BSP_PERIPH_ID_SPI2                               78
  161. #define  BSP_PERIPH_ID_SPI3                               79
  162. #define  BSP_PERIPH_ID_USART2                             81
  163. #define  BSP_PERIPH_ID_USART3                             82
  164. #define  BSP_PERIPH_ID_USART4                             83
  165. #define  BSP_PERIPH_ID_USART5                             84
  166. #define  BSP_PERIPH_ID_I2C1                               85
  167. #define  BSP_PERIPH_ID_I2C2                               86
  168. #define  BSP_PERIPH_ID_USB                                87
  169. #define  BSP_PERIPH_ID_CAN                                89
  170. #define  BSP_PERIPH_ID_BKP                                91
  171. #define  BSP_PERIPH_ID_PWR                                92
  172. #define  BSP_PERIPH_ID_DAC                                93
  173. /*
  174. *********************************************************************************************************
  175. *                                               DATA TYPES
  176. *********************************************************************************************************
  177. */
  178. /*
  179. *********************************************************************************************************
  180. *                                            GLOBAL VARIABLES
  181. *********************************************************************************************************
  182. */
  183. /*
  184. *********************************************************************************************************
  185. *                                                 MACRO'S
  186. *********************************************************************************************************
  187. */
  188. /*
  189. *********************************************************************************************************
  190. *                                           FUNCTION PROTOTYPES
  191. *********************************************************************************************************
  192. */
  193. void         BSP_Init                    (void);
  194. void         BSP_IntDisAll               (void);
  195. CPU_INT32U   BSP_CPU_ClkFreq             (void);
  196. /*
  197. *********************************************************************************************************
  198. *                                           INTERRUPT SERVICES
  199. *********************************************************************************************************
  200. */
  201. void         BSP_IntInit                 (void);
  202. void         BSP_IntEn                   (CPU_DATA       int_id);
  203. void         BSP_IntDis                  (CPU_DATA       int_id);
  204. void         BSP_IntClr                  (CPU_DATA       int_id);
  205. void         BSP_IntVectSet              (CPU_DATA       int_id,
  206.                                           CPU_FNCT_VOID  isr);
  207. void         BSP_IntPrioSet              (CPU_DATA       int_id,
  208.                                           CPU_INT08U     prio);
  209. void         BSP_IntHandlerWWDG          (void);
  210. void         BSP_IntHandlerPVD           (void);
  211. void         BSP_IntHandlerTAMPER        (void);
  212. void         BSP_IntHandlerRTC           (void);
  213. void         BSP_IntHandlerFLASH         (void);
  214. void         BSP_IntHandlerRCC           (void);
  215. void         BSP_IntHandlerEXTI0         (void);
  216. void         BSP_IntHandlerEXTI1         (void);
  217. void         BSP_IntHandlerEXTI2         (void);
  218. void         BSP_IntHandlerEXTI3         (void);
  219. void         BSP_IntHandlerEXTI4         (void);
  220. void         BSP_IntHandlerDMA1_CH1      (void);
  221. void         BSP_IntHandlerDMA1_CH2      (void);
  222. void         BSP_IntHandlerDMA1_CH3      (void);
  223. void         BSP_IntHandlerDMA1_CH4      (void);
  224. void         BSP_IntHandlerDMA1_CH5      (void);
  225. void         BSP_IntHandlerDMA1_CH6      (void);
  226. void         BSP_IntHandlerDMA1_CH7      (void);
  227. void         BSP_IntHandlerADC1_2        (void);
  228. void         BSP_IntHandlerUSB_HP_CAN_TX (void);
  229. void         BSP_IntHandlerUSB_LP_CAN_RX0(void);
  230. void         BSP_IntHandlerCAN_RX1       (void);
  231. void         BSP_IntHandlerCAN_SCE       (void);
  232. void         BSP_IntHandlerEXTI9_5       (void);
  233. void         BSP_IntHandlerTIM1_BRK      (void);
  234. void         BSP_IntHandlerTIM1_UP       (void);
  235. void         BSP_IntHandlerTIM1_TRG_COM  (void);
  236. void         BSP_IntHandlerTIM1_CC       (void);
  237. void         BSP_IntHandlerTIM2          (void);
  238. void         BSP_IntHandlerTIM3          (void);
  239. void         BSP_IntHandlerTIM4          (void);
  240. void         BSP_IntHandlerI2C1_EV       (void);
  241. void         BSP_IntHandlerI2C1_ER       (void);
  242. void         BSP_IntHandlerI2C2_EV       (void);
  243. void         BSP_IntHandlerI2C2_ER       (void);
  244. void         BSP_IntHandlerSPI1          (void);
  245. void         BSP_IntHandlerSPI2          (void);
  246. void         BSP_IntHandlerUSART1        (void);
  247. void         BSP_IntHandlerUSART2        (void);
  248. void         BSP_IntHandlerUSART3        (void);
  249. void         BSP_IntHandlerEXTI15_10     (void);
  250. void         BSP_IntHandlerRTCAlarm      (void);
  251. void         BSP_IntHandlerUSBWakeUp     (void);
  252. /*
  253. *********************************************************************************************************
  254. *                                     PERIPHERAL POWER/CLOCK SERVICES
  255. *********************************************************************************************************
  256. */
  257. CPU_INT32U   BSP_PeriphClkFreqGet        (CPU_DATA       pwr_clk_id);
  258. void         BSP_PeriphEn                (CPU_DATA       pwr_clk_id);
  259. void         BSP_PeriphDis               (CPU_DATA       pwr_clk_id);
  260. /*
  261. *********************************************************************************************************
  262. *                                              LED SERVICES
  263. *********************************************************************************************************
  264. */
  265. void         BSP_LED_On                  (CPU_INT08U     led);
  266. void         BSP_LED_Off                 (CPU_INT08U     led);
  267. void         BSP_LED_Toggle              (CPU_INT08U     led);
  268. /*
  269. *********************************************************************************************************
  270. *                                              ADC SERVICES
  271. *********************************************************************************************************
  272. */
  273. CPU_INT16U   BSP_ADC_GetStatus           (CPU_INT08U     led);
  274. /*
  275. *********************************************************************************************************
  276. *                                               MODULE END
  277. *********************************************************************************************************
  278. */
  279. #define ADC1_DR_Address  ((INT32U)0x4001244C)
  280. #define ADC_RCVTab_SIZE  8
  281. #define ADC_CONV_COUNT  10
  282. #define ADC_NICK 0
  283. #define ADC_ROLL 1
  284. #define ADC_GIER 2
  285. #define ADC_ACCX 3
  286. #define ADC_ACCY 4
  287. #define ADC_ACCZ 5
  288. BSP_EXT OS_EVENT        *App_ADCSem;
  289. BSP_EXT DMA_InitTypeDef  DMA_InitStructure;
  290. BSP_EXT ADC_InitTypeDef ADC_InitStructure;
  291. BSP_EXT INT16U  ADC_RCVTab[ADC_RCVTab_SIZE];
  292. BSP_EXT INT8U ADC_CurConvCount;
  293. BSP_EXT INT32S  ADC_ValueMux[ADC_RCVTab_SIZE]; 
  294. BSP_EXT INT32S ADC_Mittelwert[ADC_RCVTab_SIZE];
  295. BSP_EXT INT32S ADC_Neutral[ADC_RCVTab_SIZE];
  296. #if (DEBUG_MODULE == DEF_ENABLED)
  297. #ifdef __GNUC__
  298.   /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
  299.      set to 'Yes') calls __io_putchar() */
  300.   #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
  301. #else
  302.   #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
  303. #endif /* __GNUC__ */
  304. #endif
  305. #endif                                                          /* End of module include.                               */