PageRenderTime 24ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/drivers/boards/esc35-v1/board_config.h

https://bitbucket.org/VitalyGrachev/firmware
C Header | 282 lines | 59 code | 44 blank | 179 comment | 6 complexity | c33d0715b76bfc18ae2ccee773bbdd27 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /****************************************************************************
  2. *
  3. * Copyright (c) 2012-2016 PX4 Development Team. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. * 3. Neither the name PX4 nor the names of its contributors may be
  16. * used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  29. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. ****************************************************************************/
  33. /**
  34. * @file board_config.h
  35. *
  36. * ESC35v1 internal definitions
  37. */
  38. #pragma once
  39. /****************************************************************************************************
  40. * Included Files
  41. ****************************************************************************************************/
  42. #include <px4_config.h>
  43. #include <nuttx/compiler.h>
  44. #include <stdint.h>
  45. /************************************************************************************
  46. * Definitions
  47. ************************************************************************************/
  48. #if STM32_NSPI < 1
  49. # undef CONFIG_STM32_SPI1
  50. # undef CONFIG_STM32_SPI2
  51. #elif STM32_NSPI < 2
  52. # undef CONFIG_STM32_SPI2
  53. #endif
  54. /* High-resolution timer
  55. */
  56. #define HRT_TIMER 3 /* use timer1 for the HRT */
  57. #define HRT_TIMER_CHANNEL 1 /* use capture/compare channel */
  58. /* GPIO ***********************************************************************
  59. *
  60. * GPIO Function MPU Board
  61. * Pin # Name
  62. * -- ----- -------------------------------- ----------------------
  63. *
  64. * PB[6] PB06 42 nCAN_SILENT
  65. */
  66. #define GPIO_CAN_SILENT (GPIO_OUTPUT | GPIO_PUSHPULL | \
  67. GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_CLEAR)
  68. #define GPIO_RC_PWM (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTA | GPIO_PIN0)
  69. #define GPIO_OC_ADJ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  70. GPIO_PORTA | GPIO_PIN4 | GPIO_OUTPUT_CLEAR)
  71. #define GPIO_EN_GATE (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  72. GPIO_PORTA | GPIO_PIN5 | GPIO_OUTPUT_CLEAR)
  73. #define GPIO_DC_CAL (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  74. GPIO_PORTA | GPIO_PIN6 | GPIO_OUTPUT_CLEAR)
  75. /* CAN ************************************************************************ *
  76. *
  77. * GPIO Function MPU Board
  78. * Pin # Name
  79. * -- ----- -------------------------------- ------------------------
  80. *
  81. * PB[8] PB8/CAN_RX 45 CAN_RX
  82. * PB[9] PB9/CAN_TX 46 CAN_TX
  83. *
  84. */
  85. #define GPIO_CAN1_RX GPIO_CAN_RX_3
  86. #define GPIO_CAN1_TX GPIO_CAN_TX_3
  87. /* Analog ***********************************************************************
  88. *
  89. * GPIO Function MPU Board
  90. * Pin # Name
  91. * -- ----- -------------------------------- ----------------------
  92. *
  93. * PC[00] PC0/ADC123_IN10 8 TEMP_SENS
  94. * PC[01] PC1/ADC123_IN11/SPI3_MOSI/SPI2_MOSI 9 VBAT_SENS
  95. * PC[02] PC2/ADC123_IN12/SPI2_MISO, 10 CURR_SENS2
  96. * PC[03] PC3/ADC123_IN13/SPI2_MOSI 11 CURR_SENS1
  97. *
  98. */
  99. /* LEDs ***********************************************************************
  100. *
  101. * GPIO Function MPU Board
  102. * Pin # Name
  103. * -- ----- -------------------------------- ----------------------
  104. *
  105. * PC[07] PC7/TIM3_CH2/TIM8_CH2 38 LED_RED
  106. * PC[08] PC8/TIM3_CH3/TIM8_CH3 39 LED_GREEN
  107. * PC[09] PC9/TIM3_CH4/TIM8_CH4 40 LED_BLUE
  108. */
  109. #define GPIO_LED1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  110. GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR)
  111. #define GPIO_LED_RED GPIO_LED1
  112. #define GPIO_LED2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  113. GPIO_PORTA | GPIO_PIN3 | GPIO_OUTPUT_CLEAR)
  114. #define GPIO_LED_GREEN GPIO_LED2
  115. #define GPIO_LED3 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
  116. GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_CLEAR)
  117. #define GPIO_LED_BLUE GPIO_LED3
  118. #define BOARD_NAME "ESC35_V1"
  119. __BEGIN_DECLS
  120. /************************************************************************************
  121. * Public Types
  122. ************************************************************************************/
  123. /************************************************************************************
  124. * Public data
  125. ************************************************************************************/
  126. #ifndef __ASSEMBLY__
  127. /************************************************************************************
  128. * Public Functions
  129. ************************************************************************************/
  130. /************************************************************************************
  131. * Name: stm32_spiinitialize
  132. *
  133. * Description:
  134. * Called to configure SPI chip select GPIO pins.
  135. *
  136. ************************************************************************************/
  137. #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || \
  138. defined(CONFIG_STM32_SPI3)
  139. void weak_function board_spiinitialize(void);
  140. #endif
  141. /************************************************************************************
  142. * Name: stm32_usbinitialize
  143. *
  144. * Description:
  145. * Called to setup USB-related GPIO pins.
  146. *
  147. ************************************************************************************/
  148. void stm32_usbinitialize(void);
  149. /************************************************************************************
  150. * Name: stm32_usb_set_pwr_callback()
  151. *
  152. * Description:
  153. * Called to setup set a call back for USB power state changes.
  154. *
  155. * Inputs:
  156. * pwr_changed_handler: An interrupt handler that will be called on VBUS power
  157. * state changes.
  158. *
  159. ************************************************************************************/
  160. void stm32_usb_set_pwr_callback(xcpt_t pwr_changed_handler);
  161. /****************************************************************************
  162. * Name: stm32_led_initialize
  163. *
  164. * Description:
  165. * This functions is called very early in initialization to perform board-
  166. * specific initialization of LED-related resources. This includes such
  167. * things as, for example, configure GPIO pins to drive the LEDs and also
  168. * putting the LEDs in their correct initial state.
  169. *
  170. * NOTE: In most architectures, LED initialization() is called from
  171. * board-specific initialization and should, therefore, have the name
  172. * <arch>_led_intialize(). But there are a few architectures where the
  173. * LED initialization function is still called from common chip
  174. * architecture logic. This interface is not, however, a common board
  175. * interface in any event and the name board_autoled_initialization is
  176. * deprecated.
  177. *
  178. * Input Parameters:
  179. * None
  180. *
  181. * Returned Value:
  182. * None
  183. *
  184. ****************************************************************************/
  185. #ifdef CONFIG_ARCH_LEDS
  186. void board_autoled_initialize(void);
  187. #endif
  188. /************************************************************************************
  189. * Name: stm32_can_initialize
  190. *
  191. * Description:
  192. * Called at application startup time to initialize the CAN functionality.
  193. *
  194. ************************************************************************************/
  195. #if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
  196. int board_can_initialize(void);
  197. #endif
  198. /************************************************************************************
  199. * Name: board_button_initialize
  200. *
  201. * Description:
  202. * Called at application startup time to initialize the Buttons functionality.
  203. *
  204. ************************************************************************************/
  205. #if defined(CONFIG_ARCH_BUTTONS)
  206. void board_button_initialize(void);
  207. #endif
  208. /****************************************************************************
  209. * Name: usbmsc_archinitialize
  210. *
  211. * Description:
  212. * Called from the application system/usbmc or the boards_nsh if the
  213. * application is not included.
  214. * Perform architecture specific initialization. This function must
  215. * configure the block device to export via USB. This function must be
  216. * provided by architecture-specific logic in order to use this add-on.
  217. *
  218. ****************************************************************************/
  219. #if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_SYSTEM_USBMSC)
  220. int usbmsc_archinitialize(void);
  221. #endif
  222. /****************************************************************************
  223. * Name: composite_archinitialize
  224. *
  225. * Description:
  226. * Called from the application system/composite or the boards_nsh if the
  227. * application is not included.
  228. * Perform architecture specific initialization. This function must
  229. * configure the block device to export via USB. This function must be
  230. * provided by architecture-specific logic in order to use this add-on.
  231. *
  232. ****************************************************************************/
  233. #if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_SYSTEM_COMPOSITE)
  234. extern int composite_archinitialize(void);
  235. #endif
  236. #include "../common/board_common.h"
  237. #endif /* __ASSEMBLY__ */
  238. __END_DECLS