diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/driver_axp209.c b/driver_axp209.c index 2408172..ef96592 100755 --- a/driver_axp209.c +++ b/driver_axp209.c @@ -58,26 +58,26 @@ bool axp209_init(void) { // Enable only chosen interrupts (PEK short and long presses) int err; - err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_1_ENABLE, 0x00); + /*err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_1_ENABLE, 0x00); if(err < 0){ printf("ERROR initializing interrupts 1 for AXP209\n"); } err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_2_ENABLE, 0x00); if(err < 0){ printf("ERROR initializing interrupts 2 for AXP209\n"); - } + }*/ err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_3_ENABLE, 0x03); if(err < 0){ printf("ERROR initializing interrupts 3 for AXP209\n"); } - err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_4_ENABLE, 0x00); + /*err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_4_ENABLE, 0x00); if(err < 0){ printf("ERROR initializing interrupts 4 for AXP209\n"); } err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_5_ENABLE, 0x00); if(err < 0){ printf("ERROR initializing interrupts 5 for AXP209\n"); - } + }*/ return true; } @@ -95,7 +95,7 @@ int axp209_read_interrupt_bank_3(void){ } // Clear interrupts - int err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_3_STATUS, 0xFF); + int err = i2c_smbus_write_byte_data( fd_axp209 ,AXP209_INTERRUPT_BANK_3_STATUS, 0xFF ); if(err < 0){ return err; } diff --git a/funkey_gpio_management_BAK b/funkey_gpio_management_BAK new file mode 100755 index 0000000..f72df64 Binary files /dev/null and b/funkey_gpio_management_BAK differ diff --git a/gpio_mapping.c b/gpio_mapping.c old mode 100644 new mode 100755 index adcb6f3..c654da0 --- a/gpio_mapping.c +++ b/gpio_mapping.c @@ -39,10 +39,10 @@ // This define forces to perform a gpio sanity check after a timeout. // If not declared, there will be no timeout and no periodical sanity check of GPIO expander values -#define TIMEOUT_SEC_SANITY_CHECK_GPIO_EXP 1 -//#define TIMEOUT_MICROSEC_SANITY_CHECK_GPIO_EXP (500*1000) +//#define TIMEOUT_SEC_SANITY_CHECK_GPIO_EXP 1 +#define TIMEOUT_MICROSEC_SANITY_CHECK_GPIO_EXP (30*1000) -// This is for debug purposes on cards or eval boards that do not have the AXP209 +// Comment this for debug purposes on cards or eval boards that do not have the AXP209 #define ENABLE_AXP209_INTERRUPTS #define KEY_IDX_MAPPED_FOR_SHORT_PEK_PRESS 16 //KEY_Q @@ -62,6 +62,8 @@ static fd_set fds; static bool * mask_gpio_value; static bool interrupt_i2c_expander_found = false; static bool interrupt_axp209_found = false; +static bool mapping_PEK_short_press_activated = false; +static bool mapping_PEK_long_press_activated = false; /**************************************************************** @@ -330,8 +332,10 @@ int listen_gpios_interrupts(void) if(!nb_interrupts){ // Timeout case GPIO_PRINTF(" Timeout, forcing sanity check\n"); + // Timeout forcing a "Found interrupt" event for sanity check interrupt_i2c_expander_found = true; + interrupt_axp209_found = true; } else if ( nb_interrupts < 0) { perror("select"); @@ -385,11 +389,15 @@ int listen_gpios_interrupts(void) if(val_int_bank_3 & AXP209_INTERRUPT_PEK_SHORT_PRESS){ GPIO_PRINTF(" AXP209 short PEK key press detected\n"); sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_SHORT_PEK_PRESS); + /*sendKey(KEY_IDX_MAPPED_FOR_SHORT_PEK_PRESS, !mapping_PEK_short_press_activated); + mapping_PEK_short_press_activated = !mapping_PEK_short_press_activated;*/ } if(val_int_bank_3 & AXP209_INTERRUPT_PEK_LONG_PRESS){ GPIO_PRINTF(" AXP209 long PEK key press detected\n"); sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS); + /*sendKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS, !mapping_PEK_long_press_activated); + mapping_PEK_long_press_activated = !mapping_PEK_long_press_activated;*/ } } #endif //ENABLE_AXP209_INTERRUPTS diff --git a/uinput.c b/uinput.c index 962fbd6..6348804 100755 --- a/uinput.c +++ b/uinput.c @@ -35,18 +35,11 @@ //#include "config.h" //include "daemon.h" #include "uinput.h" +#include -static int sendRel(int dx, int dy); -static int sendSync(void); - -static struct input_event uidev_ev; -static int uidev_fd; -/*static keyinfo_s lastkey;*/ - -#define die(str, args...) do { \ - perror(str); \ - return(EXIT_FAILURE); \ - } while(0) +/**************************************************************** + * Defines + ****************************************************************/ #define DEBUG_UINPUT_PRINTF (0) #if DEBUG_UINPUT_PRINTF @@ -54,7 +47,31 @@ static int uidev_fd; #else #define UINPUT_PRINTF(...) #endif + +#define SLEEP_TIME_SEND_STOP_KEY_US 20*1000 +#define die(str, args...) do { \ + perror(str); \ + return(EXIT_FAILURE); \ + } while(0) + + +/**************************************************************** + * Static functions declaration + ****************************************************************/ +static int sendRel(int dx, int dy); +static int sendSync(void); + +/**************************************************************** + * Static variables + ****************************************************************/ +static struct input_event uidev_ev; +static int uidev_fd; +/*static keyinfo_s lastkey;*/ + +/**************************************************************** + * Functions Implementation + ****************************************************************/ int init_uinput(void) { int fd; @@ -187,6 +204,7 @@ int sendKey(int key, int value) int sendKeyAndStopKey(int key) { sendKey(key, 1); + usleep(SLEEP_TIME_SEND_STOP_KEY_US); sendKey(key, 0); return 0;