1 /*
2  * Copyright (c) 2017 - 2023, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 /**
36  * @brief Module that contains debug helpers for the 802.15.4 radio driver for the nRF SoC devices.
37  *
38  */
39 
40 #ifndef NRF_802154_DEBUG_H_
41 #define NRF_802154_DEBUG_H_
42 
43 #include <stdint.h>
44 
45 #include "nrf_802154_config.h"
46 #include "nrf_802154_sl_log.h"
47 #include "nrf_802154_debug_log.h"
48 #include "nrf_802154_debug_core.h"
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #define PIN_DBG_RADIO_EVT_END           11
55 #define PIN_DBG_RADIO_EVT_DISABLED      12
56 #define PIN_DBG_RADIO_EVT_READY         13
57 #define PIN_DBG_RADIO_EVT_FRAMESTART    14
58 #define PIN_DBG_RADIO_EVT_EDEND         25
59 #define PIN_DBG_RADIO_EVT_PHYEND        24
60 
61 #define PPI_DBG_RADIO_EVT_END           0
62 #define PPI_DBG_RADIO_EVT_DISABLED      1
63 #define PPI_DBG_RADIO_EVT_READY         2
64 #define PPI_DBG_RADIO_EVT_FRAMESTART    3
65 #define PPI_DBG_RADIO_EVT_EDEND         4
66 #define PPI_DBG_RADIO_EVT_PHYEND        5
67 
68 #define GPIOTE_DBG_RADIO_EVT_END        0
69 #define GPIOTE_DBG_RADIO_EVT_DISABLED   1
70 #define GPIOTE_DBG_RADIO_EVT_READY      2
71 #define GPIOTE_DBG_RADIO_EVT_FRAMESTART 3
72 #define GPIOTE_DBG_RADIO_EVT_EDEND      4
73 #define GPIOTE_DBG_RADIO_EVT_PHYEND     5
74 
75 #if ENABLE_DEBUG_GPIO
76 
77 #define NRF_802154_DEBUG_PINS_USED_MASK            ((1 << PIN_DBG_RADIO_EVT_END) |        \
78                                                     (1 << PIN_DBG_RADIO_EVT_DISABLED) |   \
79                                                     (1 << PIN_DBG_RADIO_EVT_READY) |      \
80                                                     (1 << PIN_DBG_RADIO_EVT_FRAMESTART) | \
81                                                     (1 << PIN_DBG_RADIO_EVT_EDEND) |      \
82                                                     (1 << PIN_DBG_RADIO_EVT_PHYEND))
83 
84 #define NRF_802154_DEBUG_PPI_CHANNELS_USED_MASK    ((1 << PPI_DBG_RADIO_EVT_END) |        \
85                                                     (1 << PPI_DBG_RADIO_EVT_DISABLED) |   \
86                                                     (1 << PPI_DBG_RADIO_EVT_READY) |      \
87                                                     (1 << PPI_DBG_RADIO_EVT_FRAMESTART) | \
88                                                     (1 << PPI_DBG_RADIO_EVT_EDEND) |      \
89                                                     (1 << PPI_DBG_RADIO_EVT_PHYEND))
90 
91 #define NRF_802154_DEBUG_GPIOTE_CHANNELS_USED_MASK ((1 << GPIOTE_DBG_RADIO_EVT_END) |        \
92                                                     (1 << GPIOTE_DBG_RADIO_EVT_DISABLED) |   \
93                                                     (1 << GPIOTE_DBG_RADIO_EVT_READY) |      \
94                                                     (1 << GPIOTE_DBG_RADIO_EVT_FRAMESTART) | \
95                                                     (1 << GPIOTE_DBG_RADIO_EVT_EDEND) |      \
96                                                     (1 << GPIOTE_DBG_RADIO_EVT_PHYEND))
97 
98 #else // ENABLE_DEBUG_GPIO
99 
100 #define NRF_802154_DEBUG_PINS_USED_MASK            0
101 #define NRF_802154_DEBUG_PPI_CHANNELS_USED_MASK    0
102 #define NRF_802154_DEBUG_GPIOTE_CHANNELS_USED_MASK 0
103 
104 #endif // ENABLE_DEBUG_GPIO
105 
106 /**
107  * @brief Initializes debug helpers for the nRF 802.15.4 driver.
108  */
109 void nrf_802154_debug_init(void);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* NRF_802154_DEBUG_H_ */
116