scsi_accel_rp2040.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. void scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod);
  9. // Queue a request to write data from the buffer to SCSI bus.
  10. // This function typically returns immediately and the request will complete in background.
  11. // If there are too many queued requests, this function will block until previous request finishes.
  12. void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile int *resetFlag);
  13. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  14. // If data is NULL, checks if all writes have completed.
  15. bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data);
  16. // Wait for all write requests to finish and release the bus.
  17. // If resetFlag is non-zero, aborts write immediately.
  18. void scsi_accel_rp2040_finishWrite(volatile int *resetFlag);
  19. // Queue a request to read data from SCSI bus to the buffer.
  20. // This function typically returns immediately and the request will complete in background.
  21. // If there are too many queued requests, this function will block until previous request finishes.
  22. void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);
  23. // Query whether data at address is part of a queued read request.
  24. // Returns true if there is no outstanding request.
  25. // If data is NULL, checks if all reads have completed.
  26. bool scsi_accel_rp2040_isReadFinished(const uint8_t* data);
  27. // Wait for a read request to complete.
  28. // If buf is not NULL, waits only until the data at data[0] .. data[count-1] is valid.
  29. // If buf is NULL, waits for all read requests to complete.
  30. // If there are no further read requests, releases the bus.
  31. // If resetFlag is non-zero, aborts read immediately.
  32. // If a parity error has been noticed in any buffer since starting the read, parityError is set to 1.
  33. void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);