update USBMSD::memoryWrite implementation

Fix prevents unaligned USB transfers
pull/12693/head
Maciej Bocianski 2020-03-15 13:25:41 +01:00
parent 89e67d3136
commit 1ffb4d7356
1 changed files with 8 additions and 0 deletions

View File

@ -572,6 +572,14 @@ void USBMSD::_read_next()
void USBMSD::memoryWrite(uint8_t *buf, uint16_t size)
{
// Max sized packets are required to be sent until the transfer is complete
MBED_ASSERT(_block_size % MAX_PACKET == 0);
if ((size != MAX_PACKET) && (size != 0)) {
_stage = ERROR;
endpoint_stall(_bulk_out);
return;
}
if ((_addr + size) > _memory_size) {
size = _memory_size - _addr;
_stage = ERROR;