diff --git a/tests/gadget-zero/Makefile.stm32l1-generic b/tests/gadget-zero/Makefile.stm32l1-generic index 17496378..9a410de4 100644 --- a/tests/gadget-zero/Makefile.stm32l1-generic +++ b/tests/gadget-zero/Makefile.stm32l1-generic @@ -32,7 +32,7 @@ INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR)) OPENCM3_DIR=../.. ### This section can go to an arch shared rules eventually... -LDSCRIPT = ../../lib/stm32/l1/stm32l15xxb.ld +LDSCRIPT = ../../lib/stm32/l1/stm32l15xx8.ld OPENCM3_LIB = opencm3_stm32l1 OPENCM3_DEFS = -DSTM32L1 ARCH_FLAGS = -mthumb -mcpu=cortex-m3 diff --git a/tests/gadget-zero/main-stm32l1-generic.c b/tests/gadget-zero/main-stm32l1-generic.c index 4e53720f..7e56c8e6 100644 --- a/tests/gadget-zero/main-stm32l1-generic.c +++ b/tests/gadget-zero/main-stm32l1-generic.c @@ -17,10 +17,15 @@ * along with this library. If not, see . */ +/* "generic" could be any L1 board, but this file is pre-configured for the + * libopencm3-tests "hw1" board, with an stm32l151c8-A part. + */ + #include #include #include #include +#include #include #include "usb-gadget0.h" @@ -35,15 +40,16 @@ #endif const struct rcc_clock_scale this_clock_config = { - /* 32MHz PLL from 8MHz HSE */ + /* 32MHz PLL from 16MHz HSE, 96MHz for USB on PLL VCO out */ .pll_source = RCC_CFGR_PLLSRC_HSE_CLK, - .pll_mul = RCC_CFGR_PLLMUL_MUL12, + .pll_mul = RCC_CFGR_PLLMUL_MUL6, .pll_div = RCC_CFGR_PLLDIV_DIV3, .hpre = RCC_CFGR_HPRE_SYSCLK_NODIV, .ppre1 = RCC_CFGR_PPRE1_HCLK_NODIV, .ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV, .voltage_scale = PWR_SCALE1, .flash_waitstates = 1, + .ahb_frequency = 32000000, .apb1_frequency = 32000000, .apb2_frequency = 32000000, }; @@ -51,19 +57,24 @@ const struct rcc_clock_scale this_clock_config = { int main(void) { - rcc_clock_setup_pll(&this_clock_config); - /* LED on custom board for boot progress */ rcc_periph_clock_enable(RCC_GPIOB); - gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO1); - gpio_set(GPIOB, GPIO1); + gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO8|GPIO9); + gpio_set(GPIOB, GPIO8); + rcc_clock_setup_pll(&this_clock_config); + + /* Enable built in USB pullup on L1 */ + rcc_periph_clock_enable(RCC_SYSCFG); + SYSCFG_PMC |= SYSCFG_PMC_USB_PU; usbd_device *usbd_dev = gadget0_init(&st_usbfs_v1_usb_driver, "stm32l1-generic"); ER_DPRINTF("bootup complete\n"); - gpio_clear(GPIOB, GPIO1); + gpio_clear(GPIOB, GPIO8); while (1) { + gpio_set(GPIOB, GPIO9); gadget0_run(usbd_dev); + gpio_clear(GPIOB, GPIO9); } }