PD Buddy Sink Firmware
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

board.c 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * PD Buddy - USB Power Delivery for everyone
  3. * Copyright (C) 2017-2018 Clayton G. Hobbs <clay@lakeserv.net>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
  20. Licensed under the Apache License, Version 2.0 (the "License");
  21. you may not use this file except in compliance with the License.
  22. You may obtain a copy of the License at
  23. http://www.apache.org/licenses/LICENSE-2.0
  24. Unless required by applicable law or agreed to in writing, software
  25. distributed under the License is distributed on an "AS IS" BASIS,
  26. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  27. See the License for the specific language governing permissions and
  28. limitations under the License.
  29. */
  30. /*
  31. * This file has been automatically generated using ChibiStudio board
  32. * generator plugin. Do not edit manually.
  33. */
  34. #include "stm32f072_bootloader.h"
  35. #include "hal.h"
  36. #if HAL_USE_PAL || defined(__DOXYGEN__)
  37. /**
  38. * @brief PAL setup.
  39. * @details Digital I/O ports static configuration as defined in @p board.h.
  40. * This variable is used by the HAL when initializing the PAL driver.
  41. */
  42. const PALConfig pal_default_config = {
  43. #if STM32_HAS_GPIOA
  44. {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
  45. VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
  46. #endif
  47. #if STM32_HAS_GPIOB
  48. {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
  49. VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
  50. #endif
  51. #if STM32_HAS_GPIOC
  52. {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
  53. VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
  54. #endif
  55. #if STM32_HAS_GPIOD
  56. {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
  57. VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
  58. #endif
  59. #if STM32_HAS_GPIOE
  60. {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
  61. VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
  62. #endif
  63. #if STM32_HAS_GPIOF
  64. {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
  65. VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
  66. #endif
  67. #if STM32_HAS_GPIOG
  68. {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
  69. VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
  70. #endif
  71. #if STM32_HAS_GPIOH
  72. {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
  73. VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
  74. #endif
  75. #if STM32_HAS_GPIOI
  76. {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
  77. VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
  78. #endif
  79. };
  80. #endif
  81. /**
  82. * @brief Early initialization code.
  83. * @details This initialization must be performed just after stack setup
  84. * and before any other initialization.
  85. */
  86. void __early_init(void) {
  87. stm32_clock_init();
  88. /* Jump to the bootloader if the magic value is set in
  89. * dfu_reset_to_bootloader_magic. */
  90. if (dfu_reset_to_bootloader_magic == RESET_TO_BOOTLOADER_MAGIC_CODE) {
  91. asm("cpsie i");
  92. void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *) SYSMEM_RESET_VECTOR));
  93. dfu_reset_to_bootloader_magic = 0;
  94. __set_MSP(BOOTLOADER_STACK_POINTER);
  95. bootloader();
  96. while (42);
  97. }
  98. }
  99. #if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
  100. /**
  101. * @brief MMC_SPI card detection.
  102. */
  103. bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
  104. (void)mmcp;
  105. /* TODO: Fill the implementation.*/
  106. return true;
  107. }
  108. /**
  109. * @brief MMC_SPI card write protection detection.
  110. */
  111. bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
  112. (void)mmcp;
  113. /* TODO: Fill the implementation.*/
  114. return false;
  115. }
  116. #endif
  117. /**
  118. * @brief Board-specific initialization code.
  119. * @todo Add your board-specific code, if any.
  120. */
  121. void boardInit(void) {
  122. }