void setup_usb_fullspeed()
{
	gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
			GPIO9 | GPIO11 | GPIO12);
	gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);

	usbd_init(&otgfs_usb_driver, &dev, &config, usb_strings);
	usbd_register_set_config_callback(cdcacm_set_config);
}
예제 #2
0
usbd_device* cmp_usb_setup(void) {
    int num_strings = sizeof(usb_strings)/sizeof(const char*);

    const usbd_driver* driver = target_usb_init();
    usbd_device* usbd_dev = usbd_init(driver, &dev, &config,
                                      usb_strings, num_strings,
                                      usbd_control_buffer, sizeof(usbd_control_buffer));
    usbd_register_set_config_callback(usbd_dev, cmp_usb_set_config);
    usbd_register_reset_callback(usbd_dev, cmp_usb_handle_reset);
    return usbd_dev;
}
예제 #3
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);
}
예제 #4
0
usbd_device *usbd_create(void)
{
    usbd_device *usbd;

    if (!(usbd = usbd_init(&otgfs_usb_driver, &__usbdev_desc, &__usbconf_desc,
                           __usb_strings, 3, __usbd_buf,
                           sizeof(__usbd_buf))))
        return NULL;
    usbd_register_set_config_callback(usbd, __cdcacm_set_config);

    return usbd;
}
예제 #5
0
파일: usb_tmc.c 프로젝트: antboard/discotmc
void usb_tmc_init(usbd_device **usbd_dev, const char *serial_number)
{
	strcpy(_our_serial_number, serial_number);
	usb_tmc_setup_pre_arch();

	// 4 == ARRAY_LENGTH(usb_strings)
	*usbd_dev = usbd_init(&USB_DRIVER, &dev, &config, usb_strings, 4,
		usbd_control_buffer, sizeof (usbd_control_buffer));
	tmc_dev = *usbd_dev;
	usbd_register_set_config_callback(tmc_dev, tmc_set_config);

	usb_tmc_setup_post_arch();
}
예제 #6
0
static int usb_fibre(fibre_t *fibre)
{
	PT_BEGIN_FIBRE(fibre);

	rcc_periph_clock_enable(RCC_OTGFS);

	gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
			GPIO9 | GPIO11 | GPIO12);
	gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);

	usbd_dev = usbd_init(&otgfs_usb_driver, &dev, &config,
			usb_strings, 2,
			usbd_control_buffer, sizeof(usbd_control_buffer));
	usbd_register_set_config_callback(usbd_dev, usb_set_config);

	while (true) {
		usbd_poll(usbd_dev);
		PT_YIELD();
	}

	PT_END();
}
예제 #7
0
void usbmanager_init(void) {
    usbd_dev = usbd_init(&otgfs_usb_driver, &dev, &config, usb_strings, 3, (uint8_t*) controlBuffer, 128);
    usbd_register_set_config_callback(usbd_dev, usbmanager_set_config);
}