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 Internal header file of Application Message Distributor
26 * \cond UCS_INTERNAL_DOC
33 /*------------------------------------------------------------------------------------------------*/
35 /*------------------------------------------------------------------------------------------------*/
38 #include "ucs_amsmessage.h"
45 /*------------------------------------------------------------------------------------------------*/
47 /*------------------------------------------------------------------------------------------------*/
48 /*! \brief Assignable function which is invoked as soon as an application message is received
49 * completely and available in the Rx message queue
50 * \param self The instance
52 typedef void (*Amd_RxMsgCompleteCb_t)(void *self);
54 /*! \brief Assignable callback function which is able to read and modify the Rx message
55 * \param self The instance
56 * \param msg_ptr Reference to the Rx message object
58 typedef void (*Amd_RxModificationCb_t)(void *self, Ucs_AmsRx_Msg_t *msg_ptr);
60 /*------------------------------------------------------------------------------------------------*/
62 /*------------------------------------------------------------------------------------------------*/
63 /*! \brief Application Message Service Class
64 * \details Allows transmission and reception of MOST Application Messages
68 CBase *base_ptr; /*!< \brief Reference to basic services */
69 CAms *ams_ptr; /*!< \brief Reference to AMS */
71 CAmsMsgPool *pool_ptr; /*!< \brief Reference to AMS message pool */
72 CInic *inic_ptr; /*!< \brief Reference to INIC */
73 CNetworkManagement *net_ptr; /*!< \brief Reference to network management */
75 CService service; /*!< \brief Service object */
76 bool started; /*!< \brief Is \c true if the AMD is allowed
77 * to distribute messages
79 CMaskedObserver event_observer; /*!< \brief Observes init complete event */
80 CMaskedObserver terminate_observer; /*!< \brief Observes events leading to termination */
82 void *preprocess_inst_ptr; /*!< \brief Reference to the message preprocessor */
83 Amd_RxMsgCompleteCb_t preprocess_fptr; /*!< \brief Callback function which is invoked first
84 * on completed message reception
87 void *receive_inst_ptr; /*!< \brief Reference to the message receiver */
88 Amd_RxMsgCompleteCb_t receive_fptr; /*!< \brief Callback function which is invoked after
89 * the preprocessor has finished
92 CDlList tx_notify_queue; /*!< \brief Queue to notify asynchronously a failed transmission */
94 CDlList pre_queue; /*!< \brief Queue of messages for the preprocessor */
95 CDlList rx_queue; /*!< \brief Queue of messages for the receiver */
97 CDlList *first_q_ptr; /*!< \brief Reference where to queue the messages first */
98 Amd_RxMsgCompleteCb_t first_receive_fptr; /*!< \brief Reference of the callback to be fired first */
99 void *first_receive_inst_ptr; /*!< \brief Reference to the first receiver */
101 Amd_RxModificationCb_t rx_modification_fptr; /*!< \brief Callback function for message modification */
102 void *rx_modification_inst_ptr; /*!< \brief Callback reference for message modification */
106 /*------------------------------------------------------------------------------------------------*/
108 /*------------------------------------------------------------------------------------------------*/
109 extern void Amd_Ctor(CAmd *self, CBase *base_ptr, CAms *ams_ptr);
110 extern void Amd_AssignPreprocessor(CAmd *self, Amd_RxMsgCompleteCb_t callback_fptr, void *inst_ptr);
111 extern void Amd_AssignReceiver(CAmd *self, Amd_RxMsgCompleteCb_t callback_fptr, void *inst_ptr);
112 extern void Amd_RxAssignModificator(CAmd *self, Amd_RxModificationCb_t callback_fptr, void *inst_ptr);
114 extern Ucs_AmsRx_Msg_t* Amd_PrePeekMsg(CAmd *self);
115 extern void Amd_PreReleaseMsg(CAmd *self);
116 extern void Amd_PreForwardMsg(CAmd *self);
118 extern Ucs_AmsRx_Msg_t* Amd_RxPeekMsg(CAmd *self);
119 extern void Amd_RxReleaseMsg(CAmd *self);
120 extern uint16_t Amd_RxGetMsgCnt(CAmd *self);
122 #ifdef AMD_TX_DISTRIB
123 Ucs_Return_t Amd_TxSendMsg(CAmd *self, Ucs_AmsTx_Msg_t *msg_ptr, Amsg_TxCompleteSiaCb_t tx_complete_sia_fptr,
124 Amsg_TxCompleteCb_t tx_complete_fptr, void* tx_complete_inst_ptr);
131 #endif /* UCS_AMD_H */
138 /*------------------------------------------------------------------------------------------------*/
140 /*------------------------------------------------------------------------------------------------*/