eRPC API Reference  Rev. 1.7.0
NXP Semiconductors
erpc_mu_transport.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright 2017 NXP
4  * All rights reserved.
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _EMBEDDED_RPC__MU_TRANSPORT_H_
36 #define _EMBEDDED_RPC__MU_TRANSPORT_H_
37 
38 #include "erpc_config_internal.h"
39 #if ERPC_THREADS
40 #include "erpc_threading.h"
41 #endif
42 #include "erpc_message_buffer.h"
43 #include "erpc_transport.h"
44 #include "fsl_device_registers.h"
45 #include "fsl_mu.h"
46 
53 // Definitions
56 #if ERPC_TRANSPORT_MU_USE_MCMGR
57 
59 #define MU_REG_COUNT (MU_RR_COUNT - 1U)
60 #define MU_LAST_REG_IDX 2
61 
62 #define MU_RX_Interrupt_Handler(x) MU_RX_Interrupt(x)
63 #define MU_RX_Interrupt(number) MU_Rx##number##FullFlagISR
64 #define MU_RxFullFlagISRCallback MU_RX_Interrupt_Handler(MU_LAST_REG_IDX)
65 
66 #define MU_TX_Interrupt_Handler(x) MU_TX_Interrupt(x)
67 #define MU_TX_Interrupt(number) MU_Tx##number##EmptyFlagISR
68 #define MU_TxEmptyFlagISRCallback MU_TX_Interrupt_Handler(MU_LAST_REG_IDX)
69 
70 #else
71 #define MU_REG_COUNT (MU_RR_COUNT)
72 #endif /* ERPC_TRANSPORT_MU_USE_MCMGR */
73 // Classes
76 
77 namespace erpc {
96 class MUTransport : public Transport
97 {
98 public:
104  MUTransport(void);
105 
109  virtual ~MUTransport(void);
110 
121  virtual erpc_status_t init(MU_Type *muBase);
122 
132  virtual erpc_status_t receive(MessageBuffer *message);
133 
142  virtual erpc_status_t send(MessageBuffer *message);
143 
151  virtual bool hasMessage() { return m_newMessage; }
152 
153 #if ERPC_TRANSPORT_MU_USE_MCMGR
154 
162  static void mu_tx_empty_irq_callback(void);
170  static void mu_rx_full_irq_callback(void);
171 #else
172 
179  static void mu_irq_callback(void);
180 #endif /* ERPC_TRANSPORT_MU_USE_MCMGR */
181 
182 protected:
192  void rx_cb(void);
193 
200  void tx_cb(void);
201 
202  volatile bool m_newMessage;
204  uint32_t m_rxMsgSize;
206  uint32_t m_rxCntBytes;
207  uint32_t *volatile m_rxBuffer;
208  uint32_t m_txMsgSize;
210  uint32_t m_txCntBytes;
211  uint32_t *volatile m_txBuffer;
213 #if ERPC_THREADS
219 #endif
220 
221  MU_Type *m_muBase;
222 };
223 
224 } // namespace erpc
225 
228 #endif // _EMBEDDED_RPC__MU_TRANSPORT_H_
Abstract interface for transport layer.
Definition: erpc_transport.h:61
int32_t erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:112
uint32_t m_txMsgSize
Definition: erpc_mu_transport.h:208
virtual erpc_status_t receive(MessageBuffer *message)
Start receiving data and stores it to passed message buffer.
Definition: erpc_mu_transport.cpp:210
virtual ~MUTransport(void)
Destructor of MU transport.
Definition: erpc_mu_transport.cpp:117
MUTransport(void)
Constructor of MU transport.
Definition: erpc_mu_transport.cpp:97
Semaphore m_txSemaphore
Definition: erpc_mu_transport.h:215
MU_Type * m_muBase
Definition: erpc_mu_transport.h:221
uint32_t m_rxMsgSize
Definition: erpc_mu_transport.h:204
Semaphore m_rxSemaphore
Definition: erpc_mu_transport.h:214
Mutex m_sendLock
Definition: erpc_mu_transport.h:217
virtual bool hasMessage()
Function to check if is new message to receive.
Definition: erpc_mu_transport.h:151
virtual erpc_status_t init(MU_Type *muBase)
Initialization of MU transport layer.
Definition: erpc_mu_transport.cpp:119
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.h:62
uint32_t m_rxCntBytes
Definition: erpc_mu_transport.h:206
Definition: erpc_arbitrated_client_manager.h:51
uint32_t *volatile m_txBuffer
Definition: erpc_mu_transport.h:211
virtual erpc_status_t send(MessageBuffer *message)
Function to send prepared message.
Definition: erpc_mu_transport.cpp:243
Transport that uses Messaging Unit (MU) for interprocessor messaging.
Definition: erpc_mu_transport.h:96
uint32_t *volatile m_rxBuffer
Definition: erpc_mu_transport.h:207
void tx_cb(void)
Function called from MU IRQ when the MU TX empty flag is asserted and the IRQ is enabled.
Definition: erpc_mu_transport.cpp:180
Mutex m_receiveLock
Definition: erpc_mu_transport.h:218
volatile bool m_newMessage
Definition: erpc_mu_transport.h:202
uint32_t m_txCntBytes
Definition: erpc_mu_transport.h:210
static void mu_irq_callback(void)
Callback function called from MU IRQ.
Definition: erpc_mu_transport.cpp:68
Mutex.
Definition: erpc_threading.h:285
Simple semaphore class.
Definition: erpc_threading.h:385
void rx_cb(void)
Function called from MU IRQ when the MU RX full flag is asserted and the IRQ is enabled.
Definition: erpc_mu_transport.cpp:137