1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef _NRF_HW_MODEL_UART_PRIVATE_H 7 #define _NRF_HW_MODEL_UART_PRIVATE_H 8 9 #include "bs_types.h" 10 #include <stdint.h> 11 #include <stdio.h> 12 #include "NHW_UART_backend_if.h" 13 14 #ifdef __cplusplus 15 extern "C"{ 16 #endif 17 18 enum uart_tx_status {Tx_Off = 0, 19 Tx_Idle, 20 Tx_Pend /* Waiting for CTS to lower to start Tx'ing */, 21 Txing, 22 Tx_Stopping /* Waiting for current frame to finish to finish a TASK STOP */}; 23 enum uarte_dma_status {DMA_Off = 0, DMAing}; 24 enum uart_rx_status {Rx_Off = 0, Rx_turning_off /* Waiting for RX TO */, Rx_On}; 25 26 #define RX_FIFO_SIZE 6 27 #define RX_FIFO_RTS_THRESHOLD 2 28 29 struct uarte_status { 30 bs_time_t Rx_TO_timer; 31 bs_time_t Tx_byte_done_timer; 32 33 uint inst; 34 35 NRF_UART_Type *UART_regs[NHW_UARTE_TOTAL_INST]; 36 NRF_UARTE_Type *UARTE_regs[NHW_UARTE_TOTAL_INST]; 37 #if (NHW_HAS_DPPI) 38 /* Mapping of peripheral instance to DPPI instance */ 39 uint dppi_map; 40 #endif 41 42 enum uart_tx_status tx_status; 43 enum uart_rx_status rx_status; 44 45 /* When was the last time the receiver was off (only valid if the receiver is currently On */ 46 bs_time_t Last_Rx_off_time; 47 48 uint8_t Rx_FIFO[RX_FIFO_SIZE]; 49 int Rx_FIFO_cnt; 50 51 uint8_t Tx_byte; 52 53 bool RTSR; /* Logical level of RTS/R (false/lowered => Ready to receive) 54 (this value is internal, and toggles even if the flow-control is disabled) */ 55 bool CTS_blocking; /* CTS is blocking the Tx (i.e. it is high), 56 * this value toggles even if flow control is disabled */ 57 58 /* DMA status including internally buffered/shadow version of the corresponding registers */ 59 uint32_t TXD_PTR; 60 uint32_t TXD_MAXCNT; 61 uint32_t TXD_AMOUNT; 62 enum uarte_dma_status tx_dma_status; 63 64 uint32_t RXD_PTR; 65 uint32_t RXD_MAXCNT; 66 uint32_t RXD_AMOUNT; 67 enum uarte_dma_status rx_dma_status; 68 69 struct backend_if backend; 70 71 char *Rx_log_file_name; 72 char *Tx_log_file_name; 73 FILE *Tx_log_file; 74 FILE *Rx_log_file; 75 76 uart_rtxb_cb_f trx_callbacks[2]; 77 }; 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif /* _NRF_HW_MODEL_UART_PRIVATE_H */ 84