]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/IntQueueTimer.c
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Demo / CORTEX_LM3Sxxxx_IAR_Keil / IntQueueTimer.c
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 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. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /* Scheduler includes. */\r
30 #include "FreeRTOS.h"\r
31 \r
32 /* Demo includes. */\r
33 #include "IntQueueTimer.h"\r
34 #include "IntQueue.h"\r
35 \r
36 /* Library includes. */\r
37 #include "hw_ints.h"\r
38 #include "hw_memmap.h"\r
39 #include "hw_types.h"\r
40 #include "interrupt.h"\r
41 #include "sysctl.h"\r
42 #include "lmi_timer.h"\r
43 \r
44 #define tmrTIMER_2_FREQUENCY    ( 2000UL )\r
45 #define tmrTIMER_3_FREQUENCY    ( 2001UL )\r
46 \r
47 void vInitialiseTimerForIntQueueTest( void )\r
48 {\r
49 unsigned long ulFrequency;\r
50 \r
51         /* Timer 2 and 3 are utilised for this test. */\r
52         SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER2 );\r
53     SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER3 );\r
54     TimerConfigure( TIMER2_BASE, TIMER_CFG_32_BIT_PER );\r
55     TimerConfigure( TIMER3_BASE, TIMER_CFG_32_BIT_PER );\r
56         \r
57         /* Set the timer interrupts to be above the kernel.  The interrupts are\r
58          assigned different priorities so they nest with each other. */\r
59         IntPrioritySet( INT_TIMER2A, configMAX_SYSCALL_INTERRUPT_PRIORITY + ( 1 << 5 ) ); /* Shift left 5 as only the top 3 bits are implemented. */\r
60         IntPrioritySet( INT_TIMER3A, configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
61 \r
62         /* Ensure interrupts do not start until the scheduler is running. */\r
63         portDISABLE_INTERRUPTS();\r
64         \r
65         /* The rate at which the timers will interrupt. */\r
66         ulFrequency = configCPU_CLOCK_HZ / tmrTIMER_2_FREQUENCY;        \r
67     TimerLoadSet( TIMER2_BASE, TIMER_A, ulFrequency );\r
68     IntEnable( INT_TIMER2A );\r
69     TimerIntEnable( TIMER2_BASE, TIMER_TIMA_TIMEOUT );\r
70 \r
71         /* The rate at which the timers will interrupt. */\r
72         ulFrequency = configCPU_CLOCK_HZ / tmrTIMER_3_FREQUENCY;        \r
73     TimerLoadSet( TIMER3_BASE, TIMER_A, ulFrequency );\r
74     IntEnable( INT_TIMER3A );\r
75     TimerIntEnable( TIMER3_BASE, TIMER_TIMA_TIMEOUT );\r
76 \r
77     /* Enable both timers. */   \r
78     TimerEnable( TIMER2_BASE, TIMER_A );\r
79     TimerEnable( TIMER3_BASE, TIMER_A );\r
80 }\r
81 /*-----------------------------------------------------------*/\r
82 \r
83 void vT2InterruptHandler( void )\r
84 {\r
85     TimerIntClear( TIMER2_BASE, TIMER_TIMA_TIMEOUT );   \r
86         portEND_SWITCHING_ISR( xFirstTimerHandler() );\r
87 }\r
88 /*-----------------------------------------------------------*/\r
89 \r
90 void vT3InterruptHandler( void )\r
91 {\r
92         TimerIntClear( TIMER3_BASE, TIMER_TIMA_TIMEOUT );\r
93         portEND_SWITCHING_ISR( xSecondTimerHandler() );\r
94 }\r
95 \r
96 \r