From 3a5bd813f0b925448b8240ecbcfb61418a3ce7ec Mon Sep 17 00:00:00 2001 From: richardbarry Date: Wed, 20 Apr 2011 15:03:42 +0000 Subject: [PATCH] git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1369 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/CORTEX_A2F200_SoftConsole/OLED.c | 82 --------------------- Demo/CORTEX_A2F200_SoftConsole/main-full.c | 83 ++++++++++++++++++---- 2 files changed, 70 insertions(+), 95 deletions(-) delete mode 100644 Demo/CORTEX_A2F200_SoftConsole/OLED.c diff --git a/Demo/CORTEX_A2F200_SoftConsole/OLED.c b/Demo/CORTEX_A2F200_SoftConsole/OLED.c deleted file mode 100644 index 8771107e8..000000000 --- a/Demo/CORTEX_A2F200_SoftConsole/OLED.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and 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 modification 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 "oled.h" - -#define oledFIRST_CHARACTER 0 - -static struct oled_data xOLEDData; - -void vOLEDInit( void ) -{ - /* Initialise the display itslef. */ - OLED_init(); - - xOLEDData.line1 = FIRST_LINE; - xOLEDData.char_offset1 = oledFIRST_CHARACTER; - xOLEDData.string1 = "www.FreeRTOS.org"; - - xOLEDData.line2 = SECOND_LINE; - xOLEDData.char_offset2 = oledFIRST_CHARACTER; - xOLEDData.string2 = 0x00; - - xOLEDData.contrast_val = OLED_CONTRAST_VAL; - xOLEDData.on_off = OLED_HORIZ_SCROLL_OFF; - xOLEDData.column_scrool_per_step = OLED_HORIZ_SCROLL_STEP; - xOLEDData.start_page = OLED_START_PAGE; - xOLEDData.time_intrval_btw_scroll_step = OLED_HORIZ_SCROLL_TINVL; - xOLEDData.end_page = OLED_END_PAGE; - - OLED_write_data( &xOLEDData, BOTH_LINES ); -} - diff --git a/Demo/CORTEX_A2F200_SoftConsole/main-full.c b/Demo/CORTEX_A2F200_SoftConsole/main-full.c index 35661670b..d965dc8bf 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/main-full.c +++ b/Demo/CORTEX_A2F200_SoftConsole/main-full.c @@ -71,7 +71,7 @@ * incorporates a Cortex-M3 microcontroller. * * The main() Function: - * main() creates two demo specific software timers, one demo specific queue, + * main() creates three demo specific software timers, one demo specific queue, * and two demo specific tasks. It then creates a whole host of 'standard demo' * tasks/queues/semaphores, before starting the scheduler. The demo specific * tasks and timers are described in the comments here. The standard demo @@ -110,9 +110,9 @@ * Therefore, pressing the user button will turn the LED on, and the LED will * remain on until a full five seconds pass without the button being pressed. * - * The Demo Specific Idle Hook Function: - * The idle hook function demonstrates how to query the amount of FreeRTOS heap - * space that is remaining (see vApplicationIdleHook() defined in this file). + * The Demo Specific OLED Software Timer: + * The OLED software timer is responsible for drawing a scrolling text message + * on the OLED. * * The Demo Specific "Check" Callback Function: * This is called each time the 'check' timer expires. The check timer @@ -126,6 +126,10 @@ * been found. The task in which the error was discovered is displayed at the * bottom of the "task stats" page that is served by the embedded web server. * + * The Demo Specific Idle Hook Function: + * The idle hook function demonstrates how to query the amount of FreeRTOS heap + * space that is remaining (see vApplicationIdleHook() defined in this file). + * * The Web Server Task: * The IP address used by the SmartFusion target is configured by the * definitions configIP_ADDR0 to configIP_ADDR3, which are located in the @@ -142,7 +146,7 @@ /* Microsemi drivers/libraries includes. */ #include "mss_gpio.h" #include "mss_watchdog.h" -#include "OLED.h" +#include "oled.h" /* Common demo includes. */ #include "partest.h" @@ -200,6 +204,10 @@ stack than most of the other tasks. */ have been reported by any of the standard demo tasks. */ #define mainCHECK_TIMER_PERIOD_ms ( 3000UL ) +/* The period at which the OLED timer will expire. Each time it expires, it's +callback function updates the OLED text. */ +#define mainOLED_PERIOD_ms ( 75UL ) + /* The period at which the check timer will expire, in ms, if an error has been reported in one of the standard demo tasks. */ #define mainERROR_CHECK_TIMER_PERIOD_ms ( 500UL ) @@ -230,6 +238,11 @@ static void vLEDTimerCallback( xTimerHandle xTimer ); */ static void vCheckTimerCallback( xTimerHandle xTimer ); +/* + * The OLED timer callback function, as described at the top of this file. + */ +static void vOLEDTimerCallback( xTimerHandle xHandle ); + /* * This is not a 'standard' partest function, so the prototype is not in * partest.h, and is instead included here. @@ -254,12 +267,14 @@ static xTimerHandle xLEDTimer = NULL; function. */ static xTimerHandle xCheckTimer = NULL; +/* The OLED software timer. Writes a moving text string to the OLED. */ +static xTimerHandle xOLEDTimer = NULL; + /* The status message that is displayed at the bottom of the "task stats" web page, which is served by the uIP task. This will report any errors picked up by the check timer callback. */ static const char *pcStatusMessage = NULL; - /*-----------------------------------------------------------*/ int main(void) @@ -296,6 +311,9 @@ int main(void) vCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ ); + /* Create the OLED timer as described at the top of this file. */ + xOLEDTimer = xTimerCreate( ( const signed char * ) "OLEDTimer", ( mainOLED_PERIOD_ms / portTICK_RATE_MS ), pdTRUE, ( void * ) 0, vOLEDTimerCallback ); + /* Create a lot of 'standard demo' tasks. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); @@ -307,7 +325,7 @@ int main(void) vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); /* Create the web server task. */ - xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL ); +// xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL ); /* Start the tasks and timer running. */ vTaskStartScheduler(); @@ -432,13 +450,14 @@ const unsigned long ulValueToSend = 100UL; instead created here. */ vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); - /* The check timer command queue will have been filled when the timer test - tasks were created in main() (this is part of the test they perform). - Therefore, while the check timer can be created in main(), it could not be + /* The timer command queue will have been filled when the timer test tasks + were created in main() (this is part of the test they perform). Therefore, + while the check and OLED timers can be created in main(), they cannot be started from main(). Once the scheduler has started, the timer service - task will have drained the command queue, and now the check task can be + task will drain the command queue, and now the check and OLED timers can be started successfully. */ xTimerStart( xCheckTimer, portMAX_DELAY ); + xTimerStart( xOLEDTimer, portMAX_DELAY ); /* Initialise xNextWakeTime - this only needs to be done once. */ xNextWakeTime = xTaskGetTickCount(); @@ -481,6 +500,44 @@ unsigned long ulReceivedValue; } /*-----------------------------------------------------------*/ +static void vOLEDTimerCallback( xTimerHandle xHandle ) +{ +volatile size_t xFreeStackSpace; +static struct oled_data xOLEDData; +static unsigned char ucOffset1 = 0, ucOffset2 = 5; + + /* This function is called on each cycle of the idle task. In this case it + does nothing useful, other than report the amount of FreeRTOS heap that + remains unallocated. */ + xFreeStackSpace = xPortGetFreeHeapSize(); + + if( xFreeStackSpace > 100 ) + { + /* By now, the kernel has allocated everything it is going to, so + if there is a lot of heap remaining unallocated then + the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be + reduced accordingly. */ + } + + xOLEDData.line1 = FIRST_LINE; + xOLEDData.char_offset1 = ucOffset1++; + xOLEDData.string1 = "www.FreeRTOS.org"; + + xOLEDData.line2 = SECOND_LINE; + xOLEDData.char_offset2 = ucOffset2++; + xOLEDData.string2 = "www.FreeRTOS.org"; + + xOLEDData.contrast_val = OLED_CONTRAST_VAL; + xOLEDData.on_off = OLED_HORIZ_SCROLL_OFF; + xOLEDData.column_scrool_per_step = OLED_HORIZ_SCROLL_STEP; + xOLEDData.start_page = OLED_START_PAGE; + xOLEDData.time_intrval_btw_scroll_step = OLED_HORIZ_SCROLL_TINVL; + xOLEDData.end_page = OLED_END_PAGE; + + OLED_write_data( &xOLEDData, BOTH_LINES ); +} +/*-----------------------------------------------------------*/ + static void prvSetupHardware( void ) { /* Disable the Watch Dog Timer */ @@ -490,7 +547,7 @@ static void prvSetupHardware( void ) vParTestInitialise(); /* Initialise the display. */ - OLED_init(); + OLED_init(); /* Setup the GPIO and the NVIC for the switch used in this simple demo. */ NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); @@ -557,5 +614,5 @@ char *pcGetTaskStatusMessage( void ) return ( char * ) pcStatusMessage; } } - +/*-----------------------------------------------------------*/ -- 2.39.2