Ejemplo n.º 1
0
unsigned char UARTGetChar(unsigned long ulBase, unsigned char *data, int timeout)
{
	unsigned char ret=0;
	if (ulBase == UART0_BASE)
	{
		ret = OSQueuePend(Serial0, data, timeout);
	}

	if (ulBase == UART1_BASE)
	{
		ret = OSQueuePend(Serial1, data, timeout);
	}
	if (ulBase == UART2_BASE)
	{
		ret = OSQueuePend(Serial2, data, timeout);
	}

	return ret;
}
Ejemplo n.º 2
0
/* UART comm is used in simulation only */
void Comm2PC_Task(void)
{
   INT8U c;
   
   // Init UART port with a max mutex priority
   UART_init(Serial_Mutex_Priority);
   
   if(Comm2PC_check_cmdorder() != OK){
      while(1){} /* command are out of order */
   }
   
   for(;;){
   
      (void)OSQueuePend(Serial, &c, 0);
      Comm2PC_FSM((CHAR8)c);
   }


}
Ejemplo n.º 3
0
void Keyb_Task(void)
{
	char text[320];
	uint8_t key = 0;

	while(1)
	{
		if(!OSQueuePend(qKeyboard, &key, 0))
		{
			switch(key)
			{
				case LEFT_KEY:
					// Block LED RGB task
					UARTPutString(UART0_BASE, "Botão Esquerdo pressionado!\n\r");
					OSAvailableMemory(text);
					UARTPutString(UART0_BASE, text);
					OSCPULoad(text);
					UARTPutString(UART0_BASE, text);
					UARTPutString(UART0_BASE, "\n\r");
					break;

				case RIGHT_KEY:
					// UnBlock LED RGB task
					UARTPutString(UART0_BASE, "Botão Direito pressionado!\n\r");
					OSUptimeInfo(text);
					UARTPutString(UART0_BASE, text);
					UARTPutString(UART0_BASE, "\n\r");
					break;

				case BOTH_KEY:
					UARTPutString(UART0_BASE, "Ambos os botões pressionados!\n\r");
					OSTaskList(text);
					UARTPutString(UART0_BASE, text);
					UARTPutString(UART0_BASE, "\n\r");
					break;

				default:
					break;
			}
		}
	}
}
Ejemplo n.º 4
0
void HMI(void)
{
	/* task setup */
	INT8U key = 0;

	/* task main loop */
	for (;;)
	{

		if (!OSQueuePend(qKeyboard, &key, 500))
		{

			switch (key)
			{

			case UP_KEY :
				break;

			case DOWN_KEY :
				break;
			}
		}
	}
}
Ejemplo n.º 5
0
INT8U rs485_rx(CHAR8* caracter, INT16U timeout)
{	
	INT8U ret;
	ret = OSQueuePend(RS485_QUEUE, (INT8U*)caracter, timeout);
	return (ret != TIMEOUT) ? TRUE:FALSE;
}
Ejemplo n.º 6
0
void Terminal(void)
{
	char data;

   if (OSSemCreate(0,&sUART) != ALLOC_EVENT_OK)
   {
     // Oh Oh
     // Não deveria entrar aqui !!!
     BlockTask(th6);
   };

   if (OSMutexCreate(&mutexTx,6) != ALLOC_EVENT_OK)
   {
     // Oh Oh
     // Não deveria entrar aqui !!!
     BlockTask(th6);
   };

   if (OSQueueCreate(64, &qUART) != ALLOC_EVENT_OK)
   {
     // Oh Oh
     // Não deveria entrar aqui !!!
	 BlockTask(th6);
   };

	//
	// Enable the peripherals used by this example.
	// The UART itself needs to be enabled, as well as the GPIO port
	// containing the pins that will be used.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	//
	// Configure the GPIO pin muxing for the UART function.
	// This is only necessary if your part supports GPIO pin function muxing.
	// Study the data sheet to see which functions are allocated per pin.
	// TODO: change this to select the port/pin you are using
	//
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);

	//
	// Since GPIO A0 and A1 are used for the UART function, they must be
	// configured for use as a peripheral function (instead of GPIO).
	// TODO: change this to match the port/pin you are using
	//
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	//
	// Configure the UART for 115,200, 8-N-1 operation.
	// This function uses SysCtlClockGet() to get the system clock
	// frequency.  This could be also be a variable or hard coded value
	// instead of a function call.
	//
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
						(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
						 UART_CONFIG_PAR_NONE));

	UARTFIFODisable(UART0_BASE);

	//
	// Enable the UART interrupt.
	//
	ROM_IntEnable(INT_UART0);
	ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

    //
    // Put a character to show start of example.  This will display on the
    // terminal.
    //
    UARTPutString(UART0_BASE, "Iniciou!\n\r\n\r");

    while(1)
    {
    	if(!OSQueuePend(qUART, (INT8U*)&data, 0))
    	{
    		if (data != 13)
    		{
    			UARTPutChar(UART0_BASE, data);
    		}else
    		{
    			UARTPutString(UART0_BASE, "\n\r");
    		}
    	}
    }
}
Ejemplo n.º 7
0
/*****************************************************************************
* Name:
*    terminal_proces
* In:
*    N/A
*
* Out:
*    N/A
*
* Description:
*    Main loop of terminal application. gathers input, and executes commands.
*
* Assumptions:
*    --
*****************************************************************************/
void usb_terminal_process(void)
{
    INT8U data;
    char c;

    while(1)
    {
        (void)OSQueuePend(USB, &data, 0);
        c=(char)data;

        if ((c != '\n') && (c != '\r'))
        {
            if (c != 0x7F)
            {
                if (SilentMode == FALSE)
                {
                    while(c!=(char)(*putch)(c)) {};
                }
            } else
            {
                if (usb_cmd_line_ndx)
                {
                    while(c!=(char)(*putch)(c)) {};
                }
            }
        }

        /* Execute command if enter is received, or usb_cmd_line is full. */
        if ((c=='\r') || (usb_cmd_line_ndx == sizeof(usb_cmd_line)-2))
        {
            int usb_start = usb_skipp_space(usb_cmd_line, 0);
            int usb_end = usb_find_word(usb_cmd_line, usb_start);
            int usb_x;

            /* Separate command string from parameters, and close
               parameters string. */
            usb_cmd_line[usb_end]=usb_cmd_line[usb_cmd_line_ndx]='\0';

            /* Identify command. */
            usb_x=usb_find_command(usb_cmd_line+usb_start);

            /* Command not found. */
            if (usb_x == -1)
            {
                print_usb("\r\nUnknown command!\r\n");
            }
            else
            {
                (*usb_cmds[usb_x]->func)(usb_cmd_line+usb_end+1);
            }
            usb_cmd_line_ndx=0;
            usb_print_prompt();
            SetSilentMode(FALSE);
        }
        else
        {   /* Put character to usb_cmd_line. */
            if (c=='\b')
            {
                if (usb_cmd_line_ndx > 0)
                {
                    usb_cmd_line[usb_cmd_line_ndx]='\0';
                    usb_cmd_line_ndx--;
                }
            }
            else if(c=='\n') {
                continue;
            }
            else
            {
                if (c == 0x7F)
                {
                    if (usb_cmd_line_ndx)
                    {
                        usb_cmd_line[usb_cmd_line_ndx]=0;
                        usb_cmd_line_ndx--;
                        usb_cmd_line[usb_cmd_line_ndx]=0;
                    }
                } else
                {
                    usb_cmd_line[usb_cmd_line_ndx++]=c;
                }
            }
        }

        if (SilentMode == FALSE)
        {
            cdc_process();
        }
    }
}
Ejemplo n.º 8
0
void Task_Serial(void)
{
    /* task setup */
    INT8U pedido = 0;  
  
	strcpy_P(BufferText, (PGM_P)pgm_read_word(&(BRTOSStringTable[0])));
	Serial_Envia_Frase((CHAR8*)BufferText);
			
	Serial_Envia_Caracter(10);
	Serial_Envia_Caracter(13);
			
   // task main loop
   for (;;) 
   {

      if(!OSQueuePend(Serial, &pedido, 0))
      {
		switch(pedido)
        {
          
		  #if (COMPUTES_CPU_LOAD == 1)
          case '1':
            Transmite_CPU_Load();
			//OSCPULoad(BufferTextDebug);
			//Serial_Envia_Frase((CHAR8*)BufferTextDebug);
			Serial_Envia_Caracter(10);
			Serial_Envia_Caracter(13);			
            break;
          #endif
          case '2':
            Transmite_Uptime();
			//OSUptimeInfo(BufferTextDebug);
			//Serial_Envia_Frase((CHAR8*)BufferTextDebug);
			Serial_Envia_Caracter(10);
			Serial_Envia_Caracter(13);			
            break;
          case '3':			
            strcpy_P(BufferText, (PGM_P)pgm_read_word(&(BRTOSStringTable[0])));
            Serial_Envia_Frase((CHAR8*)BufferText);
			
            Serial_Envia_Caracter(10);
            Serial_Envia_Caracter(13);
            break;
          case '4':
            //Transmite_RAM_Ocupada();
			OSAvailableMemory(BufferTextDebug);
			Serial_Envia_Frase((CHAR8*)BufferTextDebug);
			Serial_Envia_Caracter(10);
			Serial_Envia_Caracter(13);			
            break;
		  case '5':
            Transmite_Task_Stacks();
			//OSTaskList(BufferTextDebug);
			//Serial_Envia_Frase((CHAR8*)BufferTextDebug);
			Serial_Envia_Caracter(10);
			Serial_Envia_Caracter(13);			
            break;
          #if (OSTRACE == 1) 
          case '6':
            Send_OSTrace();
            Serial_Envia_Caracter(LF);
            Serial_Envia_Caracter(CR);            
            break;            
          #endif                                    
          default:
            Serial_Envia_Caracter(pedido);
            break;
        }
      }
   }
}