diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-02-19 20:41:40 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-02-19 20:41:40 +0000 |
commit | 71989f8323da84187bb4b06ef9d4435d037d7a27 (patch) | |
tree | 01227ace93e2d30ac0c4ec5959aa8aaaed769539 /nuttx/arch/c5471/src/up_timerisr.c | |
parent | 9de7429aec0c1f6bafcd03824f8b70cff7ee6461 (diff) | |
download | px4-nuttx-71989f8323da84187bb4b06ef9d4435d037d7a27.tar.gz px4-nuttx-71989f8323da84187bb4b06ef9d4435d037d7a27.tar.bz2 px4-nuttx-71989f8323da84187bb4b06ef9d4435d037d7a27.zip |
Progress with C5471 boot
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@8 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/c5471/src/up_timerisr.c')
-rw-r--r-- | nuttx/arch/c5471/src/up_timerisr.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nuttx/arch/c5471/src/up_timerisr.c b/nuttx/arch/c5471/src/up_timerisr.c index b636d1084..ab1155b71 100644 --- a/nuttx/arch/c5471/src/up_timerisr.c +++ b/nuttx/arch/c5471/src/up_timerisr.c @@ -41,7 +41,30 @@ #include <sys/types.h> #include <debug.h> #include <nuttx/arch.h> +#include "clock_internal.h" #include "up_internal.h" +#include "c5471.h" + +/************************************************************ + * Definitions + ************************************************************/ + +/* We want the general purpose timer running at the rate + * MSEC_PER_TICK. The C5471 clock is 47.5MHz and we're using + * a timer PTV value of 3 (3 == divide incoming frequency by + * 16) which then yields a 16 bitCLKS_PER_INT value + * of 29687. + * + * 47500000 / 16 = 2968750 clocks/sec + * 2968750 / 100 = 29687 clocks/ 100Hz interrupt + * + */ + +#define CLKS_PER_INT 29687 +#define CLKS_PER_INT_SHIFT 5 +#define AR 0x00000010 +#define ST 0x00000008 +#define PTV 0x00000003 /************************************************************ * Private Types @@ -91,3 +114,23 @@ int up_timerisr(int irq, uint32 *regs) current_regs = saved_regs; return 0; } + +void up_timerinit(void) +{ + uint32 val; + + up_disable_irq(C5471_IRQ_SYSTIMER); + + /* Start the general purpose timer running in auto-reload mode + * so that an interrupt is generated at the rate MSEC_PER_TICK. + */ + + val = ((CLKS_PER_INT-1) << CLKS_PER_INT_SHIFT) | AR | ST | PTV; + putreg32(val, C5471_TIMER2_CTRL); + + /* Attach and enable the timer interrupt */ + + irq_attach(C5471_IRQ_SYSTIMER, (xcpt_t)up_timerisr); + up_enable_irq(C5471_IRQ_SYSTIMER); +} + |