board.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /************************************************************************************
  2. * configs/olimex-lpc-h3131/include/board.h
  3. *
  4. * Copyright (C) 2013, 2017 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_OLIMEX_LPC_H3131_INCLUDE_BOARD_H
  36. #define __CONFIGS_OLIMEX_LPC_H3131_INCLUDE_BOARD_H
  37. /************************************************************************************
  38. * Included Files
  39. ************************************************************************************/
  40. #include <nuttx/config.h>
  41. #ifndef __ASSEMBLY__
  42. # include <stdint.h>
  43. # include "lpc31_cgudrvr.h"
  44. #endif
  45. /************************************************************************************
  46. * Pre-processor Definitions
  47. ************************************************************************************/
  48. /* Clocking *************************************************************************/
  49. /* Frequency of the FFAST input */
  50. #define BOARD_FREQIN_FFAST (12000000) /* ffast (12 MHz crystal) */
  51. /* HPLL0 configuration */
  52. #define BOARD_HPLL0_FINSEL CGU_HPFINSEL_FFAST /* Frequency input selection */
  53. #define BOARD_HPLL0_NDEC 131 /* PLL N-divider value */
  54. #define BOARD_HPLL0_MDEC 29784 /* PLL M-divider value */
  55. #define BOARD_HPLL0_PDEC 7 /* PLL P-divider value */
  56. #define BOARD_HPLL0_SELR 0 /* SELR bandwidth selection */
  57. #define BOARD_HPLL0_SELI 8 /* SELI bandwidth selection */
  58. #define BOARD_HPLL0_SELP 31 /* SELP bandwidth selection */
  59. #define BOARD_HPLL0_MODE 0 /* PLL mode */
  60. #define BOARD_HPLL0_FREQ 406425600 /* Frequency of the PLL in MHz */
  61. /* HPLL1 configuration */
  62. #define BOARD_HPLL1_FINSEL CGU_HPFINSEL_FFAST /* Frequency input selection */
  63. #define BOARD_HPLL1_NDEC 770 /* PLL N-divider value */
  64. #define BOARD_HPLL1_MDEC 8191 /* PLL M-divider value */
  65. #define BOARD_HPLL1_PDEC 98 /* PLL P-divider value */
  66. #define BOARD_HPLL1_SELR 0 /* SELR bandwidth selection */
  67. #define BOARD_HPLL1_SELI 16 /* SELI bandwidth selection */
  68. #define BOARD_HPLL1_SELP 8 /* SELP bandwidth selection */
  69. #define BOARD_HPLL1_MODE 0 /* PLL mode */
  70. #define BOARD_HPLL1_FREQ 180000000 /* Frequency of the PLL in MHz */
  71. /* The following 3 bitsets determine which clocks will be enabled at initialization
  72. * time.
  73. */
  74. #define BOARD_CLKS_0_31 \
  75. (_RBIT(CLKID_APB0CLK,0)|_RBIT(CLKID_APB1CLK,0)|_RBIT(CLKID_APB2CLK,0)|\
  76. _RBIT(CLKID_APB3CLK,0)|_RBIT(CLKID_APB4CLK,0)|_RBIT(CLKID_AHB2INTCCLK,0)|\
  77. _RBIT(CLKID_AHB0CLK,0)|_RBIT(CLKID_ARM926CORECLK,0)|_RBIT(CLKID_ARM926BUSIFCLK,0)|\
  78. _RBIT(CLKID_ARM926RETIMECLK,0)|_RBIT(CLKID_ISRAM0CLK,0)|_RBIT(CLKID_ISRAM1CLK,0)|\
  79. _RBIT(CLKID_ISROMCLK,0)|_RBIT(CLKID_INTCCLK,0)|_RBIT(CLKID_AHB2APB0PCLK,0)|\
  80. _RBIT(CLKID_EVENTROUTERPCLK,0)|_RBIT(CLKID_CLOCKOUT,0))
  81. #define BOARD_CLKS_32_63 \
  82. (_RBIT(CLKID_IOCONFPCLK,32)|_RBIT(CLKID_CGUPCLK,32)|_RBIT(CLKID_SYSCREGPCLK,32)|\
  83. _RBIT(CLKID_OTPPCLK,32)|_RBIT(CLKID_AHB2APB1PCLK,32)|_RBIT(CLKID_AHB2APB2PCLK,32)|\
  84. _RBIT(CLKID_AHB2APB3PCLK,32)|_RBIT(CLKID_EDGEDETPCLK,32))
  85. #define BOARD_CLKS_64_92 \
  86. (0)
  87. /* LED definitions ******************************************************************/
  88. /* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
  89. * way. The following definitions are used to access individual LEDs.
  90. */
  91. /* LED index values for use with board_userled() */
  92. #define BOARD_LED1 0
  93. #define BOARD_LED2 1
  94. #define BOARD_NLEDS 2
  95. /* LED bits for use with board_userled_all() */
  96. #define BOARD_LED1_BIT (1 << BOARD_LED1)
  97. #define BOARD_LED2_BIT (1 << BOARD_LED2)
  98. /* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
  99. * defined. In that case, the usage by the board port is as follows:
  100. *
  101. * SYMBOL Meaning LED state
  102. * LED2 LED1
  103. * ------------------------ -------------------------- ------ ------ */
  104. #define LED_STARTED 0 /* NuttX has been started OFF OFF */
  105. #define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF OFF */
  106. #define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF */
  107. #define LED_STACKCREATED 1 /* Idle stack created ON OFF */
  108. #define LED_INIRQ 2 /* In an interrupt N/C N/C */
  109. #define LED_SIGNAL 2 /* In a signal handler N/C N/C */
  110. #define LED_ASSERTION 2 /* An assertion failed N/C N/C */
  111. #define LED_PANIC 3 /* The system has crashed N/C Blinking */
  112. #undef LED_IDLE /* MCU is is sleep mode Not used */
  113. /* Thus if LED2 is statically on, NuttX has successfully booted and is,
  114. * apparently, running normmally. If LED1 is flashing at approximately
  115. * 2Hz, then a fatal error has been detected and the system has halted.
  116. *
  117. * NOTE: That LED2 is not used after completion of booting and may
  118. * be used by other board-specific logic.
  119. */
  120. /* Button definitions ***************************************************************/
  121. /* The Olimex LPC_H3131 has no user buttons */
  122. /************************************************************************************
  123. * Public Data
  124. ************************************************************************************/
  125. #ifndef __ASSEMBLY__
  126. #undef EXTERN
  127. #if defined(__cplusplus)
  128. #define EXTERN extern "C"
  129. extern "C"
  130. {
  131. #else
  132. #define EXTERN extern
  133. #endif
  134. /************************************************************************************
  135. * Public Function Prototypes
  136. ************************************************************************************/
  137. /************************************************************************************
  138. * Name: lpc31_boardinitialize
  139. *
  140. * Description:
  141. * All LPC31XX architectures must provide the following entry point. This entry
  142. * point is called early in the intitialization -- after all memory has been
  143. * configured and mapped but before any devices have been initialized.
  144. *
  145. ************************************************************************************/
  146. void lpc31_boardinitialize(void);
  147. #undef EXTERN
  148. #if defined(__cplusplus)
  149. }
  150. #endif
  151. /************************************************************************************
  152. * Name: lpc31_setup_overcurrent
  153. *
  154. * Description:
  155. * Setup to receive an interrupt-level callback if an overcurrent condition is
  156. * detected.
  157. *
  158. * Input parameter:
  159. * handler - New overcurrent interrupt handler
  160. * arg - The argument that will accompany the interrupt
  161. *
  162. * Returned value:
  163. * Zero (OK) returned on success; a negated errno value is returned on failure.
  164. *
  165. ************************************************************************************/
  166. #if 0 /* Not ready yet */
  167. int lpc31_setup_overcurrent(xcpt_t handler, void *arg);
  168. #endif
  169. #endif /* __ASSEMBLY__ */
  170. #endif /* __CONFIGS_OLIMEX_LPC_H3131_INCLUDE_BOARD_H */