Prusa MINI Firmware overview
sdio.h File Reference
#include "../shared/Marduino.h"
#include <libmaple/sdio.h>
#include <libmaple/dma.h>

Go to the source code of this file.

Classes

struct  SDIO_CardInfoTypeDef
 

Macros

#define SDMMC_CMD_GO_IDLE_STATE   ((uint8_t)0) /* Resets the SD memory card. */
 
#define SDMMC_CMD_ALL_SEND_CID   ((uint8_t)2) /* Asks any card connected to the host to send the CID numbers on the CMD line. */
 
#define SDMMC_CMD_SET_REL_ADDR   ((uint8_t)3) /* Asks the card to publish a new relative address (RCA). */
 
#define SDMMC_CMD_SEL_DESEL_CARD   ((uint8_t)7) /* Selects the card by its own relative address and gets deselected by any other address */
 
#define SDMMC_CMD_HS_SEND_EXT_CSD   ((uint8_t)8) /* Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage. */
 
#define SDMMC_CMD_SEND_CSD   ((uint8_t)9) /* Addressed card sends its card specific data (CSD) on the CMD line. */
 
#define SDMMC_CMD_SEND_STATUS   ((uint8_t)13)
 
#define SDMMC_CMD_READ_SINGLE_BLOCK   ((uint8_t)17) /* Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */
 
#define SDMMC_CMD_WRITE_SINGLE_BLOCK   ((uint8_t)24) /* Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */
 
#define SDMMC_CMD_APP_CMD   ((uint8_t)55) /* Indicates to the card that the next command is an application specific command rather than a standard command. */
 
#define SDMMC_ACMD_APP_SD_SET_BUSWIDTH   ((uint8_t)6) /* (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus widths are given in SCR register. */
 
#define SDMMC_ACMD_SD_APP_OP_COND   ((uint8_t)41) /* (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */
 
#define SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT   ((uint8_t)42) /* (ACMD42) Connect/Disconnect the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card */
 
#define CMD0_GO_IDLE_STATE   (uint16_t)(SDMMC_CMD_GO_IDLE_STATE | SDIO_CMD_WAIT_NO_RESP)
 
#define CMD2_ALL_SEND_CID   (uint16_t)(SDMMC_CMD_ALL_SEND_CID | SDIO_CMD_WAIT_LONG_RESP)
 
#define CMD3_SET_REL_ADDR   (uint16_t)(SDMMC_CMD_SET_REL_ADDR | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD7_SEL_DESEL_CARD   (uint16_t)(SDMMC_CMD_SEL_DESEL_CARD | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD8_HS_SEND_EXT_CSD   (uint16_t)(SDMMC_CMD_HS_SEND_EXT_CSD | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD9_SEND_CSD   (uint16_t)(SDMMC_CMD_SEND_CSD | SDIO_CMD_WAIT_LONG_RESP)
 
#define CMD13_SEND_STATUS   (uint16_t)(SDMMC_CMD_SEND_STATUS | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD17_READ_SINGLE_BLOCK   (uint16_t)(SDMMC_CMD_READ_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD24_WRITE_SINGLE_BLOCK   (uint16_t)(SDMMC_CMD_WRITE_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
 
#define CMD55_APP_CMD   (uint16_t)(SDMMC_CMD_APP_CMD | SDIO_CMD_WAIT_SHORT_RESP)
 
#define ACMD6_APP_SD_SET_BUSWIDTH   (uint16_t)(SDMMC_ACMD_APP_SD_SET_BUSWIDTH | SDIO_CMD_WAIT_SHORT_RESP)
 
#define ACMD41_SD_APP_OP_COND   (uint16_t)(SDMMC_ACMD_SD_APP_OP_COND | SDIO_CMD_WAIT_SHORT_RESP)
 
#define ACMD42_SD_APP_SET_CLR_CARD_DETECT   (uint16_t)(SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT | SDIO_CMD_WAIT_SHORT_RESP)
 
#define SDMMC_ALLZERO   0x00000000U
 
#define SDMMC_OCR_ERRORBITS   0xFDFFE008U
 
#define SDMMC_R6_GENERAL_UNKNOWN_ERROR   0x00002000U
 
#define SDMMC_R6_ILLEGAL_CMD   0x00004000U
 
#define SDMMC_R6_COM_CRC_FAILED   0x00008000U
 
#define SDMMC_VOLTAGE_WINDOW_SD   0x80100000U
 
#define SDMMC_HIGH_CAPACITY   0x40000000U
 
#define SDMMC_STD_CAPACITY   0x00000000U
 
#define SDMMC_CHECK_PATTERN   0x000001AAU
 
#define SDIO_TRANSFER_MODE_BLOCK   0x00000000U
 
#define SDIO_DPSM_ENABLE   0x00000001U
 
#define SDIO_TRANSFER_DIR_TO_CARD   0x00000000U
 
#define SDIO_DATABLOCK_SIZE_512B   0x00000090U
 
#define SDIO_TRANSFER_DIR_TO_SDIO   0x00000100U
 
#define SDIO_DMA_ENABLE   0x00001000U
 
#define CARD_V1_X   0x00000000U
 
#define CARD_V2_X   0x00000001U
 
#define CARD_SDSC   0x00000000U
 
#define CARD_SDHC_SDXC   0x00000001U
 
#define SDIO_RESP1   0
 
#define SDIO_RESP2   1
 
#define SDIO_RESP3   2
 
#define SDIO_RESP4   3
 
#define SDIO_GET_FLAG(__FLAG__)   !!((SDIO->STA) & (__FLAG__))
 
#define SDIO_CLEAR_FLAG(__FLAG__)   (SDIO->ICR = (__FLAG__))
 
#define SDMMC_MAX_VOLT_TRIAL   0x00000FFFU
 
#define SDIO_CARD_TRANSFER   0x00000004U /* Card is in transfer state */
 
#define SDIO_CARD_ERROR   0x000000FFU /* Card response Error */
 
#define SDIO_CMDTIMEOUT   200U /* Command send and response timeout */
 
#define SDIO_DATA_TIMEOUT   100U /* Read data transfer timeout */
 
#define SDIO_WRITE_TIMEOUT   200U /* Write data transfer timeout */
 
#define SDIO_CLOCK   18000000 /* 18 MHz */
 

Functions

uint32_t SDIO_GetCardState ()
 
bool SDIO_CmdGoIdleState ()
 
bool SDIO_CmdSendCID ()
 
bool SDIO_CmdSetRelAdd (uint32_t *rca)
 
bool SDIO_CmdSelDesel (uint32_t address)
 
bool SDIO_CmdOperCond ()
 
bool SDIO_CmdSendCSD (uint32_t argument)
 
bool SDIO_CmdSendStatus (uint32_t argument)
 
bool SDIO_CmdReadSingleBlock (uint32_t address)
 
bool SDIO_CmdWriteSingleBlock (uint32_t address)
 
bool SDIO_CmdAppCommand (uint32_t rsa)
 
bool SDIO_CmdAppSetBusWidth (uint32_t rsa, uint32_t argument)
 
bool SDIO_CmdAppOperCommand (uint32_t sdType)
 
bool SDIO_CmdAppSetClearCardDetect (uint32_t rsa)
 
void SDIO_SendCommand (uint16_t command, uint32_t argument)
 
uint8_t SDIO_GetCommandResponse ()
 
uint32_t SDIO_GetResponse (uint32_t response)
 
bool SDIO_GetCmdError ()
 
bool SDIO_GetCmdResp1 (uint8_t command)
 
bool SDIO_GetCmdResp2 ()
 
bool SDIO_GetCmdResp3 ()
 
bool SDIO_GetCmdResp6 (uint8_t command, uint32_t *rca)
 
bool SDIO_GetCmdResp7 ()
 

Macro Definition Documentation

◆ SDMMC_CMD_GO_IDLE_STATE

#define SDMMC_CMD_GO_IDLE_STATE   ((uint8_t)0) /* Resets the SD memory card. */

Marlin 3D Printer Firmware

Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] Copyright (c) 2016 Bob Cousins bobco.nosp@m.usin.nosp@m.s42@g.nosp@m.oogl.nosp@m.email.nosp@m..com Copyright (c) 2017 Victor Perez

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

◆ SDMMC_CMD_ALL_SEND_CID

#define SDMMC_CMD_ALL_SEND_CID   ((uint8_t)2) /* Asks any card connected to the host to send the CID numbers on the CMD line. */

◆ SDMMC_CMD_SET_REL_ADDR

#define SDMMC_CMD_SET_REL_ADDR   ((uint8_t)3) /* Asks the card to publish a new relative address (RCA). */

◆ SDMMC_CMD_SEL_DESEL_CARD

#define SDMMC_CMD_SEL_DESEL_CARD   ((uint8_t)7) /* Selects the card by its own relative address and gets deselected by any other address */

◆ SDMMC_CMD_HS_SEND_EXT_CSD

#define SDMMC_CMD_HS_SEND_EXT_CSD   ((uint8_t)8) /* Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage. */

◆ SDMMC_CMD_SEND_CSD

#define SDMMC_CMD_SEND_CSD   ((uint8_t)9) /* Addressed card sends its card specific data (CSD) on the CMD line. */

◆ SDMMC_CMD_SEND_STATUS

#define SDMMC_CMD_SEND_STATUS   ((uint8_t)13)

Addressed card sends its status register.

◆ SDMMC_CMD_READ_SINGLE_BLOCK

#define SDMMC_CMD_READ_SINGLE_BLOCK   ((uint8_t)17) /* Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */

◆ SDMMC_CMD_WRITE_SINGLE_BLOCK

#define SDMMC_CMD_WRITE_SINGLE_BLOCK   ((uint8_t)24) /* Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */

◆ SDMMC_CMD_APP_CMD

#define SDMMC_CMD_APP_CMD   ((uint8_t)55) /* Indicates to the card that the next command is an application specific command rather than a standard command. */

◆ SDMMC_ACMD_APP_SD_SET_BUSWIDTH

#define SDMMC_ACMD_APP_SD_SET_BUSWIDTH   ((uint8_t)6) /* (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus widths are given in SCR register. */

◆ SDMMC_ACMD_SD_APP_OP_COND

#define SDMMC_ACMD_SD_APP_OP_COND   ((uint8_t)41) /* (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */

◆ SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT

#define SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT   ((uint8_t)42) /* (ACMD42) Connect/Disconnect the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card */

◆ CMD0_GO_IDLE_STATE

#define CMD0_GO_IDLE_STATE   (uint16_t)(SDMMC_CMD_GO_IDLE_STATE | SDIO_CMD_WAIT_NO_RESP)

◆ CMD2_ALL_SEND_CID

#define CMD2_ALL_SEND_CID   (uint16_t)(SDMMC_CMD_ALL_SEND_CID | SDIO_CMD_WAIT_LONG_RESP)

◆ CMD3_SET_REL_ADDR

#define CMD3_SET_REL_ADDR   (uint16_t)(SDMMC_CMD_SET_REL_ADDR | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD7_SEL_DESEL_CARD

#define CMD7_SEL_DESEL_CARD   (uint16_t)(SDMMC_CMD_SEL_DESEL_CARD | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD8_HS_SEND_EXT_CSD

#define CMD8_HS_SEND_EXT_CSD   (uint16_t)(SDMMC_CMD_HS_SEND_EXT_CSD | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD9_SEND_CSD

#define CMD9_SEND_CSD   (uint16_t)(SDMMC_CMD_SEND_CSD | SDIO_CMD_WAIT_LONG_RESP)

◆ CMD13_SEND_STATUS

#define CMD13_SEND_STATUS   (uint16_t)(SDMMC_CMD_SEND_STATUS | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD17_READ_SINGLE_BLOCK

#define CMD17_READ_SINGLE_BLOCK   (uint16_t)(SDMMC_CMD_READ_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD24_WRITE_SINGLE_BLOCK

#define CMD24_WRITE_SINGLE_BLOCK   (uint16_t)(SDMMC_CMD_WRITE_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)

◆ CMD55_APP_CMD

#define CMD55_APP_CMD   (uint16_t)(SDMMC_CMD_APP_CMD | SDIO_CMD_WAIT_SHORT_RESP)

◆ ACMD6_APP_SD_SET_BUSWIDTH

#define ACMD6_APP_SD_SET_BUSWIDTH   (uint16_t)(SDMMC_ACMD_APP_SD_SET_BUSWIDTH | SDIO_CMD_WAIT_SHORT_RESP)

◆ ACMD41_SD_APP_OP_COND

#define ACMD41_SD_APP_OP_COND   (uint16_t)(SDMMC_ACMD_SD_APP_OP_COND | SDIO_CMD_WAIT_SHORT_RESP)

◆ ACMD42_SD_APP_SET_CLR_CARD_DETECT

#define ACMD42_SD_APP_SET_CLR_CARD_DETECT   (uint16_t)(SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT | SDIO_CMD_WAIT_SHORT_RESP)

◆ SDMMC_ALLZERO

#define SDMMC_ALLZERO   0x00000000U

◆ SDMMC_OCR_ERRORBITS

#define SDMMC_OCR_ERRORBITS   0xFDFFE008U

◆ SDMMC_R6_GENERAL_UNKNOWN_ERROR

#define SDMMC_R6_GENERAL_UNKNOWN_ERROR   0x00002000U

◆ SDMMC_R6_ILLEGAL_CMD

#define SDMMC_R6_ILLEGAL_CMD   0x00004000U

◆ SDMMC_R6_COM_CRC_FAILED

#define SDMMC_R6_COM_CRC_FAILED   0x00008000U

◆ SDMMC_VOLTAGE_WINDOW_SD

#define SDMMC_VOLTAGE_WINDOW_SD   0x80100000U

◆ SDMMC_HIGH_CAPACITY

#define SDMMC_HIGH_CAPACITY   0x40000000U

◆ SDMMC_STD_CAPACITY

#define SDMMC_STD_CAPACITY   0x00000000U

◆ SDMMC_CHECK_PATTERN

#define SDMMC_CHECK_PATTERN   0x000001AAU

◆ SDIO_TRANSFER_MODE_BLOCK

#define SDIO_TRANSFER_MODE_BLOCK   0x00000000U

◆ SDIO_DPSM_ENABLE

#define SDIO_DPSM_ENABLE   0x00000001U

◆ SDIO_TRANSFER_DIR_TO_CARD

#define SDIO_TRANSFER_DIR_TO_CARD   0x00000000U

◆ SDIO_DATABLOCK_SIZE_512B

#define SDIO_DATABLOCK_SIZE_512B   0x00000090U

◆ SDIO_TRANSFER_DIR_TO_SDIO

#define SDIO_TRANSFER_DIR_TO_SDIO   0x00000100U

◆ SDIO_DMA_ENABLE

#define SDIO_DMA_ENABLE   0x00001000U

◆ CARD_V1_X

#define CARD_V1_X   0x00000000U

◆ CARD_V2_X

#define CARD_V2_X   0x00000001U

◆ CARD_SDSC

#define CARD_SDSC   0x00000000U

◆ CARD_SDHC_SDXC

#define CARD_SDHC_SDXC   0x00000001U

◆ SDIO_RESP1

#define SDIO_RESP1   0

◆ SDIO_RESP2

#define SDIO_RESP2   1

◆ SDIO_RESP3

#define SDIO_RESP3   2

◆ SDIO_RESP4

#define SDIO_RESP4   3

◆ SDIO_GET_FLAG

#define SDIO_GET_FLAG (   __FLAG__)    !!((SDIO->STA) & (__FLAG__))

◆ SDIO_CLEAR_FLAG

#define SDIO_CLEAR_FLAG (   __FLAG__)    (SDIO->ICR = (__FLAG__))

◆ SDMMC_MAX_VOLT_TRIAL

#define SDMMC_MAX_VOLT_TRIAL   0x00000FFFU

◆ SDIO_CARD_TRANSFER

#define SDIO_CARD_TRANSFER   0x00000004U /* Card is in transfer state */

◆ SDIO_CARD_ERROR

#define SDIO_CARD_ERROR   0x000000FFU /* Card response Error */

◆ SDIO_CMDTIMEOUT

#define SDIO_CMDTIMEOUT   200U /* Command send and response timeout */

◆ SDIO_DATA_TIMEOUT

#define SDIO_DATA_TIMEOUT   100U /* Read data transfer timeout */

◆ SDIO_WRITE_TIMEOUT

#define SDIO_WRITE_TIMEOUT   200U /* Write data transfer timeout */

◆ SDIO_CLOCK

#define SDIO_CLOCK   18000000 /* 18 MHz */

Function Documentation

◆ SDIO_GetCardState()

uint32_t SDIO_GetCardState ( )

◆ SDIO_CmdGoIdleState()

bool SDIO_CmdGoIdleState ( )

◆ SDIO_CmdSendCID()

bool SDIO_CmdSendCID ( )

◆ SDIO_CmdSetRelAdd()

bool SDIO_CmdSetRelAdd ( uint32_t *  rca)

◆ SDIO_CmdSelDesel()

bool SDIO_CmdSelDesel ( uint32_t  address)

◆ SDIO_CmdOperCond()

bool SDIO_CmdOperCond ( )

◆ SDIO_CmdSendCSD()

bool SDIO_CmdSendCSD ( uint32_t  argument)

◆ SDIO_CmdSendStatus()

bool SDIO_CmdSendStatus ( uint32_t  argument)

◆ SDIO_CmdReadSingleBlock()

bool SDIO_CmdReadSingleBlock ( uint32_t  address)

◆ SDIO_CmdWriteSingleBlock()

bool SDIO_CmdWriteSingleBlock ( uint32_t  address)

◆ SDIO_CmdAppCommand()

bool SDIO_CmdAppCommand ( uint32_t  rsa)

◆ SDIO_CmdAppSetBusWidth()

bool SDIO_CmdAppSetBusWidth ( uint32_t  rsa,
uint32_t  argument 
)

◆ SDIO_CmdAppOperCommand()

bool SDIO_CmdAppOperCommand ( uint32_t  sdType)

◆ SDIO_CmdAppSetClearCardDetect()

bool SDIO_CmdAppSetClearCardDetect ( uint32_t  rsa)

◆ SDIO_SendCommand()

void SDIO_SendCommand ( uint16_t  command,
uint32_t  argument 
)

◆ SDIO_GetCommandResponse()

uint8_t SDIO_GetCommandResponse ( )

◆ SDIO_GetResponse()

uint32_t SDIO_GetResponse ( uint32_t  response)

◆ SDIO_GetCmdError()

bool SDIO_GetCmdError ( )

◆ SDIO_GetCmdResp1()

bool SDIO_GetCmdResp1 ( uint8_t  command)

◆ SDIO_GetCmdResp2()

bool SDIO_GetCmdResp2 ( )

◆ SDIO_GetCmdResp3()

bool SDIO_GetCmdResp3 ( )

◆ SDIO_GetCmdResp6()

bool SDIO_GetCmdResp6 ( uint8_t  command,
uint32_t *  rca 
)

◆ SDIO_GetCmdResp7()

bool SDIO_GetCmdResp7 ( )