xtw100.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __BOARD_H__
  2. #define __BOARD_H__
  3. #include <stdbool.h>
  4. #include <libopencm3/stm32/rcc.h>
  5. #include <libopencm3/stm32/gpio.h>
  6. #include <libopencm3/cm3/nvic.h>
  7. #define BOARD_USE_DEBUG_PINS_AS_GPIO false /* We don't have to disable SWD to access GPIO's on these boards */
  8. #define BOARD_RCC_LED RCC_GPIOB
  9. #define BOARD_PORT_LED GPIOB
  10. #define BOARD_PIN_LED GPIO7
  11. #define BOARD_LED_HIGH_IS_BUSY true
  12. #define BOARD_RCC_USB_PULLUP RCC_GPIOB
  13. #define BOARD_PORT_USB_PULLUP GPIOB
  14. #define BOARD_PIN_USB_PULLUP GPIO8
  15. #define BOARD_USB_HIGH_IS_PULLUP true
  16. /* Currently you can only use SPI1, since it has highest clock. */
  17. #define HAS_BOARD_INIT 1
  18. void board_init (void) {
  19. // Enable power LED (PB6)
  20. gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
  21. gpio_set(GPIOB, GPIO6);
  22. // Toggle power to the 25xx flash chip
  23. // PB2 + PB1 serve as GND supply, GPIO_50_MHZ to increase drive current
  24. gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO1|GPIO2);
  25. gpio_clear(GPIOB, GPIO1|GPIO2);
  26. // Set #WP and #HOLD high (PA2|PA3)
  27. rcc_periph_clock_enable(RCC_GPIOA);
  28. gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO2|GPIO3);
  29. gpio_set(GPIOA, GPIO2|GPIO3);
  30. }
  31. #endif /* __BOARD_H__ */