2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\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
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
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
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
30 * This file initialises the two timers available in the Timer32 peripheral.
\r
32 * Channels 0 and 1 provide the interrupts that are used with the IntQ
\r
33 * standard demo tasks, which test interrupt nesting and using queues from
\r
37 /* Scheduler includes. */
\r
38 #include "FreeRTOS.h"
\r
40 /* Demo includes. */
\r
41 #include "IntQueueTimer.h"
\r
42 #include "IntQueue.h"
\r
44 /* The frequencies at which the two timers expire are slightly offset to ensure
\r
45 they don't remain synchronised. */
\r
46 #define tmrTIMER_0_FREQUENCY ( 2000UL )
\r
47 #define tmrTIMER_1_FREQUENCY ( 2003UL )
\r
49 /* The interrupts use the FreeRTOS API so must be at or below the max syscall
\r
50 interrupt priority. Counter-intuitively, the higher the numeric number the
\r
51 lower the logical priority. http://www.freertos.org/RTOS-Cortex-M3-M4.html */
\r
52 #define tmrLOWER_PRIORITY ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
\r
53 #define tmrHIGHER_PRIORITY ( configMAX_SYSCALL_INTERRUPT_PRIORITY + 1 )
\r
54 /*-----------------------------------------------------------*/
\r
56 /* Handlers for the two timer peripherals - two channels are used in the TC0
\r
58 void vT32_0_Handler( void );
\r
59 void vT32_1_Handler( void );
\r
61 /*-----------------------------------------------------------*/
\r
63 void vInitialiseTimerForIntQueueTest( void )
\r
65 /* Configure the timer channels. */
\r
66 MAP_Timer32_initModule( (uint32_t)TIMER32_0_BASE, TIMER32_PRESCALER_1, TIMER32_32BIT, TIMER32_PERIODIC_MODE );
\r
67 MAP_Timer32_setCount( (uint32_t)TIMER32_0_BASE, CS_getMCLK() / tmrTIMER_0_FREQUENCY );
\r
68 MAP_Timer32_enableInterrupt( (uint32_t)TIMER32_0_BASE );
\r
69 MAP_Timer32_startTimer( (uint32_t)TIMER32_0_BASE, false );
\r
70 MAP_Interrupt_setPriority( INT_T32_INT1, tmrLOWER_PRIORITY );
\r
71 MAP_Interrupt_enableInterrupt( INT_T32_INT1 );
\r
73 MAP_Timer32_initModule( (uint32_t)TIMER32_1_BASE, TIMER32_PRESCALER_1, TIMER32_32BIT, TIMER32_PERIODIC_MODE );
\r
74 MAP_Timer32_setCount( (uint32_t)TIMER32_1_BASE, CS_getMCLK() / tmrTIMER_1_FREQUENCY );
\r
75 MAP_Timer32_enableInterrupt( (uint32_t)TIMER32_1_BASE );
\r
76 MAP_Timer32_startTimer( (uint32_t)TIMER32_1_BASE, false );
\r
77 MAP_Interrupt_setPriority( INT_T32_INT2, tmrHIGHER_PRIORITY );
\r
78 MAP_Interrupt_enableInterrupt( INT_T32_INT2 );
\r
80 /*-----------------------------------------------------------*/
\r
82 void vT32_0_Handler( void )
\r
84 MAP_Timer32_clearInterruptFlag( (uint32_t)TIMER32_0_BASE );
\r
85 portYIELD_FROM_ISR( xFirstTimerHandler() );
\r
87 /*-----------------------------------------------------------*/
\r
89 void vT32_1_Handler( void )
\r
91 MAP_Timer32_clearInterruptFlag( (uint32_t)TIMER32_1_BASE );
\r
92 portYIELD_FROM_ISR( xSecondTimerHandler() );
\r