board.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /****************************************************************************
  2. * configs/sure-pic32mx/include/board.h
  3. * include/arch/board/board.h
  4. *
  5. * Copyright (C) 2011-2012 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 __CONFIGS_SURE_PIC32MX_INCLUDE_BOARD_H
  37. #define __CONFIGS_SURE_PIC32MX_INCLUDE_BOARD_H
  38. /****************************************************************************
  39. * Included Files
  40. ****************************************************************************/
  41. #include <nuttx/config.h>
  42. /****************************************************************************
  43. * Pre-processor Definitions
  44. ****************************************************************************/
  45. /* Configuration ************************************************************/
  46. /* Clocking *****************************************************************/
  47. /* Crystal frequencies */
  48. #define BOARD_POSC_FREQ 20000000 /* Primary OSC XTAL frequency (20MHz) */
  49. #define BOARD_SOSC_FREQ 32768 /* Secondary OSC XTAL frequency (32.768KHz) */
  50. /* Oscillator modes */
  51. #define BOARD_FNOSC_POSCPLL 1 /* Use primary oscillator w/PLL */
  52. #define BOARD_POSC_HSMODE 1 /* High-speed crystal (HS) mode */
  53. /* PLL configuration and resulting CPU clock.
  54. * CPU_CLOCK = ((POSC_FREQ / IDIV) * MULT) / ODIV
  55. */
  56. #define BOARD_PLL_INPUT BOARD_POSC_FREQ
  57. #define BOARD_PLL_IDIV 5 /* PLL input divider */
  58. #define BOARD_PLL_MULT 15 /* PLL multiplier */
  59. #define BOARD_PLL_ODIV 1 /* PLL output divider */
  60. #define BOARD_CPU_CLOCK 60000000 /* CPU clock (60MHz = (20MHz / 5) * 15 / 1) */
  61. /* USB PLL configuration.
  62. * USB_CLOCK = ((POSC_XTAL / IDIV) * 24) / 2
  63. */
  64. #define BOARD_UPLL_IDIV 5 /* USB PLL divider */
  65. #define BOARD_USB_CLOCK 48000000 /* USB clock ((20MHz / 5) * 24) / 2 */
  66. /* Peripheral clock is *not* divided down from CPU clock.
  67. * PBCLOCK = CPU_CLOCK / PBDIV
  68. */
  69. #define BOARD_PBDIV 1 /* Peripheral clock divisor (PBDIV) */
  70. #define BOARD_PBCLOCK 60000000 /* Peripheral clock (PBCLK = 60MHz/1) */
  71. /* Watchdog pre-scaler (re-visit) */
  72. #define BOARD_WD_ENABLE 0 /* Watchdog is disabled */
  73. #define BOARD_WD_PRESCALER 8 /* Watchdog pre-scaler */
  74. /* Timer 1 is a type A timer and is used as system clock. It can be clocked
  75. * with either the SOSC or the PBCLOCK. We will use the PBCLOCK because it
  76. * is much more accurate.
  77. */
  78. #undef BOARD_TIMER1_SOSC
  79. /* LED definitions **********************************************************/
  80. /* The Sure DB_DP11215 PIC32 Storage Demo Board board has five LEDs. One
  81. * (D4, lablel "Power") is not controllable by software. Four are
  82. * controllable by software:
  83. *
  84. * D7 "USB" Yellow RD7 Low illuminates
  85. * D8 "SD" Yellow RD6 Low illuminates
  86. * D9 "Flash" Yellow RF0 Low illuminates
  87. * D10 "Error" Red RF1 Low illuminates
  88. */
  89. /* ON OFF */
  90. /* USB SD FLASH ERROR USB SD FLASH ERROR */
  91. #define LED_STARTED 0 /* OFF OFF OFF OFF --- --- --- --- */
  92. #define LED_HEAPALLOCATE 1 /* ON OFF N/C N/C --- --- --- --- */
  93. #define LED_IRQSENABLED 2 /* OFF ON N/C N/C --- --- --- --- */
  94. #define LED_STACKCREATED 3 /* ON ON N/C N/C --- --- --- --- */
  95. #define LED_INIRQ 4 /* N/C N/C ON N/C N/C N/C OFF N/C */
  96. #define LED_SIGNAL 4 /* N/C N/C ON N/C N/C N/C OFF N/C */
  97. #define LED_ASSERTION 4 /* N/C N/C ON N/C N/C N/C OFF N/C */
  98. #define LED_PANIC 5 /* N/C N/C N/C ON N/C N/C N/C OFF */
  99. #define LED_NVALUES 6
  100. /* The Sure DB-DP11212 PIC32 General Purpose Demo Board does not have any user
  101. * controllable LEDs, but does does have a segment LED display. That display is
  102. * however, obscured by the larger segment display attached to the board and, so,
  103. * is not supported.
  104. */
  105. /* For distinguishing individual LEDs */
  106. #define LED_USB 0
  107. #define LED_SD 1
  108. #define LED_FLASH 2
  109. #define LED_ERROR 3
  110. /* Button Definitions *******************************************************/
  111. /* The Sure PIC32MX board has three buttons.
  112. *
  113. * SW1 (SW_UP, left arrow) RB3 Pulled high, Grounded/low when depressed
  114. * SW2 (SW_DOWN, down/right arrow) RB2 Pulled high, Grounded/low when depressed
  115. * SW3 (SW_OK, right arrow) RB4 Pulled high, Grounded/low when depressed
  116. */
  117. #define BUTTON_SW1 0
  118. #define BUTTON_SW2 1
  119. #define BUTTON_SW3 2
  120. #define NUM_BUTTONS 3
  121. #define BUTTON_SW1_BIT (1 << BUTTON_SW1)
  122. #define BUTTON_SW2_BIT (1 << BUTTON_SW2)
  123. #define BUTTON_SW3_BIT (1 << BUTTON_SW3)
  124. /****************************************************************************
  125. * Public Types
  126. ****************************************************************************/
  127. #ifndef __ASSEMBLY__
  128. /****************************************************************************
  129. * Inline Functions
  130. ****************************************************************************/
  131. /****************************************************************************
  132. * Public Function Prototypes
  133. ****************************************************************************/
  134. #ifdef __cplusplus
  135. #define EXTERN extern "C"
  136. extern "C" {
  137. #else
  138. #define EXTERN extern
  139. #endif
  140. #undef EXTERN
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif /* __ASSEMBLY__ */
  145. #endif /* __CONFIGS_SURE_PIC32MX_INCLUDE_BOARD_H */