I think this is a very basic but important question.
I did a trial just now but failed. The code is below.
GPIO 0x48002110 is the CAM_B_EN signal of N900, which could change the camera to A or B. If success, when you open N900's camera application(that's camera A, the big one), it will be influenced due to 1/0 in turn each 1000ms.
Then I compile it in the scratchbox and upload it to N900. When running it, below feedback comes.
Code:
Nokia-N900:~# ./gpio
Segmentation fault
Can anyone help to find the reason? Thanks!
Code:
#include <sys/types.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <memory.h>
#define GPIO 0x48002110
#define INT *(volatile unsigned int*)
void *map_base;
int n,fd;
int main(int argc,char *argv[])
{
if((fd=open("/dev/mem",O_RDWR | O_SYNC))==-1){
perror("open error!\n");
return(-1);
}
map_base = mmap(0,0xff,PROT_READ | PROT_WRITE,MAP_SHARED,fd,GPIO);
while(1){
INT(map_base) = 1; //set it high
sleep(1000);
INT(map_base) = 0; //set it low
sleep(1000);
}
close(fd);
munmap(map_base,0xff);
}
I did a trial just now but failed. The code is below.
GPIO 0x48002110 is the CAM_B_EN signal of N900, which could change the camera to A or B. If success, when you open N900's camera application(that's camera A, the big one), it will be influenced due to 1/0 in turn each 1000ms.
Then I compile it in the scratchbox and upload it to N900. When running it, below feedback comes.
Can anyone help to find the reason? Thanks!