Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/Server.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/Server.h	(revision 253)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/Server.h	(revision 259)
@@ -21,4 +21,6 @@
 #define server_h
 
+#include "Print.h"
+
 class Server : public Print {
 public:
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/USB/USBCore.cpp
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/USB/USBCore.cpp	(revision 253)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/USB/USBCore.cpp	(revision 259)
@@ -44,5 +44,5 @@
 
 #define USB_PID_ZERO_PRO	0x804d
-#define USB_PRODUCT "Arduino M0 Pro"
+
 #ifndef USB_PRODUCT
 // Use a hardcoded product name if none is provided
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/README.adoc
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/README.adoc	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/README.adoc	(revision 259)
@@ -0,0 +1,24 @@
+= RTC Library for Arduino =
+
+The RTC library enables an Arduino Zero board to take control of the internal RTC.
+
+For more information about this library please visit us at
+http://arduino.cc/en/Reference/RTC
+
+== License ==
+
+Copyright (c) Arduino LLC. All right reserved.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_interrupt/ALARM_interrupt.ino
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_interrupt/ALARM_interrupt.ino	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_interrupt/ALARM_interrupt.ino	(revision 259)
@@ -0,0 +1,54 @@
+/*****************************************************************************************************************************************************************************
+* This sketch demonstrate how to use alarm in interrupt mode.
+This mode is more conveniently because you use processor for other tasks and when alarm match occurs interrupt routine is executed.
+In this way, alarm flag checking is indipendent from main program flow.
+
+NOTE: for M0/M0 pro only you can select the oscillator source for count.
+If you want to use a low power oscillator use rtc.begin(TIME_H24, LOW_POWER); function.
+If you want to use a more accurate oscillator use rtc.begin(TIME_H24, HIGH_PRECISION); function.
+******************************************************************************************************************************************************************************/
+
+
+#include <RTCInt.h>
+
+RTCInt rtc;
+
+void setup() 
+{
+  Serial.begin(9600);       //serial communication initializing
+  pinMode(13,OUTPUT);
+  rtc.begin(TIME_H24);      //RTC initializing with 24 hour representation mode
+  rtc.setTime(17,0,5,0);    //setting time (hour minute and second)
+  rtc.setDate(13,8,15);     //setting date
+  rtc.enableAlarm(SEC,ALARM_INTERRUPT,alarm_int); //enabling alarm in polled mode and match on second
+  rtc.time.hour=17;
+  rtc.time.minute=5;
+  rtc.time.second=10;  //setting second to match
+  rtc.setAlarm();  //write second in alarm register
+}
+
+void loop()
+{
+  digitalWrite(13,HIGH);   //main program code
+  delay(100);
+  digitalWrite(13,LOW);
+  delay(900);
+  
+}
+
+
+/*************** Interrupt routine for alarm ******************************/
+void alarm_int(void)
+{
+  Serial.println("Alarm match!");
+    for(int i=0; i < 10; i++)
+    {
+      digitalWrite(13,HIGH);
+      //delay(200);
+      for(int j=0; j < 1000000; j++) asm("NOP");  //in interrupt routine you cannot use delay function then an alternative is NOP instruction cicled many time as you need
+      digitalWrite(13,LOW);
+      //delay(800);
+      for(int j=0; j < 2000000; j++) asm("NOP");
+    }
+    rtc.alarmClearFlag();  //clearing alarm flag
+}    
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_polled/ALARM_polled.ino
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_polled/ALARM_polled.ino	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/ALARM_polled/ALARM_polled.ino	(revision 259)
@@ -0,0 +1,50 @@
+/*********************************************************************************************************************************************************************************
+* This sketch demonstrates how configure alarm in polled mode.
+  In this mode you hav to check continuously ALARM0 flag in the main program code.
+  
+  NOTE: for M0/M0 pro only you can select the oscillator source for count.
+If you want to use a low power oscillator use rtc.begin(TIME_H24, LOW_POWER); function.
+If you want to use a more accurate oscillator use rtc.begin(TIME_H24, HIGH_PRECISION); function.
+*********************************************************************************************************************************************************************************/  
+
+
+#include <RTCInt.h>
+
+RTCInt rtc;
+
+void setup() 
+{
+  Serial.begin(9600);       //serial communication initializing
+  pinMode(13,OUTPUT);
+  rtc.begin(TIME_H24);      //RTC initializing with 24 hour representation mode
+  rtc.setTime(17,0,5,0);    //setting time (hour minute and second)
+  rtc.setDate(13,8,15);     //setting date
+  rtc.enableAlarm(SEC,ALARM_POLLED,NULL); //enabling alarm in polled mode and match on second
+  rtc.time.hour=17;
+  rtc.time.minute=5;
+  rtc.time.second=10;  //setting second to match
+  rtc.setAlarm();  //write second in alarm register
+}
+
+void loop()
+{
+
+   digitalWrite(13,HIGH);
+   delay(100);
+   digitalWrite(13,LOW);
+   delay(400);
+   
+  if(rtc.alarmMatch())        //when match occurs led on pin 13 blinks ten times
+  {
+    Serial.println("Alarm match!");
+    for(int i=0; i < 10; i++)
+    {
+      digitalWrite(13,HIGH);
+      delay(200);
+      digitalWrite(13,LOW);
+      delay(800);
+    }
+    rtc.alarmClearFlag();  //clearing alarm flag
+  } 
+   
+}
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple/RTC_simple.ino
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple/RTC_simple.ino	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple/RTC_simple.ino	(revision 259)
@@ -0,0 +1,66 @@
+/**********************************************************************************************************************************************************
+This sketch gives a simple demonstration of how to use RTC library.
+The code sets date and time using internal structure and then print on serial date and time. Time representation is 12 hour mode
+
+NOTE: for M0/M0 pro only you can select the oscillator source for count.
+If you want to use a low power oscillator use rtc.begin(TIME_H12, LOW_POWER); function.
+If you want to use a more accurate oscillator use rtc.begin(TIME_H12, HIGH_PRECISION); function.
+**********************************************************************************************************************************************************/
+
+
+
+#include <RTCInt.h>
+
+RTCInt rtc;  //create an RTCInt type object
+
+
+void setup() 
+{
+  Serial.begin(9600);
+  rtc.begin(TIME_H12); //init RTC in 12 hour mode
+  
+  //filling internal structure for time
+  rtc.time.hour = 10;          //hour
+  rtc.time.minute = 44;       //minute
+  rtc.time.second = 0;        //second
+  rtc.time.Tmode = ANTI_MERIDIAN;  
+  
+  //filling internal structure for date
+  rtc.date.day = 13;        //day
+  rtc.date.month = 8;       //month
+  rtc.date.year = 15;       //year
+  
+  rtc.setTime();  //setting time
+  rtc.setDate();  //setting date
+  
+  
+  
+  
+
+}
+
+void loop() 
+{
+ rtc.getDate();      //getting date in local structure (local_date)
+ rtc.getTime();      //getting time in local structure(local_time)
+ 
+ //printing date in format YYYY/MM/DD
+ Serial.print(rtc.date.year+2000); // year
+ Serial.print('/');
+ Serial.print(rtc.date.month);    // month
+ Serial.print('/');
+ Serial.print(rtc.date.day);      // day
+ Serial.print(' ');
+ 
+ //printing time
+ Serial.print(rtc.time.hour);    //hour
+ Serial.print(':');
+ Serial.print(rtc.time.minute);  //minute
+ Serial.print(':');
+ Serial.print(rtc.time.second);  //second
+ Serial.print (' ');
+ if(rtc.time.Tmode == ANTI_MERIDIAN) Serial.println("AM"); // print AM or PM
+ else Serial.println("PM");
+ 
+ delay(1000);
+}
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple_24H_mode/RTC_simple_24H_mode.ino
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple_24H_mode/RTC_simple_24H_mode.ino	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/examples/RTC_simple_24H_mode/RTC_simple_24H_mode.ino	(revision 259)
@@ -0,0 +1,55 @@
+/**********************************************************************************************************************************************************
+This sketch gives a simple demonstration of how to use RTC library.
+The code sets date and time using internal structure and then print on serial date and time. Time representation is 24 hour mode
+
+NOTE: for M0/M0 pro only you can select the oscillator source for count.
+If you want to use a low power oscillator use rtc.begin(TIME_H24, LOW_POWER); function.
+If you want to use a more accurate oscillator use rtc.begin(TIME_H24, HIGH_PRECISION); function.
+**********************************************************************************************************************************************************/
+
+
+
+#include <RTCInt.h>
+
+RTCInt rtc;  //create an RTCInt type object
+
+
+void setup() 
+{
+  Serial.begin(9600);
+  rtc.begin(TIME_H24); //init RTC in 12 hour mode
+  
+  //time settings
+  rtc.setHour(15,0);  //setting hour
+  rtc.setMinute(43);  //setting minute
+  rtc.setSecond(0);   //setting second
+  
+  
+  rtc.setDay(13);     //setting day
+  rtc.setMonth(8);    //setting month
+  rtc.setYear(15);    //setting year
+  
+}
+
+void loop() 
+{
+ rtc.getDate();      //getting date in local structure (local_date)
+ rtc.getTime();      //getting time in local structure(local_time)
+ 
+ //printing date in format YYYY/MM/DD
+ Serial.print(rtc.date.year+2000); // year
+ Serial.print('/');
+ Serial.print(rtc.date.month);    // month
+ Serial.print('/');
+ Serial.print(rtc.date.day);      // day
+ Serial.print(' ');
+ 
+ //printing time
+ Serial.print(rtc.time.hour);    //hour
+ Serial.print(':');
+ Serial.print(rtc.time.minute);  //minute
+ Serial.print(':');
+ Serial.println(rtc.time.second);  //second
+ 
+ delay(1000);
+}
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/keywords.txt
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/keywords.txt	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/keywords.txt	(revision 259)
@@ -0,0 +1,58 @@
+#######################################
+# Syntax Coloring Map For RTC
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+RTCInt	KEYWORD1
+local_time	KEYWORD1
+local_date	KEYWORD1
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+getDay	KEYWORD2
+getMonth	KEYWORD2
+getYear	KEYWORD2
+getHour	KEYWORD2
+getMinute	KEYWORD2
+getSecond	KEYWORD2
+getDate	KEYWORD2
+getTime	Keyword2
+
+setDay	KEYWORD2
+setMonth	KEYWORD2
+setYear	KEYWORD2
+setHour	KEYWORD2
+setMinute	KEYWORD2
+setSecond	KEYWORD2
+setDate	KEYWORD2
+setTime	KEYWORD2
+
+enableAlarm	KEYWORD2
+setAlarm	KEYWORD2
+alarmMatch	KEYWORD2
+
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+TIME_H24	LITERAL1
+TIME_H12	LITERAL1
+
+
+OFF	LITERAL1
+
+
+MMSS	LITERAL1
+HHMMSS	LITERAL1
+DDHHMMSS	LITERAL1
+MMDDHHMMSS	LITERAL1
+YYMMDDHHMMSS	LITERAL1
+SEC	LITERAL1
+ANTI_MERIDIAN	LITERAL1
+POST_MERIDIAN	LITERAL1
+ALARM_POLLED	LITERAL1
+ALARM_INTERRUPT	LITERAL1
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/library.properties
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/library.properties	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/library.properties	(revision 259)
@@ -0,0 +1,9 @@
+name=RTC
+version=1.0.0
+author=Arduino
+maintainer=Arduino
+sentence=Allows to use the RTC functionalities. For Arduino M0 or M0PRO only.
+paragraph=With this library you can use the RTC peripheral of an Arduino M0/M0PRO in order to program actions related to date and time.
+category=Timing
+url=http://www.arduino.cc/en/Reference/RTCZero
+architectures=samd
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.cpp
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.cpp	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.cpp	(revision 259)
@@ -0,0 +1,644 @@
+/*
+  RTC library for Arduino M0/M0PRO.
+  Copyright (c) 2015 Arduino SRL. All right reserved.
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+ 
+#include "RTCInt.h"
+//#include <Arduino.h>
+
+static bool time_Mode = false;
+
+/*******************************************************************************************
+*Description: Function responsible of RTC initialization
+*Input Parameters: bool timeRep this parameter can be TIME_H24 (24 hour mode) or TIME_H12 (12 hour mode)
+*Return Parameter: None
+*******************************************************************************************/
+void RTCInt::begin(bool timeRep, int oscillatorType) 
+{
+  
+  
+  PM->APBAMASK.reg |= PM_APBAMASK_RTC; // turn on digital interface clock for RTC
+  
+  GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK4 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos)));
+  while (GCLK->STATUS.bit.SYNCBUSY);
+  
+  //Set the oscillator to use - M0 only
+  if(oscillatorType==HIGH_PRECISION)
+  //External oscillator
+  GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_XOSC32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL );
+  
+  else
+  //Internal low power oscillator (default configuration)
+  GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN |  GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL );
+  
+  while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
+  
+  GCLK->GENDIV.reg = GCLK_GENDIV_ID(4); 
+  GCLK->GENDIV.bit.DIV=4;
+  while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
+  
+  
+
+  RTCdisable();
+
+  RTCreset();
+
+  RTC->MODE2.CTRL.reg |= RTC_MODE2_CTRL_MODE_CLOCK; // set RTC operating mode
+  RTC->MODE2.CTRL.reg |= RTC_MODE2_CTRL_PRESCALER_DIV1024; // set prescaler to 1024 for MODE2
+  RTC->MODE2.CTRL.bit.MATCHCLR = 0; // disable clear on match
+  
+  
+  if (timeRep)
+  {
+    RTC->MODE2.CTRL.bit.CLKREP = 0; // 24h time representation
+	time_Mode = true;
+  }		
+  else
+  {  
+    RTC->MODE2.CTRL.bit.CLKREP = 1; // 12h time representation
+	time_Mode = false;
+  }	
+
+  RTC->MODE2.READREQ.reg &= ~RTC_READREQ_RCONT; // disable continuously mode
+
+  
+  while (RTCSync());
+	RTCresetRemove();
+  RTCenable();
+  
+}
+
+void RTCInt::begin(bool timeRep){
+    begin(timeRep, LOW_POWER);
+}
+
+/*
+ * Get Time Functions
+ */
+
+/**********************************************************************************************************************
+*Description: Function for getting hour, according to time representation mode this value can 
+			  be in the range 0-24 (in case of TIME_H24) or in the range 0-12 (in case of TIME_H12)	
+*Input Parameters: None
+*Return Parameter: unsigned int (hour)
+***********************************************************************************************************************/
+ unsigned int RTCInt::getHour()
+{
+	unsigned int h=0;
+	
+	
+	h=RTC->MODE2.CLOCK.bit.HOUR;
+	while (RTCSync());
+	
+	if(time_Mode ==TIME_H12)
+	{
+		h = h & 0x0000000F;
+	}
+	
+  return h;
+}
+ 
+ /**********************************************************************************************************************
+*Description: Function for getting minute, this value varies in the range 0 - 59 
+*Input Parameters: None
+*Return Parameter: unsigned int (minute)
+***********************************************************************************************************************/
+unsigned int RTCInt::getMinute()
+{
+  unsigned int m=0;
+  
+  m=RTC->MODE2.CLOCK.bit.MINUTE;
+  while (RTCSync());
+ return m; 
+}
+ 
+ 
+ /**********************************************************************************************************************
+*Description: Function for getting second, this value varies in the range 0 - 59 
+*Input Parameters: None
+*Return Parameter: unsigned int (second)
+***********************************************************************************************************************/
+ unsigned int RTCInt::getSecond()
+{
+  unsigned int s=0;
+  
+  s=RTC->MODE2.CLOCK.bit.SECOND;
+  while (RTCSync());
+ return s; 
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for getting time (hours, minutes and seconds). This function fills a structure called time
+			  accessible in the class RTCInt.	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::getTime(void)
+{
+	unsigned int hour=0, h=0;
+	
+	time.hour = getHour();
+	if(time_Mode == TIME_H12)
+	{
+		h=RTC->MODE2.CLOCK.bit.HOUR;
+		while (RTCSync());
+		time.Tmode = h & 0x10;
+	}	
+	time.minute = getMinute();
+	time.second = getSecond();
+}
+
+unsigned char RTCInt::getMeridian(void)
+{
+	unsigned int h=0;
+	unsigned char m=0;
+	
+	if(time_Mode == TIME_H12)
+	{
+		h=RTC->MODE2.CLOCK.bit.HOUR;
+		while (RTCSync());
+		m = h & 0x10;
+		m >> 4;
+	}
+	else m=0;
+return m;	
+}
+
+
+/*
+ * Get Date Functions
+ */
+
+ 
+/**********************************************************************************************************************
+*Description: Function for getting day 	
+*Input Parameters: None
+*Return Parameter: unsigned int day in the range 1 - 31
+***********************************************************************************************************************/ 
+unsigned int RTCInt::getDay()
+{
+  unsigned int d=0;
+  
+  d=RTC->MODE2.CLOCK.bit.DAY;
+  while (RTCSync());
+ return d; 
+}
+
+/**********************************************************************************************************************
+*Description: Function for getting Month 	
+*Input Parameters: None
+*Return Parameter: unsigned int month in the range 1 - 12
+***********************************************************************************************************************/
+unsigned int RTCInt::getMonth()
+{
+  unsigned int month=0;
+  
+  month=RTC->MODE2.CLOCK.bit.MONTH;
+  while (RTCSync());
+ return month; 
+}
+
+
+/************************************************************************************************************************************
+*Description: Function for getting year 	
+*Input Parameters: None
+*Return Parameter: unsigned int year in the range 0 - 63 (note: add offset to this value to obtain correct representation for year)
+*************************************************************************************************************************************/
+unsigned int RTCInt::getYear()
+{
+  unsigned int y=0;
+  
+  y=RTC->MODE2.CLOCK.bit.YEAR;
+  while (RTCSync());
+ return y; 
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for getting date (day, month and year). This function fills a structure called date
+			  accessible in the class RTCInt.	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::getDate(void)
+{
+	date.day = getDay();
+	date.month = getMonth();
+	date.year = getYear();
+}
+
+/*
+ * Set Time Functions
+ */
+
+ 
+/************************************************************************************************************************************
+*Description: Function for setting hour 	
+*Input Parameters: unsigned int hour (according to time representation the range can be 0 - 23 or 0 - 12)
+*Return Parameter: None
+*************************************************************************************************************************************/ 
+void RTCInt::setHour(unsigned int hour, unsigned char meridian)
+{
+  if (time_Mode) {
+    if((hour >= 0) && (hour <= 23))
+	{	
+		RTC->MODE2.CLOCK.bit.HOUR = hour;
+		while (RTCSync());
+	}
+	else return;	
+  } 
+  else {
+    if((hour >= 0) && (hour <=12)) 
+	{	
+		
+		hour=hour | (meridian << 4);
+		RTC->MODE2.CLOCK.bit.HOUR = hour;
+		while (RTCSync());
+	}
+	else return;	
+  }
+  
+}
+ 
+ 
+ /************************************************************************************************************************************
+*Description: Function for setting minute 	
+*Input Parameters: unsigned int minute (range 0 - 59)
+*Return Parameter: None
+*************************************************************************************************************************************/ 
+ void RTCInt::setMinute(unsigned int minute)
+{
+  if((minute >=0) && (minute <= 59))
+  {		
+	RTC->MODE2.CLOCK.bit.MINUTE = minute;
+	while (RTCSync());
+  }
+  else return;	
+}
+ 
+ 
+ 
+/************************************************************************************************************************************
+*Description: Function for setting second 	
+*Input Parameters: unsigned int second (range 0 - 59)
+*Return Parameter: None
+*************************************************************************************************************************************/  
+void RTCInt::setSecond(unsigned int second)
+{
+  if((second >=0) && (second <= 59))
+  {		
+	RTC->MODE2.CLOCK.bit.SECOND = second;
+	while (RTCSync());
+  }
+  else return;	
+}
+
+
+/************************************************************************************************************************************
+*Description: Function for setting time 	
+*Input Parameters: unsigned int hour (range 0 - 23 or 0 - 12 according to time representation)
+				   unsigned int minute (range 0 - 59)
+				   unsigned int second (range 0 - 59)		
+*Return Parameter: None
+*************************************************************************************************************************************/  
+void RTCInt::setTime(unsigned int hour,unsigned char meridian, unsigned int minute, unsigned int second)
+{
+  setHour(hour,meridian);
+  setMinute(minute);
+  setSecond(second);  
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for setting time (hour, minute and second). This function sets time retrieving values from a 
+			  local structure called time accessible in the class RTCInt.	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::setTime(void)
+{
+	setHour(time.hour,time.Tmode);
+    setMinute(time.minute);
+    setSecond(time.second);  
+}
+
+
+/*
+ * Set Date Functions
+ */
+
+
+/************************************************************************************************************************************
+*Description: Function for setting day	
+*Input Parameters: unsigned int day (range 1 - 31)
+*Return Parameter: None
+*************************************************************************************************************************************/  
+void RTCInt::setDay(unsigned int day)
+{
+  if((day > 1) && (day <=31))
+  {
+  RTC->MODE2.CLOCK.bit.DAY = day;
+  while (RTCSync());
+  }
+  else return;
+}
+
+
+/************************************************************************************************************************************
+*Description: Function for setting month 	
+*Input Parameters: unsigned int month (range 1 - 12)
+*Return Parameter: None
+*************************************************************************************************************************************/  
+void RTCInt::setMonth(unsigned int month)
+{
+  if((month > 1) && (month <=12))
+  {	  
+  RTC->MODE2.CLOCK.bit.MONTH = month;
+  while (RTCSync());
+  }
+  else return;
+}
+
+
+/************************************************************************************************************************************
+*Description: Function for setting year 	
+*Input Parameters: unsigned int year range (0 - 63) (note: add offset to this value to obtain correct representation for year)
+*Return Parameter: None 
+*************************************************************************************************************************************/
+void RTCInt::setYear(unsigned int year)
+{
+  if((year >= 0) && (year <=63))
+  {	  
+  RTC->MODE2.CLOCK.bit.YEAR = year;
+  while (RTCSync());
+  }
+  else return;
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for setting date (day, month and year).	
+*Input Parameters: unsigned int day (range 1 - 31)
+				   unsigned int month (range 1 - 12)
+				   unsigned int year (range 0 - 63)		
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::setDate(unsigned int day, unsigned int month, unsigned int year)
+{
+  setDay(day);
+  setMonth(month);  
+  setYear(year);
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for setting date (day, month and year). This function retrieves values from a local structure 
+			  called date accessible in the class RTCInt.	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::setDate(void)
+{
+	setDay(date.day);
+	setMonth(date.month);  
+    setYear(date.year);
+}
+
+/*
+ * Set Alarm Functions
+ */
+ 
+
+ /**********************************************************************************************************************
+*Description: Function for enabling alarm.	
+*Input Parameters: unsigned int mode:
+										 OFF                 alarm disabled
+										 SEC                 alarm match on seconds
+										 MMSS                alarm match on minutes and seconds
+										 HHMMSS              alarm match on hours, minute and seconds
+										 DDHHMMSS            alarm match on day, hours, minutes and seconds
+										 MMDDHHMMSS          alarm match on month, day hours, minutes and seconds
+										 YYMMDDHHMMSS        alarm match on year, month, day, hours, minutes and seconds	
+				   unsigned int type:
+										 ALARM_POLLED        alarm matching must be monitored from the code
+										 ALARM_INTERRUPT     when alarm match occurs will be generated an interrupt
+				   
+				   voidFuncPtr callback: pointer to interrupt routine for alarm match (write NULL if you use ALARM_POLLED)		
+*Return Parameter: None
+***********************************************************************************************************************/
+ void RTCInt::enableAlarm(unsigned int mode, unsigned int type, voidFuncPtr callback)
+ {
+	 
+	 Alarm_Mode = mode;
+	 RTC->MODE2.Mode2Alarm->MASK.reg = mode;
+	 while (RTCSync());
+	 
+	 if(type == ALARM_POLLED)
+	 {
+		 return;
+	 }	 
+	 
+	 else if(type == ALARM_INTERRUPT)
+	 {
+		 NVIC_DisableIRQ(RTC_IRQn); //disable any RTC interrupt
+		 NVIC_ClearPendingIRQ(RTC_IRQn); //clear all pending interrupt for RTC
+		 NVIC_SetPriority(RTC_IRQn,0);  //set RTC interrupt priority 
+		 NVIC_EnableIRQ(RTC_IRQn);  //enable general interrupt for RTC
+		 
+		 RTC->MODE2.INTENSET.bit.ALARM0 = 1; //enable ALARM0 mathc
+		 while (RTCSync());
+		 
+		 _callback = callback;
+		 RTC->MODE2.INTFLAG.bit.ALARM0 = 1; //clear interrupt flag for RTC ALARM0 interrupt
+		 
+	 }		
+ }
+ 
+ 
+ /**********************************************************************************************************************
+*Description: Function for setting alarm. This function retrieves values from two local structures 
+			  called date and time accessible in the class RTCInt. According to match alarm type, values 
+			  can be obtained from time, date or both structures.	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+ void RTCInt::setAlarm(void)
+ {
+	 
+   switch(RTCInt::Alarm_Mode)
+   {
+   case OFF :
+      break;
+   case SEC :
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+	  break;	
+   case MMSS :
+      RTC->MODE2.Mode2Alarm->ALARM.bit.MINUTE= time.minute;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+	  break;
+   case HHMMSS :
+      RTC->MODE2.Mode2Alarm->ALARM.bit.HOUR= time.hour;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.MINUTE= time.minute;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+      break;
+   case DDHHMMSS :
+      RTC->MODE2.Mode2Alarm->ALARM.bit.DAY= date.day;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.HOUR= time.hour;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.MINUTE= time.minute;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+      break;
+   case MMDDHHMMSS :
+      RTC->MODE2.Mode2Alarm->ALARM.bit.MONTH= date.month;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.DAY= date.day;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.HOUR= time.hour;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.MINUTE= time.minute;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+      break;
+   case YYMMDDHHMMSS :
+      RTC->MODE2.Mode2Alarm->ALARM.bit.YEAR= date.year;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.MONTH= date.month;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.DAY= date.day;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.HOUR= time.hour;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.MINUTE= time.minute;
+	  while (RTCSync());
+	  RTC->MODE2.Mode2Alarm->ALARM.bit.SECOND= time.second;
+	  while (RTCSync());
+      break;	  
+   default :
+      break;
+   }
+   
+}
+
+/**********************************************************************************************************************
+*Description: Function for getting status of alarm match. This function is used when you adopt ALARM_POLLED mode 	
+*Input Parameters: None
+*Return Parameter: bool alarm match
+***********************************************************************************************************************/
+bool RTCInt::alarmMatch(void)
+   {
+	   return RTC->MODE2.INTFLAG.bit.ALARM0;
+   }
+
+/**********************************************************************************************************************
+*Description: Function for clearing the alarm flag.This function is used when you adopt ALARM_POLLED mode 	
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/   
+void RTCInt::alarmClearFlag(void){
+	RTC->MODE2.INTFLAG.bit.ALARM0=1; //clearing alarm0 flag
+}   
+
+/*
+ * Private Utility Functions
+ */
+
+
+
+/**********************************************************************************************************************
+*Description: Function for retrieving sync status of RTC 
+*Input Parameters: None
+*Return Parameter: bool RTC sync
+***********************************************************************************************************************/
+bool RTCInt::RTCSync()
+{
+  return (RTC->MODE2.STATUS.bit.SYNCBUSY);
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for disabling RTC
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::RTCdisable()
+{
+  RTC->MODE2.CTRL.reg &= ~RTC_MODE2_CTRL_ENABLE; // disable RTC
+  while (RTCSync());
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for enabling RTC
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::RTCenable()
+{
+  RTC->MODE2.CTRL.reg |= RTC_MODE2_CTRL_ENABLE; // enable RTC
+  while (RTCSync());
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for resetting RTC. This function clears all RTC registers
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::RTCreset()
+{
+  RTC->MODE2.CTRL.reg |= RTC_MODE2_CTRL_SWRST; // software reset
+  while (RTCSync());
+}
+
+
+/**********************************************************************************************************************
+*Description: Function for remove reset to RTC
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTCInt::RTCresetRemove()
+{
+  RTC->MODE2.CTRL.reg &= ~RTC_MODE2_CTRL_SWRST; // software reset remove
+  while (RTCSync());
+}
+
+
+
+/**********************************************************************************************************************
+*Description: RTC handler interrupt routine. This function checks flag ALARM0 and if is set calls routine 
+			  pointed by _callback pointer then resets ALARM0 flag.
+*Input Parameters: None
+*Return Parameter: None
+***********************************************************************************************************************/
+void RTC_Handler(void)
+{
+	if(RTC->MODE2.INTFLAG.bit.ALARM0)
+	{
+		_callback(); //call interrupt routine
+		RTC->MODE2.INTFLAG.bit.ALARM0 = 1; // clear ALARM0 flag
+	}
+	
+	else return;	
+}
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.h	(revision 259)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/libraries/RTC/src/RTCInt.h	(revision 259)
@@ -0,0 +1,115 @@
+/*
+  RTC library for Arduino Zero.
+  Copyright (c) 2015 Arduino LLC. All right reserved.
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef RTCInt_H
+#define RTCInt_H
+
+#define TIME_H24 1
+#define TIME_H12 0
+
+#define OFF RTC_MODE2_MASK_SEL_OFF
+#define SEC RTC_MODE2_MASK_SEL_SS
+#define MMSS RTC_MODE2_MASK_SEL_MMSS
+#define HHMMSS RTC_MODE2_MASK_SEL_HHMMSS
+#define DDHHMMSS RTC_MODE2_MASK_SEL_DDHHMMSS
+#define MMDDHHMMSS RTC_MODE2_MASK_SEL_MMDDHHMMSS
+#define YYMMDDHHMMSS RTC_MODE2_MASK_SEL_YYMMDDHHMMSS
+
+#define ALARM_POLLED 0
+#define ALARM_INTERRUPT 1
+
+#define ANTI_MERIDIAN 0
+#define POST_MERIDIAN 1
+
+//Parameter for oscillatorType - M0 only
+#define HIGH_PRECISION 0
+#define LOW_POWER 1
+
+#include "Arduino.h"
+
+typedef struct {
+	unsigned int hour;
+	unsigned int minute;
+	unsigned int second;
+	unsigned char Tmode;
+}TIME;
+
+typedef struct {
+	unsigned int day;
+	unsigned int month;
+	unsigned int year;
+}DATE;
+
+static voidFuncPtr _callback = NULL;
+
+class RTCInt {
+public:
+
+  RTCInt() {};
+  
+  TIME time;
+  DATE date;
+  
+  void begin(bool timeMode, int oscillatorType);
+  void begin(bool timeMode);
+  
+  /* Get Time Functions */
+
+  unsigned int getHour(void);
+  unsigned int getMinute(void);
+  unsigned int getSecond(void);
+  void getTime(void);
+  unsigned char getMeridian(void); 
+ 
+ /* Get Date Functions */ 
+  unsigned int getDay(void);
+  unsigned int getMonth(void);
+  unsigned int getYear(void);
+  void getDate(void);
+
+  /* Set Time Functions */
+
+  void setHour(unsigned int hour, unsigned char meridian);
+  void setMinute(unsigned int minute);
+  void setSecond(unsigned int second);
+  void setTime(unsigned int hour, unsigned char meridian, unsigned int minute, unsigned int second);
+  void setTime(void);
+
+ /* Set Date Functions */ 
+  void setDay(unsigned int day);
+  void setMonth(unsigned int month);
+  void setYear(unsigned int year);
+  void setDate(unsigned int day, unsigned int month, unsigned int year);
+  void setDate(void);
+  
+ /* Alarm Functions */
+	void enableAlarm(unsigned int mode, unsigned int type, voidFuncPtr callback);
+	void setAlarm(void);
+	bool alarmMatch(void);
+	void alarmClearFlag(void);
+	
+
+private:
+  unsigned int Alarm_Mode=0;
+  bool RTCSync(void);  
+  void RTCdisable(void);
+  void RTCenable(void);
+  void RTCreset(void);
+  void RTCresetRemove(void);
+};
+
+
+#endif
Index: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/platform.txt
===================================================================
--- rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/platform.txt	(revision 253)
+++ rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/platform.txt	(revision 259)
@@ -13,5 +13,5 @@
 compiler.path={runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/
 compiler.c.cmd=arm-none-eabi-gcc
-compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf 
+compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
 #-std=gnu99
 compiler.c.elf.cmd=arm-none-eabi-g++
@@ -19,5 +19,5 @@
 compiler.S.flags=-c -g -x assembler-with-cpp
 compiler.cpp.cmd=arm-none-eabi-g++
-compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf 
+compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
 #-std=gnu++11
 compiler.ar.cmd=arm-none-eabi-ar
@@ -65,5 +65,5 @@
 #recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -save-temps -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" --specs=nano.specs "-L{build.path}" -Wl,--start-group -lm -lgcc -Wl,--end-group -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {object_files} "{build.path}/{archive_file}" -Wl,--end-group -Wl,--section-start=.text={build.section.start}
 
-# alfran - fix GITHUB Issue: Arduino Zero Pro alignment problem #3 
+# alfran - fix GITHUB Issue: Arduino Zero Pro alignment problem #3
 recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -save-temps -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" --specs=nano.specs "-L{build.path}" -Wl,--start-group -lm -lgcc -Wl,--end-group -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls.c.o" {object_files} "{build.path}/{archive_file}" -Wl,--end-group -Wl,--section-start=.text={build.section.start}
 
