1 /*
2  * Copyright (c) 2024, 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  * @file
37  *   This file implements final exit point for calling callouts provided by an application.
38  *   It is intended to be the only place where callouts provided by the application
39  *   are called.
40  */
41 
42 #define NRF_802154_MODULE_ID NRF_802154_DRV_MODULE_ID_CO
43 
44 #include "nrf_802154_co.h"
45 #include "nrf_802154_debug.h"
46 
nrf_802154_co_cca_done(bool channel_free)47 void nrf_802154_co_cca_done(bool channel_free)
48 {
49     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
50     nrf_802154_cca_done(channel_free);
51     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
52 }
53 
nrf_802154_co_cca_failed(nrf_802154_cca_error_t error)54 void nrf_802154_co_cca_failed(nrf_802154_cca_error_t error)
55 {
56     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
57     nrf_802154_cca_failed(error);
58     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
59 }
60 
nrf_802154_co_energy_detected(const nrf_802154_energy_detected_t * p_result)61 void nrf_802154_co_energy_detected(const nrf_802154_energy_detected_t * p_result)
62 {
63     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
64     nrf_802154_energy_detected(p_result);
65     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
66 }
67 
nrf_802154_co_energy_detection_failed(nrf_802154_ed_error_t error)68 void nrf_802154_co_energy_detection_failed(nrf_802154_ed_error_t error)
69 {
70     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
71     nrf_802154_energy_detection_failed(error);
72     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
73 }
74 
nrf_802154_co_tx_ack_started(const uint8_t * p_data)75 void nrf_802154_co_tx_ack_started(const uint8_t * p_data)
76 {
77     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
78     nrf_802154_tx_ack_started(p_data);
79     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
80 }
81 
82 #if !NRF_802154_SERIALIZATION_HOST || defined(DOXYGEN)
83 
nrf_802154_co_received_raw(uint8_t * p_data,int8_t power,uint8_t lqi)84 void nrf_802154_co_received_raw(uint8_t * p_data, int8_t power, uint8_t lqi)
85 {
86     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
87     nrf_802154_received_raw(p_data, power, lqi);
88     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
89 }
90 
91 #endif // !NRF_802154_SERIALIZATION_HOST
92 
nrf_802154_co_receive_failed(nrf_802154_rx_error_t error,uint32_t id)93 void nrf_802154_co_receive_failed(nrf_802154_rx_error_t error, uint32_t id)
94 {
95     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
96     nrf_802154_receive_failed(error, id);
97     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
98 }
99 
nrf_802154_co_transmitted_raw(uint8_t * p_frame,const nrf_802154_transmit_done_metadata_t * p_metadata)100 void nrf_802154_co_transmitted_raw(uint8_t                                   * p_frame,
101                                    const nrf_802154_transmit_done_metadata_t * p_metadata)
102 {
103     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
104     nrf_802154_transmitted_raw(p_frame, p_metadata);
105     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
106 }
107 
nrf_802154_co_transmit_failed(uint8_t * p_frame,nrf_802154_tx_error_t error,const nrf_802154_transmit_done_metadata_t * p_metadata)108 void nrf_802154_co_transmit_failed(uint8_t                                   * p_frame,
109                                    nrf_802154_tx_error_t                       error,
110                                    const nrf_802154_transmit_done_metadata_t * p_metadata)
111 {
112     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
113     nrf_802154_transmit_failed(p_frame, error, p_metadata);
114     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
115 }
116 
117 #if !NRF_802154_SERIALIZATION_HOST || defined(DOXYGEN)
118 
nrf_802154_co_tx_started(const uint8_t * p_frame)119 void nrf_802154_co_tx_started(const uint8_t * p_frame)
120 {
121     nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
122     nrf_802154_tx_started(p_frame);
123     nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
124 }
125 
126 #endif // !NRF_802154_SERIALIZATION_HOST
127