]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M0+_LPC51U68_LPCXpresso/app/IntQueueTimer.c
Remove build files accidentally checked in.
[freertos] / FreeRTOS / Demo / CORTEX_M0+_LPC51U68_LPCXpresso / app / IntQueueTimer.c
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 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 #include "task.h"\r
31 \r
32 /* Demo includes. */\r
33 #include "IntQueueTimer.h"\r
34 #include "IntQueue.h"\r
35 \r
36 /* Driver APIs.*/\r
37 #include "fsl_ctimer.h"\r
38 \r
39 /* The priorities for the two timers.  Note that a priority of 0 is the highest\r
40 possible on Cortex-M devices. */\r
41 #define tmrMAX_PRIORITY                         ( 0UL )\r
42 #define trmSECOND_HIGHEST_PRIORITY ( tmrMAX_PRIORITY + 1 )\r
43 \r
44 void vInitialiseTimerForIntQueueTest( void )\r
45 {\r
46 ctimer_config_t xConfigTimer0, xConfigTimer1;\r
47 ctimer_match_config_t xConfigInterrupt = { 0 };\r
48 \r
49         memset( &xConfigTimer0, 0x00, sizeof( xConfigTimer0 ) );\r
50         memset( &xConfigTimer1, 0x00, sizeof( xConfigTimer1 ) );\r
51 \r
52         /* Enable peripheral bus clock for CTIMER0 and CTIMER1. */\r
53         CLOCK_EnableClock( kCLOCK_Ctimer0 );\r
54         CLOCK_EnableClock( kCLOCK_Ctimer1 );\r
55 \r
56         /* Interrupt settings for timers --\r
57         A timer will generates an interrupt when the count matches the value specified.\r
58         Timer will reset itself and restart the count. The interrupt frequency is fairly\r
59         arbitrary, in a sense that all we need to make sure is IRQs are triggered so that\r
60         queues have items for tasks to process. */\r
61         xConfigInterrupt.enableCounterReset = true;\r
62         xConfigInterrupt.enableCounterStop = false;\r
63         xConfigInterrupt.enableInterrupt = true;\r
64         xConfigInterrupt.matchValue = 0xFFFFF;\r
65         xConfigInterrupt.outControl = kCTIMER_Output_NoAction;\r
66         xConfigInterrupt.outPinInitState = true;\r
67 \r
68         /* Configuration settings for timers. */\r
69         CTIMER_GetDefaultConfig( &xConfigTimer0 );\r
70         xConfigTimer0.prescale = 1;\r
71 \r
72         CTIMER_GetDefaultConfig( &xConfigTimer1 );\r
73         xConfigTimer1.prescale = 2;\r
74 \r
75         /* Initialize timers. */\r
76         CTIMER_Init( CTIMER0, &xConfigTimer0 );\r
77         CTIMER_SetupMatch( CTIMER0, kCTIMER_Match_0, &xConfigInterrupt );\r
78 \r
79         CTIMER_Init( CTIMER1, &xConfigTimer1 );\r
80         CTIMER_SetupMatch( CTIMER1, kCTIMER_Match_0, &xConfigInterrupt );\r
81 \r
82         /* Don't generate interrupts until the scheduler has been started.\r
83         Interrupts will be automatically enabled when the first task starts\r
84         running. */\r
85         taskDISABLE_INTERRUPTS();\r
86 \r
87         /* Set the timer interrupts to be above the kernel.  The interrupts are\r
88         assigned different priorities so they nest with each other. */\r
89         NVIC_SetPriority( CTIMER0_IRQn, trmSECOND_HIGHEST_PRIORITY );\r
90         NVIC_SetPriority( CTIMER1_IRQn, tmrMAX_PRIORITY );\r
91 \r
92         /* Enable the timer interrupts. */\r
93         NVIC_EnableIRQ( CTIMER0_IRQn );\r
94         NVIC_EnableIRQ( CTIMER1_IRQn );\r
95 \r
96         /* Start timers. */\r
97         CTIMER_StartTimer( CTIMER0 );\r
98         CTIMER_StartTimer( CTIMER1 );\r
99 }\r
100 /*-----------------------------------------------------------*/\r
101 \r
102 void CTIMER0_IRQHandler( void )\r
103 {\r
104 uint32_t ulInterruptStatus;\r
105 \r
106         /* Get Interrupt status flags */\r
107         ulInterruptStatus = CTIMER_GetStatusFlags( CTIMER0 );\r
108 \r
109         /* Clear the status flags that were set */\r
110         CTIMER_ClearStatusFlags( CTIMER0, ulInterruptStatus );\r
111 \r
112         portEND_SWITCHING_ISR( xFirstTimerHandler() );\r
113 }\r
114 /*-----------------------------------------------------------*/\r
115 \r
116 void CTIMER1_IRQHandler(void)\r
117 {\r
118 uint32_t ulInterruptStatus;\r
119 \r
120         /* Get Interrupt status flags */\r
121         ulInterruptStatus = CTIMER_GetStatusFlags( CTIMER1 );\r
122 \r
123         /* Clear the status flags that were set */\r
124         CTIMER_ClearStatusFlags( CTIMER1, ulInterruptStatus );\r
125 \r
126         portEND_SWITCHING_ISR( xSecondTimerHandler() );\r
127 }\r
128 /*-----------------------------------------------------------*/\r