Please see my note book http://mbed.org/users/kenjiArai/notebook/freertos-on-mbed-board-with-mbed-cloud-ide--never-/
This is too old.
Below is another FreeRTOS on mbed.
http://developer.mbed.org/users/rgrover1/code/FreeRTOS/
I don't know it works well or not.
I have not evaluated it.
FreeRTOS/Common/Minimal/flash.c@0:d4960fcea8ff, 2011-01-01 (annotated)
- Committer:
- kenjiArai
- Date:
- Sat Jan 01 11:17:45 2011 +0000
- Revision:
- 0:d4960fcea8ff
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 0:d4960fcea8ff | 1 | /* |
kenjiArai | 0:d4960fcea8ff | 2 | FreeRTOS V6.0.3 - Copyright (C) 2010 Real Time Engineers Ltd. |
kenjiArai | 0:d4960fcea8ff | 3 | |
kenjiArai | 0:d4960fcea8ff | 4 | *************************************************************************** |
kenjiArai | 0:d4960fcea8ff | 5 | * * |
kenjiArai | 0:d4960fcea8ff | 6 | * If you are: * |
kenjiArai | 0:d4960fcea8ff | 7 | * * |
kenjiArai | 0:d4960fcea8ff | 8 | * + New to FreeRTOS, * |
kenjiArai | 0:d4960fcea8ff | 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * |
kenjiArai | 0:d4960fcea8ff | 10 | * + Looking for basic training, * |
kenjiArai | 0:d4960fcea8ff | 11 | * + Wanting to improve your FreeRTOS skills and productivity * |
kenjiArai | 0:d4960fcea8ff | 12 | * * |
kenjiArai | 0:d4960fcea8ff | 13 | * then take a look at the FreeRTOS eBook * |
kenjiArai | 0:d4960fcea8ff | 14 | * * |
kenjiArai | 0:d4960fcea8ff | 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * |
kenjiArai | 0:d4960fcea8ff | 16 | * http://www.FreeRTOS.org/Documentation * |
kenjiArai | 0:d4960fcea8ff | 17 | * * |
kenjiArai | 0:d4960fcea8ff | 18 | * A pdf reference manual is also available. Both are usually delivered * |
kenjiArai | 0:d4960fcea8ff | 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * |
kenjiArai | 0:d4960fcea8ff | 20 | * and 8pm GMT (although please allow up to 24 hours in case of * |
kenjiArai | 0:d4960fcea8ff | 21 | * exceptional circumstances). Thank you for your support! * |
kenjiArai | 0:d4960fcea8ff | 22 | * * |
kenjiArai | 0:d4960fcea8ff | 23 | *************************************************************************** |
kenjiArai | 0:d4960fcea8ff | 24 | |
kenjiArai | 0:d4960fcea8ff | 25 | This file is part of the FreeRTOS distribution. |
kenjiArai | 0:d4960fcea8ff | 26 | |
kenjiArai | 0:d4960fcea8ff | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under |
kenjiArai | 0:d4960fcea8ff | 28 | the terms of the GNU General Public License (version 2) as published by the |
kenjiArai | 0:d4960fcea8ff | 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. |
kenjiArai | 0:d4960fcea8ff | 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute |
kenjiArai | 0:d4960fcea8ff | 31 | a combined work that includes FreeRTOS without being obliged to provide the |
kenjiArai | 0:d4960fcea8ff | 32 | source code for proprietary components outside of the FreeRTOS kernel. |
kenjiArai | 0:d4960fcea8ff | 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT |
kenjiArai | 0:d4960fcea8ff | 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
kenjiArai | 0:d4960fcea8ff | 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
kenjiArai | 0:d4960fcea8ff | 36 | more details. You should have received a copy of the GNU General Public |
kenjiArai | 0:d4960fcea8ff | 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it |
kenjiArai | 0:d4960fcea8ff | 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained |
kenjiArai | 0:d4960fcea8ff | 39 | by writing to Richard Barry, contact details for whom are available on the |
kenjiArai | 0:d4960fcea8ff | 40 | FreeRTOS WEB site. |
kenjiArai | 0:d4960fcea8ff | 41 | |
kenjiArai | 0:d4960fcea8ff | 42 | 1 tab == 4 spaces! |
kenjiArai | 0:d4960fcea8ff | 43 | |
kenjiArai | 0:d4960fcea8ff | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and |
kenjiArai | 0:d4960fcea8ff | 45 | contact details. |
kenjiArai | 0:d4960fcea8ff | 46 | |
kenjiArai | 0:d4960fcea8ff | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety |
kenjiArai | 0:d4960fcea8ff | 48 | critical systems. |
kenjiArai | 0:d4960fcea8ff | 49 | |
kenjiArai | 0:d4960fcea8ff | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, |
kenjiArai | 0:d4960fcea8ff | 51 | licensing and training services. |
kenjiArai | 0:d4960fcea8ff | 52 | */ |
kenjiArai | 0:d4960fcea8ff | 53 | |
kenjiArai | 0:d4960fcea8ff | 54 | /** |
kenjiArai | 0:d4960fcea8ff | 55 | * This version of flash .c is for use on systems that have limited stack space |
kenjiArai | 0:d4960fcea8ff | 56 | * and no display facilities. The complete version can be found in the |
kenjiArai | 0:d4960fcea8ff | 57 | * Demo/Common/Full directory. |
kenjiArai | 0:d4960fcea8ff | 58 | * |
kenjiArai | 0:d4960fcea8ff | 59 | * Three tasks are created, each of which flash an LED at a different rate. The first |
kenjiArai | 0:d4960fcea8ff | 60 | * LED flashes every 200ms, the second every 400ms, the third every 600ms. |
kenjiArai | 0:d4960fcea8ff | 61 | * |
kenjiArai | 0:d4960fcea8ff | 62 | * The LED flash tasks provide instant visual feedback. They show that the scheduler |
kenjiArai | 0:d4960fcea8ff | 63 | * is still operational. |
kenjiArai | 0:d4960fcea8ff | 64 | * |
kenjiArai | 0:d4960fcea8ff | 65 | */ |
kenjiArai | 0:d4960fcea8ff | 66 | |
kenjiArai | 0:d4960fcea8ff | 67 | |
kenjiArai | 0:d4960fcea8ff | 68 | #include <stdlib.h> |
kenjiArai | 0:d4960fcea8ff | 69 | |
kenjiArai | 0:d4960fcea8ff | 70 | /* Scheduler include files. */ |
kenjiArai | 0:d4960fcea8ff | 71 | #include "FreeRTOS.h" |
kenjiArai | 0:d4960fcea8ff | 72 | #include "task.h" |
kenjiArai | 0:d4960fcea8ff | 73 | |
kenjiArai | 0:d4960fcea8ff | 74 | /* Demo program include files. */ |
kenjiArai | 0:d4960fcea8ff | 75 | #include "partest.h" |
kenjiArai | 0:d4960fcea8ff | 76 | #include "flash.h" |
kenjiArai | 0:d4960fcea8ff | 77 | |
kenjiArai | 0:d4960fcea8ff | 78 | #define ledSTACK_SIZE configMINIMAL_STACK_SIZE |
kenjiArai | 0:d4960fcea8ff | 79 | #define ledNUMBER_OF_LEDS ( 3 ) |
kenjiArai | 0:d4960fcea8ff | 80 | #define ledFLASH_RATE_BASE ( ( portTickType ) 333 ) |
kenjiArai | 0:d4960fcea8ff | 81 | |
kenjiArai | 0:d4960fcea8ff | 82 | /* Variable used by the created tasks to calculate the LED number to use, and |
kenjiArai | 0:d4960fcea8ff | 83 | the rate at which they should flash the LED. */ |
kenjiArai | 0:d4960fcea8ff | 84 | static volatile unsigned portBASE_TYPE uxFlashTaskNumber = 0; |
kenjiArai | 0:d4960fcea8ff | 85 | |
kenjiArai | 0:d4960fcea8ff | 86 | /* The task that is created three times. */ |
kenjiArai | 0:d4960fcea8ff | 87 | static portTASK_FUNCTION_PROTO( vLEDFlashTask, pvParameters ); |
kenjiArai | 0:d4960fcea8ff | 88 | |
kenjiArai | 0:d4960fcea8ff | 89 | /*-----------------------------------------------------------*/ |
kenjiArai | 0:d4960fcea8ff | 90 | |
kenjiArai | 0:d4960fcea8ff | 91 | void vStartLEDFlashTasks( unsigned portBASE_TYPE uxPriority ) |
kenjiArai | 0:d4960fcea8ff | 92 | { |
kenjiArai | 0:d4960fcea8ff | 93 | signed portBASE_TYPE xLEDTask; |
kenjiArai | 0:d4960fcea8ff | 94 | |
kenjiArai | 0:d4960fcea8ff | 95 | /* Create the three tasks. */ |
kenjiArai | 0:d4960fcea8ff | 96 | for( xLEDTask = 0; xLEDTask < ledNUMBER_OF_LEDS; ++xLEDTask ) |
kenjiArai | 0:d4960fcea8ff | 97 | { |
kenjiArai | 0:d4960fcea8ff | 98 | /* Spawn the task. */ |
kenjiArai | 0:d4960fcea8ff | 99 | xTaskCreate( vLEDFlashTask, ( signed char * ) "LEDx", ledSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); |
kenjiArai | 0:d4960fcea8ff | 100 | } |
kenjiArai | 0:d4960fcea8ff | 101 | } |
kenjiArai | 0:d4960fcea8ff | 102 | /*-----------------------------------------------------------*/ |
kenjiArai | 0:d4960fcea8ff | 103 | |
kenjiArai | 0:d4960fcea8ff | 104 | static portTASK_FUNCTION( vLEDFlashTask, pvParameters ) |
kenjiArai | 0:d4960fcea8ff | 105 | { |
kenjiArai | 0:d4960fcea8ff | 106 | portTickType xFlashRate, xLastFlashTime; |
kenjiArai | 0:d4960fcea8ff | 107 | unsigned portBASE_TYPE uxLED; |
kenjiArai | 0:d4960fcea8ff | 108 | |
kenjiArai | 0:d4960fcea8ff | 109 | /* The parameters are not used. */ |
kenjiArai | 0:d4960fcea8ff | 110 | ( void ) pvParameters; |
kenjiArai | 0:d4960fcea8ff | 111 | |
kenjiArai | 0:d4960fcea8ff | 112 | /* Calculate the LED and flash rate. */ |
kenjiArai | 0:d4960fcea8ff | 113 | portENTER_CRITICAL(); |
kenjiArai | 0:d4960fcea8ff | 114 | { |
kenjiArai | 0:d4960fcea8ff | 115 | /* See which of the eight LED's we should use. */ |
kenjiArai | 0:d4960fcea8ff | 116 | uxLED = uxFlashTaskNumber; |
kenjiArai | 0:d4960fcea8ff | 117 | |
kenjiArai | 0:d4960fcea8ff | 118 | /* Update so the next task uses the next LED. */ |
kenjiArai | 0:d4960fcea8ff | 119 | uxFlashTaskNumber++; |
kenjiArai | 0:d4960fcea8ff | 120 | } |
kenjiArai | 0:d4960fcea8ff | 121 | portEXIT_CRITICAL(); |
kenjiArai | 0:d4960fcea8ff | 122 | |
kenjiArai | 0:d4960fcea8ff | 123 | xFlashRate = ledFLASH_RATE_BASE + ( ledFLASH_RATE_BASE * ( portTickType ) uxLED ); |
kenjiArai | 0:d4960fcea8ff | 124 | xFlashRate /= portTICK_RATE_MS; |
kenjiArai | 0:d4960fcea8ff | 125 | |
kenjiArai | 0:d4960fcea8ff | 126 | /* We will turn the LED on and off again in the delay period, so each |
kenjiArai | 0:d4960fcea8ff | 127 | delay is only half the total period. */ |
kenjiArai | 0:d4960fcea8ff | 128 | xFlashRate /= ( portTickType ) 2; |
kenjiArai | 0:d4960fcea8ff | 129 | |
kenjiArai | 0:d4960fcea8ff | 130 | /* We need to initialise xLastFlashTime prior to the first call to |
kenjiArai | 0:d4960fcea8ff | 131 | vTaskDelayUntil(). */ |
kenjiArai | 0:d4960fcea8ff | 132 | xLastFlashTime = xTaskGetTickCount(); |
kenjiArai | 0:d4960fcea8ff | 133 | |
kenjiArai | 0:d4960fcea8ff | 134 | for(;;) |
kenjiArai | 0:d4960fcea8ff | 135 | { |
kenjiArai | 0:d4960fcea8ff | 136 | /* Delay for half the flash period then turn the LED on. */ |
kenjiArai | 0:d4960fcea8ff | 137 | vTaskDelayUntil( &xLastFlashTime, xFlashRate ); |
kenjiArai | 0:d4960fcea8ff | 138 | vParTestToggleLED( uxLED ); |
kenjiArai | 0:d4960fcea8ff | 139 | |
kenjiArai | 0:d4960fcea8ff | 140 | /* Delay for half the flash period then turn the LED off. */ |
kenjiArai | 0:d4960fcea8ff | 141 | vTaskDelayUntil( &xLastFlashTime, xFlashRate ); |
kenjiArai | 0:d4960fcea8ff | 142 | vParTestToggleLED( uxLED ); |
kenjiArai | 0:d4960fcea8ff | 143 | } |
kenjiArai | 0:d4960fcea8ff | 144 | } /*lint !e715 !e818 !e830 Function definition must be standard for task creation. */ |
kenjiArai | 0:d4960fcea8ff | 145 |