diff options
Diffstat (limited to 'firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c')
-rw-r--r-- | firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c new file mode 100644 index 0000000000..4d7167b3ba --- /dev/null +++ b/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * | ||
10 | * Copyright (C) 2009 by Jorge Pinto | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "kernel.h" | ||
25 | #include "timer.h" | ||
26 | #include "thread.h" | ||
27 | #include "at91sam9260.h" | ||
28 | |||
29 | /*----------------------------------------------------------------------------- | ||
30 | * Function Name : pitc_handler | ||
31 | * Object : Handler for PITC interrupt | ||
32 | *---------------------------------------------------------------------------*/ | ||
33 | void pitc_handler(void) | ||
34 | { | ||
35 | unsigned long pivr = 0; | ||
36 | unsigned long pisr = 0; | ||
37 | |||
38 | /* Read the PISR */ | ||
39 | pisr = AT91C_PITC_PISR & AT91C_PITC_PITS; | ||
40 | |||
41 | /* Read the PIVR. It acknowledges the IT */ | ||
42 | pivr = AT91C_PITC_PIVR; | ||
43 | |||
44 | /* Run through the list of tick tasks */ | ||
45 | call_tick_tasks(); | ||
46 | } | ||
47 | |||
48 | void tick_start(unsigned int interval_in_ms) | ||
49 | { | ||
50 | volatile unsigned long pimr = 0; | ||
51 | |||
52 | /* Configure a resolution of 1 ms */ | ||
53 | AT91C_PITC_PIMR = MCK_FREQ / (((16 * 1000) - 1) / interval_in_ms); | ||
54 | |||
55 | /* Enable interrupts */ | ||
56 | /* Disable the interrupt on the interrupt controller */ | ||
57 | AT91C_AIC_IDCR = (1 << AT91C_ID_SYS); | ||
58 | |||
59 | /* Save the interrupt handler routine pointer and the interrupt priority */ | ||
60 | AT91C_AIC_SVR(AT91C_ID_SYS) = (unsigned long) pitc_handler; | ||
61 | |||
62 | /* Store the Source Mode Register */ | ||
63 | AT91C_AIC_SMR(AT91C_ID_SYS) = AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | \ | ||
64 | AT91C_AIC_PRIOR_LOWEST; | ||
65 | /* Clear the interrupt on the interrupt controller */ | ||
66 | AT91C_AIC_ICCR = (1 << AT91C_ID_SYS); | ||
67 | |||
68 | /* Enable the interrupt on the interrupt controller */ | ||
69 | AT91C_AIC_IECR = (1 << AT91C_ID_SYS); | ||
70 | |||
71 | /* Enable the interrupt on the pit */ | ||
72 | pimr = AT91C_PITC_PIMR; | ||
73 | AT91C_PITC_PIMR = pimr | AT91C_PITC_PITIEN; | ||
74 | |||
75 | /* Enable the pit */ | ||
76 | pimr = AT91C_PITC_PIMR; | ||
77 | AT91C_PITC_PIMR = pimr | AT91C_PITC_PITEN; | ||
78 | } | ||