int main(void) { int i; int j = 0; rcc_clock_setup_pll(&rcc_clock_config[RCC_CLOCK_VRANGE1_HSI_PLL_32MHZ]); rcc_periph_clock_enable(RCC_GPIOB); printf("hi guys!\n"); /* green led for ticking */ gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_GREEN_PIN); rcc_periph_clock_enable(RCC_GPIOA); gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5); adc_power_init(); while (1) { adc_power_task_up(); gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); for (i = 0; i < 0x100000; i++) { /* Wait a bit. */ __asm__("NOP"); } adc_power_task_down(); gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); for (i = 0; i < 0x100000; i++) { /* Wait a bit. */ __asm__("NOP"); } } return 0; }
void init_hardware(void) { __asm__ __volatile__ ("cpsid i \n\t"); rcc_clock_setup_pll( &clock_config[CLOCK_VRANGE1_HSI_PLL_32MHZ] ); rcc_periph_clock_enable(RCC_GPIOB); gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GREEN); gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, RED); }
void setup_clock(void) { /* Setup clock source @ 32MHz */ rcc_clock_setup_pll(&rcc_clock_config[1]); /* Setup sysclock to trigger every 1ms */ systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8); systick_set_reload(3999); systick_interrupt_enable(); systick_counter_enable(); }
static void clock_setup(void) { rcc_clock_setup_pll(&clock_config[CLOCK_VRANGE1_HSI_PLL_24MHZ]); /* Lots of things on all ports... */ rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_GPIOB); /* Enable clocks for USART2. */ rcc_periph_clock_enable(RCC_USART2); /* And timers. */ rcc_periph_clock_enable(RCC_TIM6); rcc_periph_clock_enable(RCC_TIM7); }
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); usbd_device *usbd_dev = gadget0_init(&st_usbfs_v1_usb_driver, "stm32l1-generic"); ER_DPRINTF("bootup complete\n"); gpio_clear(GPIOB, GPIO1); while (1) { usbd_poll(usbd_dev); } }
int main(void) { rcc_periph_clock_enable(RCC_GPIOB); 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, GPIO8); while (1) { gpio_set(GPIOB, GPIO9); gadget0_run(usbd_dev); gpio_clear(GPIOB, GPIO9); } }
static void configure_mcu_clocks(void) { rcc_clock_setup_pll(&clock_config[CLOCK_VRANGE1_HSI_PLL_32MHZ]); }