Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int test_reg_for_slowpoke(uint32_t reg, uint8_t bit) {
- uint32_t old = MMIO32(reg);
- MMIO32(reg) &= ~(1 << bit);
- MMIO32(reg) |= (1 << bit);
- return !(MMIO32(reg) & (1 << bit));
- }
- int test_reg_for_wr(uint32_t reg, uint8_t bit) {
- uint32_t old = MMIO32(reg);
- MMIO32(reg) |= (1 << bit);
- delay_ms(2);
- bool a = (MMIO32(reg) & (1 << bit));
- MMIO32(reg) &= ~(1 << bit);
- delay_ms(2);
- bool b = (MMIO32(reg) & (1 << bit));
- return a != b;
- }
- void test_reg(const char *name, uint32_t reg) {
- printf("%s - 0x%08lX:\r\n", name, reg);
- for (int i = 0; i < 32; i++) {
- bool is_slow = false;
- for (int j = 0; j < 100; j++) {
- if (test_reg_for_slowpoke(reg, i))
- is_slow = true;
- }
- bool is_wr = test_reg_for_wr(reg, i);
- printf(" -> bit %d ");
- if (is_wr) {
- printf(" [wr]");
- } else {
- printf(" [ro]");
- }
- if (is_slow && is_wr)
- printf(" [slow]");
- printf("\r\n");
- }
- }
- int test_sdio(void) {
- test_reg("SDIO_POWER", SDIO1 + 0x00);
- test_reg("SDIO_CLKCR", SDIO1 + 0x04);
- test_reg("SDIO_ARG", SDIO1 + 0x08);
- test_reg("SDIO_CMD", SDIO1 + 0x0C);
- test_reg("SDIO_RESPCMD", SDIO1 + 0x10);
- test_reg("SDIO_RESP1", SDIO1 + 0x14);
- test_reg("SDIO_RESP2", SDIO1 + 0x18);
- test_reg("SDIO_RESP3", SDIO1 + 0x1C);
- test_reg("SDIO_RESP4", SDIO1 + 0x20);
- test_reg("SDIO_DTIMER", SDIO1 + 0x24);
- test_reg("SDIO_DLEN", SDIO1 + 0x28);
- test_reg("SDIO_DCTRL", SDIO1 + 0x2C);
- test_reg("SDIO_DCOUNT", SDIO1 + 0x30);
- test_reg("SDIO_STA", SDIO1 + 0x34);
- test_reg("SDIO_ICR", SDIO1 + 0x38);
- test_reg("SDIO_MASK", SDIO1 + 0x3C);
- test_reg("SDIO_FIFOCNT", SDIO1 + 0x48);
- test_reg("SDIO_FIFO", SDIO1 + 0x80);
- }
Advertisement
Add Comment
Please, Sign In to add comment