rp2040_sdio.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // SD card access using SDIO for RP2040 platform.
  2. // This module contains the low-level SDIO bus implementation using
  3. // the PIO peripheral. The high-level commands are in sd_card_sdio.cpp.
  4. #pragma once
  5. #include <stdint.h>
  6. enum sdio_status_t {
  7. SDIO_OK = 0,
  8. SDIO_ERR_RESPONSE_TIMEOUT = 1, // Timed out waiting for response from card
  9. SDIO_ERR_CRC = 2, // Response CRC is wrong
  10. };
  11. // Execute a command that has 48-bit reply (response types R1, R3, R6 and R7)
  12. // If response is NULL, does not wait for reply.
  13. sdio_status_t rp2040_sdio_command_R1(uint8_t command, uint32_t arg, uint32_t *response);
  14. // Execute a command that has 136-bit reply (response type R2)
  15. sdio_status_t rp2040_sdio_command_R2(uint8_t command, uint32_t arg, uint32_t response[4]);
  16. // Start transferring data from SD card to memory buffer
  17. sdio_status_t rp2040_sdio_rx_start(uint8_t *buffer, uint32_t num_bytes);
  18. // Check if reception is complete
  19. bool rp2040_sdio_rx_poll();
  20. // Start transferring data from memory to SD card
  21. sdio_status_t rp2040_sdio_tx_start(const uint8_t *buffer, uint32_t num_bytes);
  22. // Check if transmission is complete
  23. bool rp2040_sdio_tx_poll();
  24. // (Re)initialize the SDIO interface
  25. void rp2040_sdio_init();