1 /* 2 * Copyright (c) 2024, NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Public APIs of HDLC RCP communication Interface 10 * 11 * This file provide the HDLC APIs to be used by an RCP host 12 */ 13 14 #include <zephyr/sys/util.h> 15 #include <zephyr/net/net_if.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * @brief OT RCP HDLC RX callback function. 23 * 24 * @note This function is called in the radio spinel HDLC level 25 */ 26 typedef void (*hdlc_rx_callback_t)(uint8_t *data, uint16_t len, void *param); 27 28 /** HDLC interface configuration data. */ 29 struct hdlc_api { 30 /** 31 * @brief HDLC interface API 32 */ 33 struct net_if_api iface_api; 34 35 /** 36 * @brief Register the Spinel HDLC RX callback. 37 * 38 * @param hdlc_rx_callback pointer to the spinel HDLC RX callback 39 * @param param pointer to the spinel HDLC interface 40 * 41 * @retval 0 The callback was successfully registered. 42 * @retval -EIO The callback could not be registered. 43 */ 44 int (*register_rx_cb)(hdlc_rx_callback_t hdlc_rx_callback, void *param); 45 46 /** 47 * @brief Transmit a HDLC frame 48 * 49 * 50 * @param frame pointer to the HDLC frame to be transmitted. 51 * @param length length of the HDLC frame to be transmitted. 52 53 * @retval 0 The frame was successfully sent. 54 * @retval -EIO The frame could not be sent due to some unspecified 55 * interface error (e.g. the interface being busy). 56 */ 57 int (*send)(const uint8_t *frame, uint16_t length); 58 59 /** 60 * @brief Deinitialize the device. 61 * 62 * @param none 63 * 64 * @retval 0 The interface was successfully stopped. 65 * @retval -EIO The interface could not be stopped. 66 */ 67 int (*deinit)(void); 68 }; 69 70 /* Make sure that the interface API is properly setup inside 71 * HDLC interface API struct (it is the first one). 72 */ 73 BUILD_ASSERT(offsetof(struct hdlc_api, iface_api) == 0); 74 75 #ifdef __cplusplus 76 } 77 #endif 78