board.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /************************************************************************************
  2. * configs/lpcxpresso-lpc1768/include/board.h
  3. * include/arch/board/board.h
  4. *
  5. * Copyright (C) 2011 Gregory Nutt. All rights reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ************************************************************************************/
  36. #ifndef __ARCH_BOARD_BOARD_H
  37. #define __ARCH_BOARD_BOARD_H
  38. /************************************************************************************
  39. * Included Files
  40. ************************************************************************************/
  41. #include <nuttx/config.h>
  42. /************************************************************************************
  43. * Pre-processor Definitions
  44. ************************************************************************************/
  45. /* Clocking *************************************************************************/
  46. /* NOTE: The following definitions require lpc17_syscon.h. It is not included here
  47. * because the including C file may not have that file in its include path.
  48. */
  49. #define BOARD_XTAL_FREQUENCY (12000000) /* XTAL oscillator frequency */
  50. #define BOARD_OSCCLK_FREQUENCY BOARD_XTAL_FREQUENCY /* Main oscillator frequency */
  51. #define BOARD_RTCCLK_FREQUENCY (32768) /* RTC oscillator frequency */
  52. #define BOARD_INTRCOSC_FREQUENCY (4000000) /* Internal RC oscillator frequency */
  53. /* This is the clock setup we configure for:
  54. *
  55. * SYSCLK = BOARD_OSCCLK_FREQUENCY = 12MHz -> Select Main oscillator for source
  56. * PLL0CLK = (2 * 20 * SYSCLK) / 1 = 480MHz -> PLL0 multipler=20, pre-divider=1
  57. * CCLCK = 480MHz / 6 = 80MHz -> CCLK divider = 6
  58. */
  59. #define LPC17_CCLK 80000000 /* 80Mhz */
  60. /* Select the main oscillator as the frequency source. SYSCLK is then the frequency
  61. * of the main oscillator.
  62. */
  63. #undef CONFIG_LPC17_MAINOSC
  64. #define CONFIG_LPC17_MAINOSC 1
  65. #define BOARD_SCS_VALUE SYSCON_SCS_OSCEN
  66. /* Select the main oscillator and CCLK divider. The output of the divider is CCLK.
  67. * The input to the divider (PLLCLK) will be determined by the PLL output.
  68. */
  69. #define BOARD_CCLKCFG_DIVIDER 6
  70. #define BOARD_CCLKCFG_VALUE ((BOARD_CCLKCFG_DIVIDER-1) << SYSCON_CCLKCFG_SHIFT)
  71. /* PLL0. PLL0 is used to generate the CPU clock divider input (PLLCLK).
  72. *
  73. * Source clock: Main oscillator
  74. * PLL0 Multiplier value (M): 20
  75. * PLL0 Pre-divider value (N): 1
  76. *
  77. * PLL0CLK = (2 * 20 * SYSCLK) / 1 = 480MHz
  78. */
  79. #undef CONFIG_LPC17_PLL0
  80. #define CONFIG_LPC17_PLL0 1
  81. #define BOARD_CLKSRCSEL_VALUE SYSCON_CLKSRCSEL_MAIN
  82. #define BOARD_PLL0CFG_MSEL 20
  83. #define BOARD_PLL0CFG_NSEL 1
  84. #define BOARD_PLL0CFG_VALUE \
  85. (((BOARD_PLL0CFG_MSEL-1) << SYSCON_PLL0CFG_MSEL_SHIFT) | \
  86. ((BOARD_PLL0CFG_NSEL-1) << SYSCON_PLL0CFG_NSEL_SHIFT))
  87. /* PLL1 -- Not used. */
  88. #undef CONFIG_LPC17_PLL1
  89. #define BOARD_PLL1CFG_MSEL 36
  90. #define BOARD_PLL1CFG_NSEL 1
  91. #define BOARD_PLL1CFG_VALUE \
  92. (((BOARD_PLL1CFG_MSEL-1) << SYSCON_PLL1CFG_MSEL_SHIFT) | \
  93. ((BOARD_PLL1CFG_NSEL-1) << SYSCON_PLL1CFG_NSEL_SHIFT))
  94. /* USB divider. This divider is used when PLL1 is not enabled to get the
  95. * USB clock from PLL0:
  96. *
  97. * USBCLK = PLL0CLK / 10 = 48MHz
  98. */
  99. #define BOARD_USBCLKCFG_VALUE SYSCON_USBCLKCFG_DIV10
  100. /* FLASH Configuration */
  101. #undef CONFIG_LPC17_FLASH
  102. #define CONFIG_LPC17_FLASH 1
  103. #define BOARD_FLASHCFG_VALUE 0x0000303a
  104. /* Ethernet configuration */
  105. //#define ETH_MCFG_CLKSEL_DIV ETH_MCFG_CLKSEL_DIV44
  106. #define ETH_MCFG_CLKSEL_DIV ETH_MCFG_CLKSEL_DIV20
  107. /* LED definitions ******************************************************************/
  108. /* The LPCXpresso LPC1768 board has a single red LED (there are additional LEDs on
  109. * the base board not considered here).
  110. */
  111. /* ON OFF */
  112. #define LED_STARTED 0 /* OFF ON (never happens) */
  113. #define LED_HEAPALLOCATE 0 /* OFF ON (never happens) */
  114. #define LED_IRQSENABLED 0 /* OFF ON (never happens) */
  115. #define LED_STACKCREATED 1 /* ON ON (never happens) */
  116. #define LED_INIRQ 2 /* OFF NC (momentary) */
  117. #define LED_SIGNAL 2 /* OFF NC (momentary) */
  118. #define LED_ASSERTION 2 /* OFF NC (momentary) */
  119. #define LED_PANIC 0 /* OFF ON (1Hz flashing) */
  120. /* Alternate pin selections *********************************************************/
  121. /* Pin Description Connector On Board Base Board
  122. * -------------------------------- --------- -------------- ---------------------
  123. * P0[0]/RD1/TXD3/SDA1 J6-9 I2C E2PROM SDA TXD3/SDA1
  124. * P0[1]/TD1/RXD3/SCL J6-10 RXD3/SCL1
  125. * P0[2]/TXD0/AD0[7] J6-21
  126. * P0[3]/RXD0/AD0[6] J6-22
  127. * P0[4]/I2SRX-CLK/RD2/CAP2.0 J6-38 CAN_RX2
  128. * P0[5]/I2SRX-WS/TD2/CAP2.1 J6-39 CAN_TX2
  129. * P0[6]/I2SRX_SDA/SSEL1/MAT2[0] J6-8 SSEL1, OLED CS
  130. * P0[7]/I2STX_CLK/SCK1/MAT2[1] J6-7 SCK1, OLED SCK
  131. * P0[8]/I2STX_WS/MISO1/MAT2[2] J6-6 MISO1
  132. * P0[9]/I2STX_SDA/MOSI1/MAT2[3] J6-5 MOSI1, OLED data in
  133. * P0[10] J6-40 TXD2/SDA2
  134. * P0[11] J6-41 RXD2/SCL2
  135. * P0[15]/TXD1/SCK0/SCK J6-13 TXD1/SCK0
  136. * P0[16]/RXD1/SSEL0/SSEL J6-14 RXD1/SSEL0
  137. * P0[17]/CTS1/MISO0/MISO J6-12 MISO0
  138. * P0[18]/DCD1/MOSI0/MOSI J6-11 MOSI0
  139. * P0[19]/DSR1/SDA1 PAD17 N/A
  140. * P0[20]/DTR1/SCL1 PAD18 I2C E2PROM SCL N/A
  141. * P0[21]/RI1/MCIPWR/RD1 J6-23
  142. * P0[22]/RTS1/TD1 J6-24 LED
  143. * P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] J6-15 AD0.0
  144. * P0[24]/AD0[1]/I2SRX_WS/CAP3[1] J6-16 AD0.1
  145. * P0[25]/AD0[2]/I2SRX_SDA/TXD3 J6-17 AD0.2
  146. * P0[26]/AD0[3]/AOUT/RXD3 J6-18 AD0.3/AOUT / RGB LED
  147. * P0[27]/SDA0/USB_SDA J6-25
  148. * P0[28]/SCL0 J6-26
  149. * P0[29]/USB_D+ J6-37 USB_D+
  150. * P0[30]/USB_D- J6-36 USB_D-
  151. */
  152. #define GPIO_UART3_TXD GPIO_UART3_TXD_1
  153. #define GPIO_I2C1_SDA GPIO_I2C1_SDA_1
  154. #define GPIO_UART3_RXD GPIO_UART3_RXD_1
  155. #define GPIO_I2C1_SCL GPIO_I2C1_SCL_1
  156. #define GPIO_SSP1_SCK GPIO_SSP1_SCK_1
  157. #define GPIO_UART2_TXD GPIO_UART2_TXD_1
  158. #define GPIO_UART2_RXD GPIO_UART2_RXD_1
  159. #define GPIO_UART1_TXD GPIO_UART1_TXD_1
  160. #define GPIO_SSP0_SCK GPIO_SSP0_SCK_1
  161. #define GPIO_UART1_RXD GPIO_UART1_RXD_1
  162. #define GPIO_SSP0_SSEL GPIO_SSP0_SSEL_1
  163. #define GPIO_SSP0_MISO GPIO_SSP0_MISO_1
  164. #define GPIO_SSP0_MOSI GPIO_SSP0_MOSI_1
  165. /* P1[0]/ENET-TXD0 J6-34? TXD0 TX-(Ethernet PHY)
  166. * P1[1]/ENET_TXD1 J6-35? TXD1 TX+(Ethernet PHY)
  167. * P1[4]/ENET_TX_EN TXEN N/A
  168. * P1[8]/ENET_CRS CRS_DV/MODE2 N/A
  169. * P1[9]/ENET_RXD0 J6-32? RXD0/MODE0 RD-(Ethernet PHY)
  170. * P1[10]/ENET_RXD1 J6-33? RXD1/MODE1 RD+(Ethernet PHY)
  171. * P1[14]/ENET_RX_ER RXER/PHYAD0 N/A
  172. * P1[15]/ENET_REF_CLK REFCLK N/A
  173. * P1[16]/ENET_MDC MDC N/A
  174. * P1[17]/ENET_MDIO MDIO N/A
  175. * P1[18]/USB_UP_LED/PWM1[1]/CAP1[0] PAD1 N/A
  176. * P1[19]/MC0A/USB_PPWR/N_CAP1.1 PAD2 N/A
  177. * P1[20]/MCFB0/PWM1.2/SCK0 PAD3 N/A
  178. * P1[21]/MCABORT/PWM1.3/SSEL0 PAD4 N/A
  179. * P1[22]/MC0B/USB-PWRD/MAT1.0 PAD5 N/A
  180. * P1[23]/MCFB1/PWM1.4/MISO0 PAD6 N/A
  181. * P1[24]/MCFB2/PWM1.5/MOSI0 PAD7 N/A
  182. * P1[25]/MC1A/MAT1.1 PAD8 N/A
  183. * P1[26]/MC1B/PWM1.6/CAP0.0 PAD9 N/A
  184. * P1[27]/CLKOUT/USB-OVRCR-N/CAP0.1 PAD10 N/A
  185. * P1[28]/MC2A/PCAP1.0/MAT0.0 PAD11 N/A
  186. * P1[29]/MC2B/PCAP1.1/MAT0.1 PAD12 N/A
  187. * P1[30]/VBUS/AD0[4] J6-19 AD0.4
  188. * P1[31]/SCK1/AD0[5] J6-20 AD0.5
  189. */
  190. #define GPIO_ENET_MDC GPIO_ENET_MDC_1
  191. #define GPIO_ENET_MDIO GPIO_ENET_MDIO_1
  192. /* P2[0]/PWM1.1/TXD1 J6-42 PWM1.1 / RGB LED / RS422 RX
  193. * P2[1]/PWM1.2/RXD1 J6-43 PWM1.2 / OLED voltage / RGB LED / RS422 RX
  194. * P2[2]/PWM1.3/CTS1/TRACEDATA[3] J6-44 PWM1.3
  195. * P2[3]/PWM1.4/DCD1/TRACEDATA[2] J6-45 PWM1.4
  196. * P2[4]/PWM1.5/DSR1/TRACEDATA[1] J6-46 PWM1.5
  197. * P2[5]/PWM1[6]/DTR1/TRACEDATA[0] J6-47 PWM1.6
  198. * P2[6]/PCAP1[0]/RI1/TRACECLK J6-48
  199. * P2[7]/RD2/RTS1 J6-49 OLED command/data
  200. * P2[8]/TD2/TXD2 J6-50
  201. * P2[9]/USB_CONNECT/RXD2 PAD19 USB Pullup N/A
  202. * P2[10]/EINT0/NMI J6-51
  203. * P2[11]/EINT1/I2STX_CLK J6-52
  204. * P2[12]/EINT2/I2STX_WS J6-53
  205. * P2[13]/EINT3/I2STX_SDA J6-27
  206. */
  207. #define GPIO_PWM1p1 GPIO_PWM1p1_2
  208. #define GPIO_PWM1p2 GPIO_PWM1p2_2
  209. #define GPIO_PWM1p3 GPIO_PWM1p3_2
  210. #define GPIO_PWM1p4 GPIO_PWM1p4_2
  211. #define GPIO_PWM1p5 GPIO_PWM1p5_2
  212. #define GPIO_PWM1p6 GPIO_PWM1p6_2
  213. /* P3[25]/MAT0.0/PWM1.2 PAD13 N/A
  214. * P3[26]/STCLK/MAT0.1/PWM1.3 PAD14 N/A
  215. *
  216. * P4[28]/RX-MCLK/MAT2.0/TXD3 PAD15 N/A
  217. * P4[29]/TX-MCLK/MAT2.1/RXD3 PAD16 N/A
  218. */
  219. /************************************************************************************
  220. * Public Types
  221. ************************************************************************************/
  222. #ifndef __ASSEMBLY__
  223. /************************************************************************************
  224. * Public Data
  225. ************************************************************************************/
  226. #undef EXTERN
  227. #if defined(__cplusplus)
  228. #define EXTERN extern "C"
  229. extern "C" {
  230. #else
  231. #define EXTERN extern
  232. #endif
  233. /************************************************************************************
  234. * Public Function Prototypes
  235. ************************************************************************************/
  236. /************************************************************************************
  237. * Name: lpc17_boardinitialize
  238. *
  239. * Description:
  240. * All LPC17xx architectures must provide the following entry point. This entry point
  241. * is called early in the intitialization -- after all memory has been configured
  242. * and mapped but before any devices have been initialized.
  243. *
  244. ************************************************************************************/
  245. EXTERN void lpc17_boardinitialize(void);
  246. #undef EXTERN
  247. #if defined(__cplusplus)
  248. }
  249. #endif
  250. #endif /* __ASSEMBLY__ */
  251. #endif /* __ARCH_BOARD_BOARD_H */