19
19
#define SHIM_NRF_COMP_DT_INST_REFSEL_IS_AREF (inst ) \
20
20
DT_INST_ENUM_HAS_VALUE(inst, refsel, aref)
21
21
22
- #define SHIM_NRF_COMP_DT_INST_EXTREFSEL (inst ) \
23
- _CONCAT(COMP_NRF_COMP_EXTREFSEL_, DT_INST_STRING_TOKEN(inst, extrefsel))
22
+ #define SHIM_NRF_COMP_DT_INST_EXTREFSEL (inst ) DT_INST_PROP(inst, extrefsel)
24
23
25
24
#define SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE (inst ) \
26
25
DT_INST_ENUM_HAS_VALUE(inst, main_mode, se)
43
42
#define SHIM_NRF_COMP_DT_INST_ISOURCE (inst ) \
44
43
_CONCAT(COMP_NRF_COMP_ISOURCE_, DT_INST_STRING_TOKEN(inst, isource))
45
44
46
- #define SHIM_NRF_COMP_DT_INST_PSEL (inst ) \
47
- _CONCAT(COMP_NRF_COMP_PSEL_, DT_INST_STRING_TOKEN(inst, psel))
45
+ #define SHIM_NRF_COMP_DT_INST_PSEL (inst ) DT_INST_PROP(inst, psel)
48
46
49
47
#if defined(COMP_HYST_HYST_Hyst40mV )
50
48
#define NRF_COMP_HYST_ENABLED NRF_COMP_HYST_40MV
@@ -73,35 +71,50 @@ BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_TH_DOWN(0) < 64);
73
71
BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_TH_UP (0 ) < 64 );
74
72
#endif
75
73
76
- #if NRF_COMP_HAS_AIN_AS_PIN
77
- BUILD_ASSERT ((COMP_NRF_COMP_PSEL_AIN0 == 0 ));
78
- BUILD_ASSERT ((COMP_NRF_COMP_PSEL_AIN7 == 7 ));
79
- BUILD_ASSERT ((COMP_NRF_COMP_EXTREFSEL_AIN0 == 0 ));
80
- BUILD_ASSERT ((COMP_NRF_COMP_EXTREFSEL_AIN7 == 7 ));
74
+ #if (NRF_COMP_HAS_AIN_AS_PIN )
75
+ BUILD_ASSERT (NRF_COMP_AIN0 == 0 );
76
+ BUILD_ASSERT (NRF_COMP_AIN7 == 7 );
81
77
#else
82
- #ifndef COMP_PSEL_PSEL_AnalogInput4
83
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_AIN4 );
78
+ BUILD_ASSERT ((NRF_COMP_AIN0 == NRF_COMP_INPUT_0 ) &&
79
+ (NRF_COMP_AIN1 == NRF_COMP_INPUT_1 ) &&
80
+ (NRF_COMP_AIN2 == NRF_COMP_INPUT_2 ) &&
81
+ (NRF_COMP_AIN3 == NRF_COMP_INPUT_3 ) &&
82
+ #if defined(COMP_PSEL_PSEL_AnalogInput4 )
83
+ (NRF_COMP_AIN4 == NRF_COMP_INPUT_4 ) &&
84
84
#endif
85
-
86
- #ifndef COMP_PSEL_PSEL_AnalogInput5
87
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_AIN5 );
85
+ #if defined(COMP_PSEL_PSEL_AnalogInput5 )
86
+ (NRF_COMP_AIN5 == NRF_COMP_INPUT_5 ) &&
88
87
#endif
89
-
90
- #ifndef COMP_PSEL_PSEL_AnalogInput6
91
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_AIN6 );
88
+ #if defined(COMP_PSEL_PSEL_AnalogInput6 )
89
+ (NRF_COMP_AIN6 == NRF_COMP_INPUT_6 ) &&
92
90
#endif
93
-
94
- #ifndef COMP_PSEL_PSEL_AnalogInput7
95
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_AIN7 );
91
+ #if defined(COMP_PSEL_PSEL_AnalogInput7 )
92
+ (NRF_COMP_AIN7 == NRF_COMP_INPUT_7 ) &&
96
93
#endif
94
+ (NRF_COMP_AIN0 == NRF_COMP_EXT_REF_0 ) &&
95
+ (NRF_COMP_AIN1 == NRF_COMP_EXT_REF_1 ) &&
96
+ (NRF_COMP_AIN2 == NRF_COMP_EXT_REF_2 ) &&
97
+ (NRF_COMP_AIN3 == NRF_COMP_EXT_REF_3 ) &&
98
+ #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference4 )
99
+ (NRF_COMP_AIN4 == NRF_COMP_EXT_REF_4 ) &&
97
100
#endif
98
-
99
- #ifndef COMP_PSEL_PSEL_VddDiv2
100
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_VDD_DIV2 );
101
+ #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference5 )
102
+ (NRF_COMP_AIN5 == NRF_COMP_EXT_REF_5 ) &&
101
103
#endif
102
-
103
- #ifndef COMP_PSEL_PSEL_VddhDiv5
104
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_PSEL (0 ) != COMP_NRF_COMP_PSEL_VDDH_DIV5 );
104
+ #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference6 )
105
+ (NRF_COMP_AIN6 == NRF_COMP_EXT_REF_6 ) &&
106
+ #endif
107
+ #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference7 )
108
+ (NRF_COMP_AIN7 == NRF_COMP_EXT_REF_7 ) &&
109
+ #endif
110
+ #if defined(COMP_PSEL_PSEL_VddDiv2 )
111
+ (NRF_COMP_VDD_DIV2 == NRF_COMP_VDD_DIV2 ) &&
112
+ #endif
113
+ #if defined(COMP_PSEL_PSEL_VddhDiv5 )
114
+ (NRF_COMP_VDDH_DIV5 == NRF_COMP_VDDH_DIV5 ) &&
115
+ #endif
116
+ 1 ,
117
+ "Definitions from nrf-comp.h do not match those from HAL" );
105
118
#endif
106
119
107
120
#ifndef COMP_MODE_SP_Normal
@@ -122,24 +135,6 @@ BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_ISOURCE(0) != COMP_NRF_COMP_ISOURCE_10UA);
122
135
#endif
123
136
#endif
124
137
125
- #if SHIM_NRF_COMP_DT_INST_REFSEL_IS_AREF (0 )
126
- #ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference4
127
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_EXTREFSEL (0 ) != COMP_NRF_COMP_EXTREFSEL_AIN4 );
128
- #endif
129
-
130
- #ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference5
131
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_EXTREFSEL (0 ) != COMP_NRF_COMP_EXTREFSEL_AIN5 );
132
- #endif
133
-
134
- #ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference6
135
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_EXTREFSEL (0 ) != COMP_NRF_COMP_EXTREFSEL_AIN6 );
136
- #endif
137
-
138
- #ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference7
139
- BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_EXTREFSEL (0 ) != COMP_NRF_COMP_EXTREFSEL_AIN7 );
140
- #endif
141
- #endif
142
-
143
138
#if SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE (0 )
144
139
#ifndef COMP_REFSEL_REFSEL_Int1V8
145
140
BUILD_ASSERT (SHIM_NRF_COMP_DT_INST_REFSEL (0 ) != COMP_NRF_COMP_REFSEL_INT_1V8 );
@@ -246,69 +241,69 @@ static int shim_nrf_comp_pm_callback(const struct device *dev, enum pm_device_ac
246
241
}
247
242
248
243
#if (NRF_COMP_HAS_AIN_AS_PIN )
249
- static int shim_nrf_comp_psel_to_nrf (enum comp_nrf_comp_psel shim ,
244
+ static int shim_nrf_comp_psel_to_nrf (uint8_t shim ,
250
245
nrf_comp_input_t * nrf )
251
246
{
252
247
if (shim >= ARRAY_SIZE (shim_nrf_comp_ain_map )) {
253
248
return - EINVAL ;
254
249
}
255
250
256
- * nrf = shim_nrf_comp_ain_map [( uint32_t ) shim ];
251
+ * nrf = shim_nrf_comp_ain_map [shim ];
257
252
return 0 ;
258
253
}
259
254
#else
260
- static int shim_nrf_comp_psel_to_nrf (enum comp_nrf_comp_psel shim ,
255
+ static int shim_nrf_comp_psel_to_nrf (uint8_t shim ,
261
256
nrf_comp_input_t * nrf )
262
257
{
263
258
switch (shim ) {
264
- case COMP_NRF_COMP_PSEL_AIN0 :
259
+ case NRF_COMP_AIN0 :
265
260
* nrf = NRF_COMP_INPUT_0 ;
266
261
break ;
267
262
268
- case COMP_NRF_COMP_PSEL_AIN1 :
263
+ case NRF_COMP_AIN1 :
269
264
* nrf = NRF_COMP_INPUT_1 ;
270
265
break ;
271
266
272
- case COMP_NRF_COMP_PSEL_AIN2 :
267
+ case NRF_COMP_AIN2 :
273
268
* nrf = NRF_COMP_INPUT_2 ;
274
269
break ;
275
270
276
- case COMP_NRF_COMP_PSEL_AIN3 :
271
+ case NRF_COMP_AIN3 :
277
272
* nrf = NRF_COMP_INPUT_3 ;
278
273
break ;
279
274
280
275
#if defined(COMP_PSEL_PSEL_AnalogInput4 )
281
- case COMP_NRF_COMP_PSEL_AIN4 :
276
+ case NRF_COMP_AIN4 :
282
277
* nrf = NRF_COMP_INPUT_4 ;
283
278
break ;
284
279
#endif
285
280
286
281
#if defined(COMP_PSEL_PSEL_AnalogInput5 )
287
- case COMP_NRF_COMP_PSEL_AIN5 :
282
+ case NRF_COMP_AIN5 :
288
283
* nrf = NRF_COMP_INPUT_5 ;
289
284
break ;
290
285
#endif
291
286
292
287
#if defined(COMP_PSEL_PSEL_AnalogInput6 )
293
- case COMP_NRF_COMP_PSEL_AIN6 :
288
+ case NRF_COMP_AIN6 :
294
289
* nrf = NRF_COMP_INPUT_6 ;
295
290
break ;
296
291
#endif
297
292
298
293
#if defined(COMP_PSEL_PSEL_AnalogInput7 )
299
- case COMP_NRF_COMP_PSEL_AIN7 :
294
+ case NRF_COMP_AIN7 :
300
295
* nrf = NRF_COMP_INPUT_7 ;
301
296
break ;
302
297
#endif
303
298
304
299
#if defined(COMP_PSEL_PSEL_VddDiv2 )
305
- case COMP_NRF_COMP_PSEL_VDD_DIV2 :
300
+ case NRF_COMP_AIN_VDD_DIV2 :
306
301
* nrf = NRF_COMP_VDD_DIV2 ;
307
302
break ;
308
303
#endif
309
304
310
305
#if defined(COMP_PSEL_PSEL_VddhDiv5 )
311
- case COMP_NRF_COMP_PSEL_VDDH_DIV5 :
306
+ case NRF_COMP_AIN_VDDH_DIV5 :
312
307
* nrf = NRF_COMP_VDDH_DIV5 ;
313
308
break ;
314
309
#endif
@@ -382,57 +377,57 @@ static int shim_nrf_comp_isource_to_nrf(enum comp_nrf_comp_isource shim,
382
377
#endif
383
378
384
379
#if (NRF_COMP_HAS_AIN_AS_PIN )
385
- static int shim_nrf_comp_extrefsel_to_nrf (enum comp_nrf_comp_extrefsel shim ,
380
+ static int shim_nrf_comp_extrefsel_to_nrf (uint8_t shim ,
386
381
nrf_comp_ext_ref_t * nrf )
387
382
{
388
383
if (shim >= ARRAY_SIZE (shim_nrf_comp_ain_map )) {
389
384
return - EINVAL ;
390
385
}
391
386
392
- * nrf = shim_nrf_comp_ain_map [( uint32_t ) shim ];
387
+ * nrf = shim_nrf_comp_ain_map [shim ];
393
388
return 0 ;
394
389
}
395
390
#else
396
- static int shim_nrf_comp_extrefsel_to_nrf (enum comp_nrf_comp_extrefsel shim ,
391
+ static int shim_nrf_comp_extrefsel_to_nrf (uint8_t shim ,
397
392
nrf_comp_ext_ref_t * nrf )
398
393
{
399
394
switch (shim ) {
400
- case COMP_NRF_COMP_EXTREFSEL_AIN0 :
395
+ case NRF_COMP_AIN0 :
401
396
* nrf = NRF_COMP_EXT_REF_0 ;
402
397
break ;
403
398
404
- case COMP_NRF_COMP_EXTREFSEL_AIN1 :
399
+ case NRF_COMP_AIN1 :
405
400
* nrf = NRF_COMP_EXT_REF_1 ;
406
401
break ;
407
402
408
- case COMP_NRF_COMP_EXTREFSEL_AIN2 :
403
+ case NRF_COMP_AIN2 :
409
404
* nrf = NRF_COMP_EXT_REF_2 ;
410
405
break ;
411
406
412
- case COMP_NRF_COMP_EXTREFSEL_AIN3 :
407
+ case NRF_COMP_AIN3 :
413
408
* nrf = NRF_COMP_EXT_REF_3 ;
414
409
break ;
415
410
416
411
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference4 )
417
- case COMP_NRF_COMP_EXTREFSEL_AIN4 :
412
+ case NRF_COMP_AIN4 :
418
413
* nrf = NRF_COMP_EXT_REF_4 ;
419
414
break ;
420
415
#endif
421
416
422
417
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference5 )
423
- case COMP_NRF_COMP_EXTREFSEL_AIN5 :
418
+ case NRF_COMP_AIN5 :
424
419
* nrf = NRF_COMP_EXT_REF_5 ;
425
420
break ;
426
421
#endif
427
422
428
423
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference6 )
429
- case COMP_NRF_COMP_EXTREFSEL_AIN6 :
424
+ case NRF_COMP_AIN6 :
430
425
* nrf = NRF_COMP_EXT_REF_6 ;
431
426
break ;
432
427
#endif
433
428
434
429
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference7 )
435
- case COMP_NRF_COMP_EXTREFSEL_AIN7 :
430
+ case NRF_COMP_AIN7 :
436
431
* nrf = NRF_COMP_EXT_REF_7 ;
437
432
break ;
438
433
#endif
0 commit comments