board.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 =
  21. {
  22. {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
  23. {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
  24. {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
  25. {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
  26. {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
  27. };
  28. #endif
  29. /*
  30. * Early initialization code.
  31. * This initialization must be performed just after stack setup and before
  32. * any other initialization.
  33. */
  34. void __early_init(void) {
  35. stm32_clock_init();
  36. }
  37. #if HAL_USE_MMC_SPI
  38. /*
  39. * Card detection through the card internal pull-up on D3.
  40. */
  41. bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
  42. (void)mmcp;
  43. return !palReadPad(GPIOC, GPIOC_SPI3_SD_CD);
  44. }
  45. /*
  46. * Card write protection detection is not possible, the card is always
  47. * reported as not protected.
  48. */
  49. bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
  50. (void)mmcp;
  51. return FALSE;
  52. }
  53. #endif
  54. /*
  55. * Board-specific initialization code.
  56. */
  57. void boardInit(void) {
  58. /*
  59. * Several I/O pins are re-mapped:
  60. * USART3 to the PD8/PD9 pins.
  61. * I2C1 to the PB8/PB9 pins.
  62. * SPI3 to the PC10/PC11/PC12 pins.
  63. */
  64. //AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_FULLREMAP |
  65. // AFIO_MAPR_I2C1_REMAP |
  66. // AFIO_MAPR_SPI3_REMAP |
  67. // AFIO_MAPR_ETH_REMAP;
  68. /*
  69. * Several I/O pins are re-mapped:
  70. * .
  71. */
  72. AFIO->MAPR |= AFIO_MAPR_ETH_REMAP |
  73. AFIO_MAPR_I2C1_REMAP |
  74. AFIO_MAPR_SPI3_REMAP |
  75. AFIO_MAPR_CAN_REMAP_REMAP3 |
  76. AFIO_MAPR_USART1_REMAP |
  77. AFIO_MAPR_USART2_REMAP;
  78. }