From: richardbarry Date: Tue, 4 Jan 2011 17:40:27 +0000 (+0000) Subject: Added PSoC5 demo applications. X-Git-Tag: V6.1.1~34 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4be6a43e0a77d23a2d33ced554407ea25e5eb2b4;p=freertos Added PSoC5 demo applications. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1223 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo Workspace.cywrk b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo Workspace.cywrk new file mode 100644 index 000000000..fcfe6936d --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo Workspace.cywrk @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h new file mode 100644 index 000000000..4180c4c6a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h @@ -0,0 +1,120 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#include + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) BCLK__BUS_CLK__HZ ) +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_CO_ROUTINES 0 +#define configUSE_MUTEXES 1 + +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 10 +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_MALLOC_FAILED_HOOK 1 + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 + +/** + * Configure the number of priority bits. This is normally + * __NVIC_PRIO_BITS but PSoC Creator beta 5 contained a larger + * value for the priority than is implemented in the hardware so + * set it here to what the data sheet describes. + */ +#define configPRIO_BITS 3 /* 8 priority levels */ + +/* The lowest priority. */ +#define configKERNEL_INTERRUPT_PRIORITY ( 7 << (8 - configPRIO_BITS) ) + +/* Priority 5, or 160 as only the top three bits are implemented. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 5 << (8 - configPRIO_BITS) ) + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr new file mode 100644 index 000000000..239418cc3 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj new file mode 100644 index 000000000..0b1cd766e --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj @@ -0,0 +1,1010 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.c new file mode 100644 index 000000000..94787b3d4 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.c @@ -0,0 +1,98 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "task.h" +/*---------------------------------------------------------------------------*/ + +extern portBASE_TYPE xFirstTimerHandler( void ); +extern portBASE_TYPE xSecondTimerHandler( void ); +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vHighFrequencyFirstISR); +CY_ISR_PROTO(vHighFrequencySecondISR); +/*---------------------------------------------------------------------------*/ + +/** + * Installs and starts the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ) +{ + taskENTER_CRITICAL(); + { + /* Initialise and start the First Timer ISR. */ + isr_High_Frequency_2000Hz_ClearPending(); + isr_High_Frequency_2000Hz_StartEx((cyisraddress)vHighFrequencyFirstISR); + + /* Initialise and start the Second Timer ISR. */ + isr_High_Frequency_2001Hz_ClearPending(); + isr_High_Frequency_2001Hz_StartEx((cyisraddress)vHighFrequencySecondISR); + } + taskEXIT_CRITICAL(); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencyFirstISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xFirstTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencySecondISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xSecondTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.h new file mode 100644 index 000000000..a022717fd --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/IntQueueTimer.h @@ -0,0 +1,62 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef INT_QUEUE_TIMER_H_ +#define INT_QUEUE_TIMER_H_ + +/** + * Install and start the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ); + +#endif /* INT_QUEUE_TIMER_H_ */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/ParTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/ParTest.c new file mode 100644 index 000000000..e98e673de --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/ParTest.c @@ -0,0 +1,117 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +#include "FreeRTOS.h" +#include "task.h" +#include "partest.h" +/*---------------------------------------------------------------------------*/ + +#define partstMAX_LED ( 4 ) +/*---------------------------------------------------------------------------*/ + +static volatile char cLedOutput[ partstMAX_LED ]; +/*---------------------------------------------------------------------------*/ + +void vParTestInitialise( void ) +{ +long lIndex; + for ( lIndex = 0; lIndex < partstMAX_LED; lIndex++ ) + { + cLedOutput[ lIndex ] = 0; + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + taskENTER_CRITICAL(); + { + switch ( uxLED ) + { + case 0: + Pin_LED_0_Write( xValue & 0x1 ); + break; + case 1: + Pin_LED_1_Write( xValue & 0x1 ); + break; + case 2: + Pin_LED_2_Write( xValue & 0x1 ); + break; + case 3: + Pin_LED_3_Write( xValue & 0x1 ); + break; + default: + /* Do nothing. */ + break; + } + } + taskEXIT_CRITICAL(); + + /* Record the output for the sake of toggling. */ + if ( uxLED < partstMAX_LED ) + { + cLedOutput[ uxLED ] = ( xValue & 0x1 ); + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) +{ + if ( uxLED < partstMAX_LED ) + { + vParTestSetLED( uxLED, !cLedOutput[ uxLED ] ); + } +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/Serial.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/Serial.c new file mode 100644 index 000000000..a82d0c00a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/Serial.c @@ -0,0 +1,226 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "queue.h" +#include "task.h" +#include "serial.h" +/*---------------------------------------------------------------------------*/ + +#define serialSTRING_DELAY_TICKS ( portMAX_DELAY ) +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vUartRxISR); +CY_ISR_PROTO(vUartTxISR); +/*---------------------------------------------------------------------------*/ + +static xQueueHandle xSerialTxQueue = NULL; +static xQueueHandle xSerialRxQueue = NULL; +/*---------------------------------------------------------------------------*/ + +xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) +{ + /* Configure Rx. */ + xSerialRxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_RX_BYTE_RECEIVED_ClearPending(); + isr_UART1_RX_BYTE_RECEIVED_StartEx(vUartRxISR); + + /* Configure Tx */ + xSerialTxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_TX_BYTE_COMPLETE_ClearPending() ; + isr_UART1_TX_BYTE_COMPLETE_StartEx(vUartTxISR); + + /* Clear the interrupt modes for the Tx for the time being. */ + UART_1_SetTxInterruptMode( 0 ); + + /* Both configured successfully. */ + return (xComPortHandle)( xSerialTxQueue && xSerialRxQueue ); +} +/*---------------------------------------------------------------------------*/ + +void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength ) +{ +unsigned short usIndex = 0; + for ( usIndex = 0; usIndex < usStringLength; usIndex++ ) + { + /* Check for pre-mature end of line. */ + if ( '\0' == pcString[ usIndex ] ) + { + break; + } + + /* Send out, one character at a time. */ + if ( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) ) + { + /* Failed to send, this will be picked up in the receive comtest task. */ + } + } +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + if ( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) ) + { + /* Picked up a character. */ + xReturn = pdTRUE; + } + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + + /* The ISR is processing characters is so just add to the end of the queue. */ + if ( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) ) + { + xReturn = pdTRUE; + } + else + { + /* The queue is probably full. */ + xReturn = pdFALSE; + } + + /* Make sure that the interrupt will fire in the case where: + * Currently sending so the Tx Complete will fire. + * Not sending so the Empty will fire. + */ + taskENTER_CRITICAL(); + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY ); + taskEXIT_CRITICAL(); + + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartRxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cInChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadRxStatus(); + + /* Only interested in a character being received. */ + if ( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) ) + { + /* Get the character. */ + cInChar = UART_1_GetChar(); + + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Try to deliver the character. */ + if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) ) + { + /* Run out of space. */ + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartTxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cOutChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadTxStatus(); + + /* Check to see whether this is a genuine interrupt. */ + if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) + || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) ) + { + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) ) + { + /* Send the next character. */ + UART_1_PutChar( cOutChar ); + + /* If we are firing, then the only interrupt we are interested in + * is the Complete. The application code will add the Empty interrupt + * when there is something else to be done. + */ + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE ); + } + else + { + /* There is no work left so disable the interrupt + * until the application puts more into the queue. + */ + UART_1_SetTxInterruptMode( 0 ); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TimerTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TimerTest.c new file mode 100644 index 000000000..3087d1683 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TimerTest.c @@ -0,0 +1,128 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +/* High speed timer test as described in main.c. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* The set frequency of the interrupt. Deviations from this are measured as +the jitter. */ +#define timerINTERRUPT_FREQUENCY ( ( unsigned portSHORT ) 20000 ) + +/* The expected time between each of the timer interrupts - if the jitter was +zero. */ +#define timerEXPECTED_DIFFERENCE_VALUE ( configCPU_CLOCK_HZ / timerINTERRUPT_FREQUENCY ) + +/* The number of interrupts to pass before we start looking at the jitter. */ +#define timerSETTLE_TIME 5 +/*---------------------------------------------------------------------------*/ + +/* + * Configures the two timers used to perform the test. + */ +void vSetupTimerTest( void ); + +/* Interrupt handler in which the jitter is measured. */ +CY_ISR_PROTO(vTimer20KHzISR); + +/* Stores the value of the maximum recorded jitter between interrupts. */ +volatile unsigned portSHORT usMaxJitter = 0; +/*---------------------------------------------------------------------------*/ + +void vSetupTimerTest( void ) +{ + /* Install the ISR. */ + isrTimer_20KHz_TC_StartEx(vTimer20KHzISR); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vTimer20KHzISR) +{ +static unsigned short usLastCount = 0, usSettleCount = 0, usMaxDifference = 0; +unsigned short usThisCount, usDifference; + + /* Capture the free running timer value as we enter the interrupt. */ + usThisCount = Timer_48MHz_ReadCounter(); + + if( usSettleCount >= timerSETTLE_TIME ) + { + /* What is the difference between the timer value in this interrupt + and the value from the last interrupt. Timer counts down. */ + usDifference = usLastCount + ~usThisCount + 1; + + /* Store the difference in the timer values if it is larger than the + currently stored largest value. The difference over and above the + expected difference will give the 'jitter' in the processing of these + interrupts. */ + if( usDifference > usMaxDifference ) + { + usMaxDifference = usDifference; + + /* Calculate the Jitter based on the difference we expect. */ + usMaxJitter = usMaxDifference - timerEXPECTED_DIFFERENCE_VALUE; + } + } + else + { + /* Don't bother storing any values for the first couple of + interrupts. */ + usSettleCount++; + } + + /* Remember what the timer value was this time through, so we can calculate + the difference the next time through. */ + usLastCount = usThisCount; +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch new file mode 100644 index 000000000..eb724d6d6 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/device.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/device.h new file mode 100644 index 000000000..d249d209a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/device.h @@ -0,0 +1,20 @@ +/******************************************************************************* +* Copyright 2009, Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +********************************************************************************/ +/* ======================================== + * + * This file is automatically generated by PSoC Creator + * and should not be edited by hand. + * + * This file is necessary for your project to build. + * Please do not delete it. + * + * ======================================== +*/ + +#include + +/*[]*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/main.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/main.c new file mode 100644 index 000000000..3aa26e31c --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_GCC/FreeRTOS_Demo.cydsn/main.c @@ -0,0 +1,347 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +/* RTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" + +/* Common Demo includes. */ +#include "serial.h" +#include "BlockQ.h" +#include "blocktim.h" +#include "comtest.h" +#include "countsem.h" +#include "death.h" +#include "dynamic.h" +#include "flash.h" +#include "flop.h" +#include "GenQTest.h" +#include "integer.h" +#include "IntQueue.h" +#include "mevents.h" +#include "partest.h" +#include "PollQ.h" +#include "print.h" +#include "QPeek.h" +#include "semtest.h" +/*---------------------------------------------------------------------------*/ + +/* The time between cycles of the 'check' functionality (defined within the +tick hook. */ +#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) +#define mainCOM_LED ( 3 ) + +/* The number of nano seconds between each processor clock. */ +#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) ) + +/* Task priorities. */ +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainCOM_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainFLASH_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) +/*---------------------------------------------------------------------------*/ + +/* + * Configures the timers and interrupts for the fast interrupt test as + * described at the top of this file. + */ +extern void vSetupTimerTest( void ); +/*---------------------------------------------------------------------------*/ + +/** + * The Check task periodical interrogates each of the running tests to + * ensure that they are still executing correctly. + * If all the tests pass, then the LCD is updated with Pass, the number of + * iterations and the Jitter time calculated but the Fast Interrupt Test. + * If any one of the tests fail, it is indicated with an error code printed on + * the display. This indicator won't disappear until the device is reset. + */ +void vCheckTask( void *pvParameters ); + +/** + * Installs the RTOS interrupt handlers and starts the peripherals. + */ +static void prvHardwareSetup( void ); +/*---------------------------------------------------------------------------*/ + +void main( void ) +{ +unsigned long ulLed = 0; +unsigned long ulIteration = 0; + + /* Place your initialization/startup code here (e.g. MyInst_Start()) */ + prvHardwareSetup(); + + /* Poll the switch connected to P1[7] + * to prevent the Soak test from (re)starting. + */ + while ( 0 != Startup_Release_Switch_Read() ) + { + if ( 100000 <= ulIteration++ ) + { + vParTestToggleLED( ulLed++ ); + ulLed = ulLed % 4; + ulIteration = 0; + } + } + + /* Reset the LEDS. */ + for ( ulLed = 0; ulLed < 4; ulLed++ ) + { + vParTestSetLED( ulLed, pdFALSE ); + } + + /* Start the standard demo tasks. These are just here to exercise the + kernel port and provide examples of how the FreeRTOS API can be used. */ + vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); + vCreateBlockTimeTasks(); + vStartCountingSemaphoreTasks(); + vStartDynamicPriorityTasks(); + vStartMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); + vStartQueuePeekTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartLEDFlashTasks( mainFLASH_TEST_TASK_PRIORITY ); + vAltStartComTestTasks( mainCOM_TEST_TASK_PRIORITY, 57600, mainCOM_LED ); + vStartInterruptQueueTasks(); + + /* Start the error checking task. */ + (void)xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); + + /* Configure the timers used by the fast interrupt timer test. */ + vSetupTimerTest(); + + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation in order to ascertain whether + or not the correct/expected number of tasks are running at any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + + /* Will only get here if there was insufficient memory to create the idle + task. The idle task is created within vTaskStartScheduler(). */ + vTaskStartScheduler(); + + /* Should never reach here. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void prvHardwareSetup( void ) +{ +/* Port layer functions that need to be copied into the vector table. */ +extern void xPortPendSVHandler( void ); +extern void xPortSysTickHandler( void ); +extern void vPortSVCHandler( void ); +extern cyisraddress CyRamVectors[]; + + /* Install the OS Interrupt Handlers. */ + CyRamVectors[11] = (cyisraddress)vPortSVCHandler; + CyRamVectors[14] = (cyisraddress)xPortPendSVHandler; + CyRamVectors[15] = (cyisraddress)xPortSysTickHandler; + + /* Start-up the peripherals. */ + + /* Enable and clear the LCD Display. */ + LCD_Character_Display_Start(); + LCD_Character_Display_ClearDisplay(); + LCD_Character_Display_Position(0,0); + LCD_Character_Display_PrintString("www.FreeRTOS.org "); + LCD_Character_Display_Position(1,0); + LCD_Character_Display_PrintString("CY8C5588AX-060 "); + + /* Start the UART. */ + UART_1_Start(); + + /* Initialise the LEDs. */ + vParTestInitialise(); + + /* Start the PWM modules that drive the IntQueue tests. */ + High_Frequency_PWM_0_Start(); + High_Frequency_PWM_1_Start(); + + /* Start the timers for the Jitter test. */ + Timer_20KHz_Start(); + Timer_48MHz_Start(); +} +/*---------------------------------------------------------------------------*/ + +void vCheckTask( void *pvParameters ) +{ +unsigned long ulRow = 0; +portTickType xDelay = 0; +unsigned short usErrorCode = 0; +unsigned long ulIteration = 0; +extern unsigned portSHORT usMaxJitter; + + /* Intialise the sleeper. */ + xDelay = xTaskGetTickCount(); + + for ( ;; ) + { + /* Perform this check every mainCHECK_DELAY milliseconds. */ + vTaskDelayUntil( &xDelay, mainCHECK_DELAY ); + + /* Check that all of the Demo tasks are still running. */ + if ( pdTRUE != xAreBlockingQueuesStillRunning() ) + { + usErrorCode |= 0x1; + } + + if ( pdTRUE != xAreBlockTimeTestTasksStillRunning() ) + { + usErrorCode |= 0x2; + } + + if ( pdTRUE != xAreCountingSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x4; + } + + if ( pdTRUE != xIsCreateTaskStillRunning() ) + { + usErrorCode |= 0x8; + } + + if ( pdTRUE != xAreDynamicPriorityTasksStillRunning() ) + { + usErrorCode |= 0x10; + } + + if ( pdTRUE != xAreMathsTaskStillRunning() ) + { + usErrorCode |= 0x20; + } + + if ( pdTRUE != xAreGenericQueueTasksStillRunning() ) + { + usErrorCode |= 0x40; + } + + if ( pdTRUE != xAreIntegerMathsTaskStillRunning() ) + { + usErrorCode |= 0x80; + } + + if ( pdTRUE != xArePollingQueuesStillRunning() ) + { + usErrorCode |= 0x100; + } + + if ( pdTRUE != xAreQueuePeekTasksStillRunning() ) + { + usErrorCode |= 0x200; + } + + if ( pdTRUE != xAreSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x400; + } + + if ( pdTRUE != xAreComTestTasksStillRunning() ) + { + usErrorCode |= 0x800; + } + + if ( pdTRUE != xAreIntQueueTasksStillRunning() ) + { + usErrorCode |= 0x1000; + } + + /* Clear the display. */ + LCD_Character_Display_ClearDisplay(); + if ( 0 == usErrorCode ) + { + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Pass: "); + LCD_Character_Display_PrintNumber(ulIteration++); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Jitter(ns):"); + LCD_Character_Display_PrintNumber((usMaxJitter * mainNS_PER_CLOCK)); + } + else + { + /* Do something to indicate the failure. */ + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Fail at: "); + LCD_Character_Display_PrintNumber(ulIteration); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Error: 0x"); + LCD_Character_Display_PrintHexUint16(usErrorCode); + } + } +} +/*---------------------------------------------------------------------------*/ + +void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) +{ + /* The stack space has been execeeded for a task, considering allocating more. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void vApplicationMallocFailedHook( void ) +{ + /* The heap space has been execeeded. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo Workspace.cywrk b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo Workspace.cywrk new file mode 100644 index 000000000..b922d029d --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo Workspace.cywrk @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h new file mode 100644 index 000000000..4180c4c6a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h @@ -0,0 +1,120 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#include + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) BCLK__BUS_CLK__HZ ) +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_CO_ROUTINES 0 +#define configUSE_MUTEXES 1 + +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 10 +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_MALLOC_FAILED_HOOK 1 + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 + +/** + * Configure the number of priority bits. This is normally + * __NVIC_PRIO_BITS but PSoC Creator beta 5 contained a larger + * value for the priority than is implemented in the hardware so + * set it here to what the data sheet describes. + */ +#define configPRIO_BITS 3 /* 8 priority levels */ + +/* The lowest priority. */ +#define configKERNEL_INTERRUPT_PRIORITY ( 7 << (8 - configPRIO_BITS) ) + +/* Priority 5, or 160 as only the top three bits are implemented. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 5 << (8 - configPRIO_BITS) ) + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr new file mode 100644 index 000000000..239418cc3 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj new file mode 100644 index 000000000..ff529603f --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj @@ -0,0 +1,1003 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.c new file mode 100644 index 000000000..94787b3d4 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.c @@ -0,0 +1,98 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "task.h" +/*---------------------------------------------------------------------------*/ + +extern portBASE_TYPE xFirstTimerHandler( void ); +extern portBASE_TYPE xSecondTimerHandler( void ); +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vHighFrequencyFirstISR); +CY_ISR_PROTO(vHighFrequencySecondISR); +/*---------------------------------------------------------------------------*/ + +/** + * Installs and starts the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ) +{ + taskENTER_CRITICAL(); + { + /* Initialise and start the First Timer ISR. */ + isr_High_Frequency_2000Hz_ClearPending(); + isr_High_Frequency_2000Hz_StartEx((cyisraddress)vHighFrequencyFirstISR); + + /* Initialise and start the Second Timer ISR. */ + isr_High_Frequency_2001Hz_ClearPending(); + isr_High_Frequency_2001Hz_StartEx((cyisraddress)vHighFrequencySecondISR); + } + taskEXIT_CRITICAL(); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencyFirstISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xFirstTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencySecondISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xSecondTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.h new file mode 100644 index 000000000..a022717fd --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.h @@ -0,0 +1,62 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef INT_QUEUE_TIMER_H_ +#define INT_QUEUE_TIMER_H_ + +/** + * Install and start the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ); + +#endif /* INT_QUEUE_TIMER_H_ */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/ParTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/ParTest.c new file mode 100644 index 000000000..e98e673de --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/ParTest.c @@ -0,0 +1,117 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +#include "FreeRTOS.h" +#include "task.h" +#include "partest.h" +/*---------------------------------------------------------------------------*/ + +#define partstMAX_LED ( 4 ) +/*---------------------------------------------------------------------------*/ + +static volatile char cLedOutput[ partstMAX_LED ]; +/*---------------------------------------------------------------------------*/ + +void vParTestInitialise( void ) +{ +long lIndex; + for ( lIndex = 0; lIndex < partstMAX_LED; lIndex++ ) + { + cLedOutput[ lIndex ] = 0; + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + taskENTER_CRITICAL(); + { + switch ( uxLED ) + { + case 0: + Pin_LED_0_Write( xValue & 0x1 ); + break; + case 1: + Pin_LED_1_Write( xValue & 0x1 ); + break; + case 2: + Pin_LED_2_Write( xValue & 0x1 ); + break; + case 3: + Pin_LED_3_Write( xValue & 0x1 ); + break; + default: + /* Do nothing. */ + break; + } + } + taskEXIT_CRITICAL(); + + /* Record the output for the sake of toggling. */ + if ( uxLED < partstMAX_LED ) + { + cLedOutput[ uxLED ] = ( xValue & 0x1 ); + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) +{ + if ( uxLED < partstMAX_LED ) + { + vParTestSetLED( uxLED, !cLedOutput[ uxLED ] ); + } +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/Serial.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/Serial.c new file mode 100644 index 000000000..a82d0c00a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/Serial.c @@ -0,0 +1,226 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "queue.h" +#include "task.h" +#include "serial.h" +/*---------------------------------------------------------------------------*/ + +#define serialSTRING_DELAY_TICKS ( portMAX_DELAY ) +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vUartRxISR); +CY_ISR_PROTO(vUartTxISR); +/*---------------------------------------------------------------------------*/ + +static xQueueHandle xSerialTxQueue = NULL; +static xQueueHandle xSerialRxQueue = NULL; +/*---------------------------------------------------------------------------*/ + +xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) +{ + /* Configure Rx. */ + xSerialRxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_RX_BYTE_RECEIVED_ClearPending(); + isr_UART1_RX_BYTE_RECEIVED_StartEx(vUartRxISR); + + /* Configure Tx */ + xSerialTxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_TX_BYTE_COMPLETE_ClearPending() ; + isr_UART1_TX_BYTE_COMPLETE_StartEx(vUartTxISR); + + /* Clear the interrupt modes for the Tx for the time being. */ + UART_1_SetTxInterruptMode( 0 ); + + /* Both configured successfully. */ + return (xComPortHandle)( xSerialTxQueue && xSerialRxQueue ); +} +/*---------------------------------------------------------------------------*/ + +void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength ) +{ +unsigned short usIndex = 0; + for ( usIndex = 0; usIndex < usStringLength; usIndex++ ) + { + /* Check for pre-mature end of line. */ + if ( '\0' == pcString[ usIndex ] ) + { + break; + } + + /* Send out, one character at a time. */ + if ( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) ) + { + /* Failed to send, this will be picked up in the receive comtest task. */ + } + } +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + if ( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) ) + { + /* Picked up a character. */ + xReturn = pdTRUE; + } + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + + /* The ISR is processing characters is so just add to the end of the queue. */ + if ( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) ) + { + xReturn = pdTRUE; + } + else + { + /* The queue is probably full. */ + xReturn = pdFALSE; + } + + /* Make sure that the interrupt will fire in the case where: + * Currently sending so the Tx Complete will fire. + * Not sending so the Empty will fire. + */ + taskENTER_CRITICAL(); + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY ); + taskEXIT_CRITICAL(); + + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartRxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cInChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadRxStatus(); + + /* Only interested in a character being received. */ + if ( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) ) + { + /* Get the character. */ + cInChar = UART_1_GetChar(); + + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Try to deliver the character. */ + if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) ) + { + /* Run out of space. */ + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartTxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cOutChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadTxStatus(); + + /* Check to see whether this is a genuine interrupt. */ + if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) + || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) ) + { + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) ) + { + /* Send the next character. */ + UART_1_PutChar( cOutChar ); + + /* If we are firing, then the only interrupt we are interested in + * is the Complete. The application code will add the Empty interrupt + * when there is something else to be done. + */ + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE ); + } + else + { + /* There is no work left so disable the interrupt + * until the application puts more into the queue. + */ + UART_1_SetTxInterruptMode( 0 ); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TimerTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TimerTest.c new file mode 100644 index 000000000..3087d1683 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TimerTest.c @@ -0,0 +1,128 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +/* High speed timer test as described in main.c. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* The set frequency of the interrupt. Deviations from this are measured as +the jitter. */ +#define timerINTERRUPT_FREQUENCY ( ( unsigned portSHORT ) 20000 ) + +/* The expected time between each of the timer interrupts - if the jitter was +zero. */ +#define timerEXPECTED_DIFFERENCE_VALUE ( configCPU_CLOCK_HZ / timerINTERRUPT_FREQUENCY ) + +/* The number of interrupts to pass before we start looking at the jitter. */ +#define timerSETTLE_TIME 5 +/*---------------------------------------------------------------------------*/ + +/* + * Configures the two timers used to perform the test. + */ +void vSetupTimerTest( void ); + +/* Interrupt handler in which the jitter is measured. */ +CY_ISR_PROTO(vTimer20KHzISR); + +/* Stores the value of the maximum recorded jitter between interrupts. */ +volatile unsigned portSHORT usMaxJitter = 0; +/*---------------------------------------------------------------------------*/ + +void vSetupTimerTest( void ) +{ + /* Install the ISR. */ + isrTimer_20KHz_TC_StartEx(vTimer20KHzISR); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vTimer20KHzISR) +{ +static unsigned short usLastCount = 0, usSettleCount = 0, usMaxDifference = 0; +unsigned short usThisCount, usDifference; + + /* Capture the free running timer value as we enter the interrupt. */ + usThisCount = Timer_48MHz_ReadCounter(); + + if( usSettleCount >= timerSETTLE_TIME ) + { + /* What is the difference between the timer value in this interrupt + and the value from the last interrupt. Timer counts down. */ + usDifference = usLastCount + ~usThisCount + 1; + + /* Store the difference in the timer values if it is larger than the + currently stored largest value. The difference over and above the + expected difference will give the 'jitter' in the processing of these + interrupts. */ + if( usDifference > usMaxDifference ) + { + usMaxDifference = usDifference; + + /* Calculate the Jitter based on the difference we expect. */ + usMaxJitter = usMaxDifference - timerEXPECTED_DIFFERENCE_VALUE; + } + } + else + { + /* Don't bother storing any values for the first couple of + interrupts. */ + usSettleCount++; + } + + /* Remember what the timer value was this time through, so we can calculate + the difference the next time through. */ + usLastCount = usThisCount; +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch new file mode 100644 index 000000000..eb724d6d6 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/device.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/device.h new file mode 100644 index 000000000..d249d209a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/device.h @@ -0,0 +1,20 @@ +/******************************************************************************* +* Copyright 2009, Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +********************************************************************************/ +/* ======================================== + * + * This file is automatically generated by PSoC Creator + * and should not be edited by hand. + * + * This file is necessary for your project to build. + * Please do not delete it. + * + * ======================================== +*/ + +#include + +/*[]*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/main.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/main.c new file mode 100644 index 000000000..3aa26e31c --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/main.c @@ -0,0 +1,347 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +/* RTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" + +/* Common Demo includes. */ +#include "serial.h" +#include "BlockQ.h" +#include "blocktim.h" +#include "comtest.h" +#include "countsem.h" +#include "death.h" +#include "dynamic.h" +#include "flash.h" +#include "flop.h" +#include "GenQTest.h" +#include "integer.h" +#include "IntQueue.h" +#include "mevents.h" +#include "partest.h" +#include "PollQ.h" +#include "print.h" +#include "QPeek.h" +#include "semtest.h" +/*---------------------------------------------------------------------------*/ + +/* The time between cycles of the 'check' functionality (defined within the +tick hook. */ +#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) +#define mainCOM_LED ( 3 ) + +/* The number of nano seconds between each processor clock. */ +#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) ) + +/* Task priorities. */ +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainCOM_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainFLASH_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) +/*---------------------------------------------------------------------------*/ + +/* + * Configures the timers and interrupts for the fast interrupt test as + * described at the top of this file. + */ +extern void vSetupTimerTest( void ); +/*---------------------------------------------------------------------------*/ + +/** + * The Check task periodical interrogates each of the running tests to + * ensure that they are still executing correctly. + * If all the tests pass, then the LCD is updated with Pass, the number of + * iterations and the Jitter time calculated but the Fast Interrupt Test. + * If any one of the tests fail, it is indicated with an error code printed on + * the display. This indicator won't disappear until the device is reset. + */ +void vCheckTask( void *pvParameters ); + +/** + * Installs the RTOS interrupt handlers and starts the peripherals. + */ +static void prvHardwareSetup( void ); +/*---------------------------------------------------------------------------*/ + +void main( void ) +{ +unsigned long ulLed = 0; +unsigned long ulIteration = 0; + + /* Place your initialization/startup code here (e.g. MyInst_Start()) */ + prvHardwareSetup(); + + /* Poll the switch connected to P1[7] + * to prevent the Soak test from (re)starting. + */ + while ( 0 != Startup_Release_Switch_Read() ) + { + if ( 100000 <= ulIteration++ ) + { + vParTestToggleLED( ulLed++ ); + ulLed = ulLed % 4; + ulIteration = 0; + } + } + + /* Reset the LEDS. */ + for ( ulLed = 0; ulLed < 4; ulLed++ ) + { + vParTestSetLED( ulLed, pdFALSE ); + } + + /* Start the standard demo tasks. These are just here to exercise the + kernel port and provide examples of how the FreeRTOS API can be used. */ + vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); + vCreateBlockTimeTasks(); + vStartCountingSemaphoreTasks(); + vStartDynamicPriorityTasks(); + vStartMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); + vStartQueuePeekTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartLEDFlashTasks( mainFLASH_TEST_TASK_PRIORITY ); + vAltStartComTestTasks( mainCOM_TEST_TASK_PRIORITY, 57600, mainCOM_LED ); + vStartInterruptQueueTasks(); + + /* Start the error checking task. */ + (void)xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); + + /* Configure the timers used by the fast interrupt timer test. */ + vSetupTimerTest(); + + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation in order to ascertain whether + or not the correct/expected number of tasks are running at any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + + /* Will only get here if there was insufficient memory to create the idle + task. The idle task is created within vTaskStartScheduler(). */ + vTaskStartScheduler(); + + /* Should never reach here. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void prvHardwareSetup( void ) +{ +/* Port layer functions that need to be copied into the vector table. */ +extern void xPortPendSVHandler( void ); +extern void xPortSysTickHandler( void ); +extern void vPortSVCHandler( void ); +extern cyisraddress CyRamVectors[]; + + /* Install the OS Interrupt Handlers. */ + CyRamVectors[11] = (cyisraddress)vPortSVCHandler; + CyRamVectors[14] = (cyisraddress)xPortPendSVHandler; + CyRamVectors[15] = (cyisraddress)xPortSysTickHandler; + + /* Start-up the peripherals. */ + + /* Enable and clear the LCD Display. */ + LCD_Character_Display_Start(); + LCD_Character_Display_ClearDisplay(); + LCD_Character_Display_Position(0,0); + LCD_Character_Display_PrintString("www.FreeRTOS.org "); + LCD_Character_Display_Position(1,0); + LCD_Character_Display_PrintString("CY8C5588AX-060 "); + + /* Start the UART. */ + UART_1_Start(); + + /* Initialise the LEDs. */ + vParTestInitialise(); + + /* Start the PWM modules that drive the IntQueue tests. */ + High_Frequency_PWM_0_Start(); + High_Frequency_PWM_1_Start(); + + /* Start the timers for the Jitter test. */ + Timer_20KHz_Start(); + Timer_48MHz_Start(); +} +/*---------------------------------------------------------------------------*/ + +void vCheckTask( void *pvParameters ) +{ +unsigned long ulRow = 0; +portTickType xDelay = 0; +unsigned short usErrorCode = 0; +unsigned long ulIteration = 0; +extern unsigned portSHORT usMaxJitter; + + /* Intialise the sleeper. */ + xDelay = xTaskGetTickCount(); + + for ( ;; ) + { + /* Perform this check every mainCHECK_DELAY milliseconds. */ + vTaskDelayUntil( &xDelay, mainCHECK_DELAY ); + + /* Check that all of the Demo tasks are still running. */ + if ( pdTRUE != xAreBlockingQueuesStillRunning() ) + { + usErrorCode |= 0x1; + } + + if ( pdTRUE != xAreBlockTimeTestTasksStillRunning() ) + { + usErrorCode |= 0x2; + } + + if ( pdTRUE != xAreCountingSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x4; + } + + if ( pdTRUE != xIsCreateTaskStillRunning() ) + { + usErrorCode |= 0x8; + } + + if ( pdTRUE != xAreDynamicPriorityTasksStillRunning() ) + { + usErrorCode |= 0x10; + } + + if ( pdTRUE != xAreMathsTaskStillRunning() ) + { + usErrorCode |= 0x20; + } + + if ( pdTRUE != xAreGenericQueueTasksStillRunning() ) + { + usErrorCode |= 0x40; + } + + if ( pdTRUE != xAreIntegerMathsTaskStillRunning() ) + { + usErrorCode |= 0x80; + } + + if ( pdTRUE != xArePollingQueuesStillRunning() ) + { + usErrorCode |= 0x100; + } + + if ( pdTRUE != xAreQueuePeekTasksStillRunning() ) + { + usErrorCode |= 0x200; + } + + if ( pdTRUE != xAreSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x400; + } + + if ( pdTRUE != xAreComTestTasksStillRunning() ) + { + usErrorCode |= 0x800; + } + + if ( pdTRUE != xAreIntQueueTasksStillRunning() ) + { + usErrorCode |= 0x1000; + } + + /* Clear the display. */ + LCD_Character_Display_ClearDisplay(); + if ( 0 == usErrorCode ) + { + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Pass: "); + LCD_Character_Display_PrintNumber(ulIteration++); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Jitter(ns):"); + LCD_Character_Display_PrintNumber((usMaxJitter * mainNS_PER_CLOCK)); + } + else + { + /* Do something to indicate the failure. */ + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Fail at: "); + LCD_Character_Display_PrintNumber(ulIteration); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Error: 0x"); + LCD_Character_Display_PrintHexUint16(usErrorCode); + } + } +} +/*---------------------------------------------------------------------------*/ + +void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) +{ + /* The stack space has been execeeded for a task, considering allocating more. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void vApplicationMallocFailedHook( void ) +{ + /* The heap space has been execeeded. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo Workspace.cywrk b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo Workspace.cywrk new file mode 100644 index 000000000..fc16c439d --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo Workspace.cywrk @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h new file mode 100644 index 000000000..4180c4c6a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOSConfig.h @@ -0,0 +1,120 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#include + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) BCLK__BUS_CLK__HZ ) +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_CO_ROUTINES 0 +#define configUSE_MUTEXES 1 + +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 10 +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_MALLOC_FAILED_HOOK 1 + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 + +/** + * Configure the number of priority bits. This is normally + * __NVIC_PRIO_BITS but PSoC Creator beta 5 contained a larger + * value for the priority than is implemented in the hardware so + * set it here to what the data sheet describes. + */ +#define configPRIO_BITS 3 /* 8 priority levels */ + +/* The lowest priority. */ +#define configKERNEL_INTERRUPT_PRIORITY ( 7 << (8 - configPRIO_BITS) ) + +/* Priority 5, or 160 as only the top three bits are implemented. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 5 << (8 - configPRIO_BITS) ) + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr new file mode 100644 index 000000000..239418cc3 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cydwr differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj new file mode 100644 index 000000000..d00e7ed6d --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/FreeRTOS_Demo.cyprj @@ -0,0 +1,1003 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.c new file mode 100644 index 000000000..94787b3d4 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.c @@ -0,0 +1,98 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "task.h" +/*---------------------------------------------------------------------------*/ + +extern portBASE_TYPE xFirstTimerHandler( void ); +extern portBASE_TYPE xSecondTimerHandler( void ); +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vHighFrequencyFirstISR); +CY_ISR_PROTO(vHighFrequencySecondISR); +/*---------------------------------------------------------------------------*/ + +/** + * Installs and starts the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ) +{ + taskENTER_CRITICAL(); + { + /* Initialise and start the First Timer ISR. */ + isr_High_Frequency_2000Hz_ClearPending(); + isr_High_Frequency_2000Hz_StartEx((cyisraddress)vHighFrequencyFirstISR); + + /* Initialise and start the Second Timer ISR. */ + isr_High_Frequency_2001Hz_ClearPending(); + isr_High_Frequency_2001Hz_StartEx((cyisraddress)vHighFrequencySecondISR); + } + taskEXIT_CRITICAL(); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencyFirstISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xFirstTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vHighFrequencySecondISR) +{ + /* Call back into the test code and context switch if necessary. */ + portEND_SWITCHING_ISR( xSecondTimerHandler() ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.h new file mode 100644 index 000000000..a022717fd --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.h @@ -0,0 +1,62 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef INT_QUEUE_TIMER_H_ +#define INT_QUEUE_TIMER_H_ + +/** + * Install and start the ISRs that drive the Interupt Queue Tests. + */ +void vInitialiseTimerForIntQueueTest( void ); + +#endif /* INT_QUEUE_TIMER_H_ */ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/ParTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/ParTest.c new file mode 100644 index 000000000..e98e673de --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/ParTest.c @@ -0,0 +1,117 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +#include "FreeRTOS.h" +#include "task.h" +#include "partest.h" +/*---------------------------------------------------------------------------*/ + +#define partstMAX_LED ( 4 ) +/*---------------------------------------------------------------------------*/ + +static volatile char cLedOutput[ partstMAX_LED ]; +/*---------------------------------------------------------------------------*/ + +void vParTestInitialise( void ) +{ +long lIndex; + for ( lIndex = 0; lIndex < partstMAX_LED; lIndex++ ) + { + cLedOutput[ lIndex ] = 0; + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + taskENTER_CRITICAL(); + { + switch ( uxLED ) + { + case 0: + Pin_LED_0_Write( xValue & 0x1 ); + break; + case 1: + Pin_LED_1_Write( xValue & 0x1 ); + break; + case 2: + Pin_LED_2_Write( xValue & 0x1 ); + break; + case 3: + Pin_LED_3_Write( xValue & 0x1 ); + break; + default: + /* Do nothing. */ + break; + } + } + taskEXIT_CRITICAL(); + + /* Record the output for the sake of toggling. */ + if ( uxLED < partstMAX_LED ) + { + cLedOutput[ uxLED ] = ( xValue & 0x1 ); + } +} +/*---------------------------------------------------------------------------*/ + +void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) +{ + if ( uxLED < partstMAX_LED ) + { + vParTestSetLED( uxLED, !cLedOutput[ uxLED ] ); + } +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/Serial.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/Serial.c new file mode 100644 index 000000000..a82d0c00a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/Serial.c @@ -0,0 +1,226 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include "FreeRTOS.h" +#include "queue.h" +#include "task.h" +#include "serial.h" +/*---------------------------------------------------------------------------*/ + +#define serialSTRING_DELAY_TICKS ( portMAX_DELAY ) +/*---------------------------------------------------------------------------*/ + +CY_ISR_PROTO(vUartRxISR); +CY_ISR_PROTO(vUartTxISR); +/*---------------------------------------------------------------------------*/ + +static xQueueHandle xSerialTxQueue = NULL; +static xQueueHandle xSerialRxQueue = NULL; +/*---------------------------------------------------------------------------*/ + +xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) +{ + /* Configure Rx. */ + xSerialRxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_RX_BYTE_RECEIVED_ClearPending(); + isr_UART1_RX_BYTE_RECEIVED_StartEx(vUartRxISR); + + /* Configure Tx */ + xSerialTxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) ); + isr_UART1_TX_BYTE_COMPLETE_ClearPending() ; + isr_UART1_TX_BYTE_COMPLETE_StartEx(vUartTxISR); + + /* Clear the interrupt modes for the Tx for the time being. */ + UART_1_SetTxInterruptMode( 0 ); + + /* Both configured successfully. */ + return (xComPortHandle)( xSerialTxQueue && xSerialRxQueue ); +} +/*---------------------------------------------------------------------------*/ + +void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength ) +{ +unsigned short usIndex = 0; + for ( usIndex = 0; usIndex < usStringLength; usIndex++ ) + { + /* Check for pre-mature end of line. */ + if ( '\0' == pcString[ usIndex ] ) + { + break; + } + + /* Send out, one character at a time. */ + if ( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) ) + { + /* Failed to send, this will be picked up in the receive comtest task. */ + } + } +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + if ( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) ) + { + /* Picked up a character. */ + xReturn = pdTRUE; + } + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime ) +{ +portBASE_TYPE xReturn = pdFALSE; + + /* The ISR is processing characters is so just add to the end of the queue. */ + if ( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) ) + { + xReturn = pdTRUE; + } + else + { + /* The queue is probably full. */ + xReturn = pdFALSE; + } + + /* Make sure that the interrupt will fire in the case where: + * Currently sending so the Tx Complete will fire. + * Not sending so the Empty will fire. + */ + taskENTER_CRITICAL(); + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY ); + taskEXIT_CRITICAL(); + + return xReturn; +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartRxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cInChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadRxStatus(); + + /* Only interested in a character being received. */ + if ( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) ) + { + /* Get the character. */ + cInChar = UART_1_GetChar(); + + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Try to deliver the character. */ + if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) ) + { + /* Run out of space. */ + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vUartTxISR) +{ +portBASE_TYPE xTaskWoken = pdFALSE; +volatile unsigned char ucStatus = 0; +signed char cOutChar = 0; +unsigned long ulMask = 0; + + /* Read the status to acknowledge. */ + ucStatus = UART_1_ReadTxStatus(); + + /* Check to see whether this is a genuine interrupt. */ + if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) + || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) ) + { + /* Mask off the other RTOS interrupts to interact with the queue. */ + ulMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) ) + { + /* Send the next character. */ + UART_1_PutChar( cOutChar ); + + /* If we are firing, then the only interrupt we are interested in + * is the Complete. The application code will add the Empty interrupt + * when there is something else to be done. + */ + UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE ); + } + else + { + /* There is no work left so disable the interrupt + * until the application puts more into the queue. + */ + UART_1_SetTxInterruptMode( 0 ); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask ); + } + + /* If we delivered the character then a context switch might be required. */ + portEND_SWITCHING_ISR( xTaskWoken ); +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TimerTest.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TimerTest.c new file mode 100644 index 000000000..3087d1683 --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TimerTest.c @@ -0,0 +1,128 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +/* High speed timer test as described in main.c. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* The set frequency of the interrupt. Deviations from this are measured as +the jitter. */ +#define timerINTERRUPT_FREQUENCY ( ( unsigned portSHORT ) 20000 ) + +/* The expected time between each of the timer interrupts - if the jitter was +zero. */ +#define timerEXPECTED_DIFFERENCE_VALUE ( configCPU_CLOCK_HZ / timerINTERRUPT_FREQUENCY ) + +/* The number of interrupts to pass before we start looking at the jitter. */ +#define timerSETTLE_TIME 5 +/*---------------------------------------------------------------------------*/ + +/* + * Configures the two timers used to perform the test. + */ +void vSetupTimerTest( void ); + +/* Interrupt handler in which the jitter is measured. */ +CY_ISR_PROTO(vTimer20KHzISR); + +/* Stores the value of the maximum recorded jitter between interrupts. */ +volatile unsigned portSHORT usMaxJitter = 0; +/*---------------------------------------------------------------------------*/ + +void vSetupTimerTest( void ) +{ + /* Install the ISR. */ + isrTimer_20KHz_TC_StartEx(vTimer20KHzISR); +} +/*---------------------------------------------------------------------------*/ + +CY_ISR(vTimer20KHzISR) +{ +static unsigned short usLastCount = 0, usSettleCount = 0, usMaxDifference = 0; +unsigned short usThisCount, usDifference; + + /* Capture the free running timer value as we enter the interrupt. */ + usThisCount = Timer_48MHz_ReadCounter(); + + if( usSettleCount >= timerSETTLE_TIME ) + { + /* What is the difference between the timer value in this interrupt + and the value from the last interrupt. Timer counts down. */ + usDifference = usLastCount + ~usThisCount + 1; + + /* Store the difference in the timer values if it is larger than the + currently stored largest value. The difference over and above the + expected difference will give the 'jitter' in the processing of these + interrupts. */ + if( usDifference > usMaxDifference ) + { + usMaxDifference = usDifference; + + /* Calculate the Jitter based on the difference we expect. */ + usMaxJitter = usMaxDifference - timerEXPECTED_DIFFERENCE_VALUE; + } + } + else + { + /* Don't bother storing any values for the first couple of + interrupts. */ + usSettleCount++; + } + + /* Remember what the timer value was this time through, so we can calculate + the difference the next time through. */ + usLastCount = usThisCount; +} +/*---------------------------------------------------------------------------*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch new file mode 100644 index 000000000..eb724d6d6 Binary files /dev/null and b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/TopDesign/TopDesign.cysch differ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/device.h b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/device.h new file mode 100644 index 000000000..d249d209a --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/device.h @@ -0,0 +1,20 @@ +/******************************************************************************* +* Copyright 2009, Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +********************************************************************************/ +/* ======================================== + * + * This file is automatically generated by PSoC Creator + * and should not be edited by hand. + * + * This file is necessary for your project to build. + * Please do not delete it. + * + * ======================================== +*/ + +#include + +/*[]*/ diff --git a/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/main.c b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/main.c new file mode 100644 index 000000000..3aa26e31c --- /dev/null +++ b/Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/main.c @@ -0,0 +1,347 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include + +/* RTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" + +/* Common Demo includes. */ +#include "serial.h" +#include "BlockQ.h" +#include "blocktim.h" +#include "comtest.h" +#include "countsem.h" +#include "death.h" +#include "dynamic.h" +#include "flash.h" +#include "flop.h" +#include "GenQTest.h" +#include "integer.h" +#include "IntQueue.h" +#include "mevents.h" +#include "partest.h" +#include "PollQ.h" +#include "print.h" +#include "QPeek.h" +#include "semtest.h" +/*---------------------------------------------------------------------------*/ + +/* The time between cycles of the 'check' functionality (defined within the +tick hook. */ +#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) +#define mainCOM_LED ( 3 ) + +/* The number of nano seconds between each processor clock. */ +#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) ) + +/* Task priorities. */ +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainCOM_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainFLASH_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) +/*---------------------------------------------------------------------------*/ + +/* + * Configures the timers and interrupts for the fast interrupt test as + * described at the top of this file. + */ +extern void vSetupTimerTest( void ); +/*---------------------------------------------------------------------------*/ + +/** + * The Check task periodical interrogates each of the running tests to + * ensure that they are still executing correctly. + * If all the tests pass, then the LCD is updated with Pass, the number of + * iterations and the Jitter time calculated but the Fast Interrupt Test. + * If any one of the tests fail, it is indicated with an error code printed on + * the display. This indicator won't disappear until the device is reset. + */ +void vCheckTask( void *pvParameters ); + +/** + * Installs the RTOS interrupt handlers and starts the peripherals. + */ +static void prvHardwareSetup( void ); +/*---------------------------------------------------------------------------*/ + +void main( void ) +{ +unsigned long ulLed = 0; +unsigned long ulIteration = 0; + + /* Place your initialization/startup code here (e.g. MyInst_Start()) */ + prvHardwareSetup(); + + /* Poll the switch connected to P1[7] + * to prevent the Soak test from (re)starting. + */ + while ( 0 != Startup_Release_Switch_Read() ) + { + if ( 100000 <= ulIteration++ ) + { + vParTestToggleLED( ulLed++ ); + ulLed = ulLed % 4; + ulIteration = 0; + } + } + + /* Reset the LEDS. */ + for ( ulLed = 0; ulLed < 4; ulLed++ ) + { + vParTestSetLED( ulLed, pdFALSE ); + } + + /* Start the standard demo tasks. These are just here to exercise the + kernel port and provide examples of how the FreeRTOS API can be used. */ + vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); + vCreateBlockTimeTasks(); + vStartCountingSemaphoreTasks(); + vStartDynamicPriorityTasks(); + vStartMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); + vStartQueuePeekTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartLEDFlashTasks( mainFLASH_TEST_TASK_PRIORITY ); + vAltStartComTestTasks( mainCOM_TEST_TASK_PRIORITY, 57600, mainCOM_LED ); + vStartInterruptQueueTasks(); + + /* Start the error checking task. */ + (void)xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); + + /* Configure the timers used by the fast interrupt timer test. */ + vSetupTimerTest(); + + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation in order to ascertain whether + or not the correct/expected number of tasks are running at any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + + /* Will only get here if there was insufficient memory to create the idle + task. The idle task is created within vTaskStartScheduler(). */ + vTaskStartScheduler(); + + /* Should never reach here. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void prvHardwareSetup( void ) +{ +/* Port layer functions that need to be copied into the vector table. */ +extern void xPortPendSVHandler( void ); +extern void xPortSysTickHandler( void ); +extern void vPortSVCHandler( void ); +extern cyisraddress CyRamVectors[]; + + /* Install the OS Interrupt Handlers. */ + CyRamVectors[11] = (cyisraddress)vPortSVCHandler; + CyRamVectors[14] = (cyisraddress)xPortPendSVHandler; + CyRamVectors[15] = (cyisraddress)xPortSysTickHandler; + + /* Start-up the peripherals. */ + + /* Enable and clear the LCD Display. */ + LCD_Character_Display_Start(); + LCD_Character_Display_ClearDisplay(); + LCD_Character_Display_Position(0,0); + LCD_Character_Display_PrintString("www.FreeRTOS.org "); + LCD_Character_Display_Position(1,0); + LCD_Character_Display_PrintString("CY8C5588AX-060 "); + + /* Start the UART. */ + UART_1_Start(); + + /* Initialise the LEDs. */ + vParTestInitialise(); + + /* Start the PWM modules that drive the IntQueue tests. */ + High_Frequency_PWM_0_Start(); + High_Frequency_PWM_1_Start(); + + /* Start the timers for the Jitter test. */ + Timer_20KHz_Start(); + Timer_48MHz_Start(); +} +/*---------------------------------------------------------------------------*/ + +void vCheckTask( void *pvParameters ) +{ +unsigned long ulRow = 0; +portTickType xDelay = 0; +unsigned short usErrorCode = 0; +unsigned long ulIteration = 0; +extern unsigned portSHORT usMaxJitter; + + /* Intialise the sleeper. */ + xDelay = xTaskGetTickCount(); + + for ( ;; ) + { + /* Perform this check every mainCHECK_DELAY milliseconds. */ + vTaskDelayUntil( &xDelay, mainCHECK_DELAY ); + + /* Check that all of the Demo tasks are still running. */ + if ( pdTRUE != xAreBlockingQueuesStillRunning() ) + { + usErrorCode |= 0x1; + } + + if ( pdTRUE != xAreBlockTimeTestTasksStillRunning() ) + { + usErrorCode |= 0x2; + } + + if ( pdTRUE != xAreCountingSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x4; + } + + if ( pdTRUE != xIsCreateTaskStillRunning() ) + { + usErrorCode |= 0x8; + } + + if ( pdTRUE != xAreDynamicPriorityTasksStillRunning() ) + { + usErrorCode |= 0x10; + } + + if ( pdTRUE != xAreMathsTaskStillRunning() ) + { + usErrorCode |= 0x20; + } + + if ( pdTRUE != xAreGenericQueueTasksStillRunning() ) + { + usErrorCode |= 0x40; + } + + if ( pdTRUE != xAreIntegerMathsTaskStillRunning() ) + { + usErrorCode |= 0x80; + } + + if ( pdTRUE != xArePollingQueuesStillRunning() ) + { + usErrorCode |= 0x100; + } + + if ( pdTRUE != xAreQueuePeekTasksStillRunning() ) + { + usErrorCode |= 0x200; + } + + if ( pdTRUE != xAreSemaphoreTasksStillRunning() ) + { + usErrorCode |= 0x400; + } + + if ( pdTRUE != xAreComTestTasksStillRunning() ) + { + usErrorCode |= 0x800; + } + + if ( pdTRUE != xAreIntQueueTasksStillRunning() ) + { + usErrorCode |= 0x1000; + } + + /* Clear the display. */ + LCD_Character_Display_ClearDisplay(); + if ( 0 == usErrorCode ) + { + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Pass: "); + LCD_Character_Display_PrintNumber(ulIteration++); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Jitter(ns):"); + LCD_Character_Display_PrintNumber((usMaxJitter * mainNS_PER_CLOCK)); + } + else + { + /* Do something to indicate the failure. */ + LCD_Character_Display_Position( (ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Fail at: "); + LCD_Character_Display_PrintNumber(ulIteration); + LCD_Character_Display_Position( (++ulRow) & 0x1, 0); + LCD_Character_Display_PrintString("Error: 0x"); + LCD_Character_Display_PrintHexUint16(usErrorCode); + } + } +} +/*---------------------------------------------------------------------------*/ + +void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) +{ + /* The stack space has been execeeded for a task, considering allocating more. */ + for (;;); +} +/*---------------------------------------------------------------------------*/ + +void vApplicationMallocFailedHook( void ) +{ + /* The heap space has been execeeded. */ + for (;;); +} +/*---------------------------------------------------------------------------*/