board.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #include "hal.h"
  14. /**
  15. * @brief PAL setup.
  16. * @details Digital I/O ports static configuration as defined in @p board.h.
  17. * This variable is used by the HAL when initializing the PAL driver.
  18. */
  19. #if HAL_USE_PAL || defined(__DOXYGEN__)
  20. const PALConfig pal_default_config = {VAL_GPIO0DATA, VAL_GPIO0DIR};
  21. #endif
  22. /*
  23. * Early initialization code.
  24. * This initialization must be performed just after stack setup and before
  25. * any other initialization.
  26. */
  27. void __early_init(void){
  28. lpc8xx_clock_init();
  29. }
  30. /*
  31. * Board-specific initialization code.
  32. */
  33. void boardInit(void){
  34. /* Enable clocks to IOCON & SWM */
  35. LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<18)|(1<<7));
  36. #if defined VAL_PIO0_0
  37. LPC_IOCON->PIO0_0 = PIN_RSVD|VAL_PIO0_0;
  38. #endif
  39. #if defined VAL_PIO0_1
  40. LPC_IOCON->PIO0_1 = PIN_RSVD|VAL_PIO0_1;
  41. #endif
  42. #if defined VAL_PIO0_2
  43. LPC_IOCON->PIO0_2 = PIN_RSVD|VAL_PIO0_2;
  44. #endif
  45. #if defined VAL_PIO0_3
  46. LPC_IOCON->PIO0_3 = PIN_RSVD|VAL_PIO0_3;
  47. #endif
  48. #if defined VAL_PIO0_4
  49. LPC_IOCON->PIO0_4 = PIN_RSVD|VAL_PIO0_4;
  50. #endif
  51. #if defined VAL_PIO0_5
  52. LPC_IOCON->PIO0_5 = PIN_RSVD|VAL_PIO0_5;
  53. #endif
  54. #if defined VAL_PIO0_6
  55. LPC_IOCON->PIO0_6 = PIN_RSVD|VAL_PIO0_6;
  56. #endif
  57. #if defined VAL_PIO0_7
  58. LPC_IOCON->PIO0_7 = PIN_RSVD|VAL_PIO0_7;
  59. #endif
  60. #if defined VAL_PIO0_8
  61. LPC_IOCON->PIO0_8 = PIN_RSVD|VAL_PIO0_8;
  62. #endif
  63. #if defined VAL_PIO0_9
  64. LPC_IOCON->PIO0_9 = PIN_RSVD|VAL_PIO0_9;
  65. #endif
  66. #if defined VAL_PIO0_10
  67. LPC_IOCON->PIO0_10 = PIN_RSVD|VAL_PIO0_10;
  68. #endif
  69. #if defined VAL_PIO0_11
  70. LPC_IOCON->PIO0_11 = PIN_RSVD|VAL_PIO0_11;
  71. #endif
  72. #if defined VAL_PIO0_12
  73. LPC_IOCON->PIO0_12 = PIN_RSVD|VAL_PIO0_12;
  74. #endif
  75. #if defined VAL_PIO0_13
  76. LPC_IOCON->PIO0_13 = PIN_RSVD|VAL_PIO0_13;
  77. #endif
  78. #if defined VAL_PIO0_14
  79. LPC_IOCON->PIO0_14 = PIN_RSVD|VAL_PIO0_14;
  80. #endif
  81. #if defined VAL_PIO0_15
  82. LPC_IOCON->PIO0_15 = PIN_RSVD|VAL_PIO0_15;
  83. #endif
  84. #if defined VAL_PIO0_16
  85. LPC_IOCON->PIO0_16 = PIN_RSVD|VAL_PIO0_16;
  86. #endif
  87. #if defined VAL_PIO0_17
  88. LPC_IOCON->PIO0_17 = PIN_RSVD|VAL_PIO0_17;
  89. #endif
  90. #if defined VAL_PINASSIGN0
  91. LPC_SWM->PINASSIGN0 = VAL_PINASSIGN0;
  92. #endif
  93. #if defined VAL_PINASSIGN1
  94. LPC_SWM->PINASSIGN1 = VAL_PINASSIGN1;
  95. #endif
  96. #if defined VAL_PINASSIGN2
  97. LPC_SWM->PINASSIGN2 = VAL_PINASSIGN2;
  98. #endif
  99. #if defined VAL_PINASSIGN3
  100. LPC_SWM->PINASSIGN3 = VAL_PINASSIGN3;
  101. #endif
  102. #if defined VAL_PINASSIGN4
  103. LPC_SWM->PINASSIGN4 = VAL_PINASSIGN4;
  104. #endif
  105. #if defined VAL_PINASSIGN5
  106. LPC_SWM->PINASSIGN5 = VAL_PINASSIGN5;
  107. #endif
  108. #if defined VAL_PINASSIGN6
  109. LPC_SWM->PINASSIGN6 = VAL_PINASSIGN6;
  110. #endif
  111. #if defined VAL_PINASSIGN7
  112. LPC_SWM->PINASSIGN7 = VAL_PINASSIGN7;
  113. #endif
  114. #if defined VAL_PINASSIGN8
  115. LPC_SWM->PINASSIGN8 = VAL_PINASSIGN8;
  116. #endif
  117. /* Disable clocks to IOCON & SWM */
  118. LPC_SYSCON->SYSAHBCLKCTRL &= ~((1<<18)|(1<<7));
  119. }