Skip to content

Commit

Permalink
Merge pull request #47 from swiftgeek/XTW100
Browse files Browse the repository at this point in the history
Add XTW100 support
  • Loading branch information
dword1511 committed Oct 25, 2020
2 parents aec99e7 + 926e904 commit 9d9aa14
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
40 changes: 40 additions & 0 deletions boards/xtw100.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef __BOARD_H__
#define __BOARD_H__

#include <stdbool.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>

#include <libopencm3/cm3/nvic.h>


#define BOARD_USE_DEBUG_PINS_AS_GPIO false /* We don't have to disable SWD to access GPIO's on these boards */

#define BOARD_RCC_LED RCC_GPIOB
#define BOARD_PORT_LED GPIOB
#define BOARD_PIN_LED GPIO7
#define BOARD_LED_HIGH_IS_BUSY true

#define BOARD_RCC_USB_PULLUP RCC_GPIOB
#define BOARD_PORT_USB_PULLUP GPIOB
#define BOARD_PIN_USB_PULLUP GPIO8
#define BOARD_USB_HIGH_IS_PULLUP true

/* Currently you can only use SPI1, since it has highest clock. */

#define HAS_BOARD_INIT 1
void board_init (void) {
// Enable power LED (PB6)
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
gpio_set(GPIOB, GPIO6);
// Toggle power to the 25xx flash chip
// PB2 + PB1 serve as GND supply, GPIO_50_MHZ to increase drive current
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO1|GPIO2);
gpio_clear(GPIOB, GPIO1|GPIO2);
// Set #WP and #HOLD high (PA2|PA3)
rcc_periph_clock_enable(RCC_GPIOA);
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO2|GPIO3);
gpio_set(GPIOA, GPIO2|GPIO3);
}

#endif /* __BOARD_H__ */
1 change: 1 addition & 0 deletions boards/xtw100.mk
4 changes: 4 additions & 0 deletions vserprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ int main(void) {
#endif /* STM32F0 */

usbcdc_init();
#ifdef HAS_BOARD_INIT
board_init();
#endif

spi_setup(SPI_DEFAULT_CLOCK);

/* The loop. */
Expand Down

0 comments on commit 9d9aa14

Please sign in to comment.