usb: device_next: Reduce code size on Full-Speed only configuration

Allow compiler optimizations to remove High-Speed handling code. Knowing
that maximum operating speed is Full-Speed allows to reduce bulk buffers
from 512 to 64 bytes. More RAM optimizations are possible but this
commit only gets the low hanging fruits.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
Tomasz Moń 2024-09-04 08:19:32 +02:00 committed by Benjamin Cabé
commit b3eb6f2d11
19 changed files with 104 additions and 59 deletions

View file

@ -136,7 +136,8 @@ static void *usb_test_enable(void)
err = usbd_add_descriptor(&test_usbd, &test_sn);
zassert_equal(err, 0, "Failed to initialize descriptor (%d)", err);
if (usbd_caps_speed(&test_usbd) == USBD_SPEED_HS) {
if (USBD_SUPPORTS_HIGH_SPEED &&
usbd_caps_speed(&test_usbd) == USBD_SPEED_HS) {
err = usbd_add_configuration(&test_usbd, USBD_SPEED_HS, &test_hs_config);
zassert_equal(err, 0, "Failed to add configuration (%d)");
}
@ -144,7 +145,8 @@ static void *usb_test_enable(void)
err = usbd_add_configuration(&test_usbd, USBD_SPEED_FS, &test_fs_config);
zassert_equal(err, 0, "Failed to add configuration (%d)");
if (usbd_caps_speed(&test_usbd) == USBD_SPEED_HS) {
if (USBD_SUPPORTS_HIGH_SPEED &&
usbd_caps_speed(&test_usbd) == USBD_SPEED_HS) {
err = usbd_register_all_classes(&test_usbd, USBD_SPEED_HS, 1, NULL);
zassert_equal(err, 0, "Failed to unregister all instances(%d)");