summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-04-19 20:04:15 +0200
committerAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-04-19 20:04:15 +0200
commit2bd8f66557fe131bf3cd7ad1d9f8b4bb0e58564d (patch)
treee5cb212cbaf9fba52d0340149131af20fc3db30e
parent9dd0713b1ba8b0ea0b79a2a8804a345545e4fb68 (diff)
downloadfreertos-2bd8f66557fe131bf3cd7ad1d9f8b4bb0e58564d.tar.gz
freertos-2bd8f66557fe131bf3cd7ad1d9f8b4bb0e58564d.tar.bz2
freertos-2bd8f66557fe131bf3cd7ad1d9f8b4bb0e58564d.tar.xz
PIC18_SDCC: Add a new demo file
This patch adds a new main2.c in order to be more FreeRTOS's demo application compatible. Signed-off-by: Abdoulaye Walsimou Gaye <walsimou@walsimou.com>
-rw-r--r--Demo/PIC18_SDCC/main2.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/Demo/PIC18_SDCC/main2.c b/Demo/PIC18_SDCC/main2.c
new file mode 100644
index 00000000..2dd73088
--- /dev/null
+++ b/Demo/PIC18_SDCC/main2.c
@@ -0,0 +1,120 @@
+/**
+* #######################################################################################
+* GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
+* Copyright (C) 2009 GAYE Abdoulaye Walsimou. All rights reserved.
+*
+* This program is free software; you can distribute it and/or modify it
+* under the terms of the GNU General Public License
+* (Version 2 or later) published by the Free Software Foundation.
+*
+* This program is distributed in the hope 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 along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+* #######################################################################################
+*
+* \file main2.c
+* \brief main function for SDCC PIC18 (pic16 arch in sddc world) port.
+* \brief It is based on existing PIC18 port.
+* \author GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
+* \date March 2009
+* #######################################################################################
+*/
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "integer.h"
+#include <malloc.h>
+
+/* Demo app include files. */
+#include "PollQ.h"
+#include "integer.h"
+
+#define LED1_PORT PORTAbits.RA0
+#define LED1_PORT_CONFIG TRISAbits.TRISA0
+
+/* The period between executions of the check task before and after an error
+has been discovered. If an error has been discovered the check task runs
+more frequently - increasing the LED1 flash rate. */
+#define mainNO_ERROR_CHECK_PERIOD ((portTickType)500/portTICK_RATE_MS)
+#define mainERROR_CHECK_PERIOD ((portTickType)50/portTICK_RATE_MS)
+
+/*
+ * Priority definitions for some of the tasks. Other tasks just use the idle
+ * priority.
+ */
+#define mainQUEUE_POLL_PRIORITY (tskIDLE_PRIORITY+2)
+#define mainCHECK_TASK_PRIORITY (tskIDLE_PRIORITY+3)
+
+static void prvSetupHardware(void);
+static void vErrorChecks(void *pvparam);
+static portBASE_TYPE prvCheckOtherTasksAreStillRunning(void);
+extern __data unsigned char heap[configTOTAL_HEAP_SIZE];
+
+#pragma stack 0x80 64
+void main(void)
+{
+ /*Setup hardware for the demo. */
+ prvSetupHardware();
+
+ /*Create check task*/
+ xTaskCreate(vErrorChecks,"Check",configMINIMAL_STACK_SIZE,NULL,mainCHECK_TASK_PRIORITY,NULL);
+
+ /*Create some demo tasks: see Demo/Common/Minimal */
+ vStartIntegerMathTasks(tskIDLE_PRIORITY);
+ vStartPolledQueueTasks(mainQUEUE_POLL_PRIORITY);
+
+ /*start scheduler*/
+ vTaskStartScheduler();
+}
+
+static void prvSetupHardware(void)
+{
+ /*Please do not remove the call of _initHeap unless you know what you're doing*/
+ _initHeap(heap,configTOTAL_HEAP_SIZE);
+
+ LED1_PORT=0;
+ LED1_PORT_CONFIG=0;
+}
+
+void vErrorChecks(void *pvparam)
+{
+ portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
+ portBASE_TYPE xErrorOccurred;
+ (void *)pvparam;
+
+ for(;;)
+ {
+ /* Wait until it is time to check the other tasks. */
+ vTaskDelay(xDelayTime);
+
+ /* Check all the other tasks are running, and running without ever
+ having an error. */
+ xErrorOccurred = prvCheckOtherTasksAreStillRunning();
+
+ if(xErrorOccurred==pdTRUE)
+ xDelayTime = mainERROR_CHECK_PERIOD;
+
+ if(LED1_PORT)
+ LED1_PORT = 0;
+ else
+ LED1_PORT = 1;
+ }
+}
+
+static portBASE_TYPE prvCheckOtherTasksAreStillRunning(void)
+{
+ portBASE_TYPE xErrorHasOccurred = pdFALSE;
+
+ if(xAreIntegerMathsTaskStillRunning()!=pdTRUE)
+ xErrorHasOccurred = pdTRUE;
+
+ if(xArePollingQueuesStillRunning()!=pdTRUE)
+ xErrorHasOccurred = pdTRUE;
+
+ return xErrorHasOccurred;
+}