diff options
m--------- | laks | 0 | ||||
-rw-r--r-- | main.cpp | 18 |
2 files changed, 11 insertions, 7 deletions
diff --git a/laks b/laks -Subproject 8d68e3d9823abe8a9ff6f8b0f6f4addee98bb26 +Subproject 754ed2f1658a58680abb6fa440ad9f7b8ad8c07 @@ -47,6 +47,7 @@ USB_otg usb(OTG_HS, dev_desc_p, conf_desc_p); class USB_I2C : public USB_class_driver { private: + USB_generic& usb; I2C_t& i2c; bool i2c_read(uint16_t wValue, uint16_t wIndex, uint16_t wLength) { @@ -58,7 +59,9 @@ class USB_I2C : public USB_class_driver { } public: - USB_I2C(I2C_t& i2c_bus) : i2c(i2c_bus) {} + USB_I2C(USB_generic& usbd, I2C_t& i2c_bus) : usb(usbd), i2c(i2c_bus) { + usb.register_driver(this); + } protected: virtual SetupStatus handle_setup(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength) { @@ -70,10 +73,12 @@ class USB_I2C : public USB_class_driver { } }; -USB_I2C usb_i2c(I2C2); +USB_I2C usb_i2c(usb, I2C2); class USB_JTAG : public USB_class_driver { private: + USB_generic& usb; + bool jtag_tick(bool tdi, bool tms) { bool tdo = jtag_tdo.get(); jtag_tdi.set(tdi); @@ -107,7 +112,9 @@ class USB_JTAG : public USB_class_driver { } public: - USB_JTAG() {} + USB_JTAG(USB_generic& usbd) : usb(usbd) { + usb.register_driver(this); + } protected: virtual SetupStatus handle_setup(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength) { @@ -119,7 +126,7 @@ class USB_JTAG : public USB_class_driver { } }; -USB_JTAG usb_jtag; +USB_JTAG usb_jtag(usb); template<> void interrupt<(Interrupt::IRQ)77>() { @@ -181,9 +188,6 @@ int main() { usb_thread.start(); - usb.register_control_handler(&usb_i2c); - usb.register_control_handler(&usb_jtag); - RCC.enable(RCC.SPI1); PA5.set_mode(Pin::AF); |