@@ -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;
4240int  as6212_int1_int_isr_count  =  0 ;
4341const  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,11 @@ 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 ;
95+ 	sensor_value_from_double (& alert_upper_thresh , CONFIG_APP_TEMP_ALERT_HIGH_THRESH );
9496
95- 	struct  sensor_value  alert_lower_thresh  =  {TEMPERATURE_THRESHOLD_LOW , 0 };
97+ 	struct  sensor_value  alert_lower_thresh ;
98+ 	sensor_value_from_double (& alert_lower_thresh , CONFIG_APP_TEMP_ALERT_LOW_THRESH );
9699
97100	struct  sensor_value  thermostat_mode  =  {0 , 0 };
98101
@@ -101,21 +104,18 @@ static void enable_temp_alerts(const struct device *as6212)
101104	sensor_attr_set (as6212 , SENSOR_CHAN_AMBIENT_TEMP , SENSOR_ATTR_UPPER_THRESH ,
102105			& alert_upper_thresh );
103106
104- 	printf ("\tSet SENSOR_ATTR_UPPER_THRESH (%d )\n" , alert_upper_thresh . val1 );
107+ 	printf ("\tSet SENSOR_ATTR_UPPER_THRESH (%gC )\n" , sensor_value_to_double ( & alert_upper_thresh ) );
105108
106109	sensor_attr_set (as6212 , SENSOR_CHAN_AMBIENT_TEMP , SENSOR_ATTR_LOWER_THRESH ,
107110			& alert_lower_thresh );
108111
109- 	printf ("\tSet SENSOR_ATTR_LOWER_THRESH (%d )\n" , alert_lower_thresh . val1 );
112+ 	printf ("\tSet SENSOR_ATTR_LOWER_THRESH (%gC )\n" , sensor_value_to_double ( & alert_lower_thresh ) );
110113
111114	sensor_trigger_set (as6212 , & sensor_trigger_type_temp_alert , temperature_alert );
112115
113116	puts ("\n\tSet temperature_alert" );
114117
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 );
118+ 	sensor_trigger_set (as6212 , & sensor_trigger_type_temp_alert , as6212_intr_callback );
119119}
120120#endif 
121121
@@ -211,8 +211,11 @@ static void setup(void)
211211		return ;
212212	}
213213
214- 	sensor_attr_set (as6212 , SENSOR_CHAN_AMBIENT_TEMP ,
214+ 	result   =   sensor_attr_set (as6212 , SENSOR_CHAN_AMBIENT_TEMP ,
215215			SENSOR_ATTR_TMP108_CONTINUOUS_CONVERSION_MODE , NULL );
216+ 	if  (result ) {
217+ 		printf ("error: sensor_attr_set(): %d\n" , result );
218+ 	}
216219
217220#if  CONFIG_APP_ENABLE_ONE_SHOT 
218221	enable_one_shot (as6212 );
0 commit comments