Skip to content

Lab 4 Tasks

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

  • Decide how many retries command writes should attempt.
  • Validate ACK responses.
  • Store packet bytes until all three are available.
  • Drop bytes until the synchronization bit identifies byte 0.
  • Convert signed movement into C integers.

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 arrived.
  • Leaving data reporting enabled after a test.

Next: checks and references.

Course/docs licensed CC BY 4.0. Code licensed MIT.