scsi_accel_rp2040.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Accelerated SCSI subroutines using RP2040 hardware PIO peripheral.
  2. #pragma once
  3. #include <stdint.h>
  4. void scsi_accel_rp2040_init();
  5. // Set SCSI access mode for synchronous transfers
  6. // Setting syncOffset = 0 enables asynchronous SCSI.
  7. // Setting syncOffset > 0 enables synchronous SCSI.
  8. // Returns false if busy, caller should issue bus reset to recover.
  9. bool scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod);
  10. // Queue a request to write data from the buffer to SCSI bus.
  11. // This function typically returns immediately and the request will complete in background.
  12. // If there are too many queued requests, this function will block until previous request finishes.
  13. void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile int *resetFlag);
  14. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  15. // If data is NULL, checks if all writes have completed.
  16. bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data);
  17. // Wait for all write requests to finish and release the bus.
  18. // If resetFlag is non-zero, aborts write immediately.
  19. void scsi_accel_rp2040_finishWrite(volatile int *resetFlag);
  20. // Queue a request to read data from SCSI bus to the buffer.
  21. // This function typically returns immediately and the request will complete in background.
  22. // If there are too many queued requests, this function will block until previous request finishes.
  23. void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);
  24. // Query whether data at address is part of a queued read request.
  25. // Returns true if there is no outstanding request.
  26. // If data is NULL, checks if all reads have completed.
  27. bool scsi_accel_rp2040_isReadFinished(const uint8_t* data);
  28. // Wait for a read request to complete.
  29. // If buf is not NULL, waits only until the data at data[0] .. data[count-1] is valid.
  30. // If buf is NULL, waits for all read requests to complete.
  31. // If there are no further read requests, releases the bus.
  32. // If resetFlag is non-zero, aborts read immediately.
  33. // If a parity error has been noticed in any buffer since starting the read, parityError is set to 1.
  34. void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);