1 /*
2  * Copyright (c) 2015 - 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 
32 #ifndef NRF_TWIM_H__
33 #define NRF_TWIM_H__
34 
35 #include <nrfx.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**
42  * @defgroup nrf_twim_hal TWIM HAL
43  * @{
44  * @ingroup nrf_twim
45  * @brief   Hardware access layer for managing the TWIM peripheral.
46  */
47 
48 /**
49  * @brief TWIM tasks.
50  */
51 typedef enum
52 {
53     /*lint -save -e30*/
54     NRF_TWIM_TASK_STARTRX = offsetof(NRF_TWIM_Type, TASKS_STARTRX), ///< Start TWI receive sequence.
55     NRF_TWIM_TASK_STARTTX = offsetof(NRF_TWIM_Type, TASKS_STARTTX), ///< Start TWI transmit sequence.
56     NRF_TWIM_TASK_STOP    = offsetof(NRF_TWIM_Type, TASKS_STOP),    ///< Stop TWI transaction.
57     NRF_TWIM_TASK_SUSPEND = offsetof(NRF_TWIM_Type, TASKS_SUSPEND), ///< Suspend TWI transaction.
58     NRF_TWIM_TASK_RESUME  = offsetof(NRF_TWIM_Type, TASKS_RESUME)   ///< Resume TWI transaction.
59     /*lint -restore*/
60 } nrf_twim_task_t;
61 
62 /**
63  * @brief TWIM events.
64  */
65 typedef enum
66 {
67     /*lint -save -e30*/
68     NRF_TWIM_EVENT_STOPPED   = offsetof(NRF_TWIM_Type, EVENTS_STOPPED),   ///< TWI stopped.
69     NRF_TWIM_EVENT_ERROR     = offsetof(NRF_TWIM_Type, EVENTS_ERROR),     ///< TWI error.
70     NRF_TWIM_EVENT_SUSPENDED = 0x148,                                     ///< TWI suspended.
71     NRF_TWIM_EVENT_RXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_RXSTARTED), ///< Receive sequence started.
72     NRF_TWIM_EVENT_TXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_TXSTARTED), ///< Transmit sequence started.
73     NRF_TWIM_EVENT_LASTRX    = offsetof(NRF_TWIM_Type, EVENTS_LASTRX),    ///< Byte boundary, starting to receive the last byte.
74     NRF_TWIM_EVENT_LASTTX    = offsetof(NRF_TWIM_Type, EVENTS_LASTTX)     ///< Byte boundary, starting to transmit the last byte.
75     /*lint -restore*/
76 } nrf_twim_event_t;
77 
78 /**
79  * @brief TWIM shortcuts.
80  */
81 typedef enum
82 {
83     NRF_TWIM_SHORT_LASTTX_STARTRX_MASK = TWIM_SHORTS_LASTTX_STARTRX_Msk,  ///< Shortcut between LASTTX event and STARTRX task.
84     NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK = TWIM_SHORTS_LASTTX_SUSPEND_Msk,  ///< Shortcut between LASTTX event and SUSPEND task.
85     NRF_TWIM_SHORT_LASTTX_STOP_MASK    = TWIM_SHORTS_LASTTX_STOP_Msk,     ///< Shortcut between LASTTX event and STOP task.
86     NRF_TWIM_SHORT_LASTRX_STARTTX_MASK = TWIM_SHORTS_LASTRX_STARTTX_Msk,  ///< Shortcut between LASTRX event and STARTTX task.
87     NRF_TWIM_SHORT_LASTRX_STOP_MASK    = TWIM_SHORTS_LASTRX_STOP_Msk,     ///< Shortcut between LASTRX event and STOP task.
88     NRF_TWIM_ALL_SHORTS_MASK           = TWIM_SHORTS_LASTTX_STARTRX_Msk |
89                                          TWIM_SHORTS_LASTTX_SUSPEND_Msk |
90                                          TWIM_SHORTS_LASTTX_STOP_Msk    |
91                                          TWIM_SHORTS_LASTRX_STARTTX_Msk |
92                                          TWIM_SHORTS_LASTRX_STOP_Msk      ///< All TWIM shortcuts.
93 } nrf_twim_short_mask_t;
94 
95 /**
96  * @brief TWIM interrupts.
97  */
98 typedef enum
99 {
100     NRF_TWIM_INT_STOPPED_MASK   = TWIM_INTENSET_STOPPED_Msk,   ///< Interrupt on STOPPED event.
101     NRF_TWIM_INT_ERROR_MASK     = TWIM_INTENSET_ERROR_Msk,     ///< Interrupt on ERROR event.
102     NRF_TWIM_INT_SUSPENDED_MASK = TWIM_INTENSET_SUSPENDED_Msk, ///< Interrupt on SUSPENDED event.
103     NRF_TWIM_INT_RXSTARTED_MASK = TWIM_INTENSET_RXSTARTED_Msk, ///< Interrupt on RXSTARTED event.
104     NRF_TWIM_INT_TXSTARTED_MASK = TWIM_INTENSET_TXSTARTED_Msk, ///< Interrupt on TXSTARTED event.
105     NRF_TWIM_INT_LASTRX_MASK    = TWIM_INTENSET_LASTRX_Msk,    ///< Interrupt on LASTRX event.
106     NRF_TWIM_INT_LASTTX_MASK    = TWIM_INTENSET_LASTTX_Msk,     ///< Interrupt on LASTTX event.
107     NRF_TWIM_ALL_INTS_MASK      = TWIM_INTENSET_STOPPED_Msk   |
108                                   TWIM_INTENSET_ERROR_Msk     |
109                                   TWIM_INTENSET_SUSPENDED_Msk |
110                                   TWIM_INTENSET_RXSTARTED_Msk |
111                                   TWIM_INTENSET_TXSTARTED_Msk |
112                                   TWIM_INTENSET_LASTRX_Msk    |
113                                   TWIM_INTENSET_LASTTX_Msk      ///< Interrupt on LASTTX event.
114 } nrf_twim_int_mask_t;
115 
116 /**
117  * @brief TWIM master clock frequency.
118  */
119 typedef enum
120 {
121     NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps.
122     NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps.
123     NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400  ///< 400 kbps.
124 } nrf_twim_frequency_t;
125 
126 /**
127  * @brief TWIM error source.
128  */
129 typedef enum
130 {
131     NRF_TWIM_ERROR_ADDRESS_NACK = TWIM_ERRORSRC_ANACK_Msk, ///< NACK received after sending the address.
132     NRF_TWIM_ERROR_DATA_NACK    = TWIM_ERRORSRC_DNACK_Msk  ///< NACK received after sending a data byte.
133 } nrf_twim_error_t;
134 
135 
136 /**
137  * @brief Function for activating a specific TWIM task.
138  *
139  * @param[in] p_reg Pointer to the peripheral registers structure.
140  * @param[in] task   Task to activate.
141  */
142 __STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
143                                            nrf_twim_task_t task);
144 
145 /**
146  * @brief Function for getting the address of a specific TWIM task register.
147  *
148  * @param[in] p_reg Pointer to the peripheral registers structure.
149  * @param[in] task   Requested task.
150  *
151  * @return Address of the specified task register.
152  */
153 __STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,
154                                                      nrf_twim_task_t task);
155 
156 /**
157  * @brief Function for clearing a specific TWIM event.
158  *
159  * @param[in] p_reg Pointer to the peripheral registers structure.
160  * @param[in] event  Event to clear.
161  */
162 __STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
163                                           nrf_twim_event_t event);
164 
165 /**
166  * @brief Function for checking the state of a specific TWIM event.
167  *
168  * @param[in] p_reg Pointer to the peripheral registers structure.
169  * @param[in] event  Event to check.
170  *
171  * @retval true  If the event is set.
172  * @retval false If the event is not set.
173  */
174 __STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_reg,
175                                           nrf_twim_event_t event);
176 
177 /**
178  * @brief Function for getting the address of a specific TWIM event register.
179  *
180  * @param[in] p_reg Pointer to the peripheral registers structure.
181  * @param[in] event  Requested event.
182  *
183  * @return Address of the specified event register.
184  */
185 __STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type  * p_reg,
186                                                       nrf_twim_event_t event);
187 
188 /**
189  * @brief Function for enabling specified shortcuts.
190  *
191  * @param[in] p_reg      Pointer to the peripheral registers structure.
192  * @param[in] shorts_mask Shortcuts to enable.
193  */
194 __STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
195                                             uint32_t shorts_mask);
196 
197 /**
198  * @brief Function for disabling specified shortcuts.
199  *
200  * @param[in] p_reg      Pointer to the peripheral registers structure.
201  * @param[in] shorts_mask Shortcuts to disable.
202  */
203 __STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
204                                              uint32_t shorts_mask);
205 
206 /**
207  * @brief Function for enabling specified interrupts.
208  *
209  * @param[in] p_reg   Pointer to the peripheral registers structure.
210  * @param[in] int_mask Interrupts to enable.
211  */
212 __STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
213                                          uint32_t int_mask);
214 
215 /**
216  * @brief Function for disabling specified interrupts.
217  *
218  * @param[in] p_reg   Pointer to the peripheral registers structure.
219  * @param[in] int_mask Interrupts to disable.
220  */
221 __STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
222                                           uint32_t int_mask);
223 
224 /**
225  * @brief Function for checking the state of a given interrupt.
226  *
227  * @param[in] p_reg   Pointer to the peripheral registers structure.
228  * @param[in] int_mask Interrupt to check.
229  *
230  * @retval true  If the interrupt is enabled.
231  * @retval false If the interrupt is not enabled.
232  */
233 __STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,
234                                                nrf_twim_int_mask_t int_mask);
235 
236 /**
237  * @brief Function for enabling the TWIM peripheral.
238  *
239  * @param[in] p_reg Pointer to the peripheral registers structure.
240  */
241 __STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg);
242 
243 /**
244  * @brief Function for disabling the TWIM peripheral.
245  *
246  * @param[in] p_reg Pointer to the peripheral registers structure.
247  */
248 __STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg);
249 
250 /**
251  * @brief Function for configuring TWI pins.
252  *
253  *
254  * @param[in] p_reg  Pointer to the peripheral registers structure.
255  * @param[in] scl_pin SCL pin number.
256  * @param[in] sda_pin SDA pin number.
257  */
258 __STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
259                                        uint32_t scl_pin,
260                                        uint32_t sda_pin);
261 
262 /**
263  * @brief Function for setting the TWI master clock frequency.
264  *
265  * @param[in] p_reg    Pointer to the peripheral registers structure.
266  * @param[in] frequency TWI frequency.
267  */
268 __STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
269                                             nrf_twim_frequency_t frequency);
270 
271 /**
272  * @brief Function for checking the TWI error source.
273  *
274  * The error flags are cleared after reading.
275  *
276  * @param[in] p_reg Pointer to the peripheral registers structure.
277  *
278  * @return Mask with error source flags.
279  */
280 __STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg);
281 
282 /**
283  * @brief Function for setting the address to be used in TWI transfers.
284  *
285  * @param[in] p_reg  Pointer to the peripheral registers structure.
286  * @param[in] address Address to be used in transfers.
287  */
288 __STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
289                                           uint8_t address);
290 
291 /**
292  * @brief Function for setting the transmit buffer.
293  *
294  * @param[in]  p_reg   Pointer to the peripheral registers structure.
295  * @param[in]  p_buffer Pointer to the buffer with data to send.
296  * @param[in]  length   Maximum number of data bytes to transmit.
297  */
298 __STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
299                                             uint8_t const * p_buffer,
300                                             size_t          length);
301 
302 /**
303  * @brief Function for setting the receive buffer.
304  *
305  * @param[in] p_reg   Pointer to the peripheral registers structure.
306  * @param[in] p_buffer Pointer to the buffer for received data.
307  * @param[in] length   Maximum number of data bytes to receive.
308  */
309 __STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
310                                             uint8_t * p_buffer,
311                                             size_t    length);
312 
313 __STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
314                                          uint32_t shorts_mask);
315 
316 __STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg);
317 
318 __STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_reg);
319 
320 /**
321  * @brief Function for enabling the TX list feature.
322  *
323  * @param[in] p_reg Pointer to the peripheral registers structure.
324  */
325 __STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg);
326 
327 /**
328  * @brief Function for disabling the TX list feature.
329  *
330  * @param[in] p_reg Pointer to the peripheral registers structure.
331  */
332 __STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg);
333 
334 /**
335  * @brief Function for enabling the RX list feature.
336  *
337  * @param[in] p_reg Pointer to the peripheral registers structure.
338  */
339 __STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg);
340 
341 /**
342  * @brief Function for disabling the RX list feature.
343  *
344  * @param[in] p_reg Pointer to the peripheral registers structure.
345  */
346 __STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg);
347 
348 #ifndef SUPPRESS_INLINE_IMPLEMENTATION
349 
nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,nrf_twim_task_t task)350 __STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_reg,
351                                            nrf_twim_task_t task)
352 {
353     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
354 }
355 
nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,nrf_twim_task_t task)356 __STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_reg,
357                                                      nrf_twim_task_t task)
358 {
359     return (uint32_t *)((uint8_t *)p_reg + (uint32_t)task);
360 }
361 
nrf_twim_event_clear(NRF_TWIM_Type * p_reg,nrf_twim_event_t event)362 __STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_reg,
363                                           nrf_twim_event_t event)
364 {
365     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
366 #if __CORTEX_M == 0x04
367     volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
368     (void)dummy;
369 #endif
370 }
371 
nrf_twim_event_check(NRF_TWIM_Type * p_reg,nrf_twim_event_t event)372 __STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_reg,
373                                           nrf_twim_event_t event)
374 {
375     return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
376 }
377 
nrf_twim_event_address_get(NRF_TWIM_Type * p_reg,nrf_twim_event_t event)378 __STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type  * p_reg,
379                                                       nrf_twim_event_t event)
380 {
381     return (uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
382 }
383 
nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,uint32_t shorts_mask)384 __STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_reg,
385                                             uint32_t shorts_mask)
386 {
387     p_reg->SHORTS |= shorts_mask;
388 }
389 
nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,uint32_t shorts_mask)390 __STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_reg,
391                                              uint32_t shorts_mask)
392 {
393     p_reg->SHORTS &= ~(shorts_mask);
394 }
395 
nrf_twim_int_enable(NRF_TWIM_Type * p_reg,uint32_t int_mask)396 __STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_reg,
397                                          uint32_t int_mask)
398 {
399     p_reg->INTENSET = int_mask;
400 }
401 
nrf_twim_int_disable(NRF_TWIM_Type * p_reg,uint32_t int_mask)402 __STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_reg,
403                                           uint32_t int_mask)
404 {
405     p_reg->INTENCLR = int_mask;
406 }
407 
nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,nrf_twim_int_mask_t int_mask)408 __STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_reg,
409                                                nrf_twim_int_mask_t int_mask)
410 {
411     return (bool)(p_reg->INTENSET & int_mask);
412 }
413 
nrf_twim_enable(NRF_TWIM_Type * p_reg)414 __STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_reg)
415 {
416     p_reg->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
417 }
418 
nrf_twim_disable(NRF_TWIM_Type * p_reg)419 __STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_reg)
420 {
421     p_reg->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
422 }
423 
nrf_twim_pins_set(NRF_TWIM_Type * p_reg,uint32_t scl_pin,uint32_t sda_pin)424 __STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_reg,
425                                        uint32_t scl_pin,
426                                        uint32_t sda_pin)
427 {
428     p_reg->PSEL.SCL = scl_pin;
429     p_reg->PSEL.SDA = sda_pin;
430 }
431 
nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,nrf_twim_frequency_t frequency)432 __STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_reg,
433                                             nrf_twim_frequency_t frequency)
434 {
435     p_reg->FREQUENCY = frequency;
436 }
437 
nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg)438 __STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_reg)
439 {
440     uint32_t error_source = p_reg->ERRORSRC;
441 
442     // [error flags are cleared by writing '1' on their position]
443     p_reg->ERRORSRC = error_source;
444 
445     return error_source;
446 }
447 
nrf_twim_address_set(NRF_TWIM_Type * p_reg,uint8_t address)448 __STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
449                                           uint8_t address)
450 {
451     p_reg->ADDRESS = address;
452 }
453 
nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,uint8_t const * p_buffer,size_t length)454 __STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_reg,
455                                             uint8_t const * p_buffer,
456                                             size_t          length)
457 {
458     p_reg->TXD.PTR    = (uint32_t)p_buffer;
459     p_reg->TXD.MAXCNT = length;
460 }
461 
nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,uint8_t * p_buffer,size_t length)462 __STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_reg,
463                                             uint8_t * p_buffer,
464                                             size_t    length)
465 {
466     p_reg->RXD.PTR    = (uint32_t)p_buffer;
467     p_reg->RXD.MAXCNT = length;
468 }
469 
nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,uint32_t shorts_mask)470 __STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
471                                          uint32_t shorts_mask)
472 {
473     p_reg->SHORTS = shorts_mask;
474 }
475 
nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg)476 __STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_reg)
477 {
478     return p_reg->TXD.AMOUNT;
479 }
480 
nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_reg)481 __STATIC_INLINE size_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_reg)
482 {
483     return p_reg->RXD.AMOUNT;
484 }
485 
nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg)486 __STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_reg)
487 {
488     p_reg->TXD.LIST = 1;
489 }
490 
nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg)491 __STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_reg)
492 {
493     p_reg->TXD.LIST = 0;
494 }
495 
nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg)496 __STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_reg)
497 {
498     p_reg->RXD.LIST = 1;
499 }
500 
nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg)501 __STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_reg)
502 {
503     p_reg->RXD.LIST = 0;
504 }
505 #endif // SUPPRESS_INLINE_IMPLEMENTATION
506 
507 /** @} */
508 
509 #ifdef __cplusplus
510 }
511 #endif
512 
513 #endif // NRF_TWIM_H__
514