Пример #1
0
/*******************************************************************************
* Function Name  : main.
* Description    : talk main routine.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void main(void)
{
  u8 i;
  u32 seed;
  StStatus status = ST_SUCCESS;
  
  /* Initialization */
  halInit();
  ST_RadioGetRandomNumbers((u16 *)&seed, 2);
  halCommonSeedRandom(seed);
  uartInit(115200, 8, PARITY_NONE, 1);
  INTERRUPTS_ON();
 
  /* init leds */
  halInitLed(); 
  
  /* Initialize radio (analog section, digital baseband and MAC).
  Leave radio powered up in non-promiscuous rx mode */
  status = ST_RadioInit(ST_RADIO_POWER_MODE_RX_ON);
  assert(status==ST_SUCCESS); 

  /* Setup some node and pan ids.  The packet above is also sent to a device
     with the same node and pan id so that two nodes running this same image
     will talk to each other, even though its not right to have two nodes
     with the same node id */
  ST_RadioSetNodeId(0x1604);
  ST_RadioSetPanId(0x1604);

  printf("\r\nSimpleMAC (%s) Talk Application\r\n",SIMPLEMAC_VERSION_STRING);

  while(1) {

    processSerialInput();

    /* print out any packets that were received */
    if(packetReceived == TRUE) {
      for (i = 8; i <= rxPacket[0]; i++)
        putchar(rxPacket[i]);
      /* The packet has been processed, so free the single entry queue up */
      packetReceived = FALSE;
    }
    ledTime++;
    if (ledTime > 20000) 
    {
      halToggleLed(LED_D1);
      ledTime = 0;
    }
  }
}/* end main ()*/
Пример #2
0
int main (void)
{
  u8 returnValue;
  u32 seed;

  interactive = 1;

  halInit();
  ST_RadioGetRandomNumbers((u16 *)&seed, 2);
  halCommonSeedRandom(seed);
  uartInit(115200, 8, PARITY_NONE, 1);
  INTERRUPTS_ON();  

  /* Initialize radio (analog section, digital baseband and MAC).
  Leave radio powered up in non-promiscuous rx mode */
  returnValue = ST_RadioInit(ST_RADIO_POWER_MODE_RX_ON);

  assert(returnValue==ST_SUCCESS); 

  TIMER_Init();

  printf("Bootloader demo application\r\n");
  
  responsePrintf("{&N API call... &t2x}\r\n", "halGetResetInfo", "resetInfo", 0);

  txBufferInit(FALSE);
  rxBufferInit();
  blInit(NULL, transmitByte, receiveByte);

  ST_RadioSetPanId(IAP_BOOTLOADER_PAN_ID);
  ST_RadioSetChannel(IAP_BOOTLOADER_DEFAULT_CHANNEL);

  commandReaderInit();

  while(1) {
    // Process input and print prompt if it returns TRUE.
    if (processCmdInput(interactive)) {
      if (interactive) {
	printf(">");
      }
      TIMER_Tick();
    }
  }
}