AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/pic18f6720/mstp.c
void MSTP_Init(
    volatile struct mstp_port_struct_t *mstp_port)
{
    int i;      /*loop counter */

    if (mstp_port) {
        mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
        mstp_port->master_state = MSTP_MASTER_STATE_INITIALIZE;
        mstp_port->ReceiveError = false;
        mstp_port->DataAvailable = false;
        mstp_port->DataRegister = 0;
        mstp_port->DataCRC = 0;
        mstp_port->DataCRC = 0;
        mstp_port->DataLength = 0;
        mstp_port->DestinationAddress = 0;
        mstp_port->EventCount = 0;
        mstp_port->FrameType = FRAME_TYPE_TOKEN;
        mstp_port->FrameCount = 0;
        mstp_port->HeaderCRC = 0;
        mstp_port->Index = 0;
        mstp_port->Index = 0;
        for (i = 0; i < sizeof(mstp_port->InputBuffer); i++) {
            mstp_port->InputBuffer[i] = 0;
        }
        mstp_port->Next_Station = mstp_port->This_Station;
        mstp_port->Poll_Station = mstp_port->This_Station;
        mstp_port->ReceivedInvalidFrame = false;
        mstp_port->ReceivedValidFrame = false;
        mstp_port->RetryCount = 0;
        mstp_port->SilenceTimer = 0;
/*        mstp_port->ReplyPostponedTimer = 0; */
        mstp_port->SoleMaster = false;
        mstp_port->SourceAddress = 0;
        mstp_port->TokenCount = 0;
#if 0
        /* these are adjustable, so should already be set */
        mstp_port->Nmax_info_frames = DEFAULT_MAX_INFO_FRAMES;
        mstp_port->Nmax_master = DEFAULT_MAX_MASTER;
#endif

        /* An array of octets, used to store PDU octets prior to being transmitted. */
        /* This array is only used for APDU messages */
        for (i = 0; i < sizeof(mstp_port->TxBuffer); i++) {
            mstp_port->TxBuffer[i] = 0;
        }
        mstp_port->TxLength = 0;
        mstp_port->TxReady = false;
        mstp_port->TxFrameType = 0;

    }
}
/* note: This_Station should be set with the MAC address */
/* note: Nmax_info_frames should be set */
/* note: Nmax_master should be set */
This_Station should be set with the MAC address
note: Nmax_info_frames should be set
note: Nmax_master should be set
This_Station should be set with the MAC address note : Nmax_info_frames should be set note : Nmax_master should be set
void MSTP_Init(
    volatile struct mstp_port_struct_t *mstp_port)
{
    int i;      
    if (mstp_port) {
        mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
        mstp_port->master_state = MSTP_MASTER_STATE_INITIALIZE;
        mstp_port->ReceiveError = false;
        mstp_port->DataAvailable = false;
        mstp_port->DataRegister = 0;
        mstp_port->DataCRC = 0;
        mstp_port->DataCRC = 0;
        mstp_port->DataLength = 0;
        mstp_port->DestinationAddress = 0;
        mstp_port->EventCount = 0;
        mstp_port->FrameType = FRAME_TYPE_TOKEN;
        mstp_port->FrameCount = 0;
        mstp_port->HeaderCRC = 0;
        mstp_port->Index = 0;
        mstp_port->Index = 0;
        for (i = 0; i < sizeof(mstp_port->InputBuffer); i++) {
            mstp_port->InputBuffer[i] = 0;
        }
        mstp_port->Next_Station = mstp_port->This_Station;
        mstp_port->Poll_Station = mstp_port->This_Station;
        mstp_port->ReceivedInvalidFrame = false;
        mstp_port->ReceivedValidFrame = false;
        mstp_port->RetryCount = 0;
        mstp_port->SilenceTimer = 0;
        mstp_port->SoleMaster = false;
        mstp_port->SourceAddress = 0;
        mstp_port->TokenCount = 0;
#if 0
        mstp_port->Nmax_info_frames = DEFAULT_MAX_INFO_FRAMES;
        mstp_port->Nmax_master = DEFAULT_MAX_MASTER;
#endif
        for (i = 0; i < sizeof(mstp_port->TxBuffer); i++) {
            mstp_port->TxBuffer[i] = 0;
        }
        mstp_port->TxLength = 0;
        mstp_port->TxReady = false;
        mstp_port->TxFrameType = 0;
    }
}
void MSTP_Init ( volatile struct mstp_port_struct_t * mstp_port ) { int i ; if ( mstp_port ) { mstp_port -> receive_state = MSTP_RECEIVE_STATE_IDLE ; mstp_port -> master_state = MSTP_MASTER_STATE_INITIALIZE ; mstp_port -> ReceiveError = false ; mstp_port -> DataAvailable = false ; mstp_port -> DataRegister = 0 ; mstp_port -> DataCRC = 0 ; mstp_port -> DataCRC = 0 ; mstp_port -> DataLength = 0 ; mstp_port -> DestinationAddress = 0 ; mstp_port -> EventCount = 0 ; mstp_port -> FrameType = FRAME_TYPE_TOKEN ; mstp_port -> FrameCount = 0 ; mstp_port -> HeaderCRC = 0 ; mstp_port -> Index = 0 ; mstp_port -> Index = 0 ; for ( i = 0 ; i < sizeof ( mstp_port -> InputBuffer ) ; i ++ ) { mstp_port -> InputBuffer [ i ] = 0 ; } mstp_port -> Next_Station = mstp_port -> This_Station ; mstp_port -> Poll_Station = mstp_port -> This_Station ; mstp_port -> ReceivedInvalidFrame = false ; mstp_port -> ReceivedValidFrame = false ; mstp_port -> RetryCount = 0 ; mstp_port -> SilenceTimer = 0 ; mstp_port -> SoleMaster = false ; mstp_port -> SourceAddress = 0 ; mstp_port -> TokenCount = 0 ; #if 0 mstp_port -> Nmax_info_frames = DEFAULT_MAX_INFO_FRAMES ; mstp_port -> Nmax_master = DEFAULT_MAX_MASTER ; #endif for ( i = 0 ; i < sizeof ( mstp_port -> TxBuffer ) ; i ++ ) { mstp_port -> TxBuffer [ i ] = 0 ; } mstp_port -> TxLength = 0 ; mstp_port -> TxReady = false ; mstp_port -> TxFrameType = 0 ; } }
note: This_Station should be set with the MAC address
note: Nmax_info_frames should be set
note: Nmax_master should be set
note : This_Station should be set with the MAC address note : Nmax_info_frames should be set note : Nmax_master should be set
/*loop counter */ /*        mstp_port->ReplyPostponedTimer = 0; */ /* these are adjustable, so should already be set */ /* An array of octets, used to store PDU octets prior to being transmitted. */ /* This array is only used for APDU messages */