scsi_accel_host.pio 1.0 KB

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