Lines Matching +full:alert +full:- +full:limit
4 * SPDX-License-Identifier: Apache-2.0
15 const struct tcn75a_config *config = dev->config; in tcn75a_trigger_set()
16 struct tcn75a_data *data = dev->data; in tcn75a_trigger_set()
19 if (trig->type != SENSOR_TRIG_THRESHOLD) { in tcn75a_trigger_set()
20 return -ENOTSUP; in tcn75a_trigger_set()
23 if ((trig->chan != SENSOR_CHAN_ALL) && (trig->chan != SENSOR_CHAN_AMBIENT_TEMP)) { in tcn75a_trigger_set()
24 return -ENOTSUP; in tcn75a_trigger_set()
27 data->sensor_cb = handler; in tcn75a_trigger_set()
28 data->sensor_trig = trig; in tcn75a_trigger_set()
33 ret = i2c_reg_update_byte_dt(&config->i2c_spec, TCN75A_CONFIG_REG, TCN75A_CONFIG_INT_EN, in tcn75a_trigger_set()
39 ret = gpio_pin_interrupt_configure_dt(&config->alert_gpios, GPIO_INT_EDGE_TO_ACTIVE); in tcn75a_trigger_set()
50 const struct tcn75a_config *config = dev->config; in tcn75a_attr_set()
54 return -ENOTSUP; in tcn75a_attr_set()
65 return -ENOTSUP; in tcn75a_attr_set()
69 tx_buf[1] = (uint8_t)val->val1; in tcn75a_attr_set()
70 tx_buf[2] = TCN75A_SENSOR_TO_FIXED_PT(val->val2); in tcn75a_attr_set()
72 LOG_DBG("Writing 0x%02X to limit reg %s", *(uint16_t *)(tx_buf + 1), in tcn75a_attr_set()
75 return i2c_write_dt(&config->i2c_spec, tx_buf, 3); in tcn75a_attr_set()
81 const struct tcn75a_config *config = dev->config; in tcn75a_attr_get()
84 uint16_t limit, temp_lsb; in tcn75a_attr_get() local
88 return -ENOTSUP; in tcn75a_attr_get()
99 return -ENOTSUP; in tcn75a_attr_get()
102 ret = i2c_write_read_dt(&config->i2c_spec, &config_reg, 1, rx_buf, 2); in tcn75a_attr_get()
107 limit = sys_get_be16(rx_buf); in tcn75a_attr_get()
109 LOG_DBG("Read 0x%02X from %s", limit, config_reg == TCN75A_THYST_REG ? "THYST" : "TSET"); in tcn75a_attr_get()
112 val->val1 = limit >> TCN75A_TEMP_MSB_POS; in tcn75a_attr_get()
113 temp_lsb = (limit & TCN75A_TEMP_LSB_MASK); in tcn75a_attr_get()
114 val->val2 = TCN75A_FIXED_PT_TO_SENSOR(temp_lsb); in tcn75a_attr_get()
121 struct tcn75a_data *data = dev->data; in tcn75a_handle_int()
126 * Reading from any register will de-assert the interrupt. in tcn75a_handle_int()
129 if (data->sensor_cb) { in tcn75a_handle_int()
130 data->sensor_cb(dev, data->sensor_trig); in tcn75a_handle_int()
138 const struct tcn75a_config *config = data->dev->config; in tcn75a_gpio_callback()
140 if ((pin_mask & BIT(config->alert_gpios.pin)) == 0U) { in tcn75a_gpio_callback()
145 k_sem_give(&data->trig_sem); in tcn75a_gpio_callback()
147 k_work_submit(&data->work); in tcn75a_gpio_callback()
160 k_sem_take(&data->trig_sem, K_FOREVER); in tcn75a_thread_main()
161 tcn75a_handle_int(data->dev); in tcn75a_thread_main()
171 tcn75a_handle_int(data->dev); in tcn75a_work_handler()
177 const struct tcn75a_config *config = dev->config; in tcn75a_trigger_init()
178 struct tcn75a_data *data = dev->data; in tcn75a_trigger_init()
182 data->dev = dev; in tcn75a_trigger_init()
184 if (!gpio_is_ready_dt(&config->alert_gpios)) { in tcn75a_trigger_init()
185 LOG_ERR("alert GPIO device is not ready"); in tcn75a_trigger_init()
186 return -ENODEV; in tcn75a_trigger_init()
189 ret = gpio_pin_configure_dt(&config->alert_gpios, GPIO_INPUT); in tcn75a_trigger_init()
194 gpio_init_callback(&data->gpio_cb, tcn75a_gpio_callback, BIT(config->alert_gpios.pin)); in tcn75a_trigger_init()
196 ret = gpio_add_callback(config->alert_gpios.port, &data->gpio_cb); in tcn75a_trigger_init()
199 k_sem_init(&data->trig_sem, 0, K_SEM_MAX_LIMIT); in tcn75a_trigger_init()
200 k_thread_create(&data->thread, data->thread_stack, CONFIG_TCN75A_THREAD_STACK_SIZE, in tcn75a_trigger_init()
204 data->work.handler = tcn75a_work_handler; in tcn75a_trigger_init()