Beispiel #1
0
static void reactToUART(void) {
	if (RxBuf_NofElements() != 0) {
		SendString((unsigned char*) "uart: ", &deviceData);
		while (RxBuf_NofElements() != 0) {
			unsigned char ch;
			(void) RxBuf_Get(&ch);
			SendChar(ch, &deviceData);
			switchLEDs(ch);
		}
		SendString((unsigned char*) "\r\n", &deviceData);
	}
}
void APP_Run(void) {
    Init();
    SendString((unsigned char*)"Hello World\r\n", &deviceData);
    for(;;) {
        if (RxBuf_NofElements()!=0) {
            SendString((unsigned char*)"echo: ", &deviceData);
            while (RxBuf_NofElements()!=0) {
                unsigned char ch;

                (void)RxBuf_Get(&ch);
                SendChar(ch, &deviceData);
            }
            SendString((unsigned char*)"\r\n", &deviceData);
        }
    }
}
Beispiel #3
0
//blue, input duty cycle
void PWM_B(uint16_t dc)
{
	LED_clear();

	for(;;)
	{
		PTD_BASE_PTR->PCOR |= 1 << 1;
		delay(dc*10);
		PTD_BASE_PTR->PSOR |= 1 << 1;
		delay(1000-dc*10);
		if (RxBuf_NofElements()!=0)
			break;
	}
}
Beispiel #4
0

extern "C" void APP_Run(void);
void APP_Run(void)
{
  Init ();
  SCmd.Init ();

  /** Startup delay */
  WAIT1_Waitms(500);

  /** Wait for commands */
  for (;;)
  {
    if (RxBuf_NofElements () != 0)
    {
      SCmd.readSerial ();
Beispiel #5
0
//control LED using inputs from virtual serial port
//use 'a' and 'd' to cycle through different colors
//use 'w' and 's' to increase or decrease brightness
void control_LED()
{
	for(;;)
	{
		if (RxBuf_NofElements()!=0)
		{
		      while (RxBuf_NofElements()!=0)
		      {
		        uint8_t ch;

		        (void)RxBuf_Get(&ch);
		        LOG_0("echo: ", 6);
		        LOG_0(&ch, 1);
		        LOG_0("\r\n", 2);

		        if (ch=='w' && dc_code<=90)
		        {
		        	dc_code+=10; //increase brightness
		        	LOG_0("Increase brightness\r\n", 21);
		        } else if (ch=='s' && dc_code>=10)
		        {
		        	dc_code-=10; //decrease brightness
		        	LOG_0("Decrease brightness\r\n", 21);
		        } else if (ch=='d' && color_code<7)
		        {
		        	color_code++;
		        	LOG_0("Change color\r\n", 14);
		        }else if (ch=='a' && color_code>0)
		        {
		        	color_code--;
		        	LOG_0("Change color\r\n", 14);
		        }

		        switch (color_code)
		        {
		        	case 0:
		        		PWM_R(dc_code);
		        		break;
		        	case 1:
		        		PWM_G(dc_code);
		        		break;
		        	case 2:
						PWM_B(dc_code);
						break;
					case 3:
						PWM_Y(dc_code);
						break;
					case 4:
						PWM_C(dc_code);
						break;
					case 5:
						PWM_M(dc_code);
						break;
					case 6:
						PWM_W(dc_code);
						break;
					case 7:
						LED_clear();
						break;
					default:
						break;
		        }
		      }
		}
	}
 }