2022-08-19

[개발노트]USB OTG ID 핀 상태 읽기 (0번비트임)

#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>

int main(void)
{
        int fd = open("/dev/mem", O_RDWR);
        void* ptr = mmap(NULL, 4096, PROT_READ,
                 MAP_SHARED, fd, 0x49000000);
        close(fd);

        if(ptr == MAP_FAILED)
        {
                printf("mmap failed\n");
                return -1;
        }
        volatile unsigned* GINTSTS = (unsigned*)(ptr + 0x14);

        printf("%08X \n",*GINTSTS);

        munmap(ptr, 4096);

        return 0;
}

댓글 없음:

댓글 쓰기

How to Convert EUC-KR Source Code to UTF-8

How to Convert EUC-KR Source Code to UTF-8 I found old STM32 firmware code. The files were in EUC-KR encoding. This is an old Korean text f...