We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi. I'm trying to go straight to the registers, but nothing works. What am I doing wrong ??
#include <sys/mman.h> #include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h>
int main(){ printf("new program"); char dev_name[] = "/dev/mem"; int gpio_base; int fd = open(dev_name, O_RDWR|O_SYNC); if(fd<0){ printf("open %s is error\n",dev_name); return -1 ; } int sz = getpagesize(); printf("\ngetsize = %u\n", sz); printf("str = %x ",(0x1c208d8/sz) * sz); volatile unsigned int str = (0x1c208d8/sz) * sz; / unsigned char buf[100]; lseek(fd, 0, SEEK_SET); lseek(fd, 0x1c208d8, SEEK_SET); read(fd, buf,1000000); */ for(int i = 0; i < 200; i+=1) { /*if ((int)(buf[i] <<3| buf[i+ 1] <<2| buf[i+2] << 1| buf[i +4]) == 0x7$ { printf("ok"); } */ printf("\n %x \n", gpio_base[i]); }
////*gpio_base_out &=0xfffffff8; ////*gpio_base_out = 1; int mum = munmap(gpio_base, 0x32); if (mum== 0) { printf("\nOK\n"); } else { printf("\nNO OK \n"); }
if(gpio_base == NULL){ printf("gpio base mmap is error\n"); close(fd); return -1; }
return 0;
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi. I'm trying to go straight to the registers, but nothing works. What am I doing wrong ??
#include <sys/mman.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
printf("new program");
char dev_name[] = "/dev/mem";
int gpio_base;
int fd = open(dev_name, O_RDWR|O_SYNC);
if(fd<0){
printf("open %s is error\n",dev_name);
return -1 ;
}
int sz = getpagesize();
printf("\ngetsize = %u\n", sz);
printf("str = %x ",(0x1c208d8/sz) * sz);
volatile unsigned int str = (0x1c208d8/sz) * sz;
/
unsigned char buf[100];
lseek(fd, 0, SEEK_SET);
lseek(fd, 0x1c208d8, SEEK_SET);
read(fd, buf,1000000);
*/
for(int i = 0; i < 200; i+=1)
{
/*if ((int)(buf[i] <<3| buf[i+ 1] <<2| buf[i+2] << 1| buf[i +4]) == 0x7$
{
printf("ok");
}
*/
printf("\n %x \n", gpio_base[i]);
}
////*gpio_base_out &=0xfffffff8;
////*gpio_base_out = 1;
int mum = munmap(gpio_base, 0x32);
if (mum== 0)
{
printf("\nOK\n");
}
else
{
printf("\nNO OK \n");
}
if(gpio_base == NULL){
printf("gpio base mmap is error\n");
close(fd);
return -1;
}
}
The text was updated successfully, but these errors were encountered: