From: richardbarry Date: Wed, 29 Dec 2010 22:07:52 +0000 (+0000) Subject: Start to write the MSP430X demo. X-Git-Tag: V6.1.1~64 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=56f551931c1b082cc02ef8aedb3669f8cbb63323;p=freertos Start to write the MSP430X demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1193 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h b/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h new file mode 100644 index 000000000..c618ab77d --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h @@ -0,0 +1,108 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). 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 exception 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. +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html. + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( 16000000UL ) +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 5 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 5 +#define configGENERATE_RUN_TIME_STATS 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 0 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_APPLICATION_TASK_TAG 0 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + +#define configTICK_INTERRUPT_VECTOR TIMER0_A0_VECTOR + + +#endif /* FREERTOS_CONFIG_H */ + diff --git a/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewd b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewd new file mode 100644 index 000000000..64ed02cb4 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewd @@ -0,0 +1,739 @@ + + + + 2 + + Debug + + MSP430 + + 1 + + C-SPY + 4 + + 25 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 430FET + 1 + + 22 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIM430 + 1 + + 4 + 1 + 1 + + + + + + + + + + + $TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin + 1 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 1 + + + $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\FreeRTOS\FreeRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\Profiling\Profiling.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + Release + + MSP430 + + 0 + + C-SPY + 4 + + 25 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 430FET + 1 + + 22 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIM430 + 1 + + 4 + 1 + 0 + + + + + + + + + + + $TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin + 1 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\FreeRTOS\FreeRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\Profiling\Profiling.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + + diff --git a/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp new file mode 100644 index 000000000..f5164b233 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp @@ -0,0 +1,1999 @@ + + + + 2 + + Debug + + MSP430 + + 1 + + General + 7 + + 27 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICC430 + 4 + + 30 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A430 + 4 + + 13 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 4 + + 22 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 4 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + MSP430 + + 0 + + General + 7 + + 27 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICC430 + 4 + + 30 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A430 + 4 + + 13 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 4 + + 22 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 4 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + F5XX_6XX_Core_Lib + + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_macros.h + + + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.c + + + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.h + + + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_UCS.c + + + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_UCS.h + + + + FreeRTOS_Source + + Portable + + $PROJ_DIR$\..\..\Source\portable\MemMang\heap_1.c + + + $PROJ_DIR$\..\..\Source\portable\IAR\MSP430X\port.c + + + $PROJ_DIR$\..\..\Source\portable\IAR\MSP430X\portext.s43 + + + + $PROJ_DIR$\..\..\Source\list.c + + + $PROJ_DIR$\..\..\Source\queue.c + + + $PROJ_DIR$\..\..\Source\tasks.c + + + + MSP-EXP430F5438_HAL + + $PROJ_DIR$\MSP-EXP430F5438_HAL\cc2500.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_board.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_board.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_buttons.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_buttons.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf_settings.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.h + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.c + + + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.h + + + + UserExperienceDemo + + $PROJ_DIR$\UserExperienceDemo\5xx_ACTIVE_test.h + + + $PROJ_DIR$\UserExperienceDemo\5xx_ACTIVE_test.s43 + + + $PROJ_DIR$\UserExperienceDemo\adcTemp.c + + + $PROJ_DIR$\UserExperienceDemo\adcTemp.h + + + $PROJ_DIR$\UserExperienceDemo\audio.c + + + $PROJ_DIR$\UserExperienceDemo\audio.h + + + $PROJ_DIR$\UserExperienceDemo\balanceBall.c + + + $PROJ_DIR$\UserExperienceDemo\balanceBall.h + + + $PROJ_DIR$\UserExperienceDemo\clock.c + + + $PROJ_DIR$\UserExperienceDemo\clock.h + + + $PROJ_DIR$\UserExperienceDemo\FFT.c + + + $PROJ_DIR$\UserExperienceDemo\FFT.h + + + $PROJ_DIR$\UserExperienceDemo\FFT_430.h + + + $PROJ_DIR$\UserExperienceDemo\FFT_430.s43 + + + $PROJ_DIR$\UserExperienceDemo\flashUtils.c + + + $PROJ_DIR$\UserExperienceDemo\flashUtils.h + + + $PROJ_DIR$\UserExperienceDemo\LPM.c + + + $PROJ_DIR$\UserExperienceDemo\LPM.h + + + $PROJ_DIR$\UserExperienceDemo\menuSetting.c + + + $PROJ_DIR$\UserExperienceDemo\menuSetting.h + + + $PROJ_DIR$\UserExperienceDemo\PMM.c + + + $PROJ_DIR$\UserExperienceDemo\PMM.h + + + $PROJ_DIR$\UserExperienceDemo\PowerTest.c + + + $PROJ_DIR$\UserExperienceDemo\PowerTest.h + + + $PROJ_DIR$\UserExperienceDemo\usbTest.c + + + $PROJ_DIR$\UserExperienceDemo\usbTest.h + + + $PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.c + + + $PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.h + + + $PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.c + + + $PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.h + + + + $PROJ_DIR$\lnk430F5438A_mod.xcl + + + $PROJ_DIR$\low_level_init.c + + + $PROJ_DIR$\main.c + + + $PROJ_DIR$\readme.txt + + + $PROJ_DIR$\RegTest.s43 + + + + diff --git a/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.eww b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.eww new file mode 100644 index 000000000..239a9381e --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\RTOSDemo.ewp + + + + + diff --git a/Demo/MSP430X_MSP430F5438_IAR/RegTest.s43 b/Demo/MSP430X_MSP430F5438_IAR/RegTest.s43 new file mode 100644 index 000000000..a750e8269 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/RegTest.s43 @@ -0,0 +1,168 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). 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 exception 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 "msp430.h" +#include "FreeRTOSConfig.h" + + IMPORT usRegTest1Counter + IMPORT usRegTest2Counter + + EXPORT vRegTest1Task + EXPORT vRegTest2Task + + RSEG CODE + +vRegTest1Task: + + movx.a #0x44444, r4 + movx.a #0x55555, r5 + movx.a #0x66666, r6 + movx.a #0x77777, r7 + movx.a #0x88888, r8 + movx.a #0x99999, r9 + movx.a #0xaaaaa, r10 + movx.a #0xbbbbb, r11 + movx.a #0xccccc, r12 + movx.a #0xddddd, r13 + movx.a #0xeeeee, r14 + movx.a #0xfffff, r15 + +prvRegTest1Loop: + + cmpx.a #0x44444, r4 + jne vRegTest1Error + cmpx.a #0x55555, r5 + jne vRegTest1Error + cmpx.a #0x66666, r6 + jne vRegTest1Error + cmpx.a #0x77777, r7 + jne vRegTest1Error + cmpx.a #0x88888, r8 + jne vRegTest1Error + cmpx.a #0x99999, r9 + jne vRegTest1Error + cmpx.a #0xaaaaa, r10 + jne vRegTest1Error + cmpx.a #0xbbbbb, r11 + jne vRegTest1Error + cmpx.a #0xccccc, r12 + jne vRegTest1Error + cmpx.a #0xddddd, r13 + jne vRegTest1Error + cmpx.a #0xeeeee, r14 + jne vRegTest1Error + cmpx.a #0xfffff, r15 + jne vRegTest1Error + incx.w &usRegTest1Counter + jmp prvRegTest1Loop + nop + + +vRegTest1Error: + jmp vRegTest1Error + nop +/*-----------------------------------------------------------*/ + +vRegTest2Task: + + movx.a #0x44444, r4 + movx.a #0x55555, r5 + movx.a #0x66666, r6 + movx.a #0x77777, r7 + movx.a #0x88888, r8 + movx.a #0x99999, r9 + movx.a #0xaaaaa, r10 + movx.a #0xbbbbb, r11 + movx.a #0xccccc, r12 + movx.a #0xddddd, r13 + movx.a #0xeeeee, r14 + movx.a #0xfffff, r15 + +prvRegTest2Loop: + + cmpx.a #0x44444, r4 + jne vRegTest2Error + cmpx.a #0x55555, r5 + jne vRegTest2Error + cmpx.a #0x66666, r6 + jne vRegTest2Error + cmpx.a #0x77777, r7 + jne vRegTest2Error + cmpx.a #0x88888, r8 + jne vRegTest2Error + cmpx.a #0x99999, r9 + jne vRegTest2Error + cmpx.a #0xaaaaa, r10 + jne vRegTest2Error + cmpx.a #0xbbbbb, r11 + jne vRegTest2Error + cmpx.a #0xccccc, r12 + jne vRegTest2Error + cmpx.a #0xddddd, r13 + jne vRegTest2Error + cmpx.a #0xeeeee, r14 + jne vRegTest2Error + cmpx.a #0xfffff, r15 + jne vRegTest2Error + incx.w &usRegTest2Counter + jmp prvRegTest2Loop + nop + + +vRegTest2Error: + jmp vRegTest2Error + nop +/*-----------------------------------------------------------*/ + + + END + diff --git a/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl b/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl new file mode 100644 index 000000000..4050f1d04 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl @@ -0,0 +1,211 @@ +// ************************************************ +// +// XLINK configuration file for MSP430F5438A +// +// Copyright 1996-2010 IAR Systems AB +// +// $Revision: $ +// +// ************************************************ + +// --------------------------------------------------------- +// Description +// + +// +// Usage: +// +// xlink [file file ...] -f lnk430f5438a.xcl +// +// ----------------------------------------------- +// Device summary +// + +// +// Core: MSP430X +// +// Interrupt vectors: 64 +// +// Peripheral units: 0-001FF +// +// Information memory (FLASH): 01800-019FF +// +// Read/write memory (RAM): 01C00-05BFF +// +// Read-only memory (FLASH): 05C00-0FFFF +// 10000-45BFF +// + + +// ----------------------------------------------- +// Segments +// + +// ------------------------------------- +// Data read/write segments (RAM) +// + +// +// The following segments are available for both +// the DATA16 and DATA20 segment groups. +// +// segment Usage +// ------- -------------------------- +// DATA_Z Data initialized to zero +// DATA_I Data initialized by copying from DATA_ID +// DATA_N Data defined using __no_init +// DATA_HEAP The heap used by 'malloc' and 'free' +// +// segment Usage +// ------- -------------------------- +// CSTACK Runtime stack +// + + +// ------------------------------------- +// Program and data read-only segments (FLASH) +// + +// +// The following segments are available for both +// the DATA16 and DATA20 segment groups. +// +// segment Usage +// ------- -------------------------- +// DATA_C Constant data, including string literals +// DATA_ID initializers for DATA_I +// +// segment Usage +// ------- -------------------------- +// INFO Information memory +// INFOA Information memory, bank A +// INFOB Information memory, bank B +// INFOC Information memory, bank C +// INFOD Information memory, bank D +// CSTART Program startup code +// CODE Program code +// ISR_CODE Program code for interrupt service routines +// DIFUNCT Dynamic initialization vector used by C++ +// CHECKSUM Checksum byte(s) generated by the -J option +// INTVEC Interrupt vectors +// RESET The reset vector +// +// Notes: +// +// * The segments CSTART, ISR_CODE, and DIFUNCT, as well as the segments in +// the DATA16 segment group must be placed in in the range 0000-FFFD. +// +// * The INFOx and INFO segments overlap, this allows data either to be +// placed in a specific bank or anywhere in the info memory. +// +// * The INTVEC and RESET segments overlap. This allows an application to +// either use the reset vector provided by the runtime library, or +// provide a reset function by defining an interrupt function associated +// with the reset vector. +// + + +// --------------------------------------------------------- +// Configuation +// + +// ----------------------------------------------- +// Stack and heap sizes +// + +// Uncomment for command line use +//-D_STACK_SIZE=80 +//-D_DATA16_HEAP_SIZE=80 +//-D_DATA20_HEAP_SIZE=80 + + +// ----------------------------------------------- +// Define cpu +// + +-cmsp430 + + +// ----------------------------------------------- +// Support for placing functions in read/write memory +// + +-QCODE_I=CODE_ID + + +// --------------------------------------------------------- +// Placement directives +// + +// ----------------------------------------------- +// Read/write memory +// + +/* Commented out and substituted the original memory region definition */ +/* for RAM to reserve the memory region from 0x2000 to 0x2021 as it is */ +/* used during active mode Icc tests in "5xx_ACTIVE_test.asm" */ +//-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,DATA16_HEAP+_DATA16_HEAP_SIZE=1C00-5BFF + +-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,DATA16_HEAP+_DATA16_HEAP_SIZE=1C00-2000,2022-5BFF +-Z(DATA)CODE_I +-Z(DATA)DATA20_I,DATA20_Z,DATA20_N,DATA20_HEAP+_DATA20_HEAP_SIZE +-Z(DATA)CSTACK+_STACK_SIZE# + + +// ----------------------------------------------- +// Read-only memory +// + +// ------------------------------------- +// Information memory +// + +-Z(CONST)INFO=1800-19FF +-Z(CONST)INFOA=1980-19FF +-Z(CONST)INFOB=1900-197F +-Z(CONST)INFOC=1880-18FF +-Z(CONST)INFOD=1800-187F + + + +// ------------------------------------- +// Low memory 0-0FFFF +// + +// --------------------------- +// Code +// + +-Z(CODE)CSTART,ISR_CODE=5C00-FF7F + +// --------------------------- +// Constant data +// + +-Z(CONST)DATA16_C,DATA16_ID,DIFUNCT,CHECKSUM=5C00-FF7F + + +// ------------------------------------- +// All memory 0-FFFFF +// + +// --------------------------- +// Code +// + +-P(CODE)CODE=5C00-FF7F,10000-45BFF +-Z(CODE)CODE_ID + +// --------------------------- +// Constant data +// + +-Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF + + +// ------------------------------------- +// Interrupt vectors +// + +-Z(CODE)INTVEC=FF80-FFFF +-Z(CODE)RESET=FFFE-FFFF diff --git a/Demo/MSP430X_MSP430F5438_IAR/low_level_init.c b/Demo/MSP430X_MSP430F5438_IAR/low_level_init.c new file mode 100644 index 000000000..9eba23652 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/low_level_init.c @@ -0,0 +1,54 @@ +/************************************************** + * + * This is a template for early application low-level initialization. + * + * Copyright 1996-2010 IAR Systems AB. + * + * $Revision: 5993 $ + * + **************************************************/ + +/* + * The function __low_level_init it called by the start-up code before + * "main" is called, and before data segment initialization is + * performed. + * + * This is a template file, modify to perform any initialization that + * should take place early. + * + * The return value of this function controls if data segment + * initialization should take place. If 0 is returned, it is bypassed. + * + * For the MSP430 microcontroller family, please consider disabling + * the watchdog timer here, as it could time-out during the data + * segment initialization. + */ + +/* + * To disable the watchdog timer, include a suitable device header + * file (or "msp430.h") and add the following line to the function + * below: + * + * WDTCTL = WDTPW+WDTHOLD; + * + */ + + +#include +#include "msp430.h" + +int __low_level_init(void) +{ + /* Insert your low-level initializations here */ + + WDTCTL = WDTPW+WDTHOLD; + + /* + * Return value: + * + * 1 - Perform data segment initialization. + * 0 - Skip data segment initialization. + */ + + return 1; +} diff --git a/Demo/MSP430X_MSP430F5438_IAR/main.c b/Demo/MSP430X_MSP430F5438_IAR/main.c new file mode 100644 index 000000000..2b0821a35 --- /dev/null +++ b/Demo/MSP430X_MSP430F5438_IAR/main.c @@ -0,0 +1,357 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). 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 exception 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 + +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" + +#include "msp430.h" +#include "hal_MSP-EXP430F5438.h" + +/* The rate at which mainCHECK_LED will toggle when all the tasks are running +without error. Controlled by the check task as described at the top of this +file. */ +#define mainNO_ERROR_CYCLE_TIME ( 5000 / portTICK_RATE_MS ) + +/* The rate at which mainCHECK_LED will toggle when an error has been reported +by at least one task. Controlled by the check task as described at the top of +this file. */ +#define mainERROR_CYCLE_TIME ( 200 / portTICK_RATE_MS ) + +/* Codes sent within messages to the LCD task so the LCD task can interpret +exactly what the message it just received was. These are sent in the +cMessageID member of the message structure (defined below). */ +#define mainMESSAGE_BUTTON_UP ( 1 ) +#define mainMESSAGE_BUTTON_SEL ( 2 ) +#define mainMESSAGE_STATUS ( 3 ) + +/* When the cMessageID member of the message sent to the LCD task is +mainMESSAGE_STATUS then these definitions are sent in the cMessageValue member +of the same message and indicate what the status actually is. */ +#define mainERROR_DYNAMIC_TASKS ( pdPASS + 1 ) +#define mainERROR_COM_TEST ( pdPASS + 2 ) +#define mainERROR_GEN_QUEUE_TEST ( pdPASS + 3 ) + +/* The length of the queue (the number of items the queue can hold) that is used +to send messages from tasks and interrupts the the LCD task. */ +#define mainQUEUE_LENGTH ( 5 ) + +#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/*-----------------------------------------------------------*/ + +extern void vRegTest1Task( void *pvParameters ); +extern void vRegTest2Task( void *pvParameters ); +static void prvCheckTask( void *pvParameters ); +static void prvSetupHardware( void ); +static void prvTerminalIOTask( void *pvParameters ); +static void prvButtonPollTask( void *pvParameters ); +static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue ); + +/*-----------------------------------------------------------*/ + +volatile unsigned short usRegTest1Counter = 0, usRegTest2Counter = 0; + +/* The handle of the queue used to send messages from tasks and interrupts to +the LCD task. */ +static xQueueHandle xLCDQueue = NULL; + +/* The definition of each message sent from tasks and interrupts to the LCD +task. */ +typedef struct +{ + char cMessageID; /* << States what the message is. */ + char cMessageValue; /* << States the message value (can be an integer, string pointer, etc. depending on the value of cMessageID. */ +} xQueueMessage; +/*-----------------------------------------------------------*/ + +void main( void ) +{ + prvSetupHardware(); + + /* Create the queue used by tasks and interrupts to send strings to the LCD + task. */ + xLCDQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( xQueueMessage ) ); + + if( xLCDQueue != NULL ) + { + /* Add the created queue to the queue registry so it can be viewed in + the IAR FreeRTOS state viewer plug-in. */ + vQueueAddToRegistry( xLCDQueue, "LCDQueue" ); + + /* Create the terminal IO and button poll tasks, as described at the top + of this file. */ + xTaskCreate( prvTerminalIOTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL ); + xTaskCreate( prvButtonPollTask, ( signed char * ) "ButPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); + + xTaskCreate( vRegTest1Task, "RegTest1", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); + xTaskCreate( vRegTest2Task, "RegTest2", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); + xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); + vTaskStartScheduler(); + } + for( ;; ); +} +/*-----------------------------------------------------------*/ + +static void prvTerminalIOTask( void *pvParameters ) +{ +xQueueMessage xReceivedMessage; + +/* Buffer into which strings are formatted and placed ready for display on the +LCD. Note this is a static variable to prevent it being allocated on the task +stack, which is too small to hold such a variable. The stack size is configured +when the task is created. */ +static char cBuffer[ 512 ]; + + /* This function is the only function that uses printf(). If printf() is + used from any other function then some sort of mutual exclusion on stdout + will be necessary. + + This is also the only function that is permitted to access the LCD. + + First print out the number of bytes that remain in the FreeRTOS heap. This + can be viewed in the terminal IO window within the IAR Embedded Workbench. */ + printf( "%d bytes of heap space remain unallocated\n", ( int ) xPortGetFreeHeapSize() ); + + for( ;; ) + { + /* Wait for a message to be received. Using portMAX_DELAY as the block + time will result in an indefinite wait provided INCLUDE_vTaskSuspend is + set to 1 in FreeRTOSConfig.h, therefore there is no need to check the + function return value and the function will only return when a value + has been received. */ + xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY ); + + /* What is this message? What does it contain? */ + switch( xReceivedMessage.cMessageID ) + { + case mainMESSAGE_BUTTON_UP : /* The button poll task has just + informed this task that the up + button on the joystick input has + been pressed or released. */ + sprintf( cBuffer, "Button up = %d", xReceivedMessage.cMessageValue ); + break; + + case mainMESSAGE_BUTTON_SEL : /* The select button interrupt + just informed this task that the + select button was pressed. + Generate a table of task run time + statistics and output this to + the terminal IO window in the IAR + embedded workbench. */ + printf( "\nTask\t Abs Time\t %%Time\n*****************************************" ); +// vTaskGetRunTimeStats( ( signed char * ) cBuffer ); +// printf( cBuffer ); + break; + + case mainMESSAGE_STATUS : /* The tick interrupt hook + function has just informed this + task of the system status. + Generate a string in accordance + with the status value. */ + prvGenerateStatusMessage( cBuffer, xReceivedMessage.cMessageValue ); + break; + + default : sprintf( cBuffer, "Unknown message" ); + break; + } + + /* Output the message that was placed into the cBuffer array within the + switch statement above. */ + printf( "%s", cBuffer ); + } +} +/*-----------------------------------------------------------*/ + +static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue ) +{ + /* Just a utility function to convert a status value into a meaningful + string for output onto the LCD. */ + switch( lStatusValue ) + { + case pdPASS : sprintf( pcBuffer, "Task status = PASS" ); + break; + case mainERROR_DYNAMIC_TASKS : sprintf( pcBuffer, "Error: Dynamic tasks" ); + break; + case mainERROR_COM_TEST : sprintf( pcBuffer, "Err: loop connected?" ); /* Error in COM test - is the Loopback connector connected? */ + break; + case mainERROR_GEN_QUEUE_TEST : sprintf( pcBuffer, "Error: Gen Q test" ); + break; + default : sprintf( pcBuffer, "Unknown status" ); + break; + } +} +/*-----------------------------------------------------------*/ + +static void prvButtonPollTask( void *pvParameters ) +{ +unsigned char ucLastState = pdFALSE, ucState; +xQueueMessage xMessage; + + /* This tasks performs the button polling functionality as described at the + top of this file. */ + for( ;; ) + { + /* Check the button state. */ + ucState = ( halButtonsPressed() & BUTTON_UP ); + if( ucState != ucLastState ) + { + /* The state has changed, send a message to the LCD task. */ + xMessage.cMessageID = mainMESSAGE_BUTTON_UP; + xMessage.cMessageValue = ucState; + ucLastState = ucState; + xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY ); + } + + /* Block for 10 milliseconds so this task does not utilise all the CPU + time and debouncing of the button is not necessary. */ + vTaskDelay( 10 / portTICK_RATE_MS ); + } +} +/*-----------------------------------------------------------*/ + +static void prvSetupHardware( void ) +{ + halBoardInit(); + halButtonsInit( BUTTON_ALL ); + halButtonsInterruptEnable( BUTTON_SELECT ); + LFXT_Start (XT1DRIVE_0); + Init_FLL_Settle( 25000, 488 ); +} +/*-----------------------------------------------------------*/ + +static void prvCheckTask( void *pvParameters ) +{ +volatile unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0; +portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME; +const char *pcStatusMessage = "OK"; + + /* Initialise xNextWakeTime - this only needs to be done once. */ + xNextWakeTime = xTaskGetTickCount(); + + for( ;; ) + { + /* Place this task in the blocked state until it is time to run again. */ + vTaskDelayUntil( &xNextWakeTime, xCycleFrequency ); + + /* Check the reg test tasks are still cycling. They will stop incrementing + their loop counters if they encounter an error. */ + if( usRegTest1Counter == usLastRegTest1Counter ) + { + pcStatusMessage = "Error: RegTest1"; + } + + if( usRegTest2Counter == usLastRegTest2Counter ) + { + pcStatusMessage = "Error: RegTest2"; + } + + usLastRegTest1Counter = usRegTest1Counter; + usLastRegTest2Counter = usRegTest2Counter; + + printf( "%s, tick count = %u\n", pcStatusMessage, ( unsigned int ) xTaskGetTickCount() ); + fflush( stdout ); + } +} +/*-----------------------------------------------------------*/ + +void vApplicationSetupTimerInterrupt( void ) +{ +const unsigned short usACLK_Frequency_Hz = 32768; + + /* Ensure the timer is stopped. */ + TA0CTL = 0; + + /* Run the timer of the ACLK. */ + TA0CTL = TASSEL_1; + + /* Clear everything to start with. */ + TA0CTL |= TACLR; + + /* Set the compare match value according to the tick rate we want. */ + TA0CCR0 = usACLK_Frequency_Hz / configTICK_RATE_HZ; + + /* Enable the interrupts. */ + TA0CCTL0 = CCIE; + + /* Start up clean. */ + TA0CTL |= TACLR; + + /* Up mode. */ + TA0CTL |= MC_1; +} +/*-----------------------------------------------------------*/ + +void vApplicationMallocFailedHook( void ) +{ + for( ;; ); +} +/*-----------------------------------------------------------*/ + +void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) +{ + ( void ) pxTask; + ( void ) pcTaskName; + + for( ;; ); +} +/*-----------------------------------------------------------*/ + +void vApplicationIdleHook( void ) +{ + __bis_SR_register( LPM3_bits + GIE ); +} + + +