PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/stm3210e-eval/src/stm3210e-eval.h

https://bitbucket.org/sanyaade/nuttx_boards
C Header | 346 lines | 99 code | 66 blank | 181 comment | 4 complexity | 9628bcc2bf5c75fa1e58f010ee9e307f MD5 | raw file
  1. /************************************************************************************
  2. * configs/stm3210e_eval/src/stm3210e-eval.h
  3. *
  4. * Copyright (C) 2009 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ************************************************************************************/
  35. #ifndef __CONFIGS_STM3210E_EVAL_SRC_STM3210E_EVAL_H
  36. #define __CONFIGS_STM3210E_EVAL_SRC_STM3210E_EVAL_H
  37. /************************************************************************************
  38. * Included Files
  39. ************************************************************************************/
  40. #include <nuttx/config.h>
  41. #include <nuttx/compiler.h>
  42. #include <stdint.h>
  43. /************************************************************************************
  44. * Pre-processor Definitions
  45. ************************************************************************************/
  46. /* How many SPI modules does this chip support? Most support 2 SPI modules (others
  47. * may support more -- in such case, the following must be expanded).
  48. */
  49. #if STM32_NSPI < 1
  50. # undef CONFIG_STM32_SPI1
  51. # undef CONFIG_STM32_SPI2
  52. #elif STM32_NSPI < 2
  53. # undef CONFIG_STM32_SPI2
  54. #endif
  55. /* There is only CAN1 on the STM3210E-EVAL board */
  56. #if defined(CONFIG_STM32_CAN2)
  57. # warning "The STM3210E-EVAL only supports CAN1"
  58. #endif
  59. /* Do we need to register I2C drivers on behalf of the I2C tool? */
  60. #define HAVE_I2CTOOL 1
  61. #if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
  62. # undef HAVE_I2CTOOL
  63. #endif
  64. /* STM3210E-EVAL GPIOs **************************************************************/
  65. /* LEDs */
  66. #define GPIO_LED1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  67. GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN6)
  68. #define GPIO_LED2 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  69. GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN7)
  70. #define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  71. GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN8)
  72. #define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  73. GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN9)
  74. /* BUTTONS -- NOTE that some have EXTI interrupts configured */
  75. #ifdef CONFIG_DJOYSTICK
  76. # define MIN_IRQBUTTON BUTTON_KEY
  77. # define MAX_IRQBUTTON BUTTON_KEY
  78. # define NUM_IRQBUTTONS (1)
  79. #else
  80. # define MIN_IRQBUTTON BUTTON_KEY
  81. # define MAX_IRQBUTTON JOYSTICK_UP
  82. # define NUM_IRQBUTTONS (JOYSTICK_UP - BUTTON_KEY + 1)
  83. #endif
  84. #define GPIO_BTN_WAKEUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  85. GPIO_PORTA|GPIO_PIN0)
  86. #define GPIO_BTN_TAMPER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  87. GPIO_PORTC|GPIO_PIN13)
  88. #define GPIO_BTN_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  89. GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
  90. #define GPIO_JOY_SEL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  91. GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
  92. #define GPIO_JOY_DOWN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  93. GPIO_EXTI|GPIO_PORTD|GPIO_PIN3)
  94. #define GPIO_JOY_LEFT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  95. GPIO_EXTI|GPIO_PORTG|GPIO_PIN14)
  96. #define GPIO_JOY_RIGHT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  97. GPIO_EXTI|GPIO_PORTG|GPIO_PIN13)
  98. #define GPIO_JOY_UP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
  99. GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
  100. /* SPI FLASH chip select: PA.4 */
  101. #define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  102. GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2)
  103. /* Backlight control: PA.8
  104. *
  105. * If CONFIG_LCD_TIM1 (and CONFIG_STM32_TIM1) is defined, PA.8 will be
  106. * configured as CH1OUT for variable backlight control. Otherwise, the
  107. * following definition will be used to support a discrete backlight control.
  108. */
  109. #define GPIO_LCD_BACKLIGHT (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
  110. GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN8)
  111. /* USB Soft Connect Pullup: PB.14 */
  112. #define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|\
  113. GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN14)
  114. /* LM-75 Temperature Sensor: PB.5 */
  115. #define GPIO_LM75_OSINT (GPIO_INPUT|GPIO_CNF_INPULLUP|GPIO_MODE_10MHz|\
  116. GPIO_EXTI|GPIO_PORTB|GPIO_PIN5)
  117. /************************************************************************************
  118. * Public Types
  119. ************************************************************************************/
  120. /* GPIO settings that will be altered when external memory is selected */
  121. struct extmem_save_s
  122. {
  123. uint32_t gpiod_crl;
  124. uint32_t gpiod_crh;
  125. uint32_t gpioe_crl;
  126. uint32_t gpioe_crh;
  127. uint32_t gpiof_crl;
  128. uint32_t gpiof_crh;
  129. uint32_t gpiog_crl;
  130. uint32_t gpiog_crh;
  131. };
  132. /************************************************************************************
  133. * Public data
  134. ************************************************************************************/
  135. #ifndef __ASSEMBLY__
  136. /* GPIO configurations common to SRAM and NOR Flash */
  137. #define NCOMMON_CONFIG 37
  138. extern const uint16_t g_commonconfig[NCOMMON_CONFIG];
  139. /************************************************************************************
  140. * Public Functions
  141. ************************************************************************************/
  142. /************************************************************************************
  143. * Name: stm32_spidev_initialize
  144. *
  145. * Description:
  146. * Called to configure SPI chip select GPIO pins for the STM3210E-EVAL board.
  147. *
  148. ************************************************************************************/
  149. void weak_function stm32_spidev_initialize(void);
  150. /************************************************************************************
  151. * Name: stm32_usbinitialize
  152. *
  153. * Description:
  154. * Called to setup USB-related GPIO pins for the STM3210E-EVAL board.
  155. *
  156. ************************************************************************************/
  157. void weak_function stm32_usbinitialize(void);
  158. /************************************************************************************
  159. * Name: stm32_extcontextsave
  160. *
  161. * Description:
  162. * Save current GPIOs that will used by external memory configurations
  163. *
  164. ************************************************************************************/
  165. #ifdef CONFIG_STM32_FSMC
  166. void stm32_extcontextsave(struct extmem_save_s *save);
  167. /************************************************************************************
  168. * Name: stm32_extcontextrestore
  169. *
  170. * Description:
  171. * Restore GPIOs that were used by external memory configurations
  172. *
  173. ************************************************************************************/
  174. void stm32_extcontextrestore(struct extmem_save_s *restore);
  175. /************************************************************************************
  176. * Name: stm32_extmemgpios
  177. *
  178. * Description:
  179. * Initialize GPIOs for NOR or SRAM
  180. *
  181. ************************************************************************************/
  182. void stm32_extmemgpios(const uint16_t *gpios, int ngpios);
  183. /************************************************************************************
  184. * Name: stm32_enablefsmc
  185. *
  186. * Description:
  187. * enable clocking to the FSMC module
  188. *
  189. ************************************************************************************/
  190. void stm32_enablefsmc(void);
  191. /************************************************************************************
  192. * Name: stm32_disablefsmc
  193. *
  194. * Description:
  195. * enable clocking to the FSMC module
  196. *
  197. ************************************************************************************/
  198. void stm32_disablefsmc(void);
  199. /************************************************************************************
  200. * Name: stm32_selectnor
  201. *
  202. * Description:
  203. * Initialize to access NOR flash
  204. *
  205. ************************************************************************************/
  206. void stm32_selectnor(void);
  207. /************************************************************************************
  208. * Name: stm32_deselectnor
  209. *
  210. * Description:
  211. * Disable NOR FLASH
  212. *
  213. ************************************************************************************/
  214. void stm32_deselectnor(void);
  215. /************************************************************************************
  216. * Name: stm32_selectsram
  217. *
  218. * Description:
  219. * Initialize to access external SRAM
  220. *
  221. ************************************************************************************/
  222. void stm32_selectsram(void);
  223. /************************************************************************************
  224. * Name: stm32_deselectsram
  225. *
  226. * Description:
  227. * Disable external SRAM
  228. *
  229. ************************************************************************************/
  230. void stm32_deselectsram(void);
  231. /************************************************************************************
  232. * Name: stm32_selectlcd
  233. *
  234. * Description:
  235. * Initialize to the LCD
  236. *
  237. ************************************************************************************/
  238. void stm32_selectlcd(void);
  239. /************************************************************************************
  240. * Name: stm32_deselectlcd
  241. *
  242. * Description:
  243. * Disable the LCD
  244. *
  245. ************************************************************************************/
  246. void stm32_deselectlcd(void);
  247. #endif /* CONFIG_STM32_FSMC */
  248. /************************************************************************************
  249. * Name: stm32_ledpminitialize
  250. *
  251. * Description:
  252. * Register the LEDs to receive power management event callbacks
  253. *
  254. ************************************************************************************/
  255. #if defined(CONFIG_PM) && defined(CONFIG_ARCH_LEDS)
  256. void stm32_ledpminitialize(void);
  257. #endif
  258. /************************************************************************************
  259. * Name: stm32_pmbuttons
  260. *
  261. * Description:
  262. * Configure all the buttons of the STM3210e-eval board as EXTI, so any button is
  263. * able to wakeup the MCU from the PM_STANDBY mode
  264. *
  265. ************************************************************************************/
  266. #if defined(CONFIG_PM) && defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
  267. void stm32_pmbuttons(void);
  268. #endif
  269. /****************************************************************************
  270. * Name: stm32_djoy_initialization
  271. *
  272. * Description:
  273. * Initialize and register the discrete joystick driver
  274. *
  275. ****************************************************************************/
  276. #ifdef CONFIG_DJOYSTICK
  277. int stm32_djoy_initialization(void);
  278. #endif
  279. #endif /* __ASSEMBLY__ */
  280. #endif /* __CONFIGS_STM3210E_EVAL_SRC_STM3210E_EVAL_H */