示例#1
0
文件: main.c 项目: ndreys/stfuboot
int main(void)
{
	int result;
	initcall_t *initcall, *tickcall;

	/*
	   FIXME: This is only workable on STM32F107 devkit with 25mhz crystall
	 */
	rcc_clock_setup_in_hse_25mhz_out_72mhz();

	for (initcall = __initcalls_start;
	     initcall < __initcalls_end; initcall++) {
		result = (*initcall)();
		if (result < 0)
			return result;
	}

	_printf("[milliboot] Done initializing peripherals\n");

	for (;;) {
		for (tickcall = __ticks_start;
		     tickcall < __ticks_end; tickcall++) {
			result = (*tickcall)();
			if (result < 0)
				return result;
		}
	}

	return -EOHFUCK;
}
示例#2
0
/* Set STM32 to 72 MHz. */
static void clock_setup(void)
{
	rcc_clock_setup_in_hse_25mhz_out_72mhz();
        rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPDEN);
        rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
}
示例#3
0
static void
configure_mcu_clocks(void)
{
  rcc_clock_setup_in_hse_25mhz_out_72mhz();

  /* GPIO Clocks */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

  /* USART 1 */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
}
示例#4
0
int main(void)
{
	usbd_device *usbd_dev;

	rcc_clock_setup_in_hse_25mhz_out_72mhz();

	rcc_periph_clock_enable(RCC_GPIOA);
	rcc_periph_clock_enable(RCC_GPIOC);
	rcc_periph_clock_enable(RCC_OTGFS);

	/* LED output */
	gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);

	usbd_dev = usbd_init(&stm32f107_usb_driver, &dev, &config, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer));
	usbd_register_control_callback(
				usbd_dev,
				USB_REQ_TYPE_VENDOR,
				USB_REQ_TYPE_TYPE,
				simple_control_callback);

	while (1)
		usbd_poll(usbd_dev);
}