Advertisement
Guest User

compas2

a guest
May 24th, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.29 KB | None | 0 0
  1. #include <stm32f10x.h>
  2.  
  3. #ifndef  DWLOS_CONFIG_H
  4. #define  DWLOS_CONFIG_H
  5.  
  6. //===============================================================================
  7. // MK Bus Speed
  8. //===============================================================================
  9. #define  DWLOS_TIM_PRESCALER        72000
  10. #define  PCLK1              36000000
  11. #define  PCLK2              72000000
  12.  
  13.  
  14. //===============================================================================
  15. // Queue's size
  16. //===============================================================================
  17. #define  Task_Turn_Size         30
  18. #define  Timer_Turn_Size        30
  19.  
  20.  
  21. //===============================================================================
  22. // LOG Configuration
  23. //===============================================================================
  24. #define  LOG_ACTIVE         1
  25. #define  LOG_DL_INTERVAL        250
  26. #define  LOG_ARR_SIZE           200
  27.  
  28.  
  29. //===============================================================================
  30. // USART1 Configuration
  31. //===============================================================================
  32. #define  USART1_RX_BUFFER_SIZE      7
  33. #define  USART1_TX_BUFFER_SIZE      40
  34.  
  35.  
  36. //===============================================================================
  37. // I2C Configuration
  38. //===============================================================================
  39. #define  I2C1_STATUS            0
  40. #define  I2C1_MODE          I2C_MODE_FAST
  41. #define  I2C1_SPEED             300000
  42. #define  I2C1_MY_ADRESS         0x05
  43. #define  I2C1_M_TX_BUFFER_SIZE      5
  44. #define  I2C1_M_RX_BUFFER_SIZE      10
  45. #define  I2C1_S_TX_BUFFER_SIZE      0
  46. #define  I2C1_S_RX_BUFFER_SIZE      0
  47.  
  48. #define  I2C2_STATUS            0
  49. #define  I2C2_MODE          I2C_MODE_FAST
  50. #define  I2C2_SPEED             400000
  51. #define  I2C2_MY_ADRESS         0x00
  52. #define  I2C2_M_TX_BUFFER_SIZE      0
  53. #define  I2C2_M_RX_BUFFER_SIZE      0
  54. #define  I2C2_S_TX_BUFFER_SIZE      0
  55. #define  I2C2_S_RX_BUFFER_SIZE      0
  56.  
  57.  
  58. //===============================================================================
  59. // DWLOS Status
  60. //===============================================================================
  61. #define  TASK_OVERFLOW          '$'
  62. #define  TIMER_OVERFLOW         '#'
  63. #define  IWG_RELOAD             'W'
  64.  
  65. #define  PROG_START             'O'
  66. #define  RUN_OS             'S'
  67. #define  STOP_OS            's'
  68.  
  69. #define  LCD_INIT_BEGIN         'w'
  70. #define  LCD_INIT_END           'W'
  71.  
  72. #define  I2C_INTERRUPT          'I'
  73. #define  I2C_TRANSMIT           'T'
  74. #define  I2C_MEM_ADR_TRANSMIT       'M'
  75. #define  I2C_FIRST_BYTE_TRANSMIT    'F'
  76. #define  I2C_BYTE_TRANSMITTING      'B'
  77. #define  I2C_BYTE_TRANSMITTED       'b'
  78.  
  79. #define  I2C_RECEIVE            'R'
  80. #define  I2C_RECEIVE_BEGIN      'r'
  81. #define  I2C_RECEIVE_BYTE       'c'
  82. #define  I2C_RECEIVE_END        'q'
  83. #define  I2C_ASC_OFF            'a'
  84.  
  85. #define  I2C_END            'X'
  86. #define  I2C_ERROR          'V'
  87. #define  I2C_DEFAULT            'd'
  88.  
  89. #define  DMA1_RX            'D'
  90.  
  91.  
  92.  
  93. //===============================================================================
  94. // LED Pins
  95. //===============================================================================
  96. #define  LED1_RCC           RCC_APB2ENR_IOPBEN
  97. #define  LED1_GPIO          GPIOB -> CRL
  98. #define  LED1_CNF           GPIO_CRL_CNF0_1 | GPIO_CRL_CNF0_0
  99. #define  LED1_MODE          GPIO_CRL_MODE0_1 | GPIO_CRL_MODE0_0
  100. #define  LED1_ON            GPIOB -> BSRR |= GPIO_BSRR_BS0
  101. #define  LED1_OFF           GPIOB -> BSRR |= GPIO_BSRR_BR0
  102.  
  103.  
  104. #define  LED2_RCC           RCC_APB2ENR_IOPBEN
  105. #define  LED2_GPIO          GPIOB -> CRL
  106. #define  LED2_CNF           GPIO_CRL_CNF1_1 | GPIO_CRL_CNF1_0
  107. #define  LED2_MODE          GPIO_CRL_MODE1_1 | GPIO_CRL_MODE1_0
  108. #define  LED2_ON            GPIOB -> BSRR |= GPIO_BSRR_BS1
  109. #define  LED2_OFF           GPIOB -> BSRR |= GPIO_BSRR_BR1
  110.  
  111.  
  112. #define  LED3_RCC           RCC_APB2ENR_IOPCEN
  113. #define  LED3_GPIO          GPIOC -> CRL
  114. #define  LED3_CNF           GPIO_CRL_CNF5_1 | GPIO_CRL_CNF5_0
  115. #define  LED3_MODE          GPIO_CRL_MODE5_1 | GPIO_CRL_MODE5_0
  116. #define  LED3_ON            GPIOC -> BSRR |= GPIO_BSRR_BS5
  117. #define  LED3_OFF           GPIOC -> BSRR |= GPIO_BSRR_BR5
  118.  
  119.  
  120. #define  LED4_RCC           RCC_APB2ENR_IOPCEN
  121. #define  LED4_GPIO          GPIOC -> CRL
  122. #define  LED4_CNF           GPIO_CRL_CNF4_1 | GPIO_CRL_CNF4_0
  123. #define  LED4_MODE          GPIO_CRL_MODE4_1 | GPIO_CRL_MODE4_0
  124. #define  LED4_ON            GPIOC -> BSRR |= GPIO_BSRR_BS4
  125. #define  LED4_OFF           GPIOC -> BSRR |= GPIO_BSRR_BR4
  126.  
  127.  
  128. //===============================================================================
  129. // LCD WH1602 Pins
  130. //===============================================================================
  131. // pin 4 [RS]
  132. #define  CMD_RS_GPIO            GPIOC
  133. #define  CMD_RS_CR          CRL
  134. #define  CMD_RS_RCC             RCC_APB2ENR_IOPCEN
  135. #define  CMD_RS_CNF             GPIO_CRL_CNF0
  136. #define  CMD_RS_MODE            GPIO_CRL_MODE0_0
  137. #define  CMD_RS_SET             GPIO_BSRR_BS0
  138. #define  CMD_RS_RESET           GPIO_BSRR_BR0
  139.  
  140. // pin 5 [RW]
  141. #define  CMD_RW_GPIO            GPIOC
  142. #define  CMD_RW_CR          CRL
  143. #define  CMD_RW_RCC             RCC_APB2ENR_IOPCEN
  144. #define  CMD_RW_CNF             GPIO_CRL_CNF1
  145. #define  CMD_RW_MODE            GPIO_CRL_MODE1_0
  146. #define  CMD_RW_SET             GPIO_BSRR_BS1
  147. #define  CMD_RW_RESET           GPIO_BSRR_BR1
  148.  
  149. // pin 6 [EN]
  150. #define  CMD_EN_GPIO            GPIOC
  151. #define  CMD_EN_CR          CRL
  152. #define  CMD_EN_RCC             RCC_APB2ENR_IOPCEN
  153. #define  CMD_EN_CNF             GPIO_CRL_CNF2
  154. #define  CMD_EN_MODE            GPIO_CRL_MODE2_0
  155. #define  CMD_EN_SET             GPIO_BSRR_BS2
  156. #define  CMD_EN_RESET           GPIO_BSRR_BR2
  157.  
  158.  
  159. // pin 7 [DATA0]
  160. #define  CMD_D0_GPIO            GPIOB
  161. #define  CMD_D0_CR          CRH
  162. #define  CMD_D0_RCC             RCC_APB2ENR_IOPBEN
  163. #define  CMD_D0_CNF             GPIO_CRH_CNF12
  164. #define  CMD_D0_MODE            GPIO_CRH_MODE12_0
  165. #define  CMD_D0_SET             GPIO_BSRR_BS12
  166. #define  CMD_D0_RESET           GPIO_BSRR_BR12
  167.  
  168. // pin 8 [DATA1]
  169. #define  CMD_D1_GPIO            GPIOB
  170. #define  CMD_D1_CR          CRH
  171. #define  CMD_D1_RCC             RCC_APB2ENR_IOPBEN
  172. #define  CMD_D1_CNF             GPIO_CRH_CNF14
  173. #define  CMD_D1_MODE            GPIO_CRH_MODE14_0
  174. #define  CMD_D1_SET             GPIO_BSRR_BS14
  175. #define  CMD_D1_RESET           GPIO_BSRR_BR14
  176.  
  177. // pin 9 [DATA2]
  178. #define  CMD_D2_GPIO            GPIOC
  179. #define  CMD_D2_CR          CRL
  180. #define  CMD_D2_RCC             RCC_APB2ENR_IOPCEN
  181. #define  CMD_D2_CNF             GPIO_CRL_CNF6
  182. #define  CMD_D2_MODE            GPIO_CRL_MODE6_0
  183. #define  CMD_D2_SET             GPIO_BSRR_BS6
  184. #define  CMD_D2_RESET           GPIO_BSRR_BR6
  185.  
  186. // pin 10 [DATA3]
  187. #define  CMD_D3_GPIO            GPIOC
  188. #define  CMD_D3_CR          CRH
  189. #define  CMD_D3_RCC             RCC_APB2ENR_IOPCEN
  190. #define  CMD_D3_CNF             GPIO_CRH_CNF8
  191. #define  CMD_D3_MODE            GPIO_CRH_MODE8_0
  192. #define  CMD_D3_SET             GPIO_BSRR_BS8
  193. #define  CMD_D3_RESET           GPIO_BSRR_BR8
  194.  
  195. // pin 11 [DATA4]
  196. #define  CMD_D4_GPIO            GPIOC
  197. #define  CMD_D4_CR          CRH
  198. #define  CMD_D4_RCC             RCC_APB2ENR_IOPCEN
  199. #define  CMD_D4_CNF             GPIO_CRH_CNF9
  200. #define  CMD_D4_MODE            GPIO_CRH_MODE9_0
  201. #define  CMD_D4_SET             GPIO_BSRR_BS9
  202. #define  CMD_D4_RESET           GPIO_BSRR_BR9
  203.  
  204. // pin 12 [DATA5]
  205. #define  CMD_D5_GPIO            GPIOC
  206. #define  CMD_D5_CR          CRL
  207. #define  CMD_D5_RCC             RCC_APB2ENR_IOPCEN
  208. #define  CMD_D5_CNF             GPIO_CRL_CNF7
  209. #define  CMD_D5_MODE            GPIO_CRL_MODE7_0
  210. #define  CMD_D5_SET             GPIO_BSRR_BS7
  211. #define  CMD_D5_RESET           GPIO_BSRR_BR7
  212.  
  213. // pin 13 [DATA6]
  214. #define  CMD_D6_GPIO            GPIOB
  215. #define  CMD_D6_CR          CRH
  216. #define  CMD_D6_RCC             RCC_APB2ENR_IOPBEN
  217. #define  CMD_D6_CNF             GPIO_CRH_CNF15
  218. #define  CMD_D6_MODE            GPIO_CRH_MODE15_0
  219. #define  CMD_D6_SET             GPIO_BSRR_BS15
  220. #define  CMD_D6_RESET           GPIO_BSRR_BR15
  221.  
  222. // pin 14 [DATA7]
  223. #define  CMD_D7_GPIO            GPIOB
  224. #define  CMD_D7_CR          CRH
  225. #define  CMD_D7_RCC             RCC_APB2ENR_IOPBEN
  226. #define  CMD_D7_CNF             GPIO_CRH_CNF13
  227. #define  CMD_D7_MODE            GPIO_CRH_MODE13_0
  228. #define  CMD_D7_SET             GPIO_BSRR_BS13
  229. #define  CMD_D7_RESET           GPIO_BSRR_BR13
  230.  
  231.  
  232. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement