/** * ####################################################################################### * GAYE Abdoulaye Walsimou, * 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 main.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, * \date february 2009 * ####################################################################################### */ #include "FreeRTOS.h" #include "task.h" #include #include void panic(void); void prvSetupHardware(void); void prvtask1_func(void *pvparam); void prvtask2_func(void *pvparam); void prvtask3_func(void *pvparam); void prvtask4_func(void *pvparam); #define LED1_PORT PORTAbits.RA0 #define LED1_PORT_CONFIG TRISAbits.TRISA0 #define LED2_PORT PORTBbits.RB7 #define LED2_PORT_CONFIG TRISBbits.TRISB7 #define LED3_PORT PORTCbits.RC0 #define LED3_PORT_CONFIG TRISCbits.TRISC0 #define PANIC_PORT PORTDbits.RD0 #define PANIC_PORT_CONFIG TRISDbits.TRISD0 extern volatile __data unsigned char heap[configTOTAL_HEAP_SIZE]; #pragma stack 0x80 64 void main (void) { prvSetupHardware(); xTaskCreate(prvtask1_func,"T1",configMINIMAL_STACK_SIZE,NULL,1,NULL); xTaskCreate(prvtask2_func,"T2",configMINIMAL_STACK_SIZE,NULL,1,NULL); xTaskCreate(prvtask3_func,"T3",configMINIMAL_STACK_SIZE,NULL,4,NULL); vTaskStartScheduler(); } void prvtask1_func(void* pvparam) { (void*) pvparam; for(;;) { portENTER_CRITICAL(); LED1_PORT=LED1_PORT^1; portEXIT_CRITICAL(); } } void prvtask2_func(void* pvparam) { (void*) pvparam; for(;;) { portENTER_CRITICAL(); LED2_PORT=LED2_PORT^1; portEXIT_CRITICAL(); } } void prvtask3_func(void* pvparam) { const portTickType xDelay = 500/portTICK_RATE_MS; (void*) pvparam; for(;;) { portENTER_CRITICAL(); LED3_PORT=LED3_PORT^1; portEXIT_CRITICAL(); vTaskDelay(xDelay); } } void panic (void) { portDISABLE_INTERRUPTS(); for(;;) { PANIC_PORT=PANIC_PORT^1; } } 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; LED2_PORT=0; LED2_PORT_CONFIG=0; LED3_PORT=0; LED3_PORT_CONFIG=0; PANIC_PORT=0; PANIC_PORT_CONFIG=0; }