Skip to content

Commit

Permalink
Merge pull request #78 from Hadatko/add_rpmsg_tty_deinit
Browse files Browse the repository at this point in the history
Add deinit function for rpmsg tty transport.
  • Loading branch information
MichalPrincNXP authored Oct 23, 2019
2 parents f1f01f5 + 96199e4 commit 74b2811
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
5 changes: 5 additions & 0 deletions erpc_c/setup/erpc_setup_rpmsg_tty_rtos_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ erpc_transport_t erpc_transport_rpmsg_lite_tty_rtos_remote_init(unsigned long sr
}
return NULL;
}

void erpc_transport_rpmsg_lite_tty_rtos_deinit()
{
s_transport.destroy();
}
25 changes: 16 additions & 9 deletions erpc_c/setup/erpc_transport_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ extern "C" {
/*!
* @brief Create a CMSIS UART transport.
*
* Create a CMSIS UART transport instance, to be used on both the server
* and the client side.
* Create a CMSIS UART transport instance, to be used on both the server
* and the client side.
*
* @param[in] uartDrv CMSIS USART driver structure address (Driver Control Block).
*
Expand All @@ -60,7 +60,7 @@ erpc_transport_t erpc_transport_cmsis_uart_init(void *uartDrv);
/*!
* @brief Create a host PC serial port transport.
*
* Create a host PC serial port transport instance.
* Create a host PC serial port transport instance.
*
* @param[in] portName Port name.
* @param[in] baudRate Baud rate.
Expand All @@ -76,7 +76,7 @@ erpc_transport_t erpc_transport_serial_init(const char *portName, long baudRate)
/*!
* @brief Create a SPI master transport.
*
* Create SPI master transport instance, to be used at master core.
* Create SPI master transport instance, to be used at master core.
*
* @param[in] baseAddr Base address of SPI peripheral used in this transport layer.
* @param[in] baudRate SPI baud rate.
Expand All @@ -89,7 +89,7 @@ erpc_transport_t erpc_transport_spi_master_init(void *baseAddr, uint32_t baudRat
/*!
* @brief Create a SPI slave transport.
*
* Create SPI slave transport instance, to be used at slave core.
* Create SPI slave transport instance, to be used at slave core.
*
* @param[in] baseAddr Base address of SPI peripheral used in this transport layer.
* @param[in] baudRate SPI baud rate.
Expand All @@ -106,7 +106,7 @@ erpc_transport_t erpc_transport_spi_slave_init(void *baseAddr, uint32_t baudRate
/*!
* @brief Create a DSPI master transport.
*
* Create DSPI master transport instance, to be used at master core.
* Create DSPI master transport instance, to be used at master core.
*
* @param[in] baseAddr Base address of DSPI peripheral used in this transport layer.
* @param[in] baudRate DSPI baud rate.
Expand All @@ -119,7 +119,7 @@ erpc_transport_t erpc_transport_dspi_master_init(void *baseAddr, uint32_t baudRa
/*!
* @brief Create a DSPI slave transport.
*
* Create DSPI slave transport instance, to be used at slave core.
* Create DSPI slave transport instance, to be used at slave core.
*
* @param[in] baseAddr Base address of DSPI peripheral used in this transport layer.
* @param[in] baudRate DSPI baud rate.
Expand All @@ -136,8 +136,8 @@ erpc_transport_t erpc_transport_dspi_slave_init(void *baseAddr, uint32_t baudRat
/*!
* @brief Create an MU transport.
*
* Create Messaging Unit (MU) transport instance, to be used on both the server
* and the client side. Base address of the MU peripheral needs to be passed.
* Create Messaging Unit (MU) transport instance, to be used on both the server
* and the client side. Base address of the MU peripheral needs to be passed.
*
* @param[in] baseAddr Base address of MU peripheral.
*
Expand Down Expand Up @@ -246,6 +246,13 @@ erpc_transport_t erpc_transport_rpmsg_lite_rtos_remote_init(unsigned long src_ad
erpc_transport_t erpc_transport_rpmsg_lite_tty_rtos_remote_init(unsigned long src_addr, unsigned long dst_addr,
void *start_address, int rpmsg_link_id,
rpmsg_ready_cb ready, char *nameservice_name);

/*!
* @brief Deinitialize an RPMSG lite tty rtos transport.
*
* This function deinitializes the RPMSG lite tty rtos transport.
*/
void erpc_transport_rpmsg_lite_tty_rtos_deinit(void);
//@}

//! @name Linux RPMSG endpoint setup
Expand Down
27 changes: 25 additions & 2 deletions erpc_c/transports/erpc_rpmsg_tty_rtos_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,31 @@ RPMsgTTYRTOSTransport::RPMsgTTYRTOSTransport(void)

RPMsgTTYRTOSTransport::~RPMsgTTYRTOSTransport(void)
{
rpmsg_lite_deinit(s_rpmsg);
s_initialized = 0;
if (s_rpmsg != NULL)
{
if (m_rpmsg_ept != RL_NULL)
{
if (RL_SUCCESS != rpmsg_lite_destroy_ept(s_rpmsg, m_rpmsg_ept))
{
return;
}
}

if (m_rpmsg_queue != RL_NULL)
{
if (RL_SUCCESS != rpmsg_queue_destroy(s_rpmsg, m_rpmsg_queue))
{
return;
}
}

if (RL_SUCCESS != rpmsg_lite_deinit(s_rpmsg))
{
return;
}

s_initialized = 0;
}
}

void RPMsgTTYRTOSTransport::setCrc16(Crc16 *crcImpl)
Expand Down

0 comments on commit 74b2811

Please sign in to comment.