]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_A2F200_SoftConsole/main-full.c
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1369 1d2547de-c912-0410...
[freertos] / Demo / CORTEX_A2F200_SoftConsole / main-full.c
index 35661670bd4181cf3ecb014b4e6a53a791e06ae2..d965dc8bff0e48f7de172fc9a81c9e6217ef7041 100644 (file)
@@ -71,7 +71,7 @@
  * incorporates a Cortex-M3 microcontroller.\r
  *\r
  * The main() Function:\r
- * main() creates two demo specific software timers, one demo specific queue,\r
+ * main() creates three demo specific software timers, one demo specific queue,\r
  * and two demo specific tasks.  It then creates a whole host of 'standard demo'\r
  * tasks/queues/semaphores, before starting the scheduler.  The demo specific\r
  * tasks and timers are described in the comments here.  The standard demo\r
  * Therefore, pressing the user button will turn the LED on, and the LED will\r
  * remain on until a full five seconds pass without the button being pressed.\r
  *\r
- * The Demo Specific Idle Hook Function:\r
- * The idle hook function demonstrates how to query the amount of FreeRTOS heap\r
- * space that is remaining (see vApplicationIdleHook() defined in this file).\r
+ * The Demo Specific OLED Software Timer:\r
+ * The OLED software timer is responsible for drawing a scrolling text message\r
+ * on the OLED.\r
  *\r
  * The Demo Specific "Check" Callback Function:\r
  * This is called each time the 'check' timer expires.  The check timer\r
  * been found.  The task in which the error was discovered is displayed at the\r
  * bottom of the "task stats" page that is served by the embedded web server.\r
  *\r
+ * The Demo Specific Idle Hook Function:\r
+ * The idle hook function demonstrates how to query the amount of FreeRTOS heap\r
+ * space that is remaining (see vApplicationIdleHook() defined in this file).\r
+ *\r
  * The Web Server Task:\r
  * The IP address used by the SmartFusion target is configured by the\r
  * definitions configIP_ADDR0 to configIP_ADDR3, which are located in the\r
 /* Microsemi drivers/libraries includes. */\r
 #include "mss_gpio.h"\r
 #include "mss_watchdog.h"\r
-#include "OLED.h"\r
+#include "oled.h"\r
 \r
 /* Common demo includes. */\r
 #include "partest.h"\r
@@ -200,6 +204,10 @@ stack than most of the other tasks. */
 have been reported by any of the standard demo tasks. */\r
 #define mainCHECK_TIMER_PERIOD_ms      ( 3000UL )\r
 \r
+/* The period at which the OLED timer will expire.  Each time it expires, it's\r
+callback function updates the OLED text. */\r
+#define mainOLED_PERIOD_ms                     ( 75UL )\r
+\r
 /* The period at which the check timer will expire, in ms, if an error has been\r
 reported in one of the standard demo tasks. */
 #define mainERROR_CHECK_TIMER_PERIOD_ms ( 500UL )\r
@@ -230,6 +238,11 @@ static void vLEDTimerCallback( xTimerHandle xTimer );
  */\r
 static void vCheckTimerCallback( xTimerHandle xTimer );\r
 \r
+/*\r
+ * The OLED timer callback function, as described at the top of this file.
+ */\r
+static void vOLEDTimerCallback( xTimerHandle xHandle );\r
+\r
 /*\r
  * This is not a 'standard' partest function, so the prototype is not in\r
  * partest.h, and is instead included here.
@@ -254,12 +267,14 @@ static xTimerHandle xLEDTimer = NULL;
 function. */\r
 static xTimerHandle xCheckTimer = NULL;\r
 \r
+/* The OLED software timer.  Writes a moving text string to the OLED. */\r
+static xTimerHandle xOLEDTimer = NULL;\r
+\r
 /* The status message that is displayed at the bottom of the "task stats" web\r
 page, which is served by the uIP task.  This will report any errors picked up\r
 by the check timer callback. */\r
 static const char *pcStatusMessage = NULL;\r
 \r
-\r
 /*-----------------------------------------------------------*/\r
 \r
 int main(void)\r
@@ -296,6 +311,9 @@ int main(void)
                                                                        vCheckTimerCallback                                             /* The callback function that inspects the status of all the other tasks. */\r
                                                                  );\r
 \r
+               /* Create the OLED timer as described at the top of this file. */\r
+               xOLEDTimer = xTimerCreate( ( const signed char * ) "OLEDTimer", ( mainOLED_PERIOD_ms / portTICK_RATE_MS ), pdTRUE, ( void * ) 0, vOLEDTimerCallback );\r
+\r
                /* Create a lot of 'standard demo' tasks. */\r
                vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
                vCreateBlockTimeTasks();\r
@@ -307,7 +325,7 @@ int main(void)
                vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
 \r
                /* Create the web server task. */\r
-               xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
+//             xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
 \r
                /* Start the tasks and timer running. */\r
                vTaskStartScheduler();\r
@@ -432,13 +450,14 @@ const unsigned long ulValueToSend = 100UL;
        instead created here. */\r
        vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
 \r
-       /* The check timer command queue will have been filled when the timer test\r
-       tasks were created in main() (this is part of the test they perform).\r
-       Therefore, while the check timer can be created in main(), it could not be\r
+       /* The timer command queue will have been filled when the timer test tasks\r
+       were created in main() (this is part of the test they perform).  Therefore,\r
+       while the check and OLED timers can be created in main(), they cannot be\r
        started from main().  Once the scheduler has started, the timer service\r
-       task will have drained the command queue, and now the check task can be\r
+       task will drain the command queue, and now the check and OLED timers can be\r
        started successfully. */
        xTimerStart( xCheckTimer, portMAX_DELAY );\r
+       xTimerStart( xOLEDTimer, portMAX_DELAY );\r
 \r
        /* Initialise xNextWakeTime - this only needs to be done once. */\r
        xNextWakeTime = xTaskGetTickCount();\r
@@ -481,6 +500,44 @@ unsigned long ulReceivedValue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void vOLEDTimerCallback( xTimerHandle xHandle )\r
+{\r
+volatile size_t xFreeStackSpace;\r
+static struct oled_data xOLEDData;\r
+static unsigned char ucOffset1 = 0, ucOffset2 = 5;\r
+\r
+       /* This function is called on each cycle of the idle task.  In this case it\r
+       does nothing useful, other than report the amount of FreeRTOS heap that\r
+       remains unallocated. */\r
+       xFreeStackSpace = xPortGetFreeHeapSize();\r
+\r
+       if( xFreeStackSpace > 100 )\r
+       {\r
+               /* By now, the kernel has allocated everything it is going to, so\r
+               if there is a lot of heap remaining unallocated then\r
+               the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be\r
+               reduced accordingly. */\r
+       }\r
+\r
+       xOLEDData.line1          = FIRST_LINE;\r
+       xOLEDData.char_offset1   = ucOffset1++;\r
+       xOLEDData.string1        = "www.FreeRTOS.org";\r
+\r
+       xOLEDData.line2          = SECOND_LINE;\r
+       xOLEDData.char_offset2   = ucOffset2++;\r
+       xOLEDData.string2        = "www.FreeRTOS.org";\r
+\r
+       xOLEDData.contrast_val                 = OLED_CONTRAST_VAL;\r
+       xOLEDData.on_off                       = OLED_HORIZ_SCROLL_OFF;\r
+       xOLEDData.column_scrool_per_step       = OLED_HORIZ_SCROLL_STEP;\r
+       xOLEDData.start_page                   = OLED_START_PAGE;\r
+       xOLEDData.time_intrval_btw_scroll_step = OLED_HORIZ_SCROLL_TINVL;\r
+       xOLEDData.end_page                     = OLED_END_PAGE;\r
+\r
+       OLED_write_data( &xOLEDData, BOTH_LINES );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void prvSetupHardware( void )\r
 {\r
        /* Disable the Watch Dog Timer */\r
@@ -490,7 +547,7 @@ static void prvSetupHardware( void )
        vParTestInitialise();\r
 \r
        /* Initialise the display. */\r
-    OLED_init();\r
+       OLED_init();\r
 \r
        /* Setup the GPIO and the NVIC for the switch used in this simple demo. */\r
        NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );\r
@@ -557,5 +614,5 @@ char *pcGetTaskStatusMessage( void )
                return ( char * ) pcStatusMessage;\r
        }\r
 }\r
-\r
+/*-----------------------------------------------------------*/\r
 \r