mirror of
https://github.com/FunKey-Project/FunKey-GPIO-Mapping.git
synced 2025-12-13 10:18:54 +01:00
force correct interrupt bank 3 config for AXP209, added edge direction selection in init gpio function
This commit is contained in:
parent
c245d61322
commit
7df1c06849
@ -56,19 +56,23 @@ bool axp209_init(void) {
|
|||||||
int err;
|
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){
|
if(err < 0){
|
||||||
printf("ERROR initializing interrupts for AXP209\n");
|
printf("ERROR initializing interrupts 1 for AXP209\n");
|
||||||
}
|
}
|
||||||
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_2_ENABLE, 0x00);
|
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_2_ENABLE, 0x00);
|
||||||
if(err < 0){
|
if(err < 0){
|
||||||
printf("ERROR initializing interrupts for AXP209\n");
|
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){
|
if(err < 0){
|
||||||
printf("ERROR initializing interrupts for AXP209\n");
|
printf("ERROR initializing interrupts 4 for AXP209\n");
|
||||||
}
|
}
|
||||||
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_5_ENABLE, 0x00);
|
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_INTERRUPT_BANK_5_ENABLE, 0x00);
|
||||||
if(err < 0){
|
if(err < 0){
|
||||||
printf("ERROR initializing interrupts for AXP209\n");
|
printf("ERROR initializing interrupts 5 for AXP209\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -189,14 +189,15 @@ static void find_and_call_mapping_function(int idx_gpio_interrupted,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***** Init GPIO Interrupt i2c expander fd *****/
|
/***** Init GPIO Interrupt i2c expander fd *****/
|
||||||
static int init_gpio_interrupt(int pin_nb, int *fd_saved)
|
static int init_gpio_interrupt(int pin_nb, int *fd_saved, const char *edge)
|
||||||
{
|
{
|
||||||
// Variables
|
// Variables
|
||||||
GPIO_PRINTF("Initializing Interrupt on GPIO pin: %d\n", pin_nb);
|
GPIO_PRINTF("Initializing Interrupt on GPIO pin: %d\n", pin_nb);
|
||||||
|
|
||||||
//Initializing I2C interrupt GPIO
|
//Initializing I2C interrupt GPIO
|
||||||
gpio_export(pin_nb);
|
gpio_export(pin_nb);
|
||||||
gpio_set_edge(pin_nb, "both"); // Can be rising, falling or both
|
gpio_set_edge(pin_nb, edge); // Can be rising, falling or both
|
||||||
|
//gpio_set_edge(pin_nb, "both"); // Can be rising, falling or both
|
||||||
//gpio_set_edge(pin_nb, "falling"); // Can be rising, falling or both
|
//gpio_set_edge(pin_nb, "falling"); // Can be rising, falling or both
|
||||||
*fd_saved = gpio_fd_open(pin_nb, O_RDONLY);
|
*fd_saved = gpio_fd_open(pin_nb, O_RDONLY);
|
||||||
GPIO_PRINTF("fd is: %d\n", *fd_saved);
|
GPIO_PRINTF("fd is: %d\n", *fd_saved);
|
||||||
@ -255,7 +256,7 @@ int init_mapping_gpios(int * gpio_pins_to_declare, int nb_gpios_to_declare,
|
|||||||
|
|
||||||
// Init GPIO interrupt from I2C GPIO expander
|
// Init GPIO interrupt from I2C GPIO expander
|
||||||
GPIO_PRINTF(" Initiating interrupt for GPIO_PIN_I2C_EXPANDER_INTERRUPT\n");
|
GPIO_PRINTF(" Initiating interrupt for GPIO_PIN_I2C_EXPANDER_INTERRUPT\n");
|
||||||
init_gpio_interrupt(GPIO_PIN_I2C_EXPANDER_INTERRUPT, &gpio_fd_interrupt_expander_gpio);
|
init_gpio_interrupt(GPIO_PIN_I2C_EXPANDER_INTERRUPT, &gpio_fd_interrupt_expander_gpio, "both"); // Can be rising, falling or both
|
||||||
|
|
||||||
// Init I2C expander
|
// Init I2C expander
|
||||||
pcal6416a_init();
|
pcal6416a_init();
|
||||||
@ -263,7 +264,7 @@ int init_mapping_gpios(int * gpio_pins_to_declare, int nb_gpios_to_declare,
|
|||||||
#ifdef ENABLE_AXP209_INTERRUPTS
|
#ifdef ENABLE_AXP209_INTERRUPTS
|
||||||
// Init GPIO interrupt from AXP209
|
// Init GPIO interrupt from AXP209
|
||||||
GPIO_PRINTF(" Initiating interrupt for GPIO_PIN_AXP209_INTERRUPT\n");
|
GPIO_PRINTF(" Initiating interrupt for GPIO_PIN_AXP209_INTERRUPT\n");
|
||||||
init_gpio_interrupt(GPIO_PIN_AXP209_INTERRUPT, &gpio_fd_interrupt_axp209);
|
init_gpio_interrupt(GPIO_PIN_AXP209_INTERRUPT, &gpio_fd_interrupt_axp209, "falling");
|
||||||
|
|
||||||
// Init AXP209
|
// Init AXP209
|
||||||
axp209_init();
|
axp209_init();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user