/* ** =================================================================== ** Method : SM1_SMasterLdd1_OnBlockReceived (component SynchroMaster) ** ** Description : ** This event is called when the requested number of data is ** moved to the input buffer. This method is available only if ** the ReceiveBlock method is enabled. The event services the ** event of the inherited component and eventually invokes other ** events. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void SMasterLdd1_OnBlockReceived(LDD_TUserData *UserDataPtr) { register byte Flags = 0U; /* Temporary variable for flags */ (void)UserDataPtr; /* Parameter is not used, suppress unused argument warning */ if (SM1_InpLen < SM1_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */ SM1_InpLen++; /* Increase number of chars in the receive buffer */ InpBuffer[InpIndexW++] = (SM1_TComData)BufferRead; /* Save received char to the receive buffer */ if (InpIndexW >= SM1_INP_BUF_SIZE) { /* Is the index out of the receive buffer? */ InpIndexW = 0x00U; /* Set index on the first item into the receive buffer */ } Flags |= ON_RX_CHAR; /* If yes then set the OnRxChar flag */ if (SM1_InpLen == SM1_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer equal to the size of buffer? */ Flags |= ON_FULL_RX; /* Set flag "OnFullRxBuf" */ } } else { SerFlag |= FULL_RX; /* Set flag "full RX buffer" */ ErrFlag |= FULL_RX; /* Set flag "full RX buffer" for GetError method */ Flags |= ON_ERROR; /* Set the OnError flag */ } if ((Flags & ON_ERROR) != 0U) { /* Is any error flag set? */ SM1_OnError(); /* Invoke user event */ } else { if ((Flags & ON_RX_CHAR) != 0U) { /* Is OnRxChar flag set? */ SM1_OnRxChar(); /* Invoke user event */ } if ((Flags & ON_FULL_RX) != 0U) { /* Is OnTxChar flag set? */ SM1_OnFullRxBuf(); /* Invoke user event */ } } (void)SMasterLdd1_ReceiveBlock(SMasterLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** Method : SM1_Init (component SynchroMaster) ** ** Description : ** Initializes the associated peripheral(s) and the component ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void SM1_Init(void) { SerFlag = 0U; /* Reset all flags */ ErrFlag = 0U; /* Reset all flags in mirror */ SM1_InpLen = 0U; /* No char in the receive buffer */ InpIndexR = 0x00U; /* Set index on the first item in the receive buffer */ InpIndexW = 0x00U; SM1_OutLen = 0U; /* No char in the transmit buffer */ OutIndexR = 0x00U; /* Set index on the first item in the transmit buffer */ OutIndexW = 0x00U; SMasterLdd1_DeviceDataPtr = SMasterLdd1_Init(NULL); /* Calling init method of the inherited component */ (void)SMasterLdd1_ReceiveBlock(SMasterLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** Method : SM1_SMasterLdd1_OnBlockReceived (component SynchroMaster) ** ** Description : ** This event is called when the requested number of data is ** moved to the input buffer. This method is available only if ** the ReceiveBlock method is enabled. The event services the ** event of the inherited component and eventually invokes other ** events. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void SMasterLdd1_OnBlockReceived(LDD_TUserData *UserDataPtr) { (void)UserDataPtr; /* Parameter is not used, suppress unused argument warning */ if (SM1_InpLen < SM1_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */ SM1_InpLen++; /* Increase number of chars in the receive buffer */ InpBuffer[InpIndexW++] = (SM1_TComData)BufferRead; /* Save received char to the receive buffer */ if (InpIndexW >= SM1_INP_BUF_SIZE) { /* Is the index out of the receive buffer? */ InpIndexW = 0x00U; /* Set index on the first item into the receive buffer */ } } else { SerFlag |= FULL_RX; /* Set flag "full RX buffer" */ ErrFlag |= FULL_RX; /* Set flag "full RX buffer" for GetError method */ } (void)SMasterLdd1_ReceiveBlock(SMasterLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** Method : HWEnDi (component SynchroMaster) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of the ** Enable and Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { if (EnUser) { /* Enable device? */ (void)SMasterLdd1_Enable(SMasterLdd1_DeviceDataPtr); /* Enable SPI device */ if (SetAttributeCmd) { /* Is request change SPI attribute in enable code? */ SetAttributeCmd = FALSE; /* Disable settings SPI attribute in enable code */ SMasterLdd1_SelectConfiguration(SMasterLdd1_DeviceDataPtr, 0x00U, SpiClockfeatures); /* Set SPI attribute index. */ } (void)SMasterLdd1_ReceiveBlock(SMasterLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ if ((SM1_OutLen) != 0U) { /* Is number of bytes in the transmit buffer greater then 0? */ SerFlag |= RUNINT_FROM_TX; /* Set flag "running int from TX"? */ (void)SMasterLdd1_SendBlock(SMasterLdd1_DeviceDataPtr, (LDD_TData *)&OutBuffer[OutIndexR], 1U); /* Send one data byte */ } } else { SerFlag &= (byte)~(RUNINT_FROM_TX); /* Clear RUNINT_FROM_TX flag */ (void)SMasterLdd1_Disable(SMasterLdd1_DeviceDataPtr); /* Disable device */ } }