The code generated by the Serial_LDD component ( Comp1.c is the name by default) related to the RTOS component is as follows:
#include "mqx.h"
#include "ioctl.h"
#include "Comp1.h"
#include "Events.h"
#include "UART_PDD.h"
/* Include inherited beans */
#include "SharedInst1.h"
LDD_TDeviceData* SharedInst1_Init(LDD_TUserData *UserDataPtr)
{
/* Allocate device structure */
Comp1_TDeviceDataPtr DeviceDataPrv;
/* {MQX1 RTOS Adapter} Driver memory allocation: RTOS function
call is defined by MQX1 RTOS Adapter property */
DeviceDataPrv = (Comp1_TDeviceData*)
_mem_alloc_system(sizeof(Comp1_TDeviceData));
#if MQX1_CHECK_MEMORY_ALLOCATION_ERRORS
if (DeviceDataPrv == NULL) {
return (NULL);
}
#endif
. . .
/* Allocate interrupt vectors */
/* {MQX1 RTOS Adapter} Save old and set new interrupt vector
(function handler and ISR parameter) */
/* Note: Exception handler for interrupt is not saved, because it
is not modified */
DeviceDataPrv->SavedISRSettings.isrData =
_int_get_isr_data(LDD_ivIndex_INT_UART0_RX_TX);
DeviceDataPrv->SavedISRSettings.isrFunction =
_int_install_isr(LDD_ivIndex_INT_UART0_RX_TX,SharedInst1_Interrupt,Dev
iceDataPrv);
. . .
return ((LDD_TDeviceData *)DeviceDataPrv);
}
void Comp1_Deinit(LDD_TDeviceData *DeviceDataPtr)
{
Comp1_TDeviceDataPtr DeviceDataPrv =
(Comp1_TDeviceDataPtr)DeviceDataPtr;
(void)DeviceDataPrv;
. . .
/* {MQX1 RTOS Adapter} Restore interrupt vector (function handler
and ISR parameter) */
/* Note: Exception handler for interrupt is not restored, because
it was not modified */
_int_install_isr(LDD_ivIndex_"@SharedCompInst0@InpInt_Name",
DeviceDataPrv->SavedISRSettings.isrFunction,DeviceDataPrv-
>SavedISRSettings.isrData);
. . .
/* {MQX1 RTOS Adapter} Driver memory deallocation: RTOS function
call is defined by MQX1 RTOS Adapter property */
_mem_free(DeviceDataPrv);
}
void SharedInst1_Interrupt(void* _isrParameter ) {
/* {MQX1 RTOS Adapter} ISR parameter is passed as parameter from
RTOS interrupt dispatcher */
Comp1_TDeviceDataPtr DeviceDataPrv =
(Comp1_TDeviceDataPtr)_isrParameter;
register uint16_t StatReg =
UART_PDD_ReadInterruptStatusReg(DeviceDataPrv->DeviceBaseAddress); /*
Read status register */
register uint16_t Data; /* Temporary variable for data */
if (StatReg & (UART_S1_NF_MASK | UART_S1_OR_MASK | UART_S1_FE_MASK |
UART_S1_PF_MASK)) { /* Is any error flag set? */
Data = (uint16_t)UART_PDD_GetChar8(DeviceDataPrv-
>DeviceBaseAddress); /* Read 8-bit character from receiver */
StatReg &= (uint16_t)(~(uint16_t)UART_S1_RDRF_MASK); /* Clear the
receive data flag to discard the errorneous data */
}
if (StatReg & UART_S1_RDRF_MASK) { /* Is the receiver's interrupt
flag set? */
InterruptRx(DeviceDataPrv); /* If yes, then invoke the
internal service routine. This routine is inlined. */
}
if (DeviceDataPrv->SerFlag & ENABLED_TX_INT) { /* Is the transmitter
interrupt enabled? */
if (StatReg & UART_S1_TDRE_MASK) { /* Is the transmitter empty? */
InterruptTx(DeviceDataPrv); /* If yes, then invoke the
internal service routine. This routine is inlined. */
}
}
return;
}
LDD_TError Comp1_ReceiveBlock(LDD_TDeviceData *DeviceDataPtr,
LDD_TData *BufferPtr, uint16_t Size)
{
Comp1_TDeviceDataPtr DeviceDataPrv =
(Comp1_TDeviceDataPtr)DeviceDataPtr;
if (Size == 0U) /*Is the parameter Size within an expected range?*/
{
return ERR_PARAM_SIZE; /* If no then error */
}
if (DeviceDataPrv->InpDataNumReq != 0x00U) {
/* Is the previous receive operation pending? */
return ERR_BUSY; /* If yes then error */
}
/* {MQX1 RTOS Adapter} Critical section begin (RTOS function call is
defined by MQX1 RTOS Adapter property) */
_int_disable();
DeviceDataPrv->InpDataPtr = BufferPtr; /* Store a pointer to the
input data. */
DeviceDataPrv->InpDataNumReq = Size; /*Store a number of characters
to be received*/
DeviceDataPrv->InpRecvDataNum = 0x00U; /*Set number of received
characters to zero*/
/* {MQX1 RTOS Adapter} Critical section ends (RTOS function call is
defined by MQX1 RTOS Adapter property) */
_int_enable();
return ERR_OK; /* OK */
}