Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2021-04-03 23:38:05 +02:00
parent 59a2e0dd16
commit 32180f7d44
8 changed files with 25 additions and 26 deletions

View File

@ -39,9 +39,9 @@
#define ERROR_AXP209
#ifdef DEBUG_AXP209
#define LOG_DEBUG(...) printf(__VA_ARGS__);
#define LOG_DEBUG(...) printf(__VA_ARGS__);
#else
#define LOG_DEBUG(...)
#define LOG_DEBUG(...)
#endif
#ifdef ERROR_AXP209

View File

@ -28,7 +28,6 @@
#ifndef _GPIO_AXP209_H_
#define _GPIO_AXP209_H_
#include <stdbool.h>
/* Chip physical address */

View File

@ -68,7 +68,7 @@
#define SHORT_PEK_PRESS_DURATION_US (200 * 1000)
#define GPIO_PIN_I2C_EXPANDER_INTERRUPT ((('B' - '@') << 4) + 3) // PB3
#define GPIO_PIN_I2C_EXPANDER_INTERRUPT ((('B' - '@') << 4) + 3) // PB3
#define GPIO_PIN_AXP209_INTERRUPT ((('B' - '@') << 4) + 5) // PB5
#define SHORT_PEK_PRESS_GPIO_MASK (1 << 5)
@ -331,7 +331,7 @@ void handle_gpio_mapping(mapping_list_t *list)
system(mapping->value.command);
}
}
}
}
/* Proccess the Power Enable Key (PEK) long keypress, the AXP209
* will shutdown the system in 3s anyway
@ -412,7 +412,7 @@ void handle_gpio_mapping(mapping_list_t *list)
}
}
/* Apply the mapping for the current gpio mask */
apply_mapping(list, current_gpio_mask);
/* Apply the mapping for the current gpio mask */
apply_mapping(list, current_gpio_mask);
return;
}

View File

@ -35,4 +35,4 @@ bool init_gpio_mapping(const char* config_filename,
void deinit_gpio_mapping(void);
void handle_gpio_mapping(mapping_list_t *mapping_list);
#endif //_GPIO_MAPPING_H_
#endif //_GPIO_MAPPING_H_

View File

@ -45,9 +45,9 @@
#define ERROR_PCAL6416A
#ifdef DEBUG_PCAL6416A
#define LOG_DEBUG(...) printf(__VA_ARGS__);
#define LOG_DEBUG(...) printf(__VA_ARGS__);
#else
#define LOG_DEBUG(...)
#define LOG_DEBUG(...)
#endif
#ifdef ERROR_PCAL6416A
@ -93,15 +93,15 @@ bool pcal6416a_init(void)
for (i = 0, i2c_expander_addr = 0; i2c_chip[i].address; i++) {
if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, i2c_chip[i]) < 0 ||
pcal6416a_read_mask_interrupts() < 0) {
pcal6416a_read_mask_interrupts() < 0) {
LOG_DEBUG("Failed to acquire bus access and/or talk to slave %s at address 0x%02X.\n",
i2c_chip[i].name, i2c_chip[i].address);
} else {
LOG_DEBUG("Found I2C gpio expander chip %s at address 0x%02X\n",
i2c_chip[i].name, i2c_chip[i].address);
i2c_expander_addr = i2c_chip[i].address;
} else {
LOG_DEBUG("Found I2C gpio expander chip %s at address 0x%02X\n",
i2c_chip[i].name, i2c_chip[i].address);
i2c_expander_addr = i2c_chip[i].address;
break;
}
}
}
/* GPIO expander chip found? */

2
main.c
View File

@ -170,7 +170,7 @@ int main(int argc, char *argv[])
handle_gpio_mapping(&mapping_list);
}
/*Deinitialize the GPIO mapping */
/* Deinitialize the GPIO mapping */
deinit_gpio_mapping();
/* Close the uinput device */

View File

@ -49,9 +49,9 @@
/* Compute the byte offset of a structure member */
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
#endif
/* Retrieve a typed pointer to the structure containing the given member */
@ -71,8 +71,8 @@
* process
*/
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
/* Add a mapping between a previous and a next one */
static inline void list_add_between(struct mapping_list_t *new,
@ -95,21 +95,21 @@ static inline void list_add(struct mapping_list_t *new,
static inline void list_add_tail(struct mapping_list_t *new,
struct mapping_list_t *head)
{
list_add_between(new, head->prev, head);
list_add_between(new, head->prev, head);
}
/* Delete a mapping between a previous and a next one */
static inline void list_delete_between(struct mapping_list_t *prev,
struct mapping_list_t *next)
{
next->prev = prev;
prev->next = next;
next->prev = prev;
prev->next = next;
}
/* Delete a mapping from the mapping list */
static inline void list_delete(struct mapping_list_t *entry)
{
list_delete_between(entry->prev, entry->next);
list_delete_between(entry->prev, entry->next);
}
/* Initalize a mapping list */

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2020-2021 Vincent Buso <vincent.buso@funkey-project.com>
Copyright (C) 2020-2021 Michel Stempin <michel.stempin@funkey-project.com>
Copyright (C) 2021 Michel Stempin <michel.stempin@funkey-project.com>
This file is part of the FunKey S GPIO keyboard daemon.