1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Declaration of class CTransceiver
26 * \cond UCS_INTERNAL_DOC
31 #ifndef UCS_TRANSCEIVER_H
32 #define UCS_TRANSCEIVER_H
34 /*------------------------------------------------------------------------------------------------*/
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_message.h"
39 #include "ucs_pmfifo.h"
46 /*------------------------------------------------------------------------------------------------*/
48 /*------------------------------------------------------------------------------------------------*/
49 /*! \brief Assignable callback function which is invoked for message reception
50 * \param self The instance
51 * \param tel_ptr Reference to the message object
53 typedef void (*Trcv_RxCompleteCb_t)(void *self, Msg_MostTel_t *tel_ptr);
55 /*! \brief Assignable callback function which is invoked to filter Rx messages
56 * \details Filtering is a synchronous operation. Hence, it is not possible to keep a message
57 * object for delayed processing. The invoked function has to decide whether a
58 * message shall be discarded and freed to the Rx pool. Therefore, it has to return
59 * \c true. By returning \ false, the message will be received in the usual way.
60 * \param self The instance
61 * \param tel_ptr Reference to the message object
62 * \return Returns \c true to discard the message and free it to the pool (no-pass). Otherwise, returns
65 typedef bool (*Trcv_RxFilterCb_t)(void *self, Msg_MostTel_t *tel_ptr);
67 /*------------------------------------------------------------------------------------------------*/
69 /*------------------------------------------------------------------------------------------------*/
70 #define TRCV_SIZE_TX_POOL 10U /*!< \brief Number of messages in the message pool */
72 /*------------------------------------------------------------------------------------------------*/
73 /* Class CTransceiver */
74 /*------------------------------------------------------------------------------------------------*/
75 /*! \brief Class CTransceiver
76 * \details Provides MOST message objects and communication methods to further classes
78 typedef struct CTransceiver_
80 CMessage tx_msgs[TRCV_SIZE_TX_POOL];/*!< \brief Messages in message pool */
81 CPool tx_msg_pool; /*!< \brief The message pool */
82 uint16_t tx_def_src; /*!< \brief Default source address for Tx message object */
83 void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
84 uint8_t own_id; /*!< \brief ID of the transceiver required for tracing */
85 CPmFifo *fifo_ptr; /*!< \brief Reference to dedicated port message FIFO */
87 Trcv_RxCompleteCb_t rx_complete_fptr; /*!< \brief Callback function which is invoked on
90 void *rx_complete_inst; /*!< \brief Instance which is notified on
93 Trcv_RxFilterCb_t rx_filter_fptr; /*!< \brief Callback function which is invoked
94 * to filter Rx messages
96 void *rx_filter_inst; /*!< \brief Instance which is notified to
101 /*------------------------------------------------------------------------------------------------*/
103 /*------------------------------------------------------------------------------------------------*/
105 extern void Trcv_Ctor(CTransceiver *self, CPmFifo *fifo_ptr, uint16_t def_src_addr, void *ucs_user_ptr, uint8_t trace_id);
107 extern Msg_MostTel_t* Trcv_TxAllocateMsg(CTransceiver *self, uint8_t size);
108 extern void Trcv_TxSendMsg(CTransceiver *self, Msg_MostTel_t *tel_ptr);
109 extern void Trcv_TxSendMsgExt(CTransceiver *self, Msg_MostTel_t *tel_ptr, Msg_TxStatusCb_t callback_fptr, void *inst_ptr);
110 extern void Trcv_TxSendMsgBypass(CTransceiver *self, Msg_MostTel_t *tel_ptr, Msg_TxStatusCb_t callback_fptr, void *inst_ptr);
111 extern void Trcv_TxReleaseMsg(Msg_MostTel_t *tel_ptr);
112 extern void Trcv_TxReuseMsg(Msg_MostTel_t *tel_ptr);
114 extern void Trcv_RxAssignReceiver(CTransceiver *self, Trcv_RxCompleteCb_t callback_fptr, void *inst_ptr);
115 extern void Trcv_RxAssignFilter(CTransceiver *self, Trcv_RxFilterCb_t callback_fptr, void *inst_ptr);
116 extern void Trcv_RxReleaseMsg(CTransceiver *self, Msg_MostTel_t *tel_ptr);
117 extern void Trcv_RxOnMsgComplete(void *self, CMessage *tel_ptr);
123 #endif /* #ifndef UCS_TRANSCEIVER_H */
130 /*------------------------------------------------------------------------------------------------*/
132 /*------------------------------------------------------------------------------------------------*/