]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/IntQueueTimer.c
fda25c3a1afbbc67b2f12d5f4c6a2b309e54bd0a
[freertos] / FreeRTOS / Demo / CORTEX_LM3Sxxxx_Rowley / IntQueueTimer.c
1 /*\r
2  * FreeRTOS Kernel V10.3.0\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /* Scheduler includes. */\r
29 #include "FreeRTOS.h"\r
30 \r
31 /* Demo includes. */\r
32 #include "IntQueueTimer.h"\r
33 #include "IntQueue.h"\r
34 \r
35 /* Library includes. */\r
36 #include "hw_ints.h"\r
37 #include "hw_memmap.h"\r
38 #include "hw_types.h"\r
39 #include "interrupt.h"\r
40 #include "sysctl.h"\r
41 #include "lmi_timer.h"\r
42 \r
43 #define tmrTIMER_2_FREQUENCY    ( 2000UL )\r
44 #define tmrTIMER_3_FREQUENCY    ( 2001UL )\r
45 \r
46 void vInitialiseTimerForIntQueueTest( void )\r
47 {\r
48 unsigned long ulFrequency;\r
49 \r
50         /* Timer 2 and 3 are utilised for this test. */\r
51         SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER2 );\r
52     SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER3 );\r
53     TimerConfigure( TIMER2_BASE, TIMER_CFG_32_BIT_PER );\r
54     TimerConfigure( TIMER3_BASE, TIMER_CFG_32_BIT_PER );\r
55         \r
56         /* Set the timer interrupts to be above the kernel.  The interrupts are\r
57          assigned different priorities so they nest with each other. */\r
58         IntPrioritySet( INT_TIMER2A, configMAX_SYSCALL_INTERRUPT_PRIORITY + ( 1 << 5 ) ); /* Shift left 5 as only the top 3 bits are implemented. */\r
59         IntPrioritySet( INT_TIMER3A, configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
60 \r
61         /* Ensure interrupts do not start until the scheduler is running. */\r
62         portDISABLE_INTERRUPTS();\r
63         \r
64         /* The rate at which the timers will interrupt. */\r
65         ulFrequency = configCPU_CLOCK_HZ / tmrTIMER_2_FREQUENCY;        \r
66     TimerLoadSet( TIMER2_BASE, TIMER_A, ulFrequency );\r
67     IntEnable( INT_TIMER2A );\r
68     TimerIntEnable( TIMER2_BASE, TIMER_TIMA_TIMEOUT );\r
69 \r
70         /* The rate at which the timers will interrupt. */\r
71         ulFrequency = configCPU_CLOCK_HZ / tmrTIMER_3_FREQUENCY;        \r
72     TimerLoadSet( TIMER3_BASE, TIMER_A, ulFrequency );\r
73     IntEnable( INT_TIMER3A );\r
74     TimerIntEnable( TIMER3_BASE, TIMER_TIMA_TIMEOUT );\r
75 \r
76     /* Enable both timers. */   \r
77     TimerEnable( TIMER2_BASE, TIMER_A );\r
78     TimerEnable( TIMER3_BASE, TIMER_A );\r
79 }\r
80 /*-----------------------------------------------------------*/\r
81 \r
82 void vT2InterruptHandler( void )\r
83 {\r
84     TimerIntClear( TIMER2_BASE, TIMER_TIMA_TIMEOUT );   \r
85         portEND_SWITCHING_ISR( xFirstTimerHandler() );\r
86 }\r
87 /*-----------------------------------------------------------*/\r
88 \r
89 void vT3InterruptHandler( void )\r
90 {\r
91         TimerIntClear( TIMER3_BASE, TIMER_TIMA_TIMEOUT );\r
92         portEND_SWITCHING_ISR( xSecondTimerHandler() );\r
93 }\r
94 \r
95 \r