--- /dev/null
+/*\r
+ FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+ ***************************************************************************\r
+ >>! NOTE: The modification to the GPL is included to allow you to !<<\r
+ >>! distribute a combined work that includes FreeRTOS without being !<<\r
+ >>! obliged to provide the source code for proprietary components !<<\r
+ >>! outside of the FreeRTOS kernel. !<<\r
+ ***************************************************************************\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that is more than just the market leader, it *\r
+ * is the industry's de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly while simultaneously helping *\r
+ * to support the FreeRTOS project by purchasing a FreeRTOS *\r
+ * tutorial book, reference manual, or both: *\r
+ * http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
+ the FAQ page "My application does not run, what could be wrong?". Have you\r
+ defined configASSERT()?\r
+\r
+ http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+ embedded software for free we request you assist our global community by\r
+ participating in the support forum.\r
+\r
+ http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+ be as productive as possible as early as possible. Now you can receive\r
+ FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+ Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+ Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+ Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * This file contains the non-portable and therefore RZ/T specific parts of\r
+ * the IntQueue standard demo task - namely the configuration of the timers\r
+ * that generate the interrupts and the interrupt entry points.\r
+ */\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Demo includes. */\r
+#include "IntQueueTimer.h"\r
+#include "IntQueue.h"\r
+\r
+/* Renesas includes. */\r
+#include "r_cg_macrodriver.h"\r
+#include "r_cg_cmt.h"\r
+#include "r_reset.h"\r
+\r
+#define tmrCMT_1_CHANNEL_0_HZ ( 2000UL )\r
+#define tmrCMT_1_CHANNEL_1_HZ ( 2011UL )\r
+\r
+/* Handlers for the two timers used. See the documentation page\r
+for this port on http://www.FreeRTOS.org for more information on writing\r
+interrupt handlers. */\r
+void vCMT_1_Channel_0_ISR( void );\r
+void vCMT_1_Channel_1_ISR( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vInitialiseTimerForIntQueueTest( void )\r
+{\r
+uint32_t ulCompareMatchValue;\r
+const uint32_t ulPeripheralClockDivider = 6UL, ulCMTClockDivider = 8UL;\r
+extern void FreeRTOS_IRQ_Handler( void );\r
+\r
+ /* Disable CMI2 and CMI3 interrupts. */\r
+ VIC.IEC0.LONG = ( 1UL << 23UL ) | ( 1UL << 24UL );\r
+\r
+ /* Cancel CMT stop state in LPC. */\r
+ r_rst_write_enable();\r
+ MSTP( CMT1 ) = 0U;\r
+ r_rst_write_disable();\r
+\r
+ /* Interrupt on compare match. */\r
+ CMT2.CMCR.BIT.CMIE = 1;\r
+ CMT3.CMCR.BIT.CMIE = 1;\r
+\r
+ /* Calculate the compare match value. */\r
+ ulCompareMatchValue = configCPU_CLOCK_HZ / ulPeripheralClockDivider;\r
+ ulCompareMatchValue /= ulCMTClockDivider;\r
+ ulCompareMatchValue /= tmrCMT_1_CHANNEL_0_HZ;\r
+ ulCompareMatchValue -= 1UL;\r
+ CMT2.CMCOR = ( unsigned short ) ulCompareMatchValue;\r
+\r
+ ulCompareMatchValue = configCPU_CLOCK_HZ / ulPeripheralClockDivider;\r
+ ulCompareMatchValue /= ulCMTClockDivider;\r
+ ulCompareMatchValue /= tmrCMT_1_CHANNEL_1_HZ;\r
+ ulCompareMatchValue -= 1UL;\r
+ CMT3.CMCOR = ( unsigned short ) ulCompareMatchValue;\r
+\r
+ /* Divide the PCLK by 8. */\r
+ CMT2.CMCR.BIT.CKS = 0;\r
+ CMT3.CMCR.BIT.CKS = 0;\r
+\r
+ /* Clear count to 0. */\r
+ CMT2.CMCNT = 0;\r
+ CMT3.CMCNT = 0;\r
+\r
+ /* Set CMI2 and CMI3 edge detection type. */\r
+ VIC.PLS0.LONG |= ( 1UL << 23UL ) | ( 1UL << 24UL );\r
+\r
+ /* Set CMI2 and CMI3 priority levels so they nest. */\r
+ VIC.PRL23.LONG = _CMT_PRIORITY_LEVEL10;\r
+ VIC.PRL24.LONG = _CMT_PRIORITY_LEVEL9;\r
+\r
+ /* Set CMI2 and CMI3 interrupt address. */\r
+#warning Int 1 timer handler addresses not set.\r
+ VIC.VAD23.LONG = ( uint32_t ) NULL;\r
+ VIC.VAD24.LONG = ( uint32_t ) NULL;\r
+\r
+ /* Enable CMI2 and CMI3 interrupts in ICU. */\r
+ VIC.IEN0.LONG |= ( 1UL << 23UL ) | ( 1UL << 24UL );\r
+\r
+ /* Start CMT1 channel 0 and 1 count. */\r
+ CMT.CMSTR1.BIT.STR2 = 1U;\r
+ CMT.CMSTR1.BIT.STR3 = 1U;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vCMT_1_Channel_0_ISR( void )\r
+{\r
+ /* Re-enabled interrupts. */\r
+ taskENABLE_INTERRUPTS();\r
+\r
+ /* Call the handler that is part of the common code - this is where the\r
+ non-portable code ends and the actual test is performed. */\r
+ portYIELD_FROM_ISR( xFirstTimerHandler() );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vCMT_1_Channel_1_ISR( void )\r
+{\r
+ /* Re-enabled interrupts. */\r
+ portENABLE_INTERRUPTS();\r
+\r
+ /* Call the handler that is part of the common code - this is where the\r
+ non-portable code ends and the actual test is performed. */\r
+ portYIELD_FROM_ISR( xSecondTimerHandler() );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r
+\r
+\r
+\r