Ejemplo n.º 1
0
DWORD WINAPI ProcWaitSignal( LPVOID lpParam){
	while(1){
		printf("checking queue\n");
        Sleep(1000);
        if (NbElmt != 0){
        	if ((!IsUpper(buf)) && (!IsLower(buf))) {
	            printf("Mengonsumsi ke - %d : %c\n", ind, buf.TI[ind]);
	            ind++;
	            NbElmt--; // konsumsi buffer            
	        } else if (IsUpper(buf)) {
	           	SendXOFF();
	           	printf("Masuk Upper limit\n");
	            printf("Mengonsumsi ke - %d : %c\n", ind, buf.TI[ind]);
	            ind++;
	            NbElmt--; // konsumsi buffer
	        } else if (IsLower(buf)) {
	            SendXON();
	            printf("Masuk Lower limit\n");
	            // no consume0
	        }
        }
        
	}
	return 0;
};
Ejemplo n.º 2
0
void USART_Driver::PrepareForClockStop()
{
    ASSERT_IRQ_MUST_BE_OFF();

    // set XOFF state and send if we haven't already
    for( int port = 0; port < TOTAL_USART_PORT; port++)
    {
        if ( USART_FLAG_STATE(Hal_Usart_State[port], HAL_USART_STATE::c_RX_SWFLOW_CTRL))
        {
            // set our XOFF state
            SendXOFF( port, XOFF_CLOCK_HALT );
        }
    }
}
Ejemplo n.º 3
0
BOOL USART_Driver::AddCharToRxBuffer( int ComPortNum, char c )
{
    ASSERT_IRQ_MUST_BE_OFF();

    if((ComPortNum < 0) || (ComPortNum >= TOTAL_USART_PORT)) return FALSE;

    HAL_USART_STATE& State = Hal_Usart_State[ComPortNum];

    if (USART_FLAG_STATE(State, HAL_USART_STATE::c_TX_SWFLOW_CTRL))

    {
        switch( c )
        {
            case XOFF:
                State.TicksStartTxXOFF = HAL_Time_CurrentTicks();
                CLEAR_USART_FLAG(State, HAL_USART_STATE::c_TX_XON_STATE);
                return TRUE;
            case XON:
                SET_USART_FLAG(State, HAL_USART_STATE::c_TX_XON_STATE);
                return TRUE;
        }
    }


    {
        GLOBAL_LOCK(irq);

        UINT8* Dst = State.RxQueue.Push();

        if(Dst)
        {
            *Dst = c;

            if( State.RxQueue.NumberOfElements() >= State.RxBufferHighWaterMark )
            {
                if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_SWFLOW_CTRL) )
                {
                    // Set our XOFF state
                    SendXOFF( ComPortNum, XOFF_FLAG_FULL );
                }
                if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_HWFLOW_CTRL) )
                {
                    // Hold off receiving characters (should pull HW handshake automatically)
                    CPU_USART_RxBufferFullInterruptEnable(ComPortNum, FALSE);
                }
            }
        }
        
        else
        {
            SetEvent( ComPortNum, USART_EVENT_ERROR_RXOVER );
                
#if !defined(BUILD_RTM)
            lcd_printf("\fBuffer OVFLW\r\n");
            hal_printf("Buffer OVFLW\r\n");
#endif
            return FALSE;
        }
    }

    SetEvent( ComPortNum, USART_EVENT_DATA_CHARS );

    Events_Set( SYSTEM_EVENT_FLAG_COM_IN );

    return TRUE;
}