board.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * board.c
  3. *
  4. * Board-specific setup and management.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. /* Pull up currently unused and possibly-floating pins. */
  12. static void gpio_pull_up_pins(GPIO gpio, uint16_t mask)
  13. {
  14. unsigned int i;
  15. for (i = 0; i < 16; i++) {
  16. if (mask & 1)
  17. gpio_configure_pin(gpio, i, GPI_pull_up);
  18. mask >>= 1;
  19. }
  20. }
  21. #if STM32F == 1
  22. #include "f1/board.c"
  23. #elif STM32F == 7
  24. #include "f7/board.c"
  25. #endif
  26. void board_init(void)
  27. {
  28. mcu_board_init();
  29. #ifdef NDEBUG
  30. /* Pull up unused debug pins (A9,A10 = serial console). */
  31. gpio_pull_up_pins(gpioa, (1u<<9) | (1u<<10));
  32. #endif
  33. /* Activity LED is active low. */
  34. gpio_configure_pin(gpio_led, pin_led, GPO_pushpull(IOSPD_LOW, HIGH));
  35. }
  36. /* Set the activity LED status. */
  37. void act_led(bool_t on)
  38. {
  39. gpio_write_pin(gpio_led, pin_led, on ? LOW : HIGH);
  40. }
  41. /*
  42. * Local variables:
  43. * mode: C
  44. * c-file-style: "Linux"
  45. * c-basic-offset: 4
  46. * tab-width: 4
  47. * indent-tabs-mode: nil
  48. * End:
  49. */