logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

f405.c (2063B)


  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "tractyl_manuform.h"
  17. #ifdef USB_VBUS_PIN
  18. bool usb_vbus_state(void) {
  19. gpio_set_pin_input_low(USB_VBUS_PIN);
  20. wait_us(5);
  21. return gpio_read_pin(USB_VBUS_PIN);
  22. }
  23. #endif
  24. #ifdef USER_BUTTON_PIN
  25. void user_button_init(void) {
  26. // Pin needs to be configured as input low
  27. gpio_set_pin_input_low(USER_BUTTON_PIN);
  28. }
  29. bool check_user_button_state(void) {
  30. return gpio_read_pin(USER_BUTTON_PIN);
  31. }
  32. #endif // USER_BUTTON_PIN
  33. void board_init(void) {
  34. // Board setup sets these pins as SPI, but we aren't using them as such.
  35. // So to prevent them from misbehaving, we need to set them to a different, non-spi mode.
  36. // This is a bit of a hack, but nothing else runs soon enough, without re-implementing spi_init().
  37. gpio_set_pin_input(A5);
  38. gpio_set_pin_input(A6);
  39. gpio_set_pin_input(A7);
  40. // If using USB_OTG_HS, we need to set the data pins since they're set wrong for our needs by default.
  41. // We set it here by default, in case it's bridged with A11/A12, as to reduce the chance of issues.
  42. palSetLineMode(
  43. B14, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING);
  44. palSetLineMode(
  45. B15, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING);
  46. }