Lines Matching full:card

18 static struct sd_card card;  variable
28 * Verify that SD stack can initialize an SD card
29 * This test must run first, to ensure the card is initialized.
38 zassert_equal(ret, 1, "SD card not present in slot"); in ZTEST()
40 ret = sd_init(sdhc_dev, &card); in ZTEST()
41 zassert_equal(ret, 0, "Card initialization failed"); in ZTEST()
49 ret = sdmmc_ioctl(&card, DISK_IOCTL_GET_SECTOR_COUNT, &sector_count); in ZTEST()
51 TC_PRINT("SD card reports sector count of %d\n", sector_count); in ZTEST()
53 ret = sdmmc_ioctl(&card, DISK_IOCTL_GET_SECTOR_SIZE, &sector_size); in ZTEST()
55 TC_PRINT("SD card reports sector size of %d\n", sector_size); in ZTEST()
59 /* Verify that SD stack can read from an SD card */
65 /* Try simple reads from start of SD card */ in ZTEST()
67 ret = sdmmc_read_blocks(&card, buf, block_addr, 1); in ZTEST()
68 zassert_equal(ret, 0, "Single block card read failed"); in ZTEST()
70 ret = sdmmc_read_blocks(&card, buf, block_addr, SECTOR_COUNT / 2); in ZTEST()
71 zassert_equal(ret, 0, "Multiple block card read failed"); in ZTEST()
76 ret = sdmmc_read_blocks(&card, buf, block_addr, SECTOR_COUNT); in ZTEST()
81 ret = sdmmc_read_blocks(&card, buf, block_addr, 1); in ZTEST()
85 ret = sdmmc_read_blocks(&card, buf, block_addr, 2); in ZTEST()
86 zassert_equal(ret, 0, "Read from end of card failed"); in ZTEST()
90 ret = sdmmc_read_blocks(&card, buf + SDMMC_UNALIGN_OFFSET, in ZTEST()
95 /* Verify that SD stack can write to an SD card */
101 /* Try simple writes from start of SD card */ in ZTEST()
103 ret = sdmmc_write_blocks(&card, buf, block_addr, 1); in ZTEST()
104 zassert_equal(ret, 0, "Single block card write failed"); in ZTEST()
106 ret = sdmmc_write_blocks(&card, buf, block_addr, SECTOR_COUNT / 2); in ZTEST()
107 zassert_equal(ret, 0, "Multiple block card write failed"); in ZTEST()
112 ret = sdmmc_write_blocks(&card, buf, block_addr, SECTOR_COUNT); in ZTEST()
117 ret = sdmmc_write_blocks(&card, buf, block_addr, 1); in ZTEST()
121 ret = sdmmc_write_blocks(&card, buf, block_addr, 2); in ZTEST()
122 zassert_equal(ret, 0, "Write to end of card failed"); in ZTEST()
126 ret = sdmmc_write_blocks(&card, buf + SDMMC_UNALIGN_OFFSET, in ZTEST()
140 ret = sdmmc_write_blocks(&card, buf, block_addr, SECTOR_COUNT / 2); in ZTEST()
141 zassert_equal(ret, 0, "Write to card failed"); in ZTEST()
143 ret = sdmmc_read_blocks(&card, buf, block_addr, SECTOR_COUNT / 2); in ZTEST()
144 zassert_equal(ret, 0, "Read from card failed"); in ZTEST()
153 ret = sdmmc_write_blocks(&card, buf, block_addr, SECTOR_COUNT); in ZTEST()
154 zassert_equal(ret, 0, "Write to card failed"); in ZTEST()
157 ret = sdmmc_read_blocks(&card, buf, block_addr, SECTOR_COUNT); in ZTEST()
158 zassert_equal(ret, 0, "Read from card failed"); in ZTEST()
165 ret = sdmmc_write_blocks(&card, buf + SDMMC_UNALIGN_OFFSET, in ZTEST()
167 zassert_equal(ret, 0, "Write to card failed"); in ZTEST()
171 ret = sdmmc_read_blocks(&card, check_buf + SDMMC_UNALIGN_OFFSET, in ZTEST()
173 zassert_equal(ret, 0, "Read from card failed"); in ZTEST()
181 /* Simply dump the card configuration. */
184 switch (card.card_voltage) { in ZTEST()
186 TC_PRINT("Card voltage: 1.2V\n"); in ZTEST()
189 TC_PRINT("Card voltage: 1.8V\n"); in ZTEST()
192 TC_PRINT("Card voltage: 3.0V\n"); in ZTEST()
195 TC_PRINT("Card voltage: 3.3V\n"); in ZTEST()
198 zassert_unreachable("Card voltage is not known value"); in ZTEST()
200 zassert_equal(card.status, CARD_INITIALIZED, "Card status is not OK"); in ZTEST()
201 switch (card.card_speed) { in ZTEST()
203 if (card.flags & SD_1800MV_FLAG) { in ZTEST()
204 TC_PRINT("Card timing: SDR12\n"); in ZTEST()
206 /* Card uses non UHS mode timing */ in ZTEST()
207 TC_PRINT("Card timing: Legacy\n"); in ZTEST()
211 if (card.flags & SD_1800MV_FLAG) { in ZTEST()
212 TC_PRINT("Card timing: SDR25\n"); in ZTEST()
214 /* Card uses non UHS mode timing */ in ZTEST()
215 TC_PRINT("Card timing: High Speed\n"); in ZTEST()
219 TC_PRINT("Card timing: SDR50\n"); in ZTEST()
220 zassert_true(card.flags & SD_1800MV_FLAG, in ZTEST()
221 "Card must support UHS mode for this timing"); in ZTEST()
224 TC_PRINT("Card timing: SDR104\n"); in ZTEST()
225 zassert_true(card.flags & SD_1800MV_FLAG, in ZTEST()
226 "Card must support UHS mode for this timing"); in ZTEST()
229 TC_PRINT("Card timing: DDR50\n"); in ZTEST()
230 zassert_true(card.flags & SD_1800MV_FLAG, in ZTEST()
231 "Card must support UHS mode for this timing"); in ZTEST()
234 zassert_unreachable("Card timing is not known value"); in ZTEST()
236 zassert_not_equal(card.bus_io.clock, 0, "Bus should have nonzero clock"); in ZTEST()
237 TC_PRINT("Bus Frequency: %d Hz\n", card.bus_io.clock); in ZTEST()
238 switch (card.type) { in ZTEST()
240 TC_PRINT("Card type: SDIO\n"); in ZTEST()
243 TC_PRINT("Card type: SDMMC\n"); in ZTEST()
246 TC_PRINT("Card type: combo card\n"); in ZTEST()
249 zassert_unreachable("Card type is not known value"); in ZTEST()
251 if (card.sd_version >= SD_SPEC_VER3_0) { in ZTEST()
252 TC_PRINT("Card spec: 3.0\n"); in ZTEST()
253 } else if (card.sd_version >= SD_SPEC_VER2_0) { in ZTEST()
254 TC_PRINT("Card spec: 2.0\n"); in ZTEST()
255 } else if (card.sd_version >= SD_SPEC_VER1_1) { in ZTEST()
256 TC_PRINT("Card spec: 1.1\n"); in ZTEST()
257 } else if (card.sd_version >= SD_SPEC_VER1_0) { in ZTEST()
258 TC_PRINT("Card spec: 1.0\n"); in ZTEST()
260 zassert_unreachable("Card spec is unknown value"); in ZTEST()