board.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. ChibiOS - Copyright (C) 2006..2016 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. #if HAL_USE_PAL || defined(__DOXYGEN__)
  15. /**
  16. * @brief PAL setup.
  17. * @details Digital I/O ports static configuration as defined in @p board.h.
  18. * This variable is used by the HAL when initializing the PAL driver.
  19. */
  20. const PALConfig pal_default_config = {
  21. # if STM32_HAS_GPIOA
  22. {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
  23. # endif
  24. # if STM32_HAS_GPIOB
  25. {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
  26. # endif
  27. # if STM32_HAS_GPIOC
  28. {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
  29. # endif
  30. # if STM32_HAS_GPIOD
  31. {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
  32. # endif
  33. # if STM32_HAS_GPIOE
  34. {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
  35. # endif
  36. # if STM32_HAS_GPIOF
  37. {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
  38. # endif
  39. # if STM32_HAS_GPIOG
  40. {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
  41. # endif
  42. # if STM32_HAS_GPIOH
  43. {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
  44. # endif
  45. # if STM32_HAS_GPIOI
  46. {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
  47. # endif
  48. };
  49. #endif
  50. void enter_bootloader_mode_if_requested(void);
  51. /**
  52. * @brief Early initialization code.
  53. * @details This initialization must be performed just after stack setup
  54. * and before any other initialization.
  55. */
  56. void __early_init(void) {
  57. enter_bootloader_mode_if_requested();
  58. stm32_clock_init();
  59. }
  60. #if HAL_USE_SDC || defined(__DOXYGEN__)
  61. /**
  62. * @brief SDC card detection.
  63. */
  64. bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
  65. (void)sdcp;
  66. /* TODO: Fill the implementation.*/
  67. return true;
  68. }
  69. /**
  70. * @brief SDC card write protection detection.
  71. */
  72. bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
  73. (void)sdcp;
  74. /* TODO: Fill the implementation.*/
  75. return false;
  76. }
  77. #endif /* HAL_USE_SDC */
  78. #if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
  79. /**
  80. * @brief MMC_SPI card detection.
  81. */
  82. bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
  83. (void)mmcp;
  84. /* TODO: Fill the implementation.*/
  85. return true;
  86. }
  87. /**
  88. * @brief MMC_SPI card write protection detection.
  89. */
  90. bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
  91. (void)mmcp;
  92. /* TODO: Fill the implementation.*/
  93. return false;
  94. }
  95. #endif
  96. /**
  97. * @brief Board-specific initialization code.
  98. * @todo Add your board-specific code, if any.
  99. */
  100. void boardInit(void) {}