Prusa MINI Firmware overview
|
Go to the documentation of this file.
24 #include "../shared/Marduino.h"
26 #include <libmaple/sdio.h>
27 #include <libmaple/dma.h>
33 #define SDMMC_CMD_GO_IDLE_STATE ((uint8_t)0)
34 #define SDMMC_CMD_ALL_SEND_CID ((uint8_t)2)
35 #define SDMMC_CMD_SET_REL_ADDR ((uint8_t)3)
36 #define SDMMC_CMD_SEL_DESEL_CARD ((uint8_t)7)
37 #define SDMMC_CMD_HS_SEND_EXT_CSD ((uint8_t)8)
38 #define SDMMC_CMD_SEND_CSD ((uint8_t)9)
39 #define SDMMC_CMD_SEND_STATUS ((uint8_t)13)
40 #define SDMMC_CMD_READ_SINGLE_BLOCK ((uint8_t)17)
41 #define SDMMC_CMD_WRITE_SINGLE_BLOCK ((uint8_t)24)
42 #define SDMMC_CMD_APP_CMD ((uint8_t)55)
44 #define SDMMC_ACMD_APP_SD_SET_BUSWIDTH ((uint8_t)6)
45 #define SDMMC_ACMD_SD_APP_OP_COND ((uint8_t)41)
46 #define SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT ((uint8_t)42)
48 #define CMD0_GO_IDLE_STATE (uint16_t)(SDMMC_CMD_GO_IDLE_STATE | SDIO_CMD_WAIT_NO_RESP)
49 #define CMD2_ALL_SEND_CID (uint16_t)(SDMMC_CMD_ALL_SEND_CID | SDIO_CMD_WAIT_LONG_RESP)
50 #define CMD3_SET_REL_ADDR (uint16_t)(SDMMC_CMD_SET_REL_ADDR | SDIO_CMD_WAIT_SHORT_RESP)
51 #define CMD7_SEL_DESEL_CARD (uint16_t)(SDMMC_CMD_SEL_DESEL_CARD | SDIO_CMD_WAIT_SHORT_RESP)
52 #define CMD8_HS_SEND_EXT_CSD (uint16_t)(SDMMC_CMD_HS_SEND_EXT_CSD | SDIO_CMD_WAIT_SHORT_RESP)
53 #define CMD9_SEND_CSD (uint16_t)(SDMMC_CMD_SEND_CSD | SDIO_CMD_WAIT_LONG_RESP)
54 #define CMD13_SEND_STATUS (uint16_t)(SDMMC_CMD_SEND_STATUS | SDIO_CMD_WAIT_SHORT_RESP)
55 #define CMD17_READ_SINGLE_BLOCK (uint16_t)(SDMMC_CMD_READ_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
56 #define CMD24_WRITE_SINGLE_BLOCK (uint16_t)(SDMMC_CMD_WRITE_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
57 #define CMD55_APP_CMD (uint16_t)(SDMMC_CMD_APP_CMD | SDIO_CMD_WAIT_SHORT_RESP)
59 #define ACMD6_APP_SD_SET_BUSWIDTH (uint16_t)(SDMMC_ACMD_APP_SD_SET_BUSWIDTH | SDIO_CMD_WAIT_SHORT_RESP)
60 #define ACMD41_SD_APP_OP_COND (uint16_t)(SDMMC_ACMD_SD_APP_OP_COND | SDIO_CMD_WAIT_SHORT_RESP)
61 #define ACMD42_SD_APP_SET_CLR_CARD_DETECT (uint16_t)(SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT | SDIO_CMD_WAIT_SHORT_RESP)
64 #define SDMMC_ALLZERO 0x00000000U
65 #define SDMMC_OCR_ERRORBITS 0xFDFFE008U
67 #define SDMMC_R6_GENERAL_UNKNOWN_ERROR 0x00002000U
68 #define SDMMC_R6_ILLEGAL_CMD 0x00004000U
69 #define SDMMC_R6_COM_CRC_FAILED 0x00008000U
71 #define SDMMC_VOLTAGE_WINDOW_SD 0x80100000U
72 #define SDMMC_HIGH_CAPACITY 0x40000000U
73 #define SDMMC_STD_CAPACITY 0x00000000U
74 #define SDMMC_CHECK_PATTERN 0x000001AAU
76 #define SDIO_TRANSFER_MODE_BLOCK 0x00000000U
77 #define SDIO_DPSM_ENABLE 0x00000001U
78 #define SDIO_TRANSFER_DIR_TO_CARD 0x00000000U
79 #define SDIO_DATABLOCK_SIZE_512B 0x00000090U
80 #define SDIO_TRANSFER_DIR_TO_SDIO 0x00000100U
81 #define SDIO_DMA_ENABLE 0x00001000U
83 #define CARD_V1_X 0x00000000U
84 #define CARD_V2_X 0x00000001U
85 #define CARD_SDSC 0x00000000U
86 #define CARD_SDHC_SDXC 0x00000001U
93 #define SDIO_GET_FLAG(__FLAG__) !!((SDIO->STA) & (__FLAG__))
94 #define SDIO_CLEAR_FLAG(__FLAG__) (SDIO->ICR = (__FLAG__))
96 #define SDMMC_MAX_VOLT_TRIAL 0x00000FFFU
97 #define SDIO_CARD_TRANSFER 0x00000004U
98 #define SDIO_CARD_ERROR 0x000000FFU
99 #define SDIO_CMDTIMEOUT 200U
100 #define SDIO_DATA_TIMEOUT 100U
101 #define SDIO_WRITE_TIMEOUT 200U
103 #define SDIO_CLOCK 18000000
#define SDMMC_STD_CAPACITY
Definition: sdio.h:73
png_uint_32 crc
Definition: png.c:2247
#define DMA_PRIORITY_MEDIUM
Definition: stm32f4xx_hal_dma.h:309
bool SDIO_CmdSendStatus(uint32_t argument)
uint32_t RelCardAdd
Definition: sdio.h:113
uint32_t CardVersion
Definition: sdio.h:111
bool SDIO_CmdSetRelAdd(uint32_t *rca)
bool SDIO_GetCmdResp1(uint8_t command)
#define SDMMC_R6_COM_CRC_FAILED
Definition: sdio.h:69
#define CMD55_APP_CMD
Definition: sdio.h:57
#define CARD_SDHC_SDXC
Definition: sdio.h:86
#define SDMMC_OCR_ERRORBITS
Definition: sdio.h:65
static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc)
bool SDIO_CmdAppCommand(uint32_t rsa)
uint32_t BlockNbr
Definition: sdio.h:114
#define CMD9_SEND_CSD
Definition: sdio.h:53
#define ACMD42_SD_APP_SET_CLR_CARD_DETECT
Definition: sdio.h:61
static bool access_finish()
uint32_t Class
Definition: sdio.h:112
#define SDMMC_ALLZERO
Definition: sdio.h:64
#define SDMMC_CMD_APP_CMD
Definition: sdio.h:42
#define SDMMC_CMD_READ_SINGLE_BLOCK
Definition: sdio.h:40
uint8_t data[8]
Definition: masstorage.h:49
static bool access_start()
uint8_t i
Definition: screen_test_graph.c:72
#define SDIO_RESP3
Definition: sdio.h:90
bool SDIO_GetCmdResp6(uint8_t command, uint32_t *rca)
uint32_t millis(void)
Definition: wiring_time.c:29
#define SDIO_GET_FLAG(__FLAG__)
Definition: sdio.h:93
uint32_t CardType
Definition: sdio.h:110
uint8_t SDIO_GetCommandResponse()
#define SDMMC_CMD_SEND_STATUS
Definition: sdio.h:39
#define SDIO_CARD_TRANSFER
Definition: sdio.h:97
#define SDMMC_HIGH_CAPACITY
Definition: sdio.h:72
#define ACMD6_APP_SD_SET_BUSWIDTH
Definition: sdio.h:59
bool SDIO_CmdReadSingleBlock(uint32_t address)
uint32_t SDIO_GetCardState()
#define CMD8_HS_SEND_EXT_CSD
Definition: sdio.h:52
uint32_t LogBlockNbr
Definition: sdio.h:116
bool SDIO_CmdAppSetBusWidth(uint32_t rsa, uint32_t argument)
#define CMD0_GO_IDLE_STATE
Definition: sdio.h:48
#define SDMMC_MAX_VOLT_TRIAL
Definition: sdio.h:96
bool SDIO_CmdWriteSingleBlock(uint32_t address)
#define E2END
Definition: pins_RAMPS_LINUX.h:52
uint32_t LogBlockSize
Definition: sdio.h:117
#define CARD_V1_X
Definition: sdio.h:83
#define SDMMC_CMD_WRITE_SINGLE_BLOCK
Definition: sdio.h:41
#define CMD3_SET_REL_ADDR
Definition: sdio.h:50
bool SDIO_CmdAppOperCommand(uint32_t sdType)
void
Definition: png.h:1083
uint32_t BlockSize
Definition: sdio.h:115
void SDIO_SendCommand(uint16_t command, uint32_t argument)
#define SDIO_DATA_TIMEOUT
Definition: sdio.h:100
#define F_CPU
Definition: stm32_def.h:23
#define CMD24_WRITE_SINGLE_BLOCK
Definition: sdio.h:56
bool SDIO_CmdGoIdleState()
#define SDMMC_R6_ILLEGAL_CMD
Definition: sdio.h:68
#define ACMD41_SD_APP_OP_COND
Definition: sdio.h:60
#define CARD_SDSC
Definition: sdio.h:85
const uint8_t[]
Definition: 404_html.c:3
#define SDIO_RESP1
Definition: sdio.h:88
UsbDeviceAddress address
Definition: address.h:202
#define CARD_V2_X
Definition: sdio.h:84
#define CMD13_SEND_STATUS
Definition: sdio.h:54
#define SDIO_CLEAR_FLAG(__FLAG__)
Definition: sdio.h:94
#define CMD7_SEL_DESEL_CARD
Definition: sdio.h:51
static bool read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing=true)
#define SDMMC_R6_GENERAL_UNKNOWN_ERROR
Definition: sdio.h:67
#define SDIO_CLOCK
Definition: sdio.h:103
static status_t status
Definition: filament_sensor.c:37
#define SDIO_WRITE_TIMEOUT
Definition: sdio.h:101
#define SDIO_RESP2
Definition: sdio.h:89
#define CMD17_READ_SINGLE_BLOCK
Definition: sdio.h:55
#define SDMMC_CHECK_PATTERN
Definition: sdio.h:74
#define SDMMC_VOLTAGE_WINDOW_SD
Definition: sdio.h:71
#define SDMMC_CMD_SEL_DESEL_CARD
Definition: sdio.h:36
void crc16(uint16_t *crc, const void *const data, uint16_t cnt)
Definition: crc16.cpp:25
#define SDMMC_CMD_SET_REL_ADDR
Definition: sdio.h:35
#define CMD2_ALL_SEND_CID
Definition: sdio.h:49
bool SDIO_CmdSelDesel(uint32_t address)
bool SDIO_CmdAppSetClearCardDetect(uint32_t rsa)
bool SDIO_CmdSendCSD(uint32_t argument)
static png_bytep size_t size
Definition: pngwrite.c:2170
#define SDIO_CARD_ERROR
Definition: sdio.h:98
uint32_t SDIO_GetResponse(uint32_t response)