/***************************************************************************
 * Copyright (c) 2005, Research Group Embedded Interaction                 *
 * Matthias Kranz <matthias@hcilab.org>                                    *
 * Paul Holleis <paul@hcilab.org>                                          *
 * Albrecht Schmidt <albrecht@hcilab.org>                                  *
 * All rights reserved.                                                    *
 *                                                                         *
 * Redistribution and use in source and binary forms, with or without      *
 * modification, are permitted provided that the following conditions      *
 * are met:                                                                *
 *                                                                         *
 *    * Redistributions of source code must retain the above copyright     *
 *      notice, this list of conditions and the following disclaimer.      *
 *    * Redistributions in binary form must reproduce the above copyright  *
 *      notice, this list of conditions and the following disclaimer in    *
 *      the documentation and/or other materials provided with the         *
 *      distribution.                                                      *
 *    * Neither the name of the <ORGANIZATION> nor the names of its        *
 *      contributors may be used to endorse or promote products derived    *
 *      from this software without specific prior written permission.      *
 *                                                                         *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       *
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR   *
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT    *
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   *
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        *
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   *
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON       *
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR      *
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF      *
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH    *
 * DAMAGE.                                                                 *
 **************************************************************************/
// APPLICATION FILE
// uses ACK, RTC & PRS.

// own pins and stuff
#include "template.h" 


// this function is called from the fsm at the end of an rf slot
// make sure that it terminates in time
#separate
void SlotEndCallBack()
{
  RTCUpdate();
  ACLACKRun();
  SDJSRun();
}


void main()
{
  // variable declarations go here
  byte test[10];


  //TYPICAL STARTUP FLOW
  //*****************************************************************
  // check if board is there, doesn't harm any settings, those are restored
  if (PCSelfTestBoardIsThere()) PCSelfTest(test);
  // is not dangerous, because all pins are set correct . 
  // bport is input, i2c and eeprom are initianlized as well
  PCInit();                     
  //SSimpInit();
  // init the stack and start it
  ACLInit();                      
  // must be done before lifesign and
  enable_interrupts(global);              

  //send out the result until board is away
  // PCSelfTestBoardIsThere(): this function does 
  // not harm the settings (it restores always)
  while (PCSelfTestBoardIsThere())          
  
  {
    if (!ACLSendingBusy())
    {
      ACLAddNewType(ACL_TYPE_CST_HI,ACL_TYPE_CST_LO);
      ACLAddData(test[0]);
      ACLAddData(test[1]);
      ACLAddData(test[2]);
      ACLAddData(test[3]);
      ACLAddData(test[4]);
      ACLAddData(test[5]);
      ACLAddData(test[9]);
      ACLSendPacket(30);
    }
    //2  packets a second is enough
    DelayMs(500);                 
  }

  // now start your code here
  /*
  // e.g.: display board init
  SDisplayInit();
  // go on with initialization of the sensors
  SDisplaySensorsInit();
  // turn off sensors after initialization
  SDisplaySensorsOff();
  */
  
  // init the rest:
  ACLACKInit();
  RTCInit();
  SDJSInit();

  // rest of your code goes here:
  while(TRUE)
  {
    // code 
    //int i = 0;
    //char a = 'a';
    //int kla = 99;
    //int i = 0;
    //int j = 0;
    //int lalal = 0;
    //
    int i = 0;
  }
}




