hw_f1.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * hw_f1.c
  3. *
  4. * STM32F103 USBD.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. void hw_usb_init(void)
  12. {
  13. usbd.init();
  14. /* Indicate we are connected by pulling up D+. */
  15. gpio_configure_pin(gpioa, 0, GPO_pushpull(_2MHz, HIGH));
  16. }
  17. void hw_usb_deinit(void)
  18. {
  19. gpio_configure_pin(gpioa, 0, GPI_floating);
  20. usbd.deinit();
  21. }
  22. bool_t hw_has_highspeed(void)
  23. {
  24. return usbd.has_highspeed();
  25. }
  26. bool_t usb_is_highspeed(void)
  27. {
  28. return usbd.is_highspeed();
  29. }
  30. int ep_rx_ready(uint8_t epnr)
  31. {
  32. return usbd.ep_rx_ready(epnr);
  33. }
  34. bool_t ep_tx_ready(uint8_t epnr)
  35. {
  36. return usbd.ep_tx_ready(epnr);
  37. }
  38. void usb_read(uint8_t epnr, void *buf, uint32_t len)
  39. {
  40. usbd.read(epnr, buf, len);
  41. }
  42. void usb_write(uint8_t epnr, const void *buf, uint32_t len)
  43. {
  44. usbd.write(epnr, buf, len);
  45. }
  46. void usb_stall(uint8_t epnr)
  47. {
  48. usbd.stall(epnr);
  49. }
  50. void usb_configure_ep(uint8_t epnr, uint8_t type, uint32_t size)
  51. {
  52. usbd.configure_ep(epnr, type, size);
  53. }
  54. void usb_setaddr(uint8_t addr)
  55. {
  56. usbd.setaddr(addr);
  57. }
  58. void usb_process(void)
  59. {
  60. usbd.process();
  61. }
  62. /*
  63. * Local variables:
  64. * mode: C
  65. * c-file-style: "Linux"
  66. * c-basic-offset: 4
  67. * tab-width: 4
  68. * indent-tabs-mode: nil
  69. * End:
  70. */