mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-30 14:20:52 +03:00
Rotary encoder + simplify
- GPIO expander works with rotary encoder - Much better mimic real GPIO, including ISR, to minimize impact on clients
This commit is contained in:
@@ -29,28 +29,30 @@ typedef struct {
|
||||
} phy;
|
||||
} gpio_exp_config_t;
|
||||
|
||||
typedef void (*gpio_exp_enumerator)(int gpio, int level, struct gpio_exp_s *expander);
|
||||
typedef BaseType_t (*gpio_exp_isr)(void *arg);
|
||||
|
||||
// set <intr> to -1 and <queue> to NULL if there is no interrupt
|
||||
struct gpio_exp_s* gpio_exp_create(const gpio_exp_config_t *config);
|
||||
bool gpio_exp_add_isr(gpio_exp_isr isr, void *arg, struct gpio_exp_s *expander);
|
||||
uint32_t gpio_exp_get_base(struct gpio_exp_s *expander);
|
||||
struct gpio_exp_s* gpio_exp_get_expander(int gpio);
|
||||
struct gpio_exp_s* gpio_exp_create(const gpio_exp_config_t *config);
|
||||
uint32_t gpio_exp_get_base(struct gpio_exp_s *expander);
|
||||
struct gpio_exp_s* gpio_exp_get_expander(int gpio);
|
||||
#define gpio_is_expanded(gpio) (gpio < GPIO_NUM_MAX)
|
||||
|
||||
/* For all functions below when <expander> is provided, GPIO's can be numbered from 0. If <expander>
|
||||
is NULL, then GPIO must start from base */
|
||||
/*
|
||||
For all functions below when <expander> is provided, GPIO's can be numbered from 0. If <expander>
|
||||
is NULL, then GPIO must start from base OR be on-chip
|
||||
*/
|
||||
esp_err_t gpio_exp_set_direction(int gpio, gpio_mode_t mode, struct gpio_exp_s *expander);
|
||||
esp_err_t gpio_exp_set_pull_mode(int gpio, gpio_pull_mode_t mode, struct gpio_exp_s *expander);
|
||||
int gpio_exp_get_level(int gpio, uint32_t age, struct gpio_exp_s *expander);
|
||||
int gpio_exp_get_level(int gpio, int age, struct gpio_exp_s *expander);
|
||||
esp_err_t gpio_exp_set_level(int gpio, int level, bool direct, struct gpio_exp_s *expander);
|
||||
esp_err_t gpio_exp_isr_handler_add(int gpio, gpio_isr_t isr, uint32_t debounce, void *arg, struct gpio_exp_s *expander);
|
||||
esp_err_t gpio_exp_isr_handler_remove(int gpio, struct gpio_exp_s *expander);
|
||||
|
||||
/* This can be called to enumerate modified GPIO since last read. Note that <enumerator>
|
||||
can be NULL to initialize all GPIOs */
|
||||
void gpio_exp_enumerate(gpio_exp_enumerator enumerator, struct gpio_exp_s *expander);
|
||||
|
||||
// option to use either built-in or expanded GPIO
|
||||
esp_err_t gpio_set_direction_u(int gpio, gpio_mode_t mode);
|
||||
esp_err_t gpio_set_pull_mode_u(int gpio, gpio_pull_mode_t mode);
|
||||
int gpio_get_level_u(int gpio);
|
||||
esp_err_t gpio_set_level_u(int gpio, int level);
|
||||
// unified function to use either built-in or expanded GPIO
|
||||
esp_err_t gpio_set_direction_x(int gpio, gpio_mode_t mode);
|
||||
esp_err_t gpio_set_pull_mode_x(int gpio, gpio_pull_mode_t mode);
|
||||
int gpio_get_level_x(int gpio);
|
||||
esp_err_t gpio_set_level_x(int gpio, int level);
|
||||
esp_err_t gpio_isr_handler_add_x(int gpio, gpio_isr_t isr_handler, void* args);
|
||||
esp_err_t gpio_isr_handler_remove_x(int gpio);
|
||||
#define gpio_set_intr_type_x(gpio, type) do { if (gpio < GPIO_NUM_MAX) gpio_set_intr_type(gpio, type); } while (0)
|
||||
#define gpio_intr_enable_x(gpio) do { if (gpio < GPIO_NUM_MAX) gpio_intr_enable(gpio); } while (0)
|
||||
#define gpio_pad_select_gpio_x(gpio) do { if (gpio < GPIO_NUM_MAX) gpio_pad_select_gpio(gpio); } while (0)
|
||||
|
||||
Reference in New Issue
Block a user