예제 #1
0
/* Set STM32 to 64 MHz. */
void clock_setup(void)
{
	rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_64MHZ]);

	/* Enable GPIOE clock. */
	rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_IOPEEN);
}
예제 #2
0
int main() {
  rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_48MHZ]);
  rcc_usb_prescale_1();
  rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_USBRST);
  rcc_peripheral_reset(&RCC_AHBRSTR, RCC_AHBRSTR_IOPARST);
  rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_USBRST);
  rcc_peripheral_clear_reset(&RCC_AHBRSTR, RCC_AHBRSTR_IOPARST);
  rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
  rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_IOPAEN);
  

  gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO11 | GPIO12);
  gpio_clear(GPIOA, GPIO11 | GPIO12);
  for (int i = 0; i < 0x800000; i++)
    __asm__ volatile("nop");
  
  
  gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO11 | GPIO12);
  gpio_set_af(GPIOA, GPIO_AF14, GPIO11| GPIO12);

  arm_bootloader::Dest dest = arm_bootloader::get_unique_dest();

  char serial[10] = {0};
  {
    uint32_t x = dest;
    char hex[] = "0123456789abcdef";
    for(int i = 0; i < 8; i++) {
      serial[7-i] = hex[x & 0xF];
      x = x >> 4;
    }
  }
  
  /* Buffer to be used for control requests. */
  uint8_t usbd_control_buffer[128];
  char const *usb_strings[] = {
    "uf-mil",
    "subbus",
    serial,
  };
  usbd_device * usbd_dev = usbd_init(&stm32f103_usb_driver, &uf_subbus_protocol::usb::dev, &uf_subbus_protocol::usb::config, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer));
  usbd_register_set_config_callback(usbd_dev, cdcacm_set_config);

  uf_subbus_protocol::usb::Sink sink(usbd_dev);

  arm_bootloader::Handler handler(
    sink,
    dest,
    2048);
  handlerp = &handler;

  while (1)
    usbd_poll(usbd_dev);
}
예제 #3
0
static void clock_setup(void)
{
	rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_64MHZ]);
}
예제 #4
0
void clock_setup(void) {
  //rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_44MHZ]);
  rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_64MHZ]);
}
예제 #5
0
void cdcacm_target_init(void)
{
	rcc_clock_setup_hsi(&rcc_hsi_8mhz[RCC_CLOCK_48MHZ]);

	usb_setup();
}