|
| 1 | +use avr_device::atmega32u4::PLL; |
| 2 | +use avr_device::atmega32u4::USB_DEVICE; |
| 3 | +use usb_device::bus::PollResult; |
| 4 | +use usb_device::bus::UsbBus; |
| 5 | +use usb_device::endpoint::EndpointAddress; |
| 6 | +use usb_device::endpoint::EndpointType; |
| 7 | +use usb_device::UsbDirection; |
| 8 | +use usb_device::UsbError; |
| 9 | + |
| 10 | +// TODO: I'm not too familiar with naming conventions in avr-hal (or Rust, for |
| 11 | +// that matter). Is `UsbdBus` acceptable? |
| 12 | +// |
| 13 | +// I decided to use the same name that the `musb` crate uses for their |
| 14 | +// implementation; I recall seeing somewhere that "usbd" was an abbreviation for |
| 15 | +// the "usb-device" crate. |
| 16 | +pub struct UsbdBus {} |
| 17 | + |
| 18 | +impl UsbdBus { |
| 19 | + // TODO: I'm not sure that the arguments to the `new` function are |
| 20 | + // correct; there's a chance that they'll need to change during |
| 21 | + // implementation. |
| 22 | + // |
| 23 | + // Considering this example code: |
| 24 | + // https://github.com/agausmann/atmega-usbd/blob/master/examples/arduino_keyboard.rs#L54-L78 |
| 25 | + // https://github.com/agausmann/atmega-usbd/blob/master/src/lib.rs#L69-L77 |
| 26 | + // |
| 27 | + // * USB_DEVICE is clearly required. |
| 28 | + // |
| 29 | + // * The PLL will definitely need to be modified, and I'm inclined to |
| 30 | + // think that we should just take ownership and do it here. |
| 31 | + // |
| 32 | + // At first glance, it looks like the PLL can simultanously drive both the |
| 33 | + // USB controller and high speed timer(s). If so, there *might* be a |
| 34 | + // usecase where the user initializes PLL, then passes a shared reference |
| 35 | + // into this constructor. I don't think that's worth worring about though; |
| 36 | + // we can always add a new constructor later, and I don't want every |
| 37 | + // single user to have duplicate code for initializing PLL. |
| 38 | + // |
| 39 | + // * I don't *think* there's anything else we need? |
| 40 | + pub fn new(_usb: USB_DEVICE, _pll: PLL) -> Self { |
| 41 | + todo!(); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +// TODO: implement this trait using code from |
| 46 | +// https://github.com/agausmann/atmega-usbd/blob/master/src/lib.rs |
| 47 | +impl UsbBus for UsbdBus { |
| 48 | + fn alloc_ep( |
| 49 | + &mut self, |
| 50 | + _: UsbDirection, |
| 51 | + _: Option<EndpointAddress>, |
| 52 | + _: EndpointType, |
| 53 | + _: u16, |
| 54 | + _: u8, |
| 55 | + ) -> Result<EndpointAddress, UsbError> { |
| 56 | + todo!() |
| 57 | + } |
| 58 | + fn enable(&mut self) { |
| 59 | + todo!() |
| 60 | + } |
| 61 | + fn reset(&self) { |
| 62 | + todo!() |
| 63 | + } |
| 64 | + fn set_device_address(&self, _: u8) { |
| 65 | + todo!() |
| 66 | + } |
| 67 | + fn write(&self, _: EndpointAddress, _: &[u8]) -> Result<usize, UsbError> { |
| 68 | + todo!() |
| 69 | + } |
| 70 | + fn read(&self, _: EndpointAddress, _: &mut [u8]) -> Result<usize, UsbError> { |
| 71 | + todo!() |
| 72 | + } |
| 73 | + fn set_stalled(&self, _: EndpointAddress, _: bool) { |
| 74 | + todo!() |
| 75 | + } |
| 76 | + fn is_stalled(&self, _: EndpointAddress) -> bool { |
| 77 | + todo!() |
| 78 | + } |
| 79 | + fn suspend(&self) { |
| 80 | + todo!() |
| 81 | + } |
| 82 | + fn resume(&self) { |
| 83 | + todo!() |
| 84 | + } |
| 85 | + fn poll(&self) -> PollResult { |
| 86 | + todo!() |
| 87 | + } |
| 88 | +} |
0 commit comments