Can_open_masternode

Dependencies:   mbed

Revision:
3:5bea13b77b97
Parent:
0:9dd7c6129683
diff -r cb8989598a0f -r 5bea13b77b97 framework/driver/mbed/timer_mbed.cpp
--- a/framework/driver/mbed/timer_mbed.cpp	Mon May 30 08:26:26 2011 +0000
+++ b/framework/driver/mbed/timer_mbed.cpp	Fri Feb 03 02:48:09 2012 +0000
@@ -30,8 +30,8 @@
 extern uint32_t SystemCoreClock;
 
 // Define the timer registers
-#define TimerAlarm        LPC_TIM1->MR0	// compare register to genterate an interrupt
-#define TimerCounter      LPC_TIM1->TC	// free running timer counter register
+#define TimerAlarm        LPC_TIM1->MR0    // compare register to genterate an interrupt
+#define TimerCounter      LPC_TIM1->TC     // free running timer counter register
 
 /************************** Module variables **********************************/
 // Store the last timer value to calculate the elapsed time
@@ -44,25 +44,25 @@
 OUTPUT    void
 ******************************************************************************/
 {
-	float prescaler = 0;
-	TimerAlarm = 0;
-	// power up the timer (if not already done)
-	LPC_SC->PCONP |= (0x1 << 0x2);
-	// reset the timer
-	LPC_TIM1->TCR = 0x2;
-	// set up the prescaler to create an 8us incrementing tick using Timer1
-	switch ((LPC_SC->PCLKSEL0 >> 0x4) & 0x3){
-			case 0x00:	prescaler = 0.000008 / (1.0 / (SystemCoreClock / 4.0));	break;
-			case 0x01:	prescaler = 0.000008 / (1.0 / SystemCoreClock);	 		break;
-			case 0x02:	prescaler = 0.000008 / (1.0 / (SystemCoreClock / 2.0));	break;
-			case 0x03:	prescaler = 0.000008 / (1.0 / (SystemCoreClock / 8.0));	break;
-	}
-	LPC_TIM1->PR = static_cast<uint32_t>(prescaler);
-	// MR0 is used as a match event to trigger an interrupt - managed through TimerAlarm
-	LPC_TIM1->MCR |= (0x1 << 0);
-	NVIC_EnableIRQ(TIMER1_IRQn);
-	// start the timer
-	LPC_TIM1->TCR = 0x1; 
+    float prescaler = 0;
+    TimerAlarm = 0;
+    // power up the timer (if not already done)
+    LPC_SC->PCONP |= (0x1 << 0x2);
+    // reset the timer
+    LPC_TIM1->TCR = 0x2;
+    // set up the prescaler to create an 8us incrementing tick using Timer1
+    switch ((LPC_SC->PCLKSEL0 >> 0x4) & 0x3){
+            case 0x00:    prescaler = 0.000008 / (1.0 / (SystemCoreClock / 4.0));    break;
+            case 0x01:    prescaler = 0.000008 / (1.0 / SystemCoreClock);            break;
+            case 0x02:    prescaler = 0.000008 / (1.0 / (SystemCoreClock / 2.0));    break;
+            case 0x03:    prescaler = 0.000008 / (1.0 / (SystemCoreClock / 8.0));    break;
+    }
+    LPC_TIM1->PR = static_cast<uint32_t>(prescaler);
+    // MR0 is used as a match event to trigger an interrupt - managed through TimerAlarm
+    LPC_TIM1->MCR |= (0x1 << 0);
+    NVIC_EnableIRQ(TIMER1_IRQn);
+    // start the timer
+    LPC_TIM1->TCR = 1; 
     // Set timer for CANopen operation tick 8us , max time is 9+ hrs
 }
 
@@ -83,9 +83,9 @@
 OUTPUT    value TIMEVAL (unsigned long) the elapsed time
 ******************************************************************************/
 {
-	uint32_t timer = TimerCounter;	// Copy the value of the running timer
-  	// Calculate the time difference and return it
-  	return timer > last_time_set ? timer - last_time_set : last_time_set - timer;
+    uint32_t timer = TimerCounter;    // Copy the value of the running timer
+      // Calculate the time difference and return it
+      return timer > last_time_set ? timer - last_time_set : last_time_set - timer;
 }
 
 ///******************************************************************************
@@ -94,11 +94,11 @@
 
 extern "C" void TIMER1_IRQHandler()
 {
-	// clear all pending interrupts
-	LPC_TIM1->IR = 0x3F;
-	// store the time of the last interrupt occurance
-	last_time_set = TimerCounter;
-	// Call the time handler of the stack to adapt the elapsed time
-	TimeDispatch();                          
+    // clear all pending interrupts
+    LPC_TIM1->IR = 0x3F;
+    // store the time of the last interrupt occurance
+    last_time_set = TimerCounter;
+    // Call the time handler of the stack to adapt the elapsed time
+    TimeDispatch();                          
 }