void RTC_IRQHandler(void)
{
#ifdef DEBUG
	/* setup uart to send commands to debug interface */
	//init_uart_interface_for_debuging();

	/* send character indicating RTC time interrupt */
	LeUart_SendChar('r');
	LeUart_SendChar('\n');

	char buff[30];
	sprintf(buff, "Rx: %d\n", rxBuff.wrI);
	LeUart_SendText(buff);

	if (true == rxBuff.overflow)
	{
		LeUart_SendText("Overflow\n");
		for (int i = 0; i < rxBuff.wrI; i++)
		{
			LeUart_SendChar(rxBuff.data[i]);
		}
		RTC_setTime(10000);
	}

	/* transmit received data from gps module */
	if (true == rxBuff.ready)
	{
		for (int i = 0; i < rxBuff.wrI; i++)
		{
			LeUart_SendChar(rxBuff.data[i]);
		}
		LeUart_SendChar('\n');
		clearRxBuffer();
	}

	/* wait */
	//debug_wait();

	/* setup uart to listen for commands from gps module */
	//init_uart_interface();

	/* wait */
	debug_wait();

#endif
	RTC_clearInt();
}
int main(void)
{
	CHIP_Init();
	initOscillators();

	//init_uart_interface();
#ifdef DEBUG
	//init_uart_interface_for_debuging();
	//uart_sendText("GPS module Startup\n");
	init_leuart_interface();
	LeUart_SendText("GPS module Startup\n");
#endif

	//RTC initialization
	RTC_init();
	RTC_setTime(1000);
	RTC_enableInt();
	while(1)
	{
		EMU_EnterEM1();
	}
}
Exemple #3
0
/* This function is called for every incoming unicast packet. */
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
  struct RTC_time t_now;
  struct unicast_message *msg, *tmp, sMsg;
  rimeaddr_t *add;
  /* The packetbuf_dataptr() returns a pointer to the first data byte
     in the received packet. */
  msg = (struct unicast_message *)packetbuf_dataptr();
  if(msg->type==INIT_RESP)
  {
  	rimeaddr_copy(&nmaddr, from);
  	id = msg->id;
  	t_now = msg->time;
  	RTC_setTime(&t_now);
  	q.month = t_now.month;
	q.day = t_now.day;
	q.hours = 18;
	q.minutes = 30;
	q.seconds = 0;
	ioPins_init();
	RTC_setAlarm(&q, alarmCallback, RPT_SECOND);
  }
}
Exemple #4
0
PROCESS_THREAD(test_RTC_process, ev, data)
{ PROCESS_BEGIN();

  leds_off(LEDS_ALL);

	// Set the RTC time to be 12:34:56 on 30/1/15
	//
	struct RTC_time t = {
		0,		// hundredths
		0,		// tenths
		56,		// seconds
		34,		// minutes
		12,		// hours
		30,		// day
		01,		// month
		15		// year
	};

	struct RTC_alarm q = {
		10,		// seconds
		35,		// minutes
		12,		// hours
		30,		// day
		01		// month
	};


	RTC_setTime(&t);

  // Alarm can be set with a callback
  // (or this can be NULL)
	RTC_setAlarm(&q, alarmCallback, RPT_MINUTE);

  int i = 0;

  while(1) {
  	printf("GOING TO SLEEP\n");
		clock_delay_msec(50);

		/* ------------
		 * Go to sleep
     * ------------
		 */

  	*CRM_SLEEP_CNTL = 0x71; 				// hibernate, keep all RAM pages, retain state, don't power GPIO, approx. 2kHz = 16.1uA 

    while((*CRM_STATUS & 0x1) == 0)	// wait for the sleep cycle to complete
    { continue; }
  
    *CRM_STATUS = 1;								// write 1 to sleep_sync --- this clears the bit (it's a r1wc bit) and powers down

		/* ------------
		 * Wake up again
     * ------------
		 */
  	printf("AWAKE AGAIN\n");
	  for (i = 0; i < 2; i++)
			FLASH_LED(LEDS_ALL);

		PROCESS_YIELD();

		RTC_getTime(&t);
		printf("%02d/%02d/%02d %02d:%02d:%02d.%d%d\n", t.day, t.month, t.year, t.hours, t.minutes, t.seconds, t.tenths, t.hundredths);

  }

  PROCESS_END();
}
Exemple #5
0
// Reset the XML buffers
void XML_resetData(){
  XML_Data_Length = 0;
  
  // Reset the RTC to get a proper graph
  RTC_setTime(0, 0, 0);
}