[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers HPLTimer2M.nc, 1.5, 1.6 AsyncAlarmC.nc, 1.3, 1.4 LocalTimeM.nc, 1.2, 1.3 AsyncAlarmM.nc, 1.5, 1.6

Jan Flora janflora at users.sourceforge.net
Wed Aug 23 03:11:39 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25330/tos/chips/hcs08/timers

Modified Files:
	HPLTimer2M.nc AsyncAlarmC.nc LocalTimeM.nc AsyncAlarmM.nc 
Log Message:
HCS08 driver updates

Index: HPLTimer2M.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers/HPLTimer2M.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** HPLTimer2M.nc	3 Mar 2006 18:07:17 -0000	1.5
--- HPLTimer2M.nc	23 Aug 2006 10:11:37 -0000	1.6
***************
*** 26,31 ****
  	command result_t StdControl.start()
  	{
! 		uint8_t clock = busClock/1000000; // Bus clock in MHz.
! 		uint8_t div = 1;//clock;
  		uint8_t i = 0;
  		
--- 26,31 ----
  	command result_t StdControl.start()
  	{
! /*		uint8_t clock = busClock/1000000; // Bus clock in MHz.
! 		uint8_t div = 16;//clock;
  		uint8_t i = 0;
  		
***************
*** 35,46 ****
  			div >>= 1;
  		}
! 		TPM2SC = i;
! 		
! 		// Set the modulo register
! 		TPM2MOD = 0x0000;
  		
  		// Select the bus clock and enable overflow interrupts.
  		TPM2SC_TOIE = 1;
! 		TPM2SC |= 0x10;// 0x08;
  		return SUCCESS;
  	}
--- 35,45 ----
  			div >>= 1;
  		}
! 		TPM2SC = i;*/
  		
  		// Select the bus clock and enable overflow interrupts.
  		TPM2SC_TOIE = 1;
! 		//TPM2SC |= 0x08;
! 		TPM2SC |= 0x10;
! 		//TPM2SC = 0x50;
  		return SUCCESS;
  	}
***************
*** 56,59 ****
--- 55,63 ----
  		return TPM2CNT;
  	}
+ 	
+ 	command void HPLTimer.reset()
+ 	{
+ 		TPM2CNT = 0;
+ 	}
  
  	command result_t HPLTimer.shortDelay(uint16_t delay, uint8_t channel)

Index: AsyncAlarmC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers/AsyncAlarmC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AsyncAlarmC.nc	7 Mar 2006 16:08:00 -0000	1.3
--- AsyncAlarmC.nc	23 Aug 2006 10:11:37 -0000	1.4
***************
*** 6,9 ****
--- 6,10 ----
  		interface StdControl;
  		interface AsyncAlarm<uint32_t> as Alarm[uint8_t timer];
+ 		interface LocalTime;
  	}
  	uses
***************
*** 16,20 ****
  	components AsyncAlarmM,
  	           LocalTimeM,
- 	           InitHCS08TimerC,
  	           HPLTimer2M;
  
--- 17,20 ----
***************
*** 22,25 ****
--- 22,26 ----
  	Alarm = AsyncAlarmM;
  	AsyncAlarmM = Debug;
+ 	LocalTime = LocalTimeM.LocalTime;
  
  	// LocalTimeM.HPLTimer MUST be wired before AsyncAlarmM.HPLTimer!!!

Index: LocalTimeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers/LocalTimeM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LocalTimeM.nc	1 Mar 2006 12:59:11 -0000	1.2
--- LocalTimeM.nc	23 Aug 2006 10:11:37 -0000	1.3
***************
*** 14,32 ****
  implementation
  {
! 	uint32_t wrapCounter = 0;
! 
! 	command uint16_t LocalTime.getTimeH()
! 	{
! 		uint16_t ret;
! 		atomic ret = wrapCounter>>16;
! 		return ret;
! 	}
  	
! 	command uint32_t LocalTime.getTimeL()
  	{
  		uint32_t ret = 0;
! 		atomic ret = wrapCounter<<16;
  		ret += call HPLTimer.getTime();
! 		return ret;
  	}
  
--- 14,46 ----
  implementation
  {
! 	uint16_t wrapCounter = 0;
  	
! 	command uint32_t LocalTime.getTime()
  	{
  		uint32_t ret = 0;
! 		atomic ret = wrapCounter;
! 		ret <<= 16;
  		ret += call HPLTimer.getTime();
! 		return ret<<1;
! 	}
! 	
! 	command uint16_t LocalTime.getHigh16()
! 	{
! 		uint16_t retval;
! 		// Most significant bit can't be trusted.
! 		// This is due to the left shifting in getTime.
! 		atomic retval = wrapCounter&0x7FFF;
! 		return retval;
! 	}
! 	
! 	command uint16_t LocalTime.getLow16()
! 	{
! 		return call HPLTimer.getTime();
! 	}
! 	
! 	command void LocalTime.reset()
! 	{
! 		call HPLTimer.reset();
! 		atomic wrapCounter = 0;
  	}
  
***************
*** 40,47 ****
  			diff = after-before;
  		}
- 		if (diff&0x80000000) {
- 			
- 			return 0;
- 		}
  		return diff;
  	}
--- 54,57 ----

Index: AsyncAlarmM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/tos/chips/hcs08/timers/AsyncAlarmM.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AsyncAlarmM.nc	7 Mar 2006 16:08:02 -0000	1.5
--- AsyncAlarmM.nc	23 Aug 2006 10:11:37 -0000	1.6
***************
*** 9,14 ****
  	uses
  	{
- 		interface Leds;
- 		interface ConsoleOutput as ConsoleOut;
  		interface LocalTime;
  		interface HPLTimer<uint16_t> as HPLTimer;
--- 9,12 ----
***************
*** 72,80 ****
  	command result_t Alarm.armCountdown[uint8_t timer](uint32_t timeout)
  	{
! 		if (timeout < 300) {
  			channelMap[3] = timer;
! 			return call HPLTimer.shortDelay(timeout,3);
  		} else {
! 			uint32_t alarm = timeout+call LocalTime.getTimeL();
  			return armTimer(alarm>>16, alarm&0xFFFF, timer);
  		}
--- 70,81 ----
  	command result_t Alarm.armCountdown[uint8_t timer](uint32_t timeout)
  	{
! 		if (timeout < 16) {
  			channelMap[3] = timer;
! 			return call HPLTimer.shortDelay(timeout>>1,3);
  		} else {
! 			uint32_t alarm = timeout+call LocalTime.getTime();
! 			// getTime is 16 micro second time instead of 32 micro second
! 			// time generated by hardware.
! 			alarm >>= 1;
  			return armTimer(alarm>>16, alarm&0xFFFF, timer);
  		}
***************
*** 82,86 ****
  	
  	command result_t Alarm.armAlarmClock[uint8_t timer](uint32_t time)
! 	{		
  		return armTimer(time>>16, time&0xFFFF, timer);
  	}
--- 83,88 ----
  	
  	command result_t Alarm.armAlarmClock[uint8_t timer](uint32_t time)
! 	{
! 		time >>= 1;
  		return armTimer(time>>16, time&0xFFFF, timer);
  	}
***************
*** 90,115 ****
  		result_t res = FAIL;
  		atomic {
! 		uint16_t nowHigh = (call LocalTime.getTimeL()>>16);
! 		if ((highStamp == nowHigh+1 && (lowStamp > 0x7FFF)) || highStamp > nowHigh+1) {
! 				m_timers[timer].isset = TRUE;
! 				m_timers[timer].highStamp = highStamp;
! 				m_timers[timer].lowStamp = lowStamp;
! 		//	}
  			res = SUCCESS;
  		} else {
  			// Program hw timer immediately.
! 	//		atomic {
! 				uint8_t channel;
! 				for (channel=0; channel < maxChannel; channel++) {
! 					if (channelFree[channel]) {
! 						channelFree[channel] = FALSE;
! 						channelMap[channel] = timer;
! 						call HPLTimer.arm(lowStamp, channel);
! 						res = SUCCESS;
! 						break;
! 					}
  				}
  			}
  		}
  		return res;
  	}
--- 92,118 ----
  		result_t res = FAIL;
  		atomic {
! 		uint32_t myTime = call LocalTime.getTime() >> 1;
! 		uint16_t nowHigh = myTime>>16;
! 		uint16_t nowLow = myTime&0xFFFF;
! 		if ((highStamp == nowHigh+1 && (lowStamp > nowLow)) || highStamp > nowHigh+1) {
! 			m_timers[timer].isset = TRUE;
! 			m_timers[timer].highStamp = highStamp;
! 			m_timers[timer].lowStamp = lowStamp;
  			res = SUCCESS;
  		} else {
  			// Program hw timer immediately.
! 			uint8_t channel;
! 			m_timers[timer].isset = FALSE;
! 			for (channel=0; channel < maxChannel; channel++) {
! 				if (channelFree[channel]) {
! 					channelFree[channel] = FALSE;
! 					channelMap[channel] = timer;
! 					call HPLTimer.arm(lowStamp, channel);
! 					res = SUCCESS;
! 					break;
  				}
  			}
  		}
+ 		}
  		return res;
  	}
***************
*** 138,142 ****
  		// Decrement highstamps on all timers and enable hw timer if 0
  		uint8_t timer;
! 		uint16_t nowHigh = (call LocalTime.getTimeL()>>16);
  		for (timer=0;timer<NUM_TIMERS;timer++) {
  			Timer_t* tt = m_timers+timer;
--- 141,145 ----
  		// Decrement highstamps on all timers and enable hw timer if 0
  		uint8_t timer;
! 		uint16_t nowHigh = call LocalTime.getHigh16();
  		for (timer=0;timer<NUM_TIMERS;timer++) {
  			Timer_t* tt = m_timers+timer;
***************
*** 156,160 ****
  			// We use channel 4 for signalling programming periods
  			uint8_t timer;
! 			uint16_t nowHigh = (call LocalTime.getTimeL()>>16)+1;
  			for (timer=0;timer<NUM_TIMERS;timer++) {
  				Timer_t* tt = m_timers+timer;
--- 159,163 ----
  			// We use channel 4 for signalling programming periods
  			uint8_t timer;
! 			uint16_t nowHigh = call LocalTime.getHigh16()+1;
  			for (timer=0;timer<NUM_TIMERS;timer++) {
  				Timer_t* tt = m_timers+timer;



More information about the Tinyos-contrib-commits mailing list