diff --git a/main/drivers/bottom_half.hpp b/main/drivers/bottom_half.hpp index 95e620e..ed8fa66 100644 --- a/main/drivers/bottom_half.hpp +++ b/main/drivers/bottom_half.hpp @@ -30,7 +30,7 @@ typedef enum { kd = 15, } KeypadKey; -static const char *_TAG = "bottom_half"; +static const char *BOTTOM_TAG = "bottom_half"; uint16_t keypad_state; uint16_t button_state; @@ -190,7 +190,7 @@ static void poll_bottom_task(void *arg) { if (new_data) { uint8_t delta = receive_delta(); // ESP_LOGI(_TAG, "delta: %d", delta); - if (delta == 0) ESP_LOGW(_TAG, "delta pin was low, but delta register returned 0"); + if (delta == 0) ESP_LOGW(BOTTOM_TAG, "delta pin was low, but delta register returned 0"); if (delta & (1 << DELTA_BIT_KP)) { receive_keypad(); diff --git a/main/drivers/wires.hpp b/main/drivers/wires.hpp index c078eec..062b147 100644 --- a/main/drivers/wires.hpp +++ b/main/drivers/wires.hpp @@ -1,12 +1,91 @@ #ifndef WIRES_HPP #define WIRES_HPP +#define WIRES_PIN_INTERUPT GPIO_NUM_2 +#define WIRES_I2C_NUM I2C_NUM_1 +#define WIRES_I2C_ADDR 125 + +static const char *WIRES_TAG = "wires"; + +uint8_t wires_states; +uint8_t wires_cut; + +static void poll_wires_task(void *arg); + void init_wires(void) { - + i2c_config_t wires_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_41, + .scl_io_num = GPIO_NUM_42, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master = { + .clk_speed = 100000, + } + }; + + ESP_ERROR_CHECK(i2c_param_config(WIRES_I2C_NUM, &wires_conf)); + ESP_ERROR_CHECK(i2c_driver_install(WIRES_I2C_NUM, wires_conf.mode, 0, 0, 0)); + + gpio_config_t int_pin_conf = {}; + // delta_pin_conf.intr_type = GPIO_INTR_LOW_LEVEL; + int_pin_conf.mode = GPIO_MODE_INPUT; + // GPIO 0 + int_pin_conf.pin_bit_mask = (1ULL<