Skip to content

Commit e6848f9

Browse files
committed
Align AS6212 sample to upstream
Signed-off-by: John Hutcherson <18317262+jvhutch@users.noreply.github.com>
1 parent 7279c52 commit e6848f9

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

samples/as6212_sample/Kconfig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#
2-
# Copyright (c) 2021 Jimmy Johnson <catch22@fastmail.net>
1+
# Copyright (c) 2022 T-Mobile USA, Inc.
32
#
43
# SPDX-License-Identifier: Apache-2.0
54
#
@@ -21,7 +20,7 @@ config APP_ENABLE_ONE_SHOT
2120
config APP_TEMP_ALERT_HIGH_THRESH
2221
int "RH [%] high threshold for alert trigger in celsius"
2322
range 0 50
24-
default 26
23+
default 44
2524
help
2625
Set this to enable alerts for high temperatures
2726
although this will work with one shot enabled,
@@ -32,7 +31,7 @@ config APP_TEMP_ALERT_HIGH_THRESH
3231
config APP_TEMP_ALERT_LOW_THRESH
3332
int "RH [%] low threshold for alert trigger in celsius"
3433
range 0 50
35-
default 18
34+
default 38
3635
help
3736
Set this to enable alerts for low temperatures
3837
although this will work with one shot enabled,

samples/as6212_sample/prj.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
# Copyright (c) 2022 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
15
CONFIG_SENSOR=y
26
CONFIG_STDOUT_CONSOLE=y
37
CONFIG_CBPRINTF_FP_SUPPORT=y
48
CONFIG_I2C=y
59
CONFIG_TMP108=y
6-
CONFIG_ASSERT=y
710
CONFIG_TMP108_ALERT_INTERRUPTS=y
811
#Power Managment
912
CONFIG_PM=y

samples/as6212_sample/src/main.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ LOG_MODULE_REGISTER(as6212_sample, LOG_LEVEL_INF);
2121
#define INTERRUPT_MODE 0x0200
2222

2323
#define SLEEP_DURATION 2U
24-
#define TEMPERATURE_THRESHOLD_LOW 38
25-
#define TEMPERATURE_THRESHOLD_HIGH 44
2624

2725
/* Thread properties */
2826
#undef TASK_STACK_SIZE
@@ -42,8 +40,11 @@ static struct k_thread as6212_b_id;
4240
int as6212_int1_int_isr_count = 0;
4341
const struct device *as6212;
4442

45-
void as6212_intr_callback(const struct device *port, struct gpio_callback *cb, uint32_t pins)
43+
static void as6212_intr_callback(const struct device *device, const struct sensor_trigger *trigger)
4644
{
45+
ARG_UNUSED(device);
46+
ARG_UNUSED(trigger);
47+
4748
as6212_int1_int_isr_count++;
4849
printk("\n%s(): Received AS6212 Temperature Sensor ALERT Interrupt (%d)\n", __func__,
4950
as6212_int1_int_isr_count);
@@ -90,9 +91,9 @@ static void enable_temp_alerts(const struct device *as6212)
9091
struct sensor_trigger sensor_trigger_type_temp_alert = {.chan = SENSOR_CHAN_AMBIENT_TEMP,
9192
.type = SENSOR_TRIG_THRESHOLD};
9293

93-
struct sensor_value alert_upper_thresh = {TEMPERATURE_THRESHOLD_HIGH, 0};
94+
struct sensor_value alert_upper_thresh = {CONFIG_APP_TEMP_ALERT_HIGH_THRESH, 0};
9495

95-
struct sensor_value alert_lower_thresh = {TEMPERATURE_THRESHOLD_LOW, 0};
96+
struct sensor_value alert_lower_thresh = {CONFIG_APP_TEMP_ALERT_LOW_THRESH, 0};
9697

9798
struct sensor_value thermostat_mode = {0, 0};
9899

@@ -112,10 +113,7 @@ static void enable_temp_alerts(const struct device *as6212)
112113

113114
puts("\n\tSet temperature_alert");
114115

115-
struct sensor_value app_callback = {0, 0};
116-
app_callback.val1 = 1;
117-
app_callback.val2 = (int32_t)as6212_intr_callback;
118-
sensor_attr_set(as6212, SENSOR_CHAN_AMBIENT_TEMP, SENSOR_ATTR_USER_CALLBACK, &app_callback);
116+
sensor_trigger_set(as6212, &sensor_trigger_type_temp_alert, as6212_intr_callback);
119117
}
120118
#endif
121119

0 commit comments

Comments
 (0)