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 /* Note that for 54 devices some tasks have been renamed: 18 * TASK_DMA.RX.START == Old TASK_STARTRX 19 * TASK_DMA.TX.START == Old TASK_STARTX 20 * TASK_DMA.RX.STOP == Old TASK_STOPRX 21 * TASK_DMA.TX.STOP == Old TASK_STOPTX 22 * These side-effecting functions below are to be used for both the old and new name 23 */ 24 void nhw_UARTE_regw_sideeffects_TASKS_STARTRX(uint i); 25 void nhw_UARTE_regw_sideeffects_TASKS_STOPRX(uint i); 26 void nhw_UARTE_regw_sideeffects_TASKS_STARTTX(uint i); 27 void nhw_UARTE_regw_sideeffects_TASKS_STOPTX(uint i); 28 void nhw_UARTE_regw_sideeffects_TASKS_SUSPEND(uint i); 29 void nhw_UARTE_regw_sideeffects_TASKS_FLUSHRX(uint i); 30 #if NHW_UARTE_HAS_MATCH 31 void nhw_UARTE_regw_sideeffects_TASKS_DMA_RX_ENABLEMATCH(uint inst, uint i); 32 void nhw_UARTE_regw_sideeffects_TASKS_DMA_RX_DISABLEMATCH(uint inst, uint i); 33 #endif 34 35 void nhw_UARTE_regw_sideeffects_INTENSET(uint i); 36 void nhw_UARTE_regw_sideeffects_INTENCLR(uint i); 37 38 /* Side-effecting function when any event register is written: */ 39 void nhw_UARTE_regw_sideeffects_EVENTS_all(uint t); 40 41 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STARTRX(uint i); 42 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STOPRX(uint i); 43 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STARTTX(uint i); 44 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_STOPTX(uint i); 45 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_FLUSHRX(uint i); 46 #if NHW_UARTE_HAS_MATCH 47 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_DMA_RX_ENABLEMATCH(uint inst, uint i); 48 void nhw_UARTE_regw_sideeffects_SUBSCRIBE_DMA_RX_DISABLEMATCH(uint inst, uint i); 49 #endif 50 51 uint32_t nhw_UARTE_regr_sideeffects_ERRORSRC(unsigned int inst); 52 void nhw_UARTE_regw_sideeffects_ERRORSRC(unsigned int inst); 53 54 uint32_t nhw_UARTE_regr_sideeffects_RXD(unsigned int inst); 55 void nhw_UARTE_regw_sideeffects_TXD(unsigned int inst); 56 57 void nhw_UARTE_regw_sideeffects_ENABLE(unsigned int inst); 58 void nhw_UARTE_regw_sideeffects_CONFIG(unsigned int inst); 59 60 #if (NHW_HAS_PPI) 61 void nhw_uarte0_TASKS_STARTRX(void); 62 void nhw_uarte0_TASKS_STOPRX(void); 63 void nhw_uarte0_TASKS_STARTTX(void); 64 void nhw_uarte0_TASKS_STOPTX(void); 65 void nhw_uarte0_TASKS_SUSPEND(void); 66 void nhw_uarte0_TASKS_FLUSHRX(void); 67 68 void nhw_uarte1_TASKS_STARTRX(void); 69 void nhw_uarte1_TASKS_STOPRX(void); 70 void nhw_uarte1_TASKS_STARTTX(void); 71 void nhw_uarte1_TASKS_STOPTX(void); 72 void nhw_uarte1_TASKS_SUSPEND(void); 73 void nhw_uarte1_TASKS_FLUSHRX(void); 74 #endif /* (NHW_HAS_PPI) */ 75 76 extern NRF_UARTE_Type NRF_UARTE_regs[]; 77 #if (NHW_UARTE_HAS_UART) 78 extern NRF_UART_Type *NRF_UART_regs[]; 79 #endif 80 81 typedef void (*uart_rtxb_cb_f)(uint inst, uint16_t *data); 82 /* 83 * (Test interface) Register a callback which will be called 84 * each time a byte is transmitted or received. 85 * The callback may replace that byte with something else which will 86 * be {stored in the UART Rx FIFO, sent over the line} instead of 87 * the original byte. 88 * 89 * If the callback does not want to modify the data being received, 90 * it should not modify the content of *data. 91 * 92 * This function returns the pointer to a possible previously registered 93 * {Rx,Tx} callback (NULL if none was registered) 94 * 95 * <inst> is the UART instance for which we are registering the callback. 96 * UARTs are indexed globally for the whole SOC, as shown in NHW_config.h 97 * and --uart_list 98 * <Rx_NotTx> should be set 1 to set the Rx callback, 0 to set the Tx callback 99 */ 100 uart_rtxb_cb_f nhw_uarte_register_callback(int inst, uart_rtxb_cb_f cb, bool Rx_NotTx); 101 102 103 #ifdef __cplusplus 104 } 105 #endif 106 107 #endif /* _NRF_HW_MODEL_UART_H */ 108