Skip to content

Commit 8c9045e

Browse files
committed
Merge branch 'develop' into feature/staticAllocation
2 parents ea55c21 + b94a617 commit 8c9045e

14 files changed

Lines changed: 167 additions & 61 deletions

.github/workflows/greetings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on: [pull_request, issues]
55
jobs:
66
greeting:
77
runs-on: ubuntu-latest
8+
permissions:
9+
issues: write
10+
pull-requests: write
811
steps:
912
- uses: actions/first-interaction@v1
1013
with:

LICENSE

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,36 @@ Copyright 2014-2016 Freescale Semiconductor, Inc.
22
Copyright 2016-2021 NXP
33
All rights reserved.
44

5-
SPDX-License-Identifier: BSD-3-Clause
5+
The BSD 3 Clause License
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 notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
3. Neither the name of the copyright holder nor the names of its contributors
18+
may be used to endorse or promote products derived from this software without
19+
specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37+
SOFTWARE.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ To get the board list with multicore support (eRPC included) use filtering based
9292
<MCUXpressoSDK_install_dir>/boards/<board_name>/multiprocessor_examples for eRPC multiprocessor examples (UART or SPI transports used).<br>
9393
eRPC examples use 'erpc_' name prefix.
9494

95+
## References
96+
97+
This section provides links to interesting erpc-based projects, articles, blogs or guides:
98+
99+
* [erpc (EmbeddedRPC) getting started notes](https://programmersought.com/article/37585084512/)
100+
* [ERPC Linux Local Environment Construction and Use](https://programmersought.com/article/88827920353/)
101+
* [The New Wio Terminal eRPC Firmware](https://www.hackster.io/Salmanfarisvp/the-new-wio-terminal-erpc-firmware-bfd8bd)
102+
95103
## Directories
96104

97105
`doc` - Documentation.

erpc_c/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SOURCES += $(ERPC_C_ROOT)/infra/erpc_arbitrated_client_manager.cpp \
7070
$(ERPC_C_ROOT)/setup/erpc_setup_mbf_static.cpp \
7171
$(ERPC_C_ROOT)/setup/erpc_server_setup.cpp \
7272
$(ERPC_C_ROOT)/setup/erpc_setup_serial.cpp \
73+
$(ERPC_C_ROOT)/setup/erpc_setup_tcp.cpp \
7374
$(ERPC_C_ROOT)/transports/erpc_inter_thread_buffer_transport.cpp \
7475
$(ERPC_C_ROOT)/transports/erpc_serial_transport.cpp \
7576
$(ERPC_C_ROOT)/transports/erpc_tcp_transport.cpp

erpc_c/setup/erpc_arbitrated_client_setup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ using namespace erpc;
3232

3333
// global client variables
3434
ERPC_MANUALLY_CONSTRUCTED(ArbitratedClientManager, s_client);
35-
extern ClientManager *g_client;
36-
ClientManager *g_client = NULL;
35+
ClientManager *g_client;
36+
#pragma weak g_client
3737

3838
ERPC_MANUALLY_CONSTRUCTED(BasicCodecFactory, s_codecFactory);
3939
ERPC_MANUALLY_CONSTRUCTED(TransportArbitrator, s_arbitrator);

erpc_c/setup/erpc_client_setup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ using namespace erpc;
3030

3131
// global client variables
3232
ERPC_MANUALLY_CONSTRUCTED(ClientManager, s_client);
33-
extern ClientManager *g_client;
34-
ClientManager *g_client = NULL;
33+
ClientManager *g_client;
34+
#pragma weak g_client
3535
ERPC_MANUALLY_CONSTRUCTED(BasicCodecFactory, s_codecFactory);
3636
ERPC_MANUALLY_CONSTRUCTED(Crc16, s_crc16);
3737

erpc_c/setup/erpc_setup_mbf_static.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
using namespace erpc;
2424

25-
#define ERPC_BUFFER_SIZE_UINT8 ((ERPC_DEFAULT_BUFFER_SIZE + sizeof(uint64_t) - 1))
26-
#define ERPC_BUFFER_SIZE_UINT64 (ERPC_BUFFER_SIZE_UINT8 / sizeof(uint64_t))
25+
#define ERPC_BUFFER_SIZE_UINT64 \
26+
((ERPC_DEFAULT_BUFFER_SIZE + sizeof(uint64_t) - 1) / sizeof(uint64_t))
2727

2828
////////////////////////////////////////////////////////////////////////////////
2929
// Classes
@@ -43,8 +43,8 @@ class StaticMessageBufferFactory : public MessageBufferFactory
4343
: m_semaphore(1)
4444
#endif
4545
{
46-
(void)memset(m_freeBufferBitmap, 0xff, ERPC_DEFAULT_BUFFERS_COUNT >> 3);
47-
(void)memset(m_buffers, 0, ERPC_DEFAULT_BUFFERS_COUNT * ERPC_BUFFER_SIZE_UINT8);
46+
(void)memset(m_freeBufferBitmap, 0xff, sizeof(m_freeBufferBitmap));
47+
(void)memset(m_buffers, 0, sizeof(m_buffers));
4848
}
4949

5050
/*!
@@ -112,8 +112,12 @@ class StaticMessageBufferFactory : public MessageBufferFactory
112112
}
113113

114114
protected:
115-
uint8_t m_freeBufferBitmap[(ERPC_DEFAULT_BUFFERS_COUNT >> 3U) + 1U]; /*!< Bitmat of used/not used buffers. */
116-
uint64_t m_buffers[ERPC_DEFAULT_BUFFERS_COUNT][ERPC_BUFFER_SIZE_UINT64]; /*!< Static buffers. */
115+
//! Bitmap representing which buffers are in use. A bit value of 1 means free and 0 means in
116+
//! use.
117+
uint8_t m_freeBufferBitmap[(ERPC_DEFAULT_BUFFERS_COUNT >> 3U) +
118+
(ERPC_DEFAULT_BUFFERS_COUNT % 8 ? 1U : 0U)];
119+
//! Static buffers
120+
uint64_t m_buffers[ERPC_DEFAULT_BUFFERS_COUNT][ERPC_BUFFER_SIZE_UINT64];
117121
#if !ERPC_THREADS_IS(NONE)
118122
Semaphore m_semaphore; /*!< Semaphore.*/
119123
#endif

erpc_c/transports/erpc_i2c_slave_transport.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ using namespace erpc;
2626
#error "Please define the ERPC_BOARD_I2C_INT_GPIO used to notify when the I2C Slave is ready to transmit"
2727
#endif
2828

29+
#define I2C_SLAVE_TRANSPORT_ADDR_7BIT (0x7EU)
30+
2931
////////////////////////////////////////////////////////////////////////////////
3032
// Variables
3133
////////////////////////////////////////////////////////////////////////////////
@@ -41,7 +43,7 @@ typedef struct i2c_clb_user_data
4143
uint8_t *rx_buffer;
4244
uint32_t rx_size;
4345
} I2C_CLB_USER_DATA, *I2C_CLB_USER_DATA_PTR;
44-
static I2C_CLB_USER_DATA volatile s_callback_user_data = { NULL, 0 };
46+
static volatile I2C_CLB_USER_DATA s_callback_user_data = { NULL, 0, NULL, 0 };
4547

4648
////////////////////////////////////////////////////////////////////////////////
4749
// Code
@@ -112,18 +114,26 @@ static void I2C_SlaveUserCallback(I2C_Type *base, volatile i2c_slave_transfer_t
112114
/* Update information for transmit process */
113115
transfer->txData = ((I2C_CLB_USER_DATA *)userData)->tx_buffer;
114116
transfer->txSize = ((I2C_CLB_USER_DATA *)userData)->tx_size;
117+
transfer->rxData = NULL;
118+
transfer->rxSize = 0;
115119
break;
116120

117121
/* Setup the slave receive buffer */
118122
case kI2C_SlaveReceiveEvent:
119123
/* Update information for received process */
120124
transfer->rxData = ((I2C_CLB_USER_DATA *)userData)->rx_buffer;
121125
transfer->rxSize = ((I2C_CLB_USER_DATA *)userData)->rx_size;
126+
transfer->txData = NULL;
127+
transfer->txSize = 0;
122128
break;
123129

124130
/* The master has sent a stop transition on the bus */
125131
case kI2C_SlaveCompletionEvent:
126132
transport->transfer_cb();
133+
transfer->rxData = NULL;
134+
transfer->rxSize = 0;
135+
transfer->txData = NULL;
136+
transfer->txSize = 0;
127137
break;
128138

129139
default:
@@ -159,7 +169,7 @@ erpc_status_t I2cSlaveTransport::init(void)
159169
i2c_slave_config_t i2cConfig;
160170

161171
I2C_SlaveGetDefaultConfig(&i2cConfig);
162-
i2cConfig.address0.address = (0x7EU); // I2C_MASTER_SLAVE_ADDR_7BIT
172+
i2cConfig.address0.address = (I2C_SLAVE_TRANSPORT_ADDR_7BIT);
163173

164174
I2C_SlaveInit(m_i2cBaseAddr, &i2cConfig, m_srcClock_Hz);
165175
I2C_SlaveTransferCreateHandle(m_i2cBaseAddr, &s_handle, I2C_SlaveUserCallback, (void *)&s_callback_user_data);
@@ -177,6 +187,8 @@ erpc_status_t I2cSlaveTransport::underlyingReceive(uint8_t *data, uint32_t size)
177187

178188
s_callback_user_data.rx_buffer = data;
179189
s_callback_user_data.rx_size = size;
190+
s_callback_user_data.tx_buffer = NULL;
191+
s_callback_user_data.tx_size = 0;
180192

181193
status =
182194
I2C_SlaveTransferNonBlocking(m_i2cBaseAddr, &s_handle, kI2C_SlaveAddressMatchEvent | kI2C_SlaveCompletionEvent);
@@ -205,6 +217,8 @@ erpc_status_t I2cSlaveTransport::underlyingSend(const uint8_t *data, uint32_t si
205217
status_t status;
206218
s_isTransferCompleted = false;
207219

220+
s_callback_user_data.rx_buffer = NULL;
221+
s_callback_user_data.rx_size = 0;
208222
s_callback_user_data.tx_buffer = (uint8_t *)data;
209223
s_callback_user_data.tx_size = size;
210224

erpc_c/transports/erpc_mu_transport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ void MUTransport::rx_cb(void)
150150
if (m_rxCntBytes >= m_rxMsgSize)
151151
{
152152
m_rxBuffer = NULL;
153-
MU_DisableInterrupts(m_muBase, (1U << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
154153
#if !ERPC_THREADS_IS(NONE)
154+
MU_DisableInterrupts(m_muBase, (1U << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
155155
m_rxSemaphore.putFromISR();
156156
#endif
157157
}

erpc_c/transports/erpc_uart_cmsis_transport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ erpc_status_t UartTransport::init(void)
103103
erpc_status_t UartTransport::underlyingReceive(uint8_t *data, uint32_t size)
104104
{
105105
erpc_status_t erpcStatus = kErpcStatus_ReceiveFailed;
106-
int32_t status = (*m_uartDrv).Receive(data, size);
107106

108107
s_isTransferReceiveCompleted = false;
108+
int32_t status = (*m_uartDrv).Receive(data, size);
109109

110110
if (status == ARM_DRIVER_OK)
111111
{
@@ -126,9 +126,9 @@ erpc_status_t UartTransport::underlyingReceive(uint8_t *data, uint32_t size)
126126
erpc_status_t UartTransport::underlyingSend(const uint8_t *data, uint32_t size)
127127
{
128128
erpc_status_t erpcStatus = kErpcStatus_SendFailed;
129-
int32_t status = (*m_uartDrv).Send(data, size);
130129

131130
s_isTransferSendCompleted = false;
131+
int32_t status = (*m_uartDrv).Send(data, size);
132132

133133
if (status == ARM_DRIVER_OK)
134134
{

0 commit comments

Comments
 (0)