cdc_acm_protocol.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * cdc_acm_protocol.h
  3. *
  4. * Greaseweazle protocol over CDC ACM streams.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. /* CMD_GET_INFO, length=3, 0. Returns 32 bytes after ACK. */
  12. #define CMD_GET_INFO 0
  13. /* CMD_SEEK, length=3, cyl# */
  14. #define CMD_SEEK 1
  15. /* CMD_SIDE, length=3, side# (0=bottom) */
  16. #define CMD_SIDE 2
  17. /* CMD_SET_DELAYS, length=2+4*2, <delay_params> */
  18. #define CMD_SET_DELAYS 3
  19. /* CMD_GET_DELAYS, length=2. Returns 4*2 bytes after ACK. */
  20. #define CMD_GET_DELAYS 4
  21. /* CMD_MOTOR, length=3, motor_state */
  22. #define CMD_MOTOR 5
  23. /* CMD_READ_FLUX, length=3, #index_pulses.
  24. * Returns flux readings until EOStream. */
  25. #define CMD_READ_FLUX 6
  26. /* CMD_WRITE_FLUX, length=2-7. Optionally include all or part of gw_write_flux.
  27. * Host follows with flux readings until EOStream. */
  28. #define CMD_WRITE_FLUX 7
  29. /* CMD_GET_FLUX_STATUS, length=2. Last read/write status returned in ACK. */
  30. #define CMD_GET_FLUX_STATUS 8
  31. /* CMD_GET_INDEX_TIMES, length=2. Returns 15*4 bytes after ACK. */
  32. #define CMD_GET_INDEX_TIMES 9
  33. /* [BOOTLOADER] CMD_UPDATE, length=6, <update_len>.
  34. * Host follows with <update_len> bytes.
  35. * Bootloader finally returns a status byte, 0 on success. */
  36. #define CMD_UPDATE 1
  37. #define ACK_OKAY 0
  38. #define ACK_BAD_COMMAND 1
  39. #define ACK_NO_INDEX 2
  40. #define ACK_NO_TRK0 3
  41. #define ACK_FLUX_OVERFLOW 4
  42. #define ACK_FLUX_UNDERFLOW 5
  43. #define ACK_WRPROT 6
  44. #define BAUD_CLEAR_COMMS 10000
  45. struct __packed gw_info {
  46. uint8_t fw_major;
  47. uint8_t fw_minor;
  48. uint8_t max_index;
  49. uint8_t max_cmd;
  50. uint32_t sample_freq;
  51. };
  52. struct __packed gw_write_flux {
  53. uint32_t index_delay_ticks; /* default: 0 */
  54. uint8_t terminate_at_index; /* default: 0 */
  55. };
  56. /*
  57. * Local variables:
  58. * mode: C
  59. * c-file-style: "Linux"
  60. * c-basic-offset: 4
  61. * tab-width: 4
  62. * indent-tabs-mode: nil
  63. * End:
  64. */