#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

void main(int argc, char *argv[])
{
    uint32_t cmd, resp;
    uint32_t addr, data;

    while (1) {
        printf("Please input cmd52 and response\r\n");
        scanf("%x %x", &cmd, &resp);
        printf("your input is cmd52:0x%08lX, resp:0x%08lX\r\n", cmd, resp);
        /* parse cmd52 */
        addr = (cmd >> 9) & 0x1FFFF;
        data = (cmd >> 0) & 0xFF;
        if (cmd & (1 << 31)) {
            printf("write 0x%02X to 0x%06X. ", data, addr);
            if (cmd & (1 << 27)) {
                printf("with read. ");
            } else {
                printf("without read. ");
            }
        } else {
            printf("read data from 0x%06X. ", addr);
        }
        printf("func=%d\r\n", (cmd >> 28) & 0x7);
        /* parse response */
        addr = (resp >> 8) & 0xFF;
        data = (resp >> 0) & 0xFF;
        printf("return data is 0x%02lX, status=0x%02lX\r\n\r\n", data, addr);
    }
}
