scsi_accel_host_RP2MCU.pio 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ; ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™
  2. ;
  3. ; ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  4. ;
  5. ; https://www.gnu.org/licenses/gpl-3.0.html
  6. ; ----
  7. ; This program is free software: you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation, either version 3 of the License, or
  10. ; (at your option) any later version. 
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details. 
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program.  If not, see <https://www.gnu.org/licenses/>.
  19. ; RP2040 PIO program for accelerating SCSI initiator / host function
  20. ; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
  21. ; GPIO mapping:
  22. ; - 0-7: DB0-DB7
  23. ; - 8: DBP
  24. ; Side set is ACK pin
  25. ; REQ is a dummy value, set by via pico-sdk encode functions
  26. .define REQ 9
  27. .define ACK 10
  28. ; Read from SCSI bus using asynchronous handshake.
  29. ; Data is returned as 16-bit words that contain the 8 data bits + 1 parity bit.
  30. ; Number of bytes to receive minus 1 should be written to TX fifo.
  31. ; Number of bytes to receive must be divisible by 2.
  32. .program scsi_host_async_read
  33. .side_set 1
  34. pull block side 1 ; Get number of bytes to receive
  35. mov x, osr side 1 ; Store to counter X
  36. start:
  37. wait 0 gpio REQ side 1 ; Wait for REQ low
  38. in pins, 9 side 0 ; Assert ACK, read GPIO
  39. in null, 7 side 0 ; Padding bits
  40. wait 1 gpio REQ side 0 ; Wait for REQ high
  41. jmp x-- start side 1 ; Deassert ACK, decrement byte count and jump to start