File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -49,19 +49,7 @@ namespace klib::usb::cdc::detail {
4949 *
5050 */
5151 template <typename Base, subtype SubType>
52- struct functional {
53- // size of the descriptor
54- const uint8_t bFunctionLength = sizeof (Base);
55-
56- // descriptor type (CS_INTERFACE)
57- const descriptor::descriptor_type bDescriptorType = descriptor::descriptor_type::cs_interface;
58-
59- // header functional descriptor subtype
60- const uint8_t bDescriptorSubtype = static_cast <uint8_t >(SubType);
61- };
62-
63- // make sure the size is correct
64- static_assert (sizeof (functional<uint8_t , subtype::header>) == 0x03 , " Cdc functional descriptor size is wrong" );
52+ struct functional : public descriptor ::cs_interface<Base, static_cast <uint8_t >(SubType)> {};
6553}
6654
6755namespace klib ::usb::cdc {
Original file line number Diff line number Diff line change @@ -436,6 +436,25 @@ namespace klib::usb::descriptor {
436436 };
437437
438438 static_assert (sizeof (interface_association) == 8 , " Interface association descriptor is not 8 bytes in length" );
439+
440+ /* *
441+ * @brief Base for all the class specific interface descriptors
442+ *
443+ */
444+ template <typename Base, uint8_t SubType>
445+ struct cs_interface {
446+ // size of the descriptor
447+ const uint8_t bFunctionLength = sizeof (Base);
448+
449+ // the device class specific descriptor type
450+ const descriptor_type bDescriptorType = descriptor_type::cs_interface;
451+
452+ // header functional descriptor subtype
453+ const uint8_t bDescriptorSubtype = static_cast <uint8_t >(SubType);
454+ };
455+
456+ // make sure the size is correct
457+ static_assert (sizeof (cs_interface<uint8_t , 0x00 >) == 0x03 , " Class specific base descriptor size is wrong" );
439458}
440459
441460// release the old pack so the rest of the structs are not
You can’t perform that action at this time.
0 commit comments