1 /*
2  * Copyright (c) 2023 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef _NRF_HW_MODEL_UART_H
7 #define _NRF_HW_MODEL_UART_H
8 
9 #include "bs_types.h"
10 #include <stdint.h>
11 #include "NHW_config.h"
12 
13 #ifdef __cplusplus
14 extern "C"{
15 #endif
16 
17 void nhw_UARTE_regw_sideeffects_TASKS_STARTRX(uint i);
18 void nhw_UARTE_regw_sideeffects_TASKS_STOPRX(uint i);
19 void nhw_UARTE_regw_sideeffects_TASKS_STARTTX(uint i);
20 void nhw_UARTE_regw_sideeffects_TASKS_STOPTX(uint i);
21 void nhw_UARTE_regw_sideeffects_TASKS_SUSPEND(uint i);
22 void nhw_UARTE_regw_sideeffects_TASKS_FLUSHRX(uint i);
23 
24 void nhw_UARTE_regw_sideeffects_INTENSET(uint i);
25 void nhw_UARTE_regw_sideeffects_INTENCLR(uint i);
26 
27 /* Side-effecting function when any event register is written: */
28 void nhw_UARTE_regw_sideeffects_EVENTS_all(uint t);
29 
30 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STARTRX(uint i);
31 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STOPRX(uint i);
32 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STARTTX(uint i);
33 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STOPTX(uint i);
34 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_FLUSHRX(uint i);
35 
36 uint32_t nhw_UARTE_regr_sideeffects_ERRORSRC(unsigned int inst);
37 void nhw_UARTE_regw_sideeffects_ERRORSRC(unsigned int inst);
38 
39 uint32_t nhw_UARTE_regr_sideeffects_RXD(unsigned int inst);
40 void nhw_UARTE_regw_sideeffects_TXD(unsigned int inst);
41 
42 void nhw_UARTE_regw_sideeffects_ENABLE(unsigned int inst);
43 void nhw_UARTE_regw_sideeffects_CONFIG(unsigned int inst);
44 
45 #if (NHW_HAS_PPI)
46 void nhw_uarte0_TASKS_STARTRX(void);
47 void nhw_uarte0_TASKS_STOPRX(void);
48 void nhw_uarte0_TASKS_STARTTX(void);
49 void nhw_uarte0_TASKS_STOPTX(void);
50 void nhw_uarte0_TASKS_SUSPEND(void);
51 void nhw_uarte0_TASKS_FLUSHRX(void);
52 
53 void nhw_uarte1_TASKS_STARTRX(void);
54 void nhw_uarte1_TASKS_STOPRX(void);
55 void nhw_uarte1_TASKS_STARTTX(void);
56 void nhw_uarte1_TASKS_STOPTX(void);
57 void nhw_uarte1_TASKS_SUSPEND(void);
58 void nhw_uarte1_TASKS_FLUSHRX(void);
59 #endif /* (NHW_HAS_PPI) */
60 
61 extern NRF_UARTE_Type NRF_UARTE_regs[];
62 #if (NHW_UARTE_HAS_UART)
63 extern NRF_UART_Type *NRF_UART_regs[];
64 #endif
65 
66 typedef void (*uart_rtxb_cb_f)(uint inst, uint8_t *data);
67 /*
68  * (Test interface) Register a callback which will be called
69  * each time a byte is transmitted or received.
70  * The callback may replace that byte with something else which will
71  * be {stored in the UART Rx FIFO, sent over the line} instead of
72  * the original byte.
73  *
74  * If the callback does not want to modify the data being received,
75  * it should not modify the content of *data.
76  *
77  * This function returns the pointer to a possible previously registered
78  * {Rx,Tx} callback (NULL if none was registered)
79  *
80  * <inst> is the UART instance for which we are registering the callback.
81  *        UARTs are indexed globally for the whole SOC, as shown in NHW_config.h
82  *        and --uart_list
83  * <Rx_NotTx> should be set 1 to set the Rx callback, 0 to set the Tx callback
84  */
85 uart_rtxb_cb_f nhw_uarte_register_callback(int inst, uart_rtxb_cb_f cb, bool Rx_NotTx);
86 
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* _NRF_HW_MODEL_UART_H */
93