scsi_accel_host.pio 1.1 KB

123456789101112131415161718192021222324252627282930
  1. ; RP2040 PIO program for accelerating SCSI initiator / host function
  2. ;
  3. ; Copyright (c) 2022 Rabbit Hole Computing™
  4. ;
  5. ; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
  6. ; GPIO mapping:
  7. ; - 0-7: DB0-DB7
  8. ; - 8: DBP
  9. ; Side set is ACK pin
  10. .define REQ 19
  11. .define ACK 26
  12. ; Read from SCSI bus using asynchronous handshake.
  13. ; Data is returned as 16-bit words that contain the 8 data bits + 1 parity bit.
  14. ; Number of bytes to receive minus 1 should be written to TX fifo.
  15. ; Number of bytes to receive must be divisible by 2.
  16. .program scsi_host_async_read
  17. .side_set 1
  18. pull block side 1 ; Get number of bytes to receive
  19. mov x, osr side 1 ; Store to counter X
  20. start:
  21. wait 0 gpio REQ side 1 ; Wait for REQ low
  22. nop [1] side 1 ; Wait for signals to settle
  23. in pins, 9 side 0 ; Assert ACK, read GPIO
  24. in null, 7 side 0 ; Padding bits
  25. wait 1 gpio REQ side 0 ; Wait for REQ high
  26. jmp x-- start side 1 ; Deassert ACK, decrement byte count and jump to start