Lab 4 tasks
Work in labs/mouse/. Build a parser that survives command responses, mid-stream starts, and invalid packets without poisoning the input stream.
Requested functions
int mouse_enable_data_reporting(void)int mouse_disable_data_reporting(void)int mouse_process_byte(uint8_t byte)int mouse_get_packet(mouse_packet_t *packet)
Guided gaps
Choose retry counts, validate ACKs, buffer three bytes, drop bytes until the synchronization bit marks byte 0, and convert signed movement to C integers. Keep these decisions visible for the final project.
IMPORTANT
Do not assume the first byte you receive is packet byte 0. Robust code must resynchronize when a stream starts mid-packet.
Common mistakes
Forgetting that X and Y have separate sign bits, treating overflow bits as movement, returning a packet before all three bytes arrive, and leaving data reporting enabled after a test. If a demo cursor jumps wildly, inspect synchronization and sign extension first.
Next: checks and references.