|
@@ -32,20 +32,20 @@ static const int pinToGpio_rev[64] = { |
|
|
//wiringPi number to native gpio number |
|
|
//wiringPi number to native gpio number |
|
|
-1,353, // 0 | 1 : | GPIOAO_3 |
|
|
-1,353, // 0 | 1 : | GPIOAO_3 |
|
|
-1, -1, // 2 | 3 : | |
|
|
-1, -1, // 2 | 3 : | |
|
|
300,301, // 4 | 5 : | GPIOA_1 |
|
|
|
|
|
|
|
|
300,301, // 4 | 5 : GPIOA_0 | GPIOA_1 |
|
|
303, -1, // 6 | 7 : GPIOA_3 | |
|
|
303, -1, // 6 | 7 : GPIOA_3 | |
|
|
-1, -1, // 8 | 9 : | |
|
|
-1, -1, // 8 | 9 : | |
|
|
302,304, // 10 | 11 : GPIOA_2 | GPIOA_4 |
|
|
302,304, // 10 | 11 : GPIOA_2 | GPIOA_4 |
|
|
-1, -1, // 12 | 13 : | |
|
|
-1, -1, // 12 | 13 : | |
|
|
-1,315, // 14 | 15 : | |
|
|
|
|
|
|
|
|
-1,315, // 14 | 15 : | GPIOA_15 |
|
|
352, -1, // 16 | 17 : GPIOAO_2 | |
|
|
352, -1, // 16 | 17 : GPIOAO_2 | |
|
|
-1, -1, // 18 | 19 : | |
|
|
-1, -1, // 18 | 19 : | |
|
|
-1,326, // 20 | 21 : | GPIOH_6 |
|
|
-1,326, // 20 | 21 : | GPIOH_6 |
|
|
327, -1, // 22 | 23 : GPIOH_7 | |
|
|
327, -1, // 22 | 23 : GPIOH_7 | |
|
|
351,350, // 24 | 25 : GPIOAO_1 | GPIOAO_0 |
|
|
351,350, // 24 | 25 : GPIOAO_1 | GPIOAO_0 |
|
|
-1, -1, // 26 | 27 : | |
|
|
-1, -1, // 26 | 27 : | |
|
|
-1,314, // 28 | 29 : | |
|
|
|
|
|
-1,324, // 30 | 31 : | |
|
|
|
|
|
|
|
|
-1,314, // 28 | 29 : | GPIOA_14 |
|
|
|
|
|
-1,324, // 30 | 31 : | GPIOH_4 |
|
|
// Padding: |
|
|
// Padding: |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //32to47 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //32to47 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //48to63 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //48to63 |
|
@@ -525,6 +525,8 @@ static int _digitalRead(int pin) |
|
|
if ((pin = _getModeToGpio(lib->mode, pin)) < 0) |
|
|
if ((pin = _getModeToGpio(lib->mode, pin)) < 0) |
|
|
return 0; |
|
|
return 0; |
|
|
if(pin >= VIM3_GPIOAO_PIN_START && pin <= VIM3_GPIOAO_PIN_END){ |
|
|
if(pin >= VIM3_GPIOAO_PIN_START && pin <= VIM3_GPIOAO_PIN_END){ |
|
|
|
|
|
printf("frank_debug : pin: %x\n\n", *(gpio1 + gpioToGPLEVReg(pin))); |
|
|
|
|
|
// printf("frank_debug : gpioToShiftReg(pin): %x\n\n", gpioToShiftReg(pin)); |
|
|
if ((*(gpio1 + gpioToGPLEVReg(pin)) & (1 << gpioToShiftReg(pin))) != 0) |
|
|
if ((*(gpio1 + gpioToGPLEVReg(pin)) & (1 << gpioToShiftReg(pin))) != 0) |
|
|
return HIGH; |
|
|
return HIGH; |
|
|
else |
|
|
else |
|
@@ -585,7 +587,7 @@ static unsigned int _digitalReadByte (void) |
|
|
/*------------------------------------------------------------------------------------------*/ |
|
|
/*------------------------------------------------------------------------------------------*/ |
|
|
static int init_gpio_mmap(void) |
|
|
static int init_gpio_mmap(void) |
|
|
{ |
|
|
{ |
|
|
int fd; |
|
|
|
|
|
|
|
|
int fd,fd1; |
|
|
|
|
|
|
|
|
/* GPIO mmap setup */ |
|
|
/* GPIO mmap setup */ |
|
|
if(access("/dev/gpiomem",0) == 0){ |
|
|
if(access("/dev/gpiomem",0) == 0){ |
|
@@ -593,20 +595,21 @@ static int init_gpio_mmap(void) |
|
|
return msg (MSG_ERR, |
|
|
return msg (MSG_ERR, |
|
|
"wiringPiSetup: Unable to open /dev/gpiomem: %s\n", |
|
|
"wiringPiSetup: Unable to open /dev/gpiomem: %s\n", |
|
|
strerror (errno)); |
|
|
strerror (errno)); |
|
|
}else{ |
|
|
|
|
|
if (geteuid () != 0) |
|
|
|
|
|
return msg (MSG_ERR, |
|
|
|
|
|
"wiringPiSetup: Must be root. (Did you forget sudo?)\n"); |
|
|
|
|
|
|
|
|
|
|
|
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if(access("/dev/gpiomem-ao",0) == 0){ |
|
|
|
|
|
if ((fd1 = open ("/dev/gpiomem-ao", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) |
|
|
return msg (MSG_ERR, |
|
|
return msg (MSG_ERR, |
|
|
"wiringPiSetup: Unable to open /dev/mem: %s\n", |
|
|
|
|
|
|
|
|
"wiringPiSetup: Unable to open /dev/gpiomem-ao: %s\n", |
|
|
strerror (errno)); |
|
|
strerror (errno)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
gpio1 = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, |
|
|
gpio1 = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, |
|
|
MAP_SHARED, fd, VIM3_GPIOAO_BASE); |
|
|
|
|
|
|
|
|
MAP_SHARED, fd1, VIM3_GPIOAO_BASE); |
|
|
gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, |
|
|
gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, |
|
|
MAP_SHARED, fd, VIM3_GPIO_BASE); |
|
|
MAP_SHARED, fd, VIM3_GPIO_BASE); |
|
|
|
|
|
|
|
|
|
|
|
printf("This is a tst line :%d\n\n\n",__LINE__); |
|
|
|
|
|
|
|
|
if (((int32_t)gpio == -1) || ((int32_t)gpio1 == -1)) |
|
|
if (((int32_t)gpio == -1) || ((int32_t)gpio1 == -1)) |
|
|
return msg (MSG_ERR, |
|
|
return msg (MSG_ERR, |
|
|
"wiringPiSetup: mmap (GPIO) failed: %s\n", |
|
|
"wiringPiSetup: mmap (GPIO) failed: %s\n", |
|
|