Skip to content

Zlp request2 #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
340dcb8
For control transfers, compare the transmitted length against the req…
pigrew Sep 12, 2019
8cca287
Add verification that there is enough buffer space for HID OUT contro…
pigrew Sep 12, 2019
1e17e2e
Add details on dcd_edpt_xfer in the porting document.
pigrew Sep 12, 2019
705b8be
Merge branch 'master' into ZLP_Request2
pigrew Sep 13, 2019
91fa24d
Merge branch 'master' into ZLP_Request2
pigrew Sep 27, 2019
0078be9
Merge branch 'master' into ZLP_Request2
pigrew Sep 29, 2019
4ea2a4e
Github's web interface changed line endings without asking me. Oops.
pigrew Sep 29, 2019
cef388b
Merge branch 'master' into ZLP_Request2
pigrew Oct 2, 2019
a29eb87
Merge branch 'ZLP_Request2' of https://github.com/pigrew/tinyusb into…
hathach Oct 29, 2019
8a57997
Merge branch 'master' into pigrew-ZLP_Request2
hathach Oct 31, 2019
e6857d8
clean up
hathach Oct 31, 2019
0029b58
rename
hathach Oct 31, 2019
d9ba4d9
move function around, more rename
hathach Oct 31, 2019
6de9eb4
add more tests, fix an issue with tud_descriptor_configuration_cb() r…
hathach Oct 31, 2019
6067adc
adeded tests for zlp
hathach Oct 31, 2019
cacbb80
zlp should work with control in, tested with Unity framework
hathach Oct 31, 2019
f587268
update doc, hid set report
hathach Oct 31, 2019
bd8b4e4
rename zlp test
hathach Oct 31, 2019
d35f869
Merge remote-tracking branch 'origin/master' into ZLP_Request2
pigrew Oct 31, 2019
981e64d
implement pigrew review
hathach Nov 1, 2019
ac0203b
update doc
hathach Nov 1, 2019
164d0db
Merge branch 'ZLP_Request2' into pigrew-ZLP_Request2
hathach Nov 1, 2019
7bf01e2
make control buf static
hathach Nov 3, 2019
585aebe
add uart support for stm32f072disco
hathach Nov 3, 2019
5ca75eb
seperate DEBUG from LOG
hathach Nov 3, 2019
62f8c14
add a bit of log1 for debugging
hathach Nov 3, 2019
5839159
Enable UART debugging on F070.
pigrew Nov 3, 2019
cebc066
Add UART HAL source file to stm32f070 makefile.
pigrew Nov 3, 2019
68a53e0
Merge pull request #2 from hathach/pigrew-ZLP_Request2
pigrew Nov 3, 2019
44ad683
fix tud_control_status() didn't update request
hathach Nov 4, 2019
0d856b7
Merge pull request #3 from hathach/pigrew-ZLP_Request2
pigrew Nov 4, 2019
c98acd3
Use control transfer function to send control data (in usbtmc)
pigrew Nov 4, 2019
a94fe05
usbd: Change TU_ASSERT to TU_VERIFY as the assertion can be hit when …
pigrew Nov 4, 2019
8d0fa15
Change one more TU_ASSERT to TU_VERIFY in usbd.
pigrew Nov 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add more tests, fix an issue with tud_descriptor_configuration_cb() r…
…eturn NULL
  • Loading branch information
hathach committed Oct 31, 2019
commit 6de9eb4b1a6bb84832ce4a55f050763d05f8a6b3
2 changes: 2 additions & 0 deletions src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
case TUSB_DESC_CONFIGURATION:
{
tusb_desc_configuration_t const* desc_config = (tusb_desc_configuration_t const*) tud_descriptor_configuration_cb(desc_index);
TU_ASSERT(desc_config);

uint16_t total_len;
memcpy(&total_len, &desc_config->wTotalLength, 2); // possibly mis-aligned memory

Expand Down
72 changes: 61 additions & 11 deletions test/test/device/usbd/test_usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TEST_FILE("usbd_control.c")

uint8_t const rhport = 0;

tusb_desc_device_t const desc_device =
tusb_desc_device_t const data_desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
Expand All @@ -65,6 +65,12 @@ tusb_desc_device_t const desc_device =
.bNumConfigurations = 0x01
};

uint8_t const data_desc_configuration[] =
{
// Interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(0, 0, TUD_CONFIG_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
};

tusb_control_request_t const req_get_desc_device =
{
.bmRequestType = 0x80,
Expand All @@ -74,20 +80,29 @@ tusb_control_request_t const req_get_desc_device =
.wLength = 64
};

tusb_control_request_t const req_get_desc_configuration =
{
.bmRequestType = 0x80,
.bRequest = TUSB_REQ_GET_DESCRIPTOR,
.wValue = (TUSB_DESC_CONFIGURATION << 8),
.wIndex = 0x0000,
.wLength = 256
};

uint8_t const* desc_device;
uint8_t const* desc_configuration;

//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
uint8_t const * ptr_desc_device;

uint8_t const * tud_descriptor_device_cb(void)
{
return ptr_desc_device;
return desc_device;
}

uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{
TEST_FAIL();
return NULL;
return desc_configuration;
}

uint16_t const* tud_descriptor_string_cb(uint8_t index)
Expand All @@ -105,29 +120,30 @@ void setUp(void)
dcd_init_Expect(rhport);
tusb_init();
}

ptr_desc_device = (uint8_t const *) &desc_device;
}

void tearDown(void)
{
}

//--------------------------------------------------------------------+
//
// Get Descriptor
//--------------------------------------------------------------------+

//------------- Device -------------//
void test_usbd_get_device_descriptor(void)
{
desc_device = (uint8_t const *) &data_desc_device;
dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_device, false);

dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*)&desc_device, sizeof(tusb_desc_device_t), sizeof(tusb_desc_device_t), true);
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*)&data_desc_device, sizeof(tusb_desc_device_t), sizeof(tusb_desc_device_t), true);

tud_task();
}

void test_usbd_get_device_descriptor_null(void)
{
ptr_desc_device = NULL;
desc_device = NULL;

dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_device, false);

Expand All @@ -136,3 +152,37 @@ void test_usbd_get_device_descriptor_null(void)

tud_task();
}

//------------- Configuration -------------//

void test_usbd_get_configuration_descriptor(void)
{
desc_configuration = data_desc_configuration;
uint16_t total_len = ((tusb_desc_configuration_t const*) data_desc_configuration)->wTotalLength;

dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_configuration, false);

dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*) data_desc_configuration, total_len, total_len, true);

tud_task();
}

void test_usbd_get_configuration_descriptor_null(void)
{
desc_configuration = NULL;
dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_configuration, false);

dcd_edpt_stall_Expect(rhport, 0);
dcd_edpt_stall_Expect(rhport, 0x80);

tud_task();
}

//--------------------------------------------------------------------+
// Control ZLP
//--------------------------------------------------------------------+

//void test_control_zlp(void)
//{
//
//}