summaryrefslogtreecommitdiff
path: root/src/c/hardware/avr/timer
diff options
context:
space:
mode:
authorsiddhu89902016-01-13 11:15:17 +0530
committersiddhu89902016-01-13 11:15:17 +0530
commit7cba1cf7d2ee89559239a22c50297a1545de0587 (patch)
tree5319b21a5679b6dabf10c57346cea9b41db02ac2 /src/c/hardware/avr/timer
parentd166736e0eb384156d30bcea45711d4c8d474ee1 (diff)
downloadScilab2C_fossee_old-7cba1cf7d2ee89559239a22c50297a1545de0587.tar.gz
Scilab2C_fossee_old-7cba1cf7d2ee89559239a22c50297a1545de0587.tar.bz2
Scilab2C_fossee_old-7cba1cf7d2ee89559239a22c50297a1545de0587.zip
Test commit
Diffstat (limited to 'src/c/hardware/avr/timer')
-rw-r--r--src/c/hardware/avr/timer/u8AVRGetTimerValues.c37
-rw-r--r--src/c/hardware/avr/timer/u8AVRTimerSetups.c42
2 files changed, 79 insertions, 0 deletions
diff --git a/src/c/hardware/avr/timer/u8AVRGetTimerValues.c b/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
new file mode 100644
index 0000000..c542c18
--- /dev/null
+++ b/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
@@ -0,0 +1,37 @@
+// Function to get timer count
+//
+// Calling Sequence
+// u8AVRGetTimerValues(timer)
+//
+// Parameters
+// timer: timer whose current count is to be returned (0,1,2)
+// ***Refer datasheet for more description about timer
+//
+// Description
+// This function returns the count of timer specified
+//
+//
+// Authors
+// Siddhesh Wani
+//
+
+
+#include "AVRPeripheralTimer.h"
+
+
+uint8 u8AVRGetTimerValues(uint8 timer)
+{
+ switch(timer)
+ {
+ case 0:
+ return TCNT0;
+
+ case 1:
+ break;
+ case 2:
+ return TCNT2;
+ }
+
+ return 0;
+}
+
diff --git a/src/c/hardware/avr/timer/u8AVRTimerSetups.c b/src/c/hardware/avr/timer/u8AVRTimerSetups.c
new file mode 100644
index 0000000..1d93429
--- /dev/null
+++ b/src/c/hardware/avr/timer/u8AVRTimerSetups.c
@@ -0,0 +1,42 @@
+// Function to setup timer on AVR
+//
+// Calling Sequence
+// u8AVRTimerSetups(timer, prescalar)
+//
+// Parameters
+// timer: timer to be set up (0,1,2)
+// prescalar: prescalar to be used for timer (0-7)
+// ***Refer datasheet for more description about timer
+//
+// Description
+// This function sets prescalr for timers. 'timer' decides which of the
+// three (0,1,2) timers available to be used. The 'prescalar' is needed for
+// deciding timer clock. Select appropriate prescalar depending on MCU clock
+// and requirement.
+//
+//
+// Authors
+// Siddhesh Wani
+//
+
+
+#include "AVRPeripheralTimer.h"
+
+
+uint8 u8AVRTimerSetups(uint8 timer,uint8 prescalar)
+{
+ switch(timer)
+ {
+ case 0:
+ TCCR0|= (prescalar & 0x07); //Select clock source
+ break;
+ case 1:
+ break;
+ case 2:
+ TCCR2|= (prescalar & 0x07); //Select clock source
+ break;
+ }
+
+ return 0;
+}
+