board.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /****************************************************************************
  2. * configs/pic32mx7mmb/include/board.h
  3. * include/arch/board/board.h
  4. *
  5. * Copyright (C) 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_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H
  37. #define __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H
  38. /****************************************************************************
  39. * Included Files
  40. ****************************************************************************/
  41. #include <nuttx/config.h>
  42. #ifndef __ASSEMBLY__
  43. # include <stdbool.h>
  44. #endif
  45. /****************************************************************************
  46. * Pre-processor Definitions
  47. ****************************************************************************/
  48. /* Configuration ************************************************************/
  49. /* Clocking *****************************************************************/
  50. /* Crystal frequencies */
  51. #define BOARD_POSC_FREQ 8000000 /* Primary OSC XTAL frequency (8MHz) */
  52. #define BOARD_SOSC_FREQ 32768 /* Secondary OSC XTAL frequency (32.768KHz) */
  53. /* Oscillator modes */
  54. #define BOARD_FNOSC_POSCPLL 1 /* Use primary oscillator w/PLL */
  55. #define BOARD_POSC_XTMODE 1 /* Resonator, crystal or resonator (XT) mode */
  56. #undef BOARD_POSC_SWITCH /* Use FRC until POSC stabilizes, then switch */
  57. #undef BOARD_POSC_FSCM /* Switch to FRC if POSC fails */
  58. #define BOARD_SOSC_ENABLE 1 /* Enable Secondary Oscillator */
  59. #define BOARD_SOSC_IESO 1 /* Internal External Switchover mode is enabled */
  60. /* PLL configuration and resulting CPU clock.
  61. * CPU_CLOCK = ((POSC_FREQ / IDIV) * MULT) / ODIV
  62. */
  63. #define BOARD_PLL_INPUT BOARD_POSC_FREQ
  64. #define BOARD_PLL_IDIV 2 /* PLL input divider */
  65. #define BOARD_PLL_MULT 20 /* PLL multiplier */
  66. #define BOARD_PLL_ODIV 1 /* PLL output divider */
  67. #define BOARD_CPU_CLOCK 80000000 /* CPU clock (80MHz = 8MHz * 20 / 2) */
  68. /* USB PLL configuration.
  69. * USB_CLOCK = ((POSC_XTAL / IDIV) * 24) / 2
  70. */
  71. #define BOARD_UPLL_IDIV 2 /* USB PLL divider (revisit) */
  72. #define BOARD_USB_CLOCK 48000000 /* USB clock (8MHz / 2) * 24 / 2) */
  73. /* Peripheral clock is divided down from CPU clock.
  74. * PBCLOCK = CPU_CLOCK / PBDIV
  75. */
  76. #define BOARD_PBDIV 2 /* Peripheral clock divisor (PBDIV) */
  77. #define BOARD_PBCLOCK 40000000 /* Peripheral clock (PBCLK = 80MHz/2) */
  78. /* Watchdog pre-scaler (re-visit) */
  79. #define BOARD_WD_ENABLE 0 /* Watchdog is disabled */
  80. #define BOARD_WD_PRESCALER 8 /* Watchdog pre-scaler */
  81. /* Ethernet MII clocking.
  82. *
  83. * The clock divider used to create the MII Management Clock (MDC). The MIIM
  84. * module uses the SYSCLK as an input clock. According to the IEEE 802.3
  85. * Specification this should be no faster than 2.5 MHz. However, some PHYs
  86. * support clock rates up to 12.5 MHz.
  87. */
  88. #define BOARD_EMAC_MIIM_DIV 32 /* Ideal: 80MHz/32 = 2.5MHz */
  89. /* LED definitions **********************************************************/
  90. /* LED Configuration ********************************************************/
  91. /* The Mikroelektronika PIC32MX7 MMB has 3 user LEDs labeled LED0-2 in the
  92. * schematics:
  93. *
  94. * --- ----- --------------------------------------------------------------
  95. * PIN Board Notes
  96. * --- ----- --------------------------------------------------------------
  97. * RA0 LED0 Pulled-up, low value illuminates
  98. * RA1 LED1 Pulled-up, low value illuminates
  99. * RD9 LED2 Pulled-up, low value illuminates
  100. * RA9 LED4 Not available for general use*, indicates MMC/SD activity
  101. * --- LED5 Not controllable by software, indicates power-on
  102. *
  103. * * RA9 is also the SD chip select. It will illuminate whenever the SD card
  104. * is selected. If SD is not used, then LED4 could also be used as a user-
  105. * controlled LED.
  106. */
  107. /* LED index values for use with board_userled() */
  108. #define PIC32MX_PIC32MX7MMB_LED0 0
  109. #define PIC32MX_PIC32MX7MMB_LED1 1
  110. #define PIC32MX_PIC32MX7MMB_LED2 2
  111. #define PIC32MX_PIC32MX7MMB_NLEDS 3
  112. /* LED bits for use with board_userled_all() */
  113. #define PIC32MX_PIC32MX7MMB_LED0_BIT (1 << PIC32MX_PIC32MX7MMB_LED0)
  114. #define PIC32MX_PIC32MX7MMB_LED1_BIT (1 << PIC32MX_PIC32MX7MMB_LED1)
  115. #define PIC32MX_PIC32MX7MMB_LED2_BIT (1 << PIC32MX_PIC32MX7MMB_LED2)
  116. /* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 3 LEDs
  117. * on board the Mikroelektronika PIC32MX7 MMB. The following definitions
  118. * describe how NuttX controls the LEDs:
  119. *
  120. * ON OFF
  121. * ------------------------- ---- ---- ---- ---- ---- ----
  122. * LED0 LED1 LED2 LED0 LED1 LED2
  123. * ------------------------- ---- ---- ---- ---- ---- ----
  124. * LED_STARTED 0 OFF OFF OFF --- --- ---
  125. * LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
  126. * LED_IRQSENABLED 2 OFF ON N/C --- --- ---
  127. * LED_STACKCREATED 3 ON ON N/C --- --- ---
  128. * LED_INIRQ 4 N/C N/C ON N/C N/C OFF
  129. * LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
  130. * LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
  131. * LED_PANIC 5 ON N/C N/C OFF N/C N/C
  132. */
  133. #define LED_STARTED 0
  134. #define LED_HEAPALLOCATE 1
  135. #define LED_IRQSENABLED 2
  136. #define LED_STACKCREATED 3
  137. #define LED_INIRQ 4
  138. #define LED_SIGNAL 4
  139. #define LED_ASSERTION 4
  140. #define LED_PANIC 5
  141. #define LED_NVALUES 6
  142. /* Switch definitions *******************************************************/
  143. /* The Mikroelektronika PIC32MX7 MMB has a joystick:
  144. *
  145. * ------ -------- --------------------------
  146. * GPIO SIGNAL BOARD CONNECTION
  147. * ------ -------- --------------------------
  148. * RB0 JOY-A Joystick A, HDR1 pin 24
  149. * RB2 JOY-C Joystick C, HDR1 pin 22
  150. * RB1 JOY-B Joystick B, HDR1 pin 23
  151. * RB3 JOY-D Joystick D, HDR1 pin 21
  152. * RA10 JOY-CP Joystick CP, HDR1 pin 25
  153. */
  154. /****************************************************************************
  155. * Public Types
  156. ****************************************************************************/
  157. #ifndef __ASSEMBLY__
  158. /****************************************************************************
  159. * Inline Functions
  160. ****************************************************************************/
  161. #ifdef __cplusplus
  162. #define EXTERN extern "C"
  163. extern "C"
  164. {
  165. #else
  166. #define EXTERN extern
  167. #endif
  168. /****************************************************************************
  169. * Public Function Prototypes
  170. ****************************************************************************/
  171. #undef EXTERN
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. #endif /* __ASSEMBLY__ */
  176. #endif /* __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H */