|
4 | 4 | #include <span> |
5 | 5 |
|
6 | 6 | #include <klib/klib.hpp> |
7 | | -#include <klib/usb/usb/usb.hpp> |
8 | 7 | #include <klib/math.hpp> |
9 | 8 | #include <klib/irq_helper.hpp> |
10 | 9 | #include <klib/usb/usb/setup.hpp> |
| 10 | +#include <klib/usb/usb/size.hpp> |
| 11 | +#include <klib/usb/usb/usb.hpp> |
11 | 12 |
|
12 | 13 | #include <io/port.hpp> |
13 | 14 |
|
@@ -51,8 +52,10 @@ namespace klib::core::mb9bf560l::io { |
51 | 52 | // amount of endpoints supported by the lpc1756 |
52 | 53 | constexpr static uint8_t endpoint_count = 6; |
53 | 54 |
|
54 | | - // max size in a single endpoint |
55 | | - constexpr static uint8_t max_endpoint_size = 64; |
| 55 | + // maximum endpoint sizes |
| 56 | + constexpr static klib::usb::endpoint_size_endpoint<endpoint_count, |
| 57 | + 64, 256, 64, 64, 64, 64 |
| 58 | + > max_endpoint_size = {}; |
56 | 59 |
|
57 | 60 | // type to use in device functions |
58 | 61 | using usb_type = usb<Usb, Device>; |
@@ -171,7 +174,7 @@ namespace klib::core::mb9bf560l::io { |
171 | 174 | Usb::port->UDCC |= 0x1; |
172 | 175 |
|
173 | 176 | // configure enpoint 0 endpoint size. |
174 | | - Usb::port->EP0C = max_endpoint_size; |
| 177 | + Usb::port->EP0C = max_endpoint_size.size(0, klib::usb::descriptor::transfer_type::control); |
175 | 178 |
|
176 | 179 | // clear the reset flag |
177 | 180 | Usb::port->UDCC &= ~(0x1 << 7); |
@@ -661,7 +664,9 @@ namespace klib::core::mb9bf560l::io { |
661 | 664 | for (uint32_t i = 0; i < endpoint_count; i++) { |
662 | 665 | // set the endpoint to a known state |
663 | 666 | state[i].is_busy = false; |
664 | | - state[i].max_size = static_cast<uint8_t>((i == 0) ? max_endpoint_size : 0); |
| 667 | + state[i].max_size = static_cast<uint8_t>( |
| 668 | + (i == 0) ? max_endpoint_size.size(0, klib::usb::descriptor::transfer_type::control) : 0 |
| 669 | + ); |
665 | 670 | state[i].data = nullptr; |
666 | 671 | state[i].requested_size = 0; |
667 | 672 | state[i].transferred_size = 0; |
@@ -765,7 +770,7 @@ namespace klib::core::mb9bf560l::io { |
765 | 770 | const uint16_t s = size & (endpoint == 1 ? 0x1ff : 0x7f); |
766 | 771 |
|
767 | 772 | // set the new endpoint size |
768 | | - state[endpoint].max_size = s; |
| 773 | + state[endpoint].max_size = klib::min(s, max_endpoint_size.size(endpoint, type)); |
769 | 774 |
|
770 | 775 | // set the endpoint configuration |
771 | 776 | (*ep_control) = ( |
|
0 commit comments