1 /*
2 * Copyright (c) 2014 - 2018, Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 #ifndef NRF_QDEC_H__
32 #define NRF_QDEC_H__
33
34 #include <nrfx.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /**
41 * @defgroup nrf_qdec_hal QDEC HAL
42 * @{
43 * @ingroup nrf_qdec
44 * @brief Hardware access layer for managing the Quadrature Decoder (QDEC) peripheral.
45 */
46
47 /**
48 * @brief This value can be provided as a parameter for the @ref nrf_qdec_pio_assign
49 * function call to specify that a LED signal shall not be use by the QDEC and
50 * connected to a physical pin.
51 */
52 #define NRF_QDEC_LED_NOT_CONNECTED 0xFFFFFFFF
53
54 /**
55 * @enum nrf_qdec_task_t
56 * @brief QDEC tasks.
57 */
58 typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
59 {
60 NRF_QDEC_TASK_START = offsetof(NRF_QDEC_Type, TASKS_START), /**< Starting the quadrature decoder. */
61 NRF_QDEC_TASK_STOP = offsetof(NRF_QDEC_Type, TASKS_STOP), /**< Stopping the quadrature decoder. */
62 NRF_QDEC_TASK_READCLRACC = offsetof(NRF_QDEC_Type, TASKS_READCLRACC) /**< Reading and clearing ACC and ACCDBL registers. */
63 } nrf_qdec_task_t;
64
65 /**
66 * @enum nrf_qdec_event_t
67 * @brief QDEC events.
68 */
69 typedef enum
70 {
71 NRF_QDEC_EVENT_SAMPLERDY = offsetof(NRF_QDEC_Type, EVENTS_SAMPLERDY), /**< Event generated for every new sample. */
72 NRF_QDEC_EVENT_REPORTRDY = offsetof(NRF_QDEC_Type, EVENTS_REPORTRDY), /**< Event generated for every new report. */
73 NRF_QDEC_EVENT_ACCOF = offsetof(NRF_QDEC_Type, EVENTS_ACCOF) /**< Event generated for every accumulator overflow. */
74 } nrf_qdec_event_t; /*lint -restore */
75
76 /**
77 * @enum nrf_qdec_short_mask_t
78 * @brief QDEC shortcuts.
79 */
80 typedef enum
81 {
82 NRF_QDEC_SHORT_REPORTRDY_READCLRACC_MASK = QDEC_SHORTS_REPORTRDY_READCLRACC_Msk, /**< Shortcut between REPORTRDY event and READCLRACC task. */
83 NRF_QDEC_SHORT_SAMPLERDY_STOP_MASK = QDEC_SHORTS_SAMPLERDY_STOP_Msk /**< Shortcut between SAMPLERDY event and STOP task. */
84 } nrf_qdec_short_mask_t;
85
86 /**
87 * @enum nrf_qdec_int_mask_t
88 * @brief QDEC interrupts.
89 */
90 typedef enum
91 {
92 NRF_QDEC_INT_SAMPLERDY_MASK = QDEC_INTENSET_SAMPLERDY_Msk, /**< Mask for enabling or disabling an interrupt on SAMPLERDY event. */
93 NRF_QDEC_INT_REPORTRDY_MASK = QDEC_INTENSET_REPORTRDY_Msk, /**< Mask for enabling or disabling an interrupt on REPORTRDY event. */
94 NRF_QDEC_INT_ACCOF_MASK = QDEC_INTENSET_ACCOF_Msk /**< Mask for enabling or disabling an interrupt on ACCOF event. */
95 } nrf_qdec_int_mask_t;
96
97 /**
98 * @enum nrf_qdec_enable_t
99 * @brief States of the enable bit.
100 */
101 typedef enum
102 {
103 NRF_QDEC_DISABLE = QDEC_ENABLE_ENABLE_Disabled, /**< Mask for disabling the QDEC periperal. When disabled, the QDEC decoder pins are not active. */
104 NRF_QDEC_ENABLE = QDEC_ENABLE_ENABLE_Enabled /**< Mask for enabling the QDEC periperal. When enabled, the QDEC pins are active. */
105 } nrf_qdec_enable_t;
106
107
108 /**
109 * @enum nrf_qdec_dbfen_t
110 * @brief States of the debounce filter enable bit.
111 */
112 typedef enum
113 {
114 NRF_QDEC_DBFEN_DISABLE = QDEC_DBFEN_DBFEN_Disabled, /**< Mask for disabling the debounce filter. */
115 NRF_QDEC_DBFEN_ENABLE = QDEC_DBFEN_DBFEN_Enabled /**< Mask for enabling the debounce filter. */
116 } nrf_qdec_dbfen_t;
117
118 /**
119 * @enum nrf_qdec_ledpol_t
120 * @brief Active LED polarity.
121 */
122 typedef enum
123 {
124 NRF_QDEC_LEPOL_ACTIVE_LOW = QDEC_LEDPOL_LEDPOL_ActiveLow, /**< QDEC LED active on output pin low. */
125 NRF_QDEC_LEPOL_ACTIVE_HIGH = QDEC_LEDPOL_LEDPOL_ActiveHigh /**< QDEC LED active on output pin high. */
126 } nrf_qdec_ledpol_t;
127
128
129 /**
130 * @enum nrf_qdec_sampleper_t
131 * @brief Available sampling periods.
132 */
133 typedef enum
134 {
135 NRF_QDEC_SAMPLEPER_128us = QDEC_SAMPLEPER_SAMPLEPER_128us, /**< QDEC sampling period 128 microseconds. */
136 NRF_QDEC_SAMPLEPER_256us = QDEC_SAMPLEPER_SAMPLEPER_256us, /**< QDEC sampling period 256 microseconds. */
137 NRF_QDEC_SAMPLEPER_512us = QDEC_SAMPLEPER_SAMPLEPER_512us, /**< QDEC sampling period 512 microseconds. */
138 NRF_QDEC_SAMPLEPER_1024us = QDEC_SAMPLEPER_SAMPLEPER_1024us, /**< QDEC sampling period 1024 microseconds. */
139 NRF_QDEC_SAMPLEPER_2048us = QDEC_SAMPLEPER_SAMPLEPER_2048us, /**< QDEC sampling period 2048 microseconds. */
140 NRF_QDEC_SAMPLEPER_4096us = QDEC_SAMPLEPER_SAMPLEPER_4096us, /**< QDEC sampling period 4096 microseconds. */
141 NRF_QDEC_SAMPLEPER_8192us = QDEC_SAMPLEPER_SAMPLEPER_8192us, /**< QDEC sampling period 8192 microseconds. */
142 NRF_QDEC_SAMPLEPER_16384us = QDEC_SAMPLEPER_SAMPLEPER_16384us /**< QDEC sampling period 16384 microseconds. */
143 } nrf_qdec_sampleper_t;
144
145 /**
146 * @enum nrf_qdec_reportper_t
147 * @brief Available report periods.
148 */
149 typedef enum
150 {
151 NRF_QDEC_REPORTPER_10 = QDEC_REPORTPER_REPORTPER_10Smpl, /**< QDEC report period 10 samples. */
152 NRF_QDEC_REPORTPER_40 = QDEC_REPORTPER_REPORTPER_40Smpl, /**< QDEC report period 40 samples. */
153 NRF_QDEC_REPORTPER_80 = QDEC_REPORTPER_REPORTPER_80Smpl, /**< QDEC report period 80 samples. */
154 NRF_QDEC_REPORTPER_120 = QDEC_REPORTPER_REPORTPER_120Smpl, /**< QDEC report period 120 samples. */
155 NRF_QDEC_REPORTPER_160 = QDEC_REPORTPER_REPORTPER_160Smpl, /**< QDEC report period 160 samples. */
156 NRF_QDEC_REPORTPER_200 = QDEC_REPORTPER_REPORTPER_200Smpl, /**< QDEC report period 200 samples. */
157 NRF_QDEC_REPORTPER_240 = QDEC_REPORTPER_REPORTPER_240Smpl, /**< QDEC report period 240 samples. */
158 NRF_QDEC_REPORTPER_280 = QDEC_REPORTPER_REPORTPER_280Smpl, /**< QDEC report period 280 samples. */
159 NRF_QDEC_REPORTPER_DISABLED /**< QDEC reporting disabled. */
160 } nrf_qdec_reportper_t;
161
162 /**
163 * @brief Function for enabling QDEC.
164 */
165 __STATIC_INLINE void nrf_qdec_enable(void);
166
167 /**
168 * @brief Function for disabling QDEC.
169 */
170 __STATIC_INLINE void nrf_qdec_disable(void);
171
172 /**
173 * @brief Function for returning the enable state of QDEC.
174 * @return State of the register.
175 */
176 __STATIC_INLINE uint32_t nrf_qdec_enable_get(void);
177
178 /**
179 * @brief Function for enabling QDEC interrupts by mask.
180 * @param[in] qdec_int_mask Sources of the interrupts to enable.
181 */
182 __STATIC_INLINE void nrf_qdec_int_enable(uint32_t qdec_int_mask);
183
184 /**
185 * @brief Function for disabling QDEC interrupts by mask.
186 * @param[in] qdec_int_mask Sources of the interrupts to disable.
187 *
188 */
189 __STATIC_INLINE void nrf_qdec_int_disable(uint32_t qdec_int_mask);
190
191 /**
192 * @brief Function for getting the enabled interrupts of the QDEC.
193 */
194 __STATIC_INLINE uint32_t nrf_qdec_int_enable_check(nrf_qdec_int_mask_t qdec_int_mask);
195
196 /**
197 * @brief Function for enabling the debouncing filter of the QED.
198 */
199 __STATIC_INLINE void nrf_qdec_dbfen_enable(void);
200
201 /**
202 * @brief Function for disabling the debouncing filter of the QED.
203 */
204 __STATIC_INLINE void nrf_qdec_dbfen_disable(void);
205
206 /**
207 * @brief Function for getting the state of the QDEC's debouncing filter.
208 * @retval NRF_QDEC_DBFEN_DISABLE If the debouncing filter is disabled.
209 * @retval NRF_QDEC_DBFEN_ENABLE If the debouncing filter is enabled.
210 */
211 __STATIC_INLINE uint32_t nrf_qdec_dbfen_get(void);
212
213 /**
214 * @brief Function for assigning QDEC pins.
215 * @param[in] psela Pin number.
216 * @param[in] pselb Pin number.
217 * @param[in] pselled Pin number.
218 */
219 __STATIC_INLINE void nrf_qdec_pio_assign( uint32_t psela, uint32_t pselb, uint32_t pselled);
220
221 /**
222 * @brief Function for setting a specific QDEC task.
223 * @param[in] qdec_task QDEC task to be set.
224 */
225 __STATIC_INLINE void nrf_qdec_task_trigger(nrf_qdec_task_t qdec_task);
226
227 /**
228 * @brief Function for retrieving the address of a QDEC task register.
229 * @param[in] qdec_task QDEC task.
230 */
231 __STATIC_INLINE uint32_t * nrf_qdec_task_address_get(nrf_qdec_task_t qdec_task);
232
233 /**
234 * @brief Function for clearing a specific QDEC event.
235 * @param[in] qdec_event QDEC event to clear.
236 */
237 __STATIC_INLINE void nrf_qdec_event_clear(nrf_qdec_event_t qdec_event);
238
239 /**
240 * @brief Function for retrieving the state of a specific QDEC event.
241 * @return State of the QDEC event.
242 */
243 __STATIC_INLINE uint32_t nrf_qdec_event_check(nrf_qdec_event_t qdec_event);
244
245 /**
246 * @brief Function for retrieving the address of a specific QDEC event register.
247 * @param[in] qdec_event QDEC event.
248 * @return Address of the specified QDEC event.
249 */
250 __STATIC_INLINE uint32_t * nrf_qdec_event_address_get(nrf_qdec_event_t qdec_event);
251
252 /**
253 * @brief Function for setting QDEC shortcuts.
254 * @param[in] qdec_short_mask QDEC shortcut by mask.
255 */
256 __STATIC_INLINE void nrf_qdec_shorts_enable(uint32_t qdec_short_mask);
257
258 /**
259 * @brief Function for clearing shortcuts of the QDEC by mask.
260 * @param[in] qdec_short_mask QDEC shortcute to be cleared.
261 */
262 __STATIC_INLINE void nrf_qdec_shorts_disable(uint32_t qdec_short_mask);
263
264 /**
265 * @brief Function for retrieving the value of QDEC's SAMPLEPER register.
266 * @return Value of the SAMPLEPER register.
267 */
268 __STATIC_INLINE int32_t nrf_qdec_sampleper_reg_get(void);
269
270 /**
271 * @brief Function for converting the value of QDEC's SAMPLE PERIOD to microseconds.
272 * @retval sampling period in microseconds.
273 */
274 __STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(uint32_t sampleper);
275
276 /**
277 * @brief Function for setting the value of QDEC's SAMPLEPER register.
278 * @param[in] sample_per Sampling period.
279 */
280 __STATIC_INLINE void nrf_qdec_sampleper_set(nrf_qdec_sampleper_t sample_per);
281
282 /**
283 * @brief Function for retrieving the value of QDEC's SAMPLE register.
284 * @return Value of the SAMPLE register.
285 */
286 __STATIC_INLINE int32_t nrf_qdec_sample_get(void);
287
288 /**
289 * @brief Function for retrieving the value of QDEC's ACC register.
290 * @return Value of the ACC register.
291 */
292 __STATIC_INLINE int32_t nrf_qdec_acc_get(void);
293
294 /**
295 * @brief Function for retrieving the value of QDEC's ACCREAD register.
296 * @return Value of the ACCREAD register.
297 */
298 __STATIC_INLINE int32_t nrf_qdec_accread_get(void);
299
300 /**
301 * @brief Function for retrieving the value of QDEC's ACCDBL register.
302 * @return Value of the ACCDBL register.
303 */
304 __STATIC_INLINE uint32_t nrf_qdec_accdbl_get(void);
305
306 /**
307 * @brief Function for retrieving the value of QDEC's ACCDBLREAD register.
308 * @return Value of the ACCDBLREAD register.
309 */
310 __STATIC_INLINE uint32_t nrf_qdec_accdblread_get(void);
311
312 /**
313 * @brief Function for setting how long the LED is switched on before sampling.
314 * @param[in] time_us Time (in microseconds) how long the LED is switched on before sampling.
315 */
316 __STATIC_INLINE void nrf_qdec_ledpre_set(uint32_t time_us);
317
318 /**
319 * @brief Function for retrieving how long the LED is switched on before sampling.
320 * @retval time_us Time (in microseconds) how long the LED is switched on before sampling.
321 */
322 __STATIC_INLINE uint32_t nrf_qdec_ledpre_get(void);
323
324 /**
325 * @brief Function for setting the report period (in samples).
326 * @param[in] reportper Number of samples.
327 */
328 __STATIC_INLINE void nrf_qdec_reportper_set(nrf_qdec_reportper_t reportper);
329
330 /**
331 * @brief Function for retrieving the report period.
332 * @retval reportper Number of samples as encoded in the register.
333 */
334 __STATIC_INLINE uint32_t nrf_qdec_reportper_reg_get(void);
335
336 /**
337 * @brief Function for retrieving the value of QDEC's SAMPLEPER register.
338 * @param [in] reportper Reportper to be converted to amount of samples per report.
339 */
340 __STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper);
341
342 /**
343 * @brief Function for setting the active level for the LED.
344 * @param[in] pol Active level for the LED.
345 */
346 __STATIC_INLINE void nrf_qdec_ledpol_set(nrf_qdec_ledpol_t pol);
347
348 /**
349 * @brief Function for retrieving the active level for the LED.
350 * @return Active level for the LED.
351 */
352 __STATIC_INLINE uint32_t nrf_qdec_ledpol_get(void);
353
354 #ifndef SUPPRESS_INLINE_IMPLEMENTATION
nrf_qdec_enable(void)355 __STATIC_INLINE void nrf_qdec_enable(void)
356 {
357 NRF_QDEC->ENABLE = NRF_QDEC_ENABLE;
358 }
359
nrf_qdec_disable(void)360 __STATIC_INLINE void nrf_qdec_disable(void)
361 {
362 NRF_QDEC->ENABLE = NRF_QDEC_DISABLE;
363 }
364
nrf_qdec_enable_get(void)365 __STATIC_INLINE uint32_t nrf_qdec_enable_get(void)
366 {
367 return NRF_QDEC->ENABLE;
368 }
369
nrf_qdec_int_enable(uint32_t qdec_int_mask)370 __STATIC_INLINE void nrf_qdec_int_enable(uint32_t qdec_int_mask)
371 {
372 NRF_QDEC->INTENSET = qdec_int_mask; // writing 0 has no effect
373 }
374
nrf_qdec_int_disable(uint32_t qdec_int_mask)375 __STATIC_INLINE void nrf_qdec_int_disable(uint32_t qdec_int_mask)
376 {
377 NRF_QDEC->INTENCLR = qdec_int_mask; // writing 0 has no effect
378 }
379
nrf_qdec_int_enable_check(nrf_qdec_int_mask_t qdec_int_mask)380 __STATIC_INLINE uint32_t nrf_qdec_int_enable_check(nrf_qdec_int_mask_t qdec_int_mask)
381 {
382 return NRF_QDEC->INTENSET & qdec_int_mask; // when read this register will return the value of INTEN.
383 }
384
nrf_qdec_dbfen_enable(void)385 __STATIC_INLINE void nrf_qdec_dbfen_enable(void)
386 {
387 NRF_QDEC->DBFEN = NRF_QDEC_DBFEN_ENABLE;
388 }
389
nrf_qdec_dbfen_disable(void)390 __STATIC_INLINE void nrf_qdec_dbfen_disable(void)
391 {
392 NRF_QDEC->DBFEN = NRF_QDEC_DBFEN_DISABLE;
393 }
394
nrf_qdec_dbfen_get(void)395 __STATIC_INLINE uint32_t nrf_qdec_dbfen_get(void)
396 {
397 return NRF_QDEC->DBFEN;
398 }
399
nrf_qdec_pio_assign(uint32_t psela,uint32_t pselb,uint32_t pselled)400 __STATIC_INLINE void nrf_qdec_pio_assign( uint32_t psela, uint32_t pselb, uint32_t pselled)
401 {
402 NRF_QDEC->PSELA = psela;
403 NRF_QDEC->PSELB = pselb;
404 NRF_QDEC->PSELLED = pselled;
405 }
406
nrf_qdec_task_trigger(nrf_qdec_task_t qdec_task)407 __STATIC_INLINE void nrf_qdec_task_trigger(nrf_qdec_task_t qdec_task)
408 {
409 *( (volatile uint32_t *)( (uint8_t *)NRF_QDEC + qdec_task) ) = 1;
410 }
411
nrf_qdec_task_address_get(nrf_qdec_task_t qdec_task)412 __STATIC_INLINE uint32_t * nrf_qdec_task_address_get(nrf_qdec_task_t qdec_task)
413 {
414 return (uint32_t *)( (uint8_t *)NRF_QDEC + qdec_task);
415 }
416
nrf_qdec_event_clear(nrf_qdec_event_t qdec_event)417 __STATIC_INLINE void nrf_qdec_event_clear(nrf_qdec_event_t qdec_event)
418 {
419 *( (volatile uint32_t *)( (uint8_t *)NRF_QDEC + qdec_event) ) = 0;
420 #if __CORTEX_M == 0x04
421 volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_QDEC + qdec_event));
422 (void)dummy;
423 #endif
424 }
425
nrf_qdec_event_check(nrf_qdec_event_t qdec_event)426 __STATIC_INLINE uint32_t nrf_qdec_event_check(nrf_qdec_event_t qdec_event)
427 {
428 return *(volatile uint32_t *)( (uint8_t *)NRF_QDEC + qdec_event);
429 }
430
nrf_qdec_event_address_get(nrf_qdec_event_t qdec_event)431 __STATIC_INLINE uint32_t * nrf_qdec_event_address_get(nrf_qdec_event_t qdec_event)
432 {
433 return (uint32_t *)( (uint8_t *)NRF_QDEC + qdec_event);
434 }
435
nrf_qdec_shorts_enable(uint32_t qdec_short_mask)436 __STATIC_INLINE void nrf_qdec_shorts_enable(uint32_t qdec_short_mask)
437 {
438 NRF_QDEC->SHORTS |= qdec_short_mask;
439 }
440
nrf_qdec_shorts_disable(uint32_t qdec_short_mask)441 __STATIC_INLINE void nrf_qdec_shorts_disable(uint32_t qdec_short_mask)
442 {
443 NRF_QDEC->SHORTS &= ~qdec_short_mask;
444 }
445
nrf_qdec_sampleper_reg_get(void)446 __STATIC_INLINE int32_t nrf_qdec_sampleper_reg_get(void)
447 {
448 return NRF_QDEC->SAMPLEPER;
449 }
450
nrf_qdec_sampleper_to_value(uint32_t sampleper)451 __STATIC_INLINE uint32_t nrf_qdec_sampleper_to_value(uint32_t sampleper)
452 {
453 return (1 << (7 + sampleper));
454 }
455
nrf_qdec_sampleper_set(nrf_qdec_sampleper_t sample_per)456 __STATIC_INLINE void nrf_qdec_sampleper_set(nrf_qdec_sampleper_t sample_per)
457 {
458 NRF_QDEC->SAMPLEPER = sample_per;
459 }
460
nrf_qdec_sample_get(void)461 __STATIC_INLINE int32_t nrf_qdec_sample_get(void)
462 {
463 return NRF_QDEC->SAMPLE;
464 }
465
nrf_qdec_acc_get(void)466 __STATIC_INLINE int32_t nrf_qdec_acc_get(void)
467 {
468 return NRF_QDEC->ACC;
469 }
470
nrf_qdec_accread_get(void)471 __STATIC_INLINE int32_t nrf_qdec_accread_get(void)
472 {
473 return NRF_QDEC->ACCREAD;
474 }
475
nrf_qdec_accdbl_get(void)476 __STATIC_INLINE uint32_t nrf_qdec_accdbl_get(void)
477 {
478 return NRF_QDEC->ACCDBL;
479 }
480
nrf_qdec_accdblread_get(void)481 __STATIC_INLINE uint32_t nrf_qdec_accdblread_get(void)
482 {
483 return NRF_QDEC->ACCDBLREAD;
484 }
485
nrf_qdec_ledpre_set(uint32_t time_us)486 __STATIC_INLINE void nrf_qdec_ledpre_set(uint32_t time_us)
487 {
488 NRF_QDEC->LEDPRE = time_us;
489 }
490
nrf_qdec_ledpre_get(void)491 __STATIC_INLINE uint32_t nrf_qdec_ledpre_get(void)
492 {
493 return NRF_QDEC->LEDPRE;
494 }
495
nrf_qdec_reportper_set(nrf_qdec_reportper_t reportper)496 __STATIC_INLINE void nrf_qdec_reportper_set(nrf_qdec_reportper_t reportper)
497 {
498 NRF_QDEC->REPORTPER = reportper;
499 }
500
nrf_qdec_reportper_reg_get(void)501 __STATIC_INLINE uint32_t nrf_qdec_reportper_reg_get(void)
502 {
503 return NRF_QDEC->REPORTPER;
504 }
505
nrf_qdec_reportper_to_value(uint32_t reportper)506 __STATIC_INLINE uint32_t nrf_qdec_reportper_to_value(uint32_t reportper)
507 {
508 return (reportper == NRF_QDEC_REPORTPER_10) ? 10 : reportper * 40;
509 }
510
nrf_qdec_ledpol_set(nrf_qdec_ledpol_t pol)511 __STATIC_INLINE void nrf_qdec_ledpol_set(nrf_qdec_ledpol_t pol)
512 {
513 NRF_QDEC->LEDPOL = pol;
514 }
515
nrf_qdec_ledpol_get(void)516 __STATIC_INLINE uint32_t nrf_qdec_ledpol_get(void)
517 {
518 return NRF_QDEC->LEDPOL;
519 }
520
521 #endif // SUPPRESS_INLINE_IMPLEMENTATION
522 /** @} */
523
524 #ifdef __cplusplus
525 }
526 #endif
527
528 #endif // NRF_QDEC_H__
529