Exemplo n.º 1
0
void ShellService::executeCommand(std::string command) {

	if (std::strcmp("exit", command.c_str()) == 0) {
		echo('x');
		//echo("can't shut down the one and only shell.");
	} else if (std::strcmp("help", command.c_str()) == 0) {
	   echo('h');
		//echo("if you're using BOSS you should be a fkn geek and wouldn't need any help.");
	} else if (std::strcmp("led toggle 1", command.c_str()) == 0) {
        toggleLED(LED1);
    } else if (std::strcmp("led toggle 2", command.c_str()) == 0) {
        toggleLED(LED2);
    } else if (std::strcmp("led on 1", command.c_str()) == 0) {
        switchLEDOn(LED1);
    } else if (std::strcmp("led on 2", command.c_str()) == 0) {
        switchLEDOn(LED2);
    } else if (std::strcmp("led off 1", command.c_str()) == 0) {
        switchLEDOff(LED1);
    } else if (std::strcmp("led off 2", command.c_str()) == 0) {
        switchLEDOff(LED2);
    } else if (std::strcmp("led read 1", command.c_str()) == 0) {
        echo((char)(getLEDState(LED1) + '0'));
    } else if (std::strcmp("led read 2", command.c_str()) == 0) {
        echo((char)(getLEDState(LED2) + '0'));
    } else if (std::strcmp("launch test", command.c_str()) == 0) {
        int params[] = {0};
        performSystemCall(EXEC, 1, params);
    } else if (std::strcmp("launch test1", command.c_str()) == 0) {
        int params[] = {1};
        performSystemCall(EXEC, 1, params);
    }
}
Exemplo n.º 2
0
static void linkTo()
{
  uint8_t  msg[10], delay = 0;
  memset(msg, 0, 10);

  while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))
  {
    /* blink LEDs until we link successfully */
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND;
  }

  /* we're linked. turn off red LED. received messages will toggle the green LED. */
  if (BSP_LED2_IS_ON())
  {
    toggleLED(2);
  }

  /* turn on RX. default is RX off. */
  SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);

  /* put LED to toggle in the message */
  msg[0] = 2;  /* toggle red */
  while (1)
  {
	__bis_SR_register(LPM4_bits + GIE);       // Enter LPM4 w/interrupt
    SPIN_ABOUT_A_SECOND;
    if (delay > 0x00)
    {
      SPIN_ABOUT_A_SECOND;
    }
    if (delay > 0x01)
    {
      SPIN_ABOUT_A_SECOND;
    }
    if (delay > 0x02)
    {
      SPIN_ABOUT_A_SECOND;
    }

    /* delay longer and longer -- then start over */
    delay = (delay+1) & 0x03;
    /* put the sequence ID in the message */
    msg[9] = ++sTxTid;
    ReadRTCCTimeDate(&Rtcctimedate);
    /* put data into packet */
    msg[1] = Rtcctimedate.Sec;
    msg[2] = Rtcctimedate.Min;
    msg[3] = Rtcctimedate.Hour;
    msg[4] = Rtcctimedate.Day;
    msg[5] = Rtcctimedate.Date;
    msg[6] = Rtcctimedate.Month;
    msg[7] = Rtcctimedate.Year;
    SMPL_Send(sLinkID1, msg, sizeof(msg));
  }
}
Exemplo n.º 3
0
void TestTask::start()  {
	while(1)  {
		toggleLED(LED1);
		for (int z = 0; z < 80000;) {
			z++;
		}
		toggleLED(LED2);
		for (int z = 0; z < 80000;) {
			z++;
		}
	}
}
Exemplo n.º 4
0
void turnOffLeds(void)
{
	/* turn on LEDs. */
	if (BSP_LED2_IS_ON())
	{
		toggleLED(2);
	}
	if (BSP_LED1_IS_ON())
	{
		toggleLED(1);
	}
}
static void linkFrom()
{
  uint8_t     msg[2], tid = 0;
  
  /* Turn off one LED so we can tell the device is now listening.
   * Received messages will toggle the other LED.
   */
  //toggleLED(1);
  
  /* listen for link forever... */
  while (1)
    {
      if (SMPL_SUCCESS == SMPL_LinkListen(&sLinkID2))
	{
	  break;
	}
      /* Implement fail-to-link policy here. otherwise, listen again. */
    }
  /* we're linked. turn off red LED. Received messages will toggle the green LED. */
  if (BSP_LED2_IS_ON())
    {
      toggleLED(2);
    }
  
  if (BSP_LED1_IS_ON())
    {
      toggleLED(1);
    }
  
  /* turn on LED1 on the peer in response to receiving a frame. */
  *msg = 0x01;  /* toggle red led */
  
  /* turn on RX. default is RX off. */
  SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
  
   while (1)
   {
     /* Wait for a frame to be received. The Rx handler, which is running in
      * ISR thread, will post to this semaphore allowing the application to
      * send the reply message in the user thread.
      */
     if (sSemaphore)
     {
       *(msg+1) = ++tid;
       SMPL_Send(sLinkID2, msg, 2);

       /* Reset semaphore. This is not properly protected and there is a race
        * here. In theory we could miss a message. Good enough for a demo, though.
        */
       sSemaphore = 0;
     }
   }
}
Exemplo n.º 6
0
void main (void)
{
  BSP_Init();

  /* If an on-the-fly device address is generated it must be done before the
   * call to SMPL_Init(). If the address is set here the ROM value will not
   * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call
   * will not take effect. One shot only. The IOCTL call below is conformal.
   */
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
  {
    addr_t lAddr;
	lAddr.addr[0]=0x35;
	lAddr.addr[1]=0x35;
	lAddr.addr[2]=0x35;
	lAddr.addr[3]=0x35;

    //createRandomAddress(&lAddr);
    SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
  }
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */

  /* This call will fail because the join will fail since there is no Access Point
   * in this scenario. But we don't care -- just use the default link token later.
   * We supply a callback pointer to handle the message returned by the peer.
   */
  SMPL_Init(sRxCallback);

  /* turn on LEDs. */
  if (!BSP_RED_LED_IS_ON())
  {
    toggleLED(RED);
  }
  if (!BSP_GREEN_LED_IS_ON())
  {
    toggleLED(GREEN);
  }

  /* wait for a button press... */
  do {
    if (BSP_BUTTON() )
    {
      break;
    }
  } while (1);

  /* never coming back... */
  linkFrom();

  /* but in case we do... */
  while (1) ;
}
Exemplo n.º 7
0
void loop() {
    delay(250);
    toggleLED();

    if (isButtonPressed()) {
        if (servo1.attached()) detach();
        else                   attach();
    }

    if (!servo1.attached()) return;

    int32 average = averageAnalogReads(250);
    int16 angle1 = (int16)map(average, 0, 4095, MIN_ANGLE1, MAX_ANGLE1);
    int16 angle2 = (int16)map(average, 0, 4095, MIN_ANGLE2, MAX_ANGLE2);

    print_buf("pot reading = %d, angle 1 = %d, angle 2 = %d.",
              average, angle1, angle2);

    servo1.write(angle1);
    servo2.write(angle2);

    int16 read1 = servo1.read();
    int16 read2 = servo2.read();

    print_buf("write/read angle 1: %d/%d, angle 2: %d/%d",
              angle1, read1, angle2, read2);

    ASSERT(abs(angle1 - read1) <= 1);
    ASSERT(abs(angle2 - read2) <= 1);

    print_buf("pulse width 1: %d, pulse width 2: %d",
              servo1.readMicroseconds(), servo2.readMicroseconds());

     Serial2.println("\n--------------------------\n");
}
Exemplo n.º 8
0
/******************************************************************************
*                            GET SERIAL COMMAND DATA                          *
*******************************************************************************
* Description: Moves any new serial command data from serial data buffer to 
*              command buffer then checks for end of command ("\n").  If end
*              of command is found then the command is processed.
*
*              Supported special characters:
*                '\n'   10(0x0A) line feed
*                '\r'   13(0x0D) carriage return - end of command
*                
*
*      Global: cmdBuf[CMD_BUFFER_SIZE];
*              ptrCmdBuf
*              rxBuf[RX_BUFFER_SIZE] - circular buffer for RX data
*              ptrRxBufStart         - data extraction point in RX buffer
*              ptrRxBufEnd           - next insert point in RX buffer
*
*   Arguments: None
*
*      Return: None
******************************************************************************/
void getCommandData(void)
{   
    uint8_t ser_data;
    
    while(ptrRxBufStart != ptrRxBufEnd)
    {
        // get data byte
        ser_data = rxBuf[ptrRxBufStart++];
        if(ptrRxBufStart == RX_BUFFER_SIZE)
            ptrRxBufStart = 0;
            
        // process special characters
        if(ser_data == '\r')    // carriage return
        {
            // end of command
            printf("\r\n>");
            cmdBuf[ptrCmdBuf] = '\0';
            processSerialCommand((char *)cmdBuf);
            ptrCmdBuf = 0;
            cmdBuf[0] = '\0';
        }
        else
        { 
        // move data to command buffer
        cmdBuf[ptrCmdBuf++] = ser_data;
        if(ptrCmdBuf == CMD_BUFFER_SIZE)
            ptrCmdBuf = 0;
            
        // terminate command string
        cmdBuf[ptrCmdBuf] = '\0';
        }               
        toggleLED();
    }     
}
Exemplo n.º 9
0
static void start2Babble()
{
	uint8_t msg[1];

	/* frequency hopping doesn't support sleeping just yet */
#ifndef FREQUENCY_HOPPING
	/* wake up radio. */
	SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
#endif

	/* Send the bad news message. To prevent confusion with different "networks"
	 * such as neighboring smoke alarm arrays send a token controlled by a DIP 
	 * switch, for example, and filter in this token. 
	 */
	msg[0] = BAD_NEWS;
	while (1)
	{
		FHSS_ACTIVE( nwk_pllBackgrounder( false ) ); /* manage FHSS */
		/*wait "a while" */
		NWK_DELAY(100);
		/* babble... */
		SMPL_Send(SMPL_LINKID_USER_UUD, msg, sizeof(msg));
		toggleLED(2);
	}
}
Exemplo n.º 10
0
void loop(void) {
    toggleLED();
    delay(100);

    dma_channel_reg_map *ch_regs = dma_channel_regs(USART_DMA_DEV,
                                   USART_RX_DMA_CHANNEL);
    if (irq_fired) {
        USART_HWSER.println("** IRQ **");
        while (true)
            ;
    }
    USART_HWSER.print("[");
    USART_HWSER.print(millis());
    USART_HWSER.print("]\tISR bits: 0x");
    uint8 isr_bits = dma_get_isr_bits(USART_DMA_DEV, USART_RX_DMA_CHANNEL);
    USART_HWSER.print((int32)isr_bits, HEX);
    USART_HWSER.print("\tCCR: 0x");
    USART_HWSER.print((int64)ch_regs->CCR, HEX);
    USART_HWSER.print("\tCNDTR: 0x");
    USART_HWSER.print((int64)ch_regs->CNDTR, HEX);
    USART_HWSER.print("\tBuffer contents: ");
    for (int i = 0; i < BUF_SIZE; i++) {
        USART_HWSER.print('\'');
        USART_HWSER.print(rx_buf[i]);
        USART_HWSER.print('\'');
        if (i < BUF_SIZE - 1) USART_HWSER.print(", ");
    }
    USART_HWSER.println();
    if (isr_bits == 0x7) {
        USART_HWSER.println("** Clearing ISR bits.");
        dma_clear_isr_bits(USART_DMA_DEV, USART_RX_DMA_CHANNEL);
    }

    irq_fired = 0;
}
Exemplo n.º 11
0
void board_start(const char* program_name)
{
  // Set up the LED to steady on
  pinMode(BOARD_LED_PIN, OUTPUT);
  digitalWrite(BOARD_LED_PIN, HIGH);

  // Setup the button as input
  pinMode(BOARD_BUTTON_PIN, INPUT);
  digitalWrite(BOARD_BUTTON_PIN, HIGH);

  SerialUSB.begin();
  SerialUSB.println("Press BUT");

  // Wait for button press
  while ( !isButtonPressed() )
  {
  }

  SerialUSB.println("Welcome!");
  SerialUSB.println(program_name);

  int i = 11;
  while (i--)
  {
    toggleLED();
    delay(50);
  }
}
int main (void)
{
  WDTCTL = WDTPW + WDTHOLD;
  BSP_Init();

  /* If an on-the-fly device address is generated it must be done before the
   * call to SMPL_Init(). If the address is set here the ROM value will not
   * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call
   * will not take effect. One shot only. The IOCTL call below is conformal.
   */
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
  {
    addr_t lAddr;

    createRandomAddress(&lAddr);
    SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
  }
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */

  /* This call will fail because the join will fail since there is no Access Point
   * in this scenario. But we don't care -- just use the default link token later.
   * We supply a callback pointer to handle the message returned by the peer.
   */

  toggleLED(1);

  SMPL_Init(sRxCallback);

  /* turn on LEDs. */
  toggleLED(2);
  NWK_DELAY(500);
  int i;
  for (i = 10; --i >= 0; ) {
    toggleLED(1);
    toggleLED(2);
    NWK_DELAY(100);
  }
  toggleLED(2);


  /* never coming back... */
  linkFrom();

  /* but in case we do... */
  while (1) ;
}
Exemplo n.º 13
0
void DmxClass::send(void) {
    SerialUSB.println("DMX send");
    if (DEBUG_LED) { toggleLED(); }
    this->headerIndex = 0;
    this->channelIndex = 0;
    this->bitIndex = 0;
    timer_resume(this->dmx_timer);
}
Exemplo n.º 14
0
void savePatch(byte p) {
  debugprintln("saving patch ", p);
  cli();
  uint16_t addr = PATCH_BASE_ADDR + (p * PATCH_SIZE);
  uint16_t startAddr = addr;
  addr = writeWord(addr, PATCH_VALID_MARK);
  for(byte i=0;i<N_SETTINGS;i++) {
    toggleLED(p);
    addr = writeWord(addr, settings[i].attackVolLevelDuration);
    addr = writeWord(addr, settings[i].decayVolLevelDuration);
    uint16_t sustain = (settings[i].sustainVolLevel * 1000);
    addr = writeWord(addr, sustain);
    toggleLED(p);
    addr = writeWord(addr, settings[i].releaseVolLevelDuration);
    int16_t detune = (settings[i].detune * 1024);
    addr = writeWord(addr, detune);
    addr = writeByte(addr, settings[i].waveform);
  }

  toggleLED(p);
  addr = writeWord(addr, filterCutoff);
  addr = writeWord(addr, filterResonance);
  addr = writeByte(addr, lfoWaveform);

  if (mode == MODE_GROOVEBOX) {
    addr = writeWord(addr, SEQUENCE_VALID_MARK);
    for(byte t=0;t<SEQ_NUM_TRACKS;t++) {
      toggleLED(p);
      uint16_t volume = track[t].volumeScale * 1023;
      addr = writeWord(addr, volume);
      for(byte s=0;s<SEQ_LENGTH;s++) {
	toggleLED(p);
	addr = writeByte(addr, seq[s][t].midiVal);
	addr = writeByte(addr, seq[s][t].velocity);
	addr = writeByte(addr, seq[s][t].waveform);
	addr = writeWord(addr, seq[s][t].duration);
	addr = writeWord(addr, seq[s][t].startPulse);
      }
    }
    
  }
  digitalWrite(led[p], LOW);
  debugprintln("size = ", addr-startAddr);
  debugprintln("end address = ", addr);
  sei();
}
Exemplo n.º 15
0
/* handle received messages */
static uint8_t sRxCallback(linkID_t port)
{
  uint8_t msg[2], len, tid;

  /* is the callback for the link ID we want to handle? */
  if (port == sLinkID2)
  {
    /* yes. go get the frame. we know this call will succeed. */
     if ((SMPL_SUCCESS == SMPL_Receive(sLinkID2, msg, &len)) && len)
     {
       /* Check the application sequence number to detect
        * late or missing frames...
        */
       tid = *(msg+1);
       if (tid)
       {
         if (tid > sRxTid)
         {
           /* we're good. toggle LED */
           toggleLED(*msg);
           sRxTid = tid;
         }
       }
       else
       {
         /* wrap case... */
         if (sRxTid)
         {
           /* we're good. toggle LED */
           toggleLED(*msg);
           sRxTid = tid;
         }
       }
       /* Post to the semaphore to let application know so it sends
        * the reply
        */
       sSemaphore = 1;
       /* drop frame. we're done with it. */
       return 1;
     }
  }
  /* keep frame for later handling */
  return 0;
}
Exemplo n.º 16
0
void loop() {
    toggleLED();
    delay(100);
    toggleLED();

    for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) {
        if (boardUsesPin(i))
            continue;

        // Bring just this pin high.
        digitalWrite(i, HIGH);
        // Give the master time to detect if any other pins also went high.
        interToggleDelay();
        // Bring this pin back low again; all pins should now be low.
        digitalWrite(i, LOW);
        // Give the master time to detect if any pins are still high.
        interToggleDelay();
    }
}
void main (void)
{
  BSP_Init();

  /* If an on-the-fly device address is generated it must be done before the
   * call to SMPL_Init(). If the address is set here the ROM value will not
   * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call
   * will not take effect. One shot only. The IOCTL call below is conformal.
   */
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
  {
    addr_t lAddr;

    createRandomAddress(&lAddr);
    SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
  }
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */

  /* Keep trying to join (a side effect of successful initialization) until
   * successful. Toggle LEDS to indicate that joining has not occurred.
   */
  while (SMPL_SUCCESS != SMPL_Init(0))
  {
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND;
  }

  /* LEDs on solid to indicate successful join. */
  if (!BSP_LED2_IS_ON())
  {
    toggleLED(2);
  }
  if (!BSP_LED1_IS_ON())
  {
    toggleLED(1);
  }

  /* Unconditional link to AP which is listening due to successful join. */
  linkTo();

  while (1) ;
}
Exemplo n.º 18
0
int main (void)
{
	BSP_Init();

	/* If an on-the-fly device address is generated it must be done before the
	 * call to SMPL_Init(). If the address is set here the ROM value will not 
	 * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call 
	 * will not take effect. One shot only. The IOCTL call below is conformal.
	 */
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
	{
		addr_t lAddr;

		createRandomAddress(&lAddr);
		SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
	}
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */

	/* This call will fail because the join will fail since there is no Access Point
	 * in this scenario. but we don't care -- just use the default link token later.
	 * we supply a callback pointer to handle the message returned by the peer.
	 */
	SMPL_Init(0);

	/* turn on LEDs. */
	if (!BSP_LED2_IS_ON())	toggleLED(2);
	if (!BSP_LED1_IS_ON())	toggleLED(1);

	/* wait for a button press... */
	do
	{
		FHSS_ACTIVE( nwk_pllBackgrounder( false ) ); /* manage FHSS */
		if (BSP_BUTTON1() || BSP_BUTTON2())
			break;
	} while (1);

	/* never coming back... */
	monitorForBadNews();

	/* but in case we do... */
	while (1) ;
}
Exemplo n.º 19
0
void linkToRep() {

   // listen for link forever... 
   while (SMPL_SUCCESS != SMPL_LinkListen(&myLinkID)) {
      /* Implement fail-to-link policy here. otherwise, listen again. */
      toggleLED(2); // red led
   }

   /* turn on RX. default is RX off. */
   SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
}
Exemplo n.º 20
0
void eepromClear() {
  cli();
  for(int i=0;i<2048;i++) {
    if ((i % 8) == 0) {
      toggleLED(0);
    }
    writeByte(i, 0);
  }
  digitalWrite(led[0], LOW);
  sei();
}
Exemplo n.º 21
0
/* handle received frames. */
static uint8_t sRxCallback(linkID_t port)
{
  uint8_t msg[10], len, tid;
  memset(msg, 0, 10);

  /* is the callback for the link ID we want to handle? */
  if (port == sLinkID1)
  {
    /* yes. go get the frame. we know this call will succeed. */
     if ((SMPL_SUCCESS == SMPL_Receive(sLinkID1, msg, &len)) && len)
     {
       /* Check the application sequence number to detect
        * late or missing frames... 
        */
       tid = *(msg+9);
       if (tid)
       {
         if (tid > sRxTid)
         {
           /* we're good. toggle LED in the message */
           toggleLED(*msg);
           sRxTid = tid;
         }
       }
       else
       {
         /* the wrap case... */
         if (sRxTid)
         {
           /* we're good. toggle LED in the message */
           toggleLED(*msg);
           sRxTid = tid;
         }
       }
       /* drop frame. we're done with it. */
       return 1;
     }
  }
  /* keep frame for later handling. */
  return 0;
}
Exemplo n.º 22
0
int main(void){
  PLL_Init();                  // configure for 50 MHz clock
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOD;
	SysTick_Init();
  buttonInit();
	musicInit();
	DAC_Init(0xC000);
  setChangeTrackFunction(&changeTrack);
  while(1){
		toggleLED(2);
  }
}
Exemplo n.º 23
0
void loop() {
    toggleLED();
    delay(100);

    count += 100;
    if (count > 4095) {
        count = 0;
    }

    dac_write_channel(DAC, 1, 4095 - count);
    dac_write_channel(DAC, 2, count);
}
Exemplo n.º 24
0
int __attribute__((noreturn)) main(void)
{
    unsigned int blink_cnt = 0;

    /* initialize hardware */
    bootLoaderInit();
    /*
     * Calling the function below for it to get included in the bootloader.
     * Also, making sure that it actually doesn't do anything. And hence,
     * passing an unaligned address 0x0001, for the function to fail.
     */
#if (FLASHEND) > 0xFFFF
    flash_write_block(0x00000001, NULL);
#else
    flash_write_block(0x0001, NULL);
#endif
    odDebugInit();
    DBG1(0x00, 0, 0);
    /* jump to application if jumper is set */
    if(bootLoaderCondition()){
#ifndef TEST_MODE
        uint8_t gicr;

        gicr = GICR;
        GICR = gicr | (1 << IVCE);  /* enable change of interrupt vectors */
        GICR = gicr | (1 << IVSEL); /* move interrupts to boot flash section */
#endif
        DBG1(0x02, 0, 0);
        initForUsbConnectivity();
        do{ /* main event loop */
            //DBG2(0x03, 0, 0);
            wdt_reset();
            usbPoll();

            /* The following piece of code indicates being in bootloader */
            if (++blink_cnt == 60000)
            {
                blink_cnt = 0;
                toggleLED();
                //DBG2(0x04, 0, 0);
            }

            //DBG2(0x05, 0, 0);
#if BOOTLOADER_CAN_EXIT
            if(exitMainloop){
                break;
            }
#endif
        }while(1);
    }
    leaveBootloader();
}
static void processMessage(linkID_t lid, uint8_t *msg, uint8_t len)
{
  /* do something useful */
  if (len)
  {
    toggleLED(*msg);
    *msg |= NWK_APP_REPLY_BIT;
#ifdef FREQUENCY_AGILITY
    /* send ack frame... */
    SMPL_Send(lid, msg, len);
#endif
  }
  return;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->statusBar->showMessage("Qt to Arduino HDLC command router example", 3000);
    serial = new QSerialPort(this);
    this->fillPortsInfo();
    HDLC_qt* hdlc = HDLC_qt::instance();

    QObject::connect(hdlc, SIGNAL(hdlcTransmitByte(QByteArray)),
                     this, SLOT(putChar(QByteArray)));

    QObject::connect(hdlc, SIGNAL(hdlcTransmitByte(char)),
                     this, SLOT(putChar(char)));

    QObject::connect(hdlc, SIGNAL(hdlcValidFrameReceived(QByteArray, quint16)),
                     this, SLOT(HDLC_CommandRouter(QByteArray, quint16)));

    // All data coming from serial port (should go straight to HDLC validation)
    QObject::connect(this, SIGNAL(dataReceived(QByteArray)),
                     hdlc, SLOT(charReceiver(QByteArray)));

    // Allso echo chars HEX value
    QObject::connect(this, SIGNAL(dataReceived(QByteArray)),
                     this, SLOT(print_hex_value(QByteArray)));

    QObject::connect(this, SIGNAL(sendDataFrame(QByteArray, quint16)),
                     hdlc, SLOT(frameDecode(QByteArray, quint16)));

    QObject::connect(ui->pushButton_connect, SIGNAL(clicked()),
                     this, SLOT(openSerialPort()));

    QObject::connect(serial, SIGNAL(readyRead()),
                     this, SLOT(readData()));

    QObject::connect(ui->dial, SIGNAL(valueChanged(int)),
                     this, SLOT(setServoPosition()) );

    QObject::connect(ui->pushButton_echo, SIGNAL(clicked()),
                     this, SLOT(sendEcho()) );

    QObject::connect(ui->pushButton_LED, SIGNAL(clicked()),
                     this, SLOT(toggleLED()) );
}
Exemplo n.º 27
0
//"driver" function
static void taskToggleAnLED(void *pvParameters)
{
    xTaskParameter_t *pxTaskParameter;
    //portTickType xStartTime;

    /* The parameter points to an xTaskParameters_t structure. */
    pxTaskParameter = (xTaskParameter_t *) pvParameters;

    struct LEDMessage *pxRxedMessage;
    struct LEDMessage pxAllocMessage;
    uint8_t MessageIDtest = 0;

    int delay = 500;

    pxRxedMessage = &pxAllocMessage;

    while (1)
    {
        if(xLEDQueue[pxTaskParameter->usLEDNumber] != 0) // make sure the queue isn't null
        {
            if( uxQueueMessagesWaiting( xLEDQueue[pxTaskParameter->usLEDNumber] ) != 0 )
            {
                if( xQueueReceive( xLEDQueue[pxTaskParameter->usLEDNumber], ( &pxRxedMessage ), ( TickType_t ) 0 ) )
                {
                    // pcRxedMessage now points to the struct AMessage variable posted
                    // by vATask.
                    MessageIDtest = pxRxedMessage->ucMessageID;
                    //led_test = pxRxedMessage->LEDNum;

                    delay = pxRxedMessage->LEDDelay;
                }
                else
                {
                    //a = 0;
                }
            }
        }
        //no matter what, start out by toggling every 500ms
        toggleLED(pxTaskParameter->usLEDNumber);
        vTaskDelay(delay);
        
    }
}
Exemplo n.º 28
0
void setup()
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5);
	//Configure pins due to bit banging
        //Transfer pin to lcd
	GPIOPinConfigure(GPIO_PB1_U1TX);
        //Receiving pin from usb
	GPIOPinConfigure(GPIO_PE4_U5RX);
        //Transfer pin to usb
	GPIOPinConfigure(GPIO_PE5_U5TX);
        //LED pin
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
        //lcd pin
	GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_1);
        //usb pins
	GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);

	//Initialize the UART. 
	//Baud rate - Data bits - turn off parity - stop bits --- 9600 - 8 - Off - 1
	UARTConfigSetExpClk(b1, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
	UARTEnable(b1);
	UARTConfigSetExpClk(b5, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
	UARTEnable(b5);
	toggleLED();
	changeCursorUnderscore();
	clearDisplay();		
	putPhrase("Hello World!");  
	SysCtlDelay(3000000);
	clearDisplay();		

	//Test terminal
	UARTCharPut(b5, 'h');
	UARTCharPut(b5, 'e');
	UARTCharPut(b5, 'l');
	UARTCharPut(b5, 'l');
	UARTCharPut(b5, 'o');

}
Exemplo n.º 29
0
void loop() {
    volatile int i = 0;
    toggleLED();

    // An artificial delay
    for(i = 0; i < 150000; i++)
        ;

    if (isButtonPressed()) {
        if (disable) {
            systick_disable();
            SerialUSB.println("Disabling SysTick");
        } else {
            SerialUSB.println("Re-enabling SysTick");
            systick_enable();
        }
        disable = !disable;
    }

    SerialUSB.println(millis());
}
Exemplo n.º 30
0
void DmxClass::handler(void) {
    digitalWrite(this->dmx_tx1_pin, this->bitBuffer);
    if (this->channelIndex == this->number_of_channels) {
        timer_pause(this->dmx_timer);
        this->bitBuffer = END_OF_PACKET_BIT;
        if (DEBUG_LED) { toggleLED(); }
        SerialUSB.println("end of packet");
    }
    else if (this->headerIndex < SIZE_OF_HEADER) {
        SerialUSB.print(headerIndex, DEC);
        this->bitBuffer = this->header();
        headerIndex++;
        if (headerIndex >= SIZE_OF_HEADER) { SerialUSB.println(); }
    }
    else {
        switch ( this->bitIndex ) {
            case 0:
              this->bitBuffer = START_BIT;
              this->bitIndex++;
              SerialUSB.print("chan: ");
              SerialUSB.println(channelIndex, DEC);
              break;
            case 10:
              this->bitBuffer = STOP_BIT;
              this->bitIndex = 0;
              this->channelIndex++;
              SerialUSB.println();
              break;
            case 9: 
              this->bitBuffer = STOP_BIT;
              this->bitIndex++;
              break;
            default: // channel data: cases 1 through 8
              this->bitBuffer = bitRead(this->channel[this->channelIndex], this->bitIndex - 1);
              SerialUSB.print(bitBuffer, DEC);
              this->bitIndex++;
              break;
        }
    }
}