Multiprocessor server application
The “Matrix multiply” eRPC server project for multiprocessor applications is located in the <MCUXpressoSDK_install_dir>>/boards/<board_name>/multiprocessor_examples/ erpc_server_matrix_multiply_<transport_layer> folder.
Most of the multiprocessor application setup is the same as for the multicore application. The multiprocessor server application requires server-related generated files (server shim code), server infrastructure files, and the server user code. There is no need for server multicore infrastructure files (MCMGR and RPMsg-Lite). The RPMsg-Lite transport layer is replaced either by SPI or UART transports. The following table shows the required transport-related files per each transport type.
|SPI|<eRPC base directory>/erpc_c/setup/erpc_setup_(d)spi_slave.cpp
<eRPC base directory>/erpc_c/transports/erpc_(d)spi_slave_transport.hpp
<eRPC base directory>/erpc_c/transports/erpc_(d)spi_slave_transport.cpp
|
|UART|<eRPC base directory>/erpc_c/setup/erpc_setup_uart_cmsis.cpp
<eRPC base directory>/erpc_c/transports/erpc_uart_cmsis_transport.hpp
<eRPC base directory>/erpc_c/transports/erpc_uart_cmsis_transport.cpp
|
Server user code
The server’s user code is stored in the main_server.c
file, located in the <MCUXpressoSDK_install_dir>/boards/ <board_name>/multiprocessor_examples/erpc_server_matrix_multiply_<transport_layer>/ folder.
The eRPC-relevant code with UART as a transport is captured in the following code snippet:
/* erpcMatrixMultiply function user implementation */
void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix)
{
...
}
int main()
{
...
/* UART transport layer initialization, ERPC_DEMO_UART is the structure of CMSIS UART driver operations */
erpc_transport_t transport;
transport = erpc_transport_cmsis_uart_init((void *)&ERPC_DEMO_UART);
...
/* MessageBufferFactory initialization */
erpc_mbf_t message_buffer_factory;
message_buffer_factory = erpc_mbf_dynamic_init();
...
/* eRPC server side initialization */
erpc_server_t server;
server = erpc_server_init(transport, message_buffer_factory);
...
/* Adding the service to the server */
erpc_service_t service = create_MatrixMultiplyService_service();
erpc_add_service_to_server(server, service);
...
while (1)
{
/* Process eRPC requests */
erpc_status_t status = erpc_server_poll(server)
/* handle error status */
if (status != kErpcStatus_Success)
{
/* print error description */
erpc_error_handler(status, 0);
...
}
...
}
}
Parent topic:Multiprocessor server application
Multiprocessor client application
The “Matrix multiply” eRPC client project for multiprocessor applications is located in the <MCUXpressoSDK_install_dir>/ boards/<board_name>/multiprocessor_examples/erpc_client_matrix_multiply_<transport_layer>/iar/ folder.
Most of the multiprocessor application setup is the same as for the multicore application. The multiprocessor server application requires client-related generated files (server shim code), client infrastructure files, and the client user code. There is no need for client multicore infrastructure files (MCMGR and RPMsg-Lite). The RPMsg-Lite transport layer is replaced either by SPI or UART transports. The following table shows the required transport-related files per each transport type.
|SPI|<eRPC base directory>/erpc_c/setup/erpc_setup_(d)spi_master.cpp
<eRPC base directory>/erpc_c/transports/ erpc_(d)spi_master_transport.hpp
<eRPC base directory>/erpc_c/transports/ erpc_(d)spi_master_transport.cpp
|
|UART|<eRPC base directory>/erpc_c/setup/erpc_setup_uart_cmsis.cpp
<eRPC base directory>/erpc_c/transports/erpc_uart_cmsis_transport.hpp
<eRPC base directory>/erpc_c/transports/erpc_uart_cmsis_transport.cpp
|
Client user code
The client’s user code is stored in the main_client.c
file, located in the <MCUXpressoSDK_install_dir>/boards/<board_name>/multiprocessor_examples/ erpc_client_matrix_multiply_<transport_layer>/ folder.
The eRPC-relevant code with UART as a transport is captured in the following code snippet:
...
extern bool g_erpc_error_occurred;
...
/* Declare matrix arrays */
Matrix matrix1 = {0}, matrix2 = {0}, result_matrix = {0};
...
/* UART transport layer initialization, ERPC_DEMO_UART is the structure of CMSIS UART driver operations */
erpc_transport_t transport;
transport = erpc_transport_cmsis_uart_init((void *)&ERPC_DEMO_UART);
...
/* MessageBufferFactory initialization */
erpc_mbf_t message_buffer_factory;
message_buffer_factory = erpc_mbf_dynamic_init();
...
/* eRPC client side initialization */
erpc_client_t client;
client = erpc_client_init(transport,message_buffer_factory);
...
/* Set default error handler */
erpc_client_set_error_handler(client, erpc_error_handler);
...
while (1)
{
/* Invoke the erpcMatrixMultiply function */
erpcMatrixMultiply(matrix1, matrix2, result_matrix);
...
/* Check if some error occured in eRPC */
if (g_erpc_error_occurred)
{
/* Exit program loop */
break;
}
...
}
Parent topic:Multiprocessor client application
Parent topic:Multiprocessor server application
Parent topic:Create an eRPC application