Can someone please show me an example of how to read values โโfrom raspberry registers? I need to check the byte in AUX_MU_LSR_REG (0x7E21 5054), but I do not know how to do this without using any additional libraries. I tried: (here I am changing the oryginal message)
************************** * Start of code
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys/mman.h> #include <unistd.h> #include <errno.h> #define BCM2708 0x20000000 #define UART_BASE (BCM2708+0x215000) #define PAGE_SIZE (4*1024) #define BLOCK_SIZE (4*1024) int mem_fd; void *uart_map; volatile unsigned *uart; int main() { printf("start\n"); if((mem_fd=open("/dev/mem",O_RDWR|O_SYNC))<0) { printf("can't open /dev/mem \n"); exit(-1); } else printf("stream_file open OK \n"); if((uart_map=malloc(BLOCK_SIZE))==0) printf("malloc fail\n"); else printf("GPIO_mallocation OK %d \n", (int)uart_map ); uart_map=mmap (NULL, //any address in our space BLOCK_SIZE, //map length PROT_READ|PROT_WRITE, //Enable reading and writing to maped memmory MAP_SHARED, //Shares with other processes mem_fd, //File to map UART_BASE //Offset toUART peripheral ); if(uart_map==MAP_FAILED) { printf("mmap error %d", (int)uart_map); exit(-1); } else printf("GPIO mapping OK \n"); uart=(volatile unsigned* )uart_map; int i; for(i=0;i<32;i++) { printf("adress:%x ",uart+i); printf("value:%x\n",*(uart+i)); } printf("stop\n"); return 0; }
` *********************** * end of the code Now I really donโt remember how I show 0, but in the above code I get a pointer conflict.
What does uart point to? Theoretically, it should display values, but after a few weeks I can not get it to work.
I hope you can help me somehow
source share