The normal "flush" for SD card only queues a cache sector for writing and the actual sync to the media happens asynchronously. During this period the cache entry is not available until the write completes sometime later. So as the blackbox header fields were written they end up consuming the majority of the cache. A "flush" was made before actual logging starts, but the async writes were not completing fast enough to ensure available cache sectors for the actual logging. This resulted in the cache getting overwritten and corrupting the header.
Changed to wait until the sector cache completes writing to the media before starting the actual logging. This ensures that the logging has ample cache sectors.
Changes only affect SD card logging.
Fixes a bug in the HAL USP vcp serial logic that would cause communication to hang after receiving a packet containing exactly 64 bytes.
When a packet is exactly 64 bytes the USB specification requires an empty (0 byte) pack to be additionally sent. The receiving logic was not handling this 0 byte packet properly. The logic error would cause it to not trigger receiving he next packet and communication would stop.
The MSPv2 parsing was missing a check (present in v1) to prevent a possible buffer overrun if the payload exceeded the buffer size.
Also some code formatting cleanup.
The following driver files only contain initialization and configuration fuctions and were erroneously set up for speed-optimization. Moving them to size-optimization saves significant space. They all share common runtime functions contained in `drivers/accgyro/accgyro_mpu.c` which is correctly speed-optimized.
```
drivers/accgyro/accgyro_mpu6050.c
drivers/accgyro/accgyro_mpu6500.c
drivers/accgyro/accgyro_spi_mpu6000.c
drivers/accgyro/accgyro_spi_mpu6500.c
drivers/accgyro/accgyro_spi_mpu9250.c
drivers/accgyro/accgyro_spi_icm20689.c
```
Also added explicit `#ifdef USE_` around the code of some of the drivers missing it. Doesn't result in any space savings as the compiler optimizes out the unused functions. But better in the long-term as it will flag any cases where the code might be called without proper bounding.
Saves 10704 bytes on STM32F7X2.