Complete large memory model MSP430FR5969 demo - including CLI and run-time stats.
parent
91b249d24b
commit
34a7b0431b
@ -0,0 +1,213 @@
|
||||
/*
|
||||
FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
#include "msp430.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "data_model.h"
|
||||
|
||||
/*
|
||||
* The definition of the "register test" tasks, as described at the top of
|
||||
* main.c
|
||||
*/
|
||||
|
||||
|
||||
|
||||
IMPORT usRegTest1LoopCounter
|
||||
IMPORT usRegTest2LoopCounter
|
||||
IMPORT vPortYield
|
||||
|
||||
EXPORT vRegTest1Implementation
|
||||
EXPORT vRegTest2Implementation
|
||||
|
||||
RSEG CODE
|
||||
|
||||
EVEN
|
||||
|
||||
vRegTest1Implementation:
|
||||
|
||||
/* Fill each general purpose register with a known value. */
|
||||
mov_x #0x4444, r4
|
||||
mov_x #0x5555, r5
|
||||
mov_x #0x6666, r6
|
||||
mov_x #0x7777, r7
|
||||
mov_x #0x8888, r8
|
||||
mov_x #0x9999, r9
|
||||
mov_x #0xaaaa, r10
|
||||
mov_x #0xbbbb, r11
|
||||
mov_x #0xcccc, r12
|
||||
mov_x #0xdddd, r13
|
||||
mov_x #0xeeee, r14
|
||||
mov_x #0xffff, r15
|
||||
|
||||
prvRegTest1Loop:
|
||||
|
||||
/* Test each general purpose register to check that it still contains the
|
||||
expected known value, jumping to vRegTest1Error if any register contains
|
||||
an unexpected value. */
|
||||
cmp_x #0x4444, r4
|
||||
jne vRegTest1Error
|
||||
cmp_x #0x5555, r5
|
||||
jne vRegTest1Error
|
||||
cmp_x #0x6666, r6
|
||||
jne vRegTest1Error
|
||||
cmp_x #0x7777, r7
|
||||
jne vRegTest1Error
|
||||
cmp_x #0x8888, r8
|
||||
jne vRegTest1Error
|
||||
cmp_x #0x9999, r9
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xaaaa, r10
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xbbbb, r11
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xcccc, r12
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xdddd, r13
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xeeee, r14
|
||||
jne vRegTest1Error
|
||||
cmp_x #0xffff, r15
|
||||
jne vRegTest1Error
|
||||
|
||||
/* This task is still running without jumping to vRegTest1Error, so increment
|
||||
the loop counter so the check task knows the task is running error free. */
|
||||
incx.w &usRegTest1LoopCounter
|
||||
|
||||
/* Loop again, performing the same tests. */
|
||||
jmp prvRegTest1Loop
|
||||
nop
|
||||
|
||||
|
||||
EVEN
|
||||
|
||||
vRegTest1Error:
|
||||
jmp vRegTest1Error
|
||||
nop
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* See the comments in vRegTest1Implementation. This task is the same, it just uses
|
||||
different values in its registers. */
|
||||
vRegTest2Implementation:
|
||||
|
||||
mov_x #0x4441, r4
|
||||
mov_x #0x5551, r5
|
||||
mov_x #0x6661, r6
|
||||
mov_x #0x7771, r7
|
||||
mov_x #0x8881, r8
|
||||
mov_x #0x9991, r9
|
||||
mov_x #0xaaa1, r10
|
||||
mov_x #0xbbb1, r11
|
||||
mov_x #0xccc1, r12
|
||||
mov_x #0xddd1, r13
|
||||
mov_x #0xeee1, r14
|
||||
mov_x #0xfff1, r15
|
||||
|
||||
prvRegTest2Loop:
|
||||
|
||||
cmp_x #0x4441, r4
|
||||
jne vRegTest2Error
|
||||
cmp_x #0x5551, r5
|
||||
jne vRegTest2Error
|
||||
cmp_x #0x6661, r6
|
||||
jne vRegTest2Error
|
||||
cmp_x #0x7771, r7
|
||||
jne vRegTest2Error
|
||||
cmp_x #0x8881, r8
|
||||
jne vRegTest2Error
|
||||
cmp_x #0x9991, r9
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xaaa1, r10
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xbbb1, r11
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xccc1, r12
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xddd1, r13
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xeee1, r14
|
||||
jne vRegTest2Error
|
||||
cmp_x #0xfff1, r15
|
||||
jne vRegTest2Error
|
||||
|
||||
/* Also perform a manual yield, just to increase the scope of the test. */
|
||||
calla #vPortYield
|
||||
|
||||
incx.w &usRegTest2LoopCounter
|
||||
jmp prvRegTest2Loop
|
||||
nop
|
||||
|
||||
|
||||
vRegTest2Error:
|
||||
jmp vRegTest2Error
|
||||
nop
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
END
|
||||
|
@ -0,0 +1,407 @@
|
||||
/*
|
||||
FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the comprehensive test and demo version.
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* full demo. Generic functions, such FreeRTOS hook functions, and functions
|
||||
* required to configure the hardware, are defined in main.c.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* main_full() creates all the demo application tasks and software timers, then
|
||||
* starts the scheduler. The web documentation provides more details of the
|
||||
* standard demo application tasks, which provide no particular functionality,
|
||||
* but do provide a good example of how to use the FreeRTOS API.
|
||||
*
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Reg test" tasks - These fill both the microcontroller registers with known
|
||||
* values, then check that each register maintains its expected value for the
|
||||
* lifetime of the task. Each task uses a different set of values. The reg
|
||||
* test tasks execute with a very low priority, so get preempted very
|
||||
* frequently. A register containing an unexpected value is indicative of an
|
||||
* error in the context switching mechanism.
|
||||
*
|
||||
* "Check" task - The check task period is initially set to three seconds. The
|
||||
* task checks that all the standard demo tasks, and the register check tasks,
|
||||
* are not only still executing, but are executing without reporting any errors.
|
||||
* If the check task discovers that a task has either stalled, or reported an
|
||||
* error, then it changes its own execution period from the initial three
|
||||
* seconds, to just 200ms. The check task also toggles an LED each time it is
|
||||
* called. This provides a visual indication of the system status: If the LED
|
||||
* toggles every three seconds, then no issues have been discovered. If the LED
|
||||
* toggles every 200ms, then an issue has been discovered with at least one
|
||||
* task.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* Standard demo application includes. */
|
||||
#include "dynamic.h"
|
||||
#include "blocktim.h"
|
||||
#include "countsem.h"
|
||||
#include "GenQTest.h"
|
||||
#include "recmutex.h"
|
||||
#include "partest.h"
|
||||
#include "EventGroupsDemo.h"
|
||||
#include "TaskNotify.h"
|
||||
|
||||
/* Priorities for the check task, as described at the top of this file. */
|
||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
|
||||
/* Parameters for the task that handles the UART command console. */
|
||||
#define mainCOMMAND_CONSOLE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainCOMMAND_CONSOLE_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
/* The LED used by the check timer as described at the top of this file. */
|
||||
#define mainCHECK_LED ( 0 )
|
||||
|
||||
/* The period after which the check timer will expire, in ms, provided no errors
|
||||
have been reported by any of the standard demo tasks. ms are converted to the
|
||||
equivalent in ticks using the pdMS_TO_TICKS() macro. */
|
||||
#define mainNO_ERROR_CHECK_TASK_PERIOD pdMS_TO_TICKS( 3000 )
|
||||
|
||||
/* The period at which the check timer will expire, in ms, if an error has been
|
||||
reported in one of the standard demo tasks. ms are converted to the equivalent
|
||||
in ticks using the pdMS_TO_TICKS() macro. */
|
||||
#define mainERROR_CHECK_TASK_PERIOD pdMS_TO_TICKS( 200 )
|
||||
|
||||
/* Parameters that are passed into the register check tasks solely for the
|
||||
purpose of ensuring parameters are passed into tasks correctly. */
|
||||
#define mainREG_TEST_TASK_1_PARAMETER ( ( void * ) 0x1234 )
|
||||
#define mainREG_TEST_TASK_2_PARAMETER ( ( void * ) 0x8765 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Called by main() to run the full demo (as opposed to the blinky demo) when
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
|
||||
*/
|
||||
void main_full( void );
|
||||
|
||||
/*
|
||||
* The check task, as described at the top of this file.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Register check tasks, as described at the top of this file. The nature of
|
||||
* these files necessitates that they are written in an assembly file, but the
|
||||
* entry points are kept in the C file for the convenience of checking the task
|
||||
* parameter.
|
||||
*/
|
||||
static void prvRegTestTaskEntry1( void *pvParameters );
|
||||
extern void vRegTest1Implementation( void );
|
||||
static void prvRegTestTaskEntry2( void *pvParameters );
|
||||
extern void vRegTest2Implementation( void );
|
||||
|
||||
/* Starts the 'standard' UART command console task. UART 0 is used at 19200
|
||||
baud. */
|
||||
extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );
|
||||
|
||||
/* Registers a set of example commands that can be used in the command
|
||||
console. */
|
||||
void vRegisterSampleCLICommands( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The following two variables are used to communicate the status of the
|
||||
register check tasks to the check task. If the variables keep incrementing,
|
||||
then the register check tasks have not discovered any errors. If a variable
|
||||
stops incrementing, then an error has been found. */
|
||||
volatile uint16_t usRegTest1LoopCounter = 0UL, usRegTest2LoopCounter = 0UL;
|
||||
|
||||
/* cOutputBuffer is used by FreeRTOS+CLI. It is declared here so the
|
||||
__persistent qualifier can be used. For the buffer to be declared here, rather
|
||||
than in FreeRTOS_CLI.c, configAPPLICATION_PROVIDES_cOutputBuffer must be set to
|
||||
1 in FreeRTOSConfig.h. */
|
||||
__persistent char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ];
|
||||
|
||||
/* Used for maintaining a 32-bit run time stats counter from a 16-bit timer. */
|
||||
volatile uint32_t ulRunTimeCounterOverflows = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main_full( void )
|
||||
{
|
||||
/* Start all the standard demo/test tasks. They have no particular
|
||||
functionality, but do demonstrate how to use the FreeRTOS API and test the
|
||||
kernel port. */
|
||||
vStartDynamicPriorityTasks();
|
||||
vCreateBlockTimeTasks();
|
||||
vStartCountingSemaphoreTasks();
|
||||
vStartGenericQueueTasks( tskIDLE_PRIORITY );
|
||||
vStartRecursiveMutexTasks();
|
||||
vStartEventGroupTasks();
|
||||
vStartTaskNotifyTask();
|
||||
|
||||
/* Create the register check tasks, as described at the top of this file */
|
||||
xTaskCreate( prvRegTestTaskEntry1, /* Task entry point. */
|
||||
"Reg1", /* Text name for the task - not used by the kernel. */
|
||||
configMINIMAL_STACK_SIZE, /* Stack to allocate to the task - in words not bytes! */
|
||||
mainREG_TEST_TASK_1_PARAMETER, /* The parameter passed into the task. */
|
||||
tskIDLE_PRIORITY, /* The task's priority. */
|
||||
NULL ); /* Task handle is not needed, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* Create the task that performs the 'check' functionality, as described at
|
||||
the top of this file. */
|
||||
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Register an example set of CLI commands, then start the task that manages
|
||||
the CLI using a UART for input and output. */
|
||||
vRegisterSampleCLICommands();
|
||||
vUARTCommandConsoleStart( mainCOMMAND_CONSOLE_STACK_SIZE, mainCOMMAND_CONSOLE_TASK_PRIORITY );
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was either insufficient FreeRTOS heap memory available for the idle
|
||||
and/or timer tasks to be created. See the memory management section on the
|
||||
FreeRTOS web site for more details on the FreeRTOS heap
|
||||
http://www.freertos.org/a00111.html. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
|
||||
TickType_t xLastExecutionTime;
|
||||
static uint16_t usLastRegTest1Value = 0, usLastRegTest2Value = 0;
|
||||
uint16_t usErrorFound = pdFALSE;
|
||||
|
||||
/* Just to stop compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
|
||||
works correctly. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
/* Cycle for ever, delaying then checking all the other tasks are still
|
||||
operating without error. An on-board LED is toggled on each iteration.
|
||||
If an error is detected then the delay period is decreased from
|
||||
mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has the
|
||||
effect of increasing the rate at which the on-board LED toggles, and in so
|
||||
doing gives visual feedback of the system status. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Delay until it is time to execute again. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
|
||||
|
||||
/* Check all the demo tasks to ensure they are all still running, and
|
||||
that none have detected an error. */
|
||||
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorFound = 1UL << 0UL;
|
||||
}
|
||||
|
||||
if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorFound = 1UL << 1UL;
|
||||
}
|
||||
|
||||
if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorFound = 1UL << 2UL;
|
||||
}
|
||||
|
||||
if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorFound = 1UL << 3UL;
|
||||
}
|
||||
|
||||
if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorFound = 1UL << 4UL;
|
||||
}
|
||||
|
||||
if( xAreEventGroupTasksStillRunning() != pdPASS )
|
||||
{
|
||||
usErrorFound = 1UL << 5UL;
|
||||
}
|
||||
|
||||
if( xAreTaskNotificationTasksStillRunning() != pdPASS )
|
||||
{
|
||||
usErrorFound = 1UL << 6UL;
|
||||
}
|
||||
|
||||
/* Check that the register test 1 task is still running. */
|
||||
if( usLastRegTest1Value == usRegTest1LoopCounter )
|
||||
{
|
||||
usErrorFound = 1UL << 7UL;
|
||||
}
|
||||
usLastRegTest1Value = usRegTest1LoopCounter;
|
||||
|
||||
/* Check that the register test 2 task is still running. */
|
||||
if( usLastRegTest2Value == usRegTest2LoopCounter )
|
||||
{
|
||||
usErrorFound = 1UL << 8UL;
|
||||
}
|
||||
usLastRegTest2Value = usRegTest2LoopCounter;
|
||||
|
||||
/* Toggle the check LED to give an indication of the system status. If
|
||||
the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then
|
||||
everything is ok. A faster toggle indicates an error. */
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
|
||||
if( usErrorFound != pdFALSE )
|
||||
{
|
||||
/* An error has been detected in one of the tasks - flash the LED
|
||||
at a higher frequency to give visible feedback that something has
|
||||
gone wrong (it might just be that the loop back connector required
|
||||
by the comtest tasks has not been fitted). */
|
||||
xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTaskEntry1( void *pvParameters )
|
||||
{
|
||||
/* Although the regtest task is written in assembler, its entry point is
|
||||
written in C for convenience of checking the task parameter is being passed
|
||||
in correctly. */
|
||||
if( pvParameters == mainREG_TEST_TASK_1_PARAMETER )
|
||||
{
|
||||
/* Start the part of the test that is written in assembler. */
|
||||
vRegTest1Implementation();
|
||||
}
|
||||
|
||||
/* The following line will only execute if the task parameter is found to
|
||||
be incorrect. The check task will detect that the regtest loop counter is
|
||||
not being incremented and flag an error. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTaskEntry2( void *pvParameters )
|
||||
{
|
||||
/* Although the regtest task is written in assembler, its entry point is
|
||||
written in C for convenience of checking the task parameter is being passed
|
||||
in correctly. */
|
||||
if( pvParameters == mainREG_TEST_TASK_2_PARAMETER )
|
||||
{
|
||||
/* Start the part of the test that is written in assembler. */
|
||||
vRegTest2Implementation();
|
||||
}
|
||||
|
||||
/* The following line will only execute if the task parameter is found to
|
||||
be incorrect. The check task will detect that the regtest loop counter is
|
||||
not being incremented and flag an error. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vConfigureTimerForRunTimeStats( void )
|
||||
{
|
||||
/* Configure a timer that is used as the time base for run time stats. See
|
||||
http://www.freertos.org/rtos-run-time-stats.html */
|
||||
|
||||
/* Ensure the timer is stopped. */
|
||||
TA1CTL = 0;
|
||||
|
||||
/* Start up clean. */
|
||||
TA1CTL |= TACLR;
|
||||
|
||||
/* Run the timer from the ACLK/8, continuous mode, interrupt enable. */
|
||||
TA1CTL = TASSEL_1 | ID__8 | MC__CONTINUOUS | TAIE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#pragma vector=TIMER1_A1_VECTOR
|
||||
__interrupt void v4RunTimeStatsTimerOverflow( void )
|
||||
{
|
||||
TA1CTL &= ~TAIFG;
|
||||
|
||||
/* 16-bit overflow, so add 17th bit. */
|
||||
ulRunTimeCounterOverflows += 0x10000;
|
||||
__bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,248 @@
|
||||
/*
|
||||
FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER.
|
||||
*
|
||||
* This is not a proper UART driver. It only supports one port, and is not
|
||||
* intended to show an efficient implementation as queues are used to pass
|
||||
* individual characters one at a time! This is ok for a slow interface, such
|
||||
* as a command line interface (which this driver is used for), but is too
|
||||
* inefficient for higher bandwidth applications.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo application includes. */
|
||||
#include "serial.h"
|
||||
|
||||
/* TI includes. */
|
||||
#include "driverlib.h"
|
||||
|
||||
/* Misc. constants. */
|
||||
#define serNO_BLOCK ( ( TickType_t ) 0 )
|
||||
|
||||
/* The queue used to hold received characters. */
|
||||
static QueueHandle_t xRxedChars;
|
||||
|
||||
/* The queue used to hold characters waiting transmission. */
|
||||
static QueueHandle_t xCharsForTx;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, UBaseType_t uxQueueLength )
|
||||
{
|
||||
unsigned long ulBaudRateCount;
|
||||
|
||||
/* Initialise the hardware. */
|
||||
|
||||
/* Generate the baud rate constants for the wanted baud rate. */
|
||||
ulBaudRateCount = configCPU_CLOCK_HZ / ulWantedBaud;
|
||||
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
/* Create the queues used by the com test task. */
|
||||
xRxedChars = xQueueCreate( uxQueueLength, ( UBaseType_t ) sizeof( signed char ) );
|
||||
xCharsForTx = xQueueCreate( uxQueueLength, ( UBaseType_t ) sizeof( signed char ) );
|
||||
|
||||
/* Reset UART. */
|
||||
UCA0CTL1 |= UCSWRST;
|
||||
|
||||
/* Use SMCLK. */
|
||||
UCA0CTL1 = UCSSEL0 | UCSSEL1;
|
||||
|
||||
/* Setup baud rate low byte. */
|
||||
UCA0BR0 = ( unsigned char ) ( ulBaudRateCount & ( unsigned long ) 0xff );
|
||||
|
||||
/* Setup baud rate high byte. */
|
||||
ulBaudRateCount >>= 8UL;
|
||||
UCA0BR1 = ( unsigned char ) ( ulBaudRateCount & ( unsigned long ) 0xff );
|
||||
|
||||
/* Enable interrupts. */
|
||||
UCA0IE |= UCRXIE;
|
||||
|
||||
/* Take out of reset. */
|
||||
UCA0CTL1 &= ~UCSWRST;
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Note the comments at the top of this file about this not being a generic
|
||||
UART driver. */
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime )
|
||||
{
|
||||
/* Get the next character from the buffer. Return false if no characters
|
||||
are available, or arrive before xBlockTime expires. */
|
||||
if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
|
||||
{
|
||||
return pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
/* Send the next character to the queue of characters waiting transmission,
|
||||
then enable the UART Tx interrupt, just in case UART transmission has already
|
||||
completed and switched itself off. */
|
||||
xReturn = xQueueSend( xCharsForTx, &cOutChar, xBlockTime );
|
||||
UCA0IE |= UCTXIE;
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
||||
{
|
||||
UBaseType_t uxChar;
|
||||
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 100 );
|
||||
|
||||
/* The driver only supports one port so the pxPort parameter is not used. */
|
||||
( void ) pxPort;
|
||||
|
||||
for( uxChar = 0; uxChar < usStringLength; uxChar++ )
|
||||
{
|
||||
if( xQueueSend( xCharsForTx, &( pcString[ uxChar ] ), xMaxBlockTime ) == pdFALSE )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
UCA0IE |= UCTXIE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The implementation of this interrupt is provided to demonstrate the use
|
||||
of queues from inside an interrupt service routine. It is *not* intended to
|
||||
be an efficient interrupt implementation. A real application should make use
|
||||
of the DMA. Or, as a minimum, transmission and reception could use a simple
|
||||
RAM ring buffer, and synchronise with a task using a semaphore when a complete
|
||||
message has been received or transmitted. */
|
||||
#pragma vector=USCI_A0_VECTOR
|
||||
static __interrupt void prvUSCI_A0_ISR( void )
|
||||
{
|
||||
signed char cChar;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
while( ( UCA0IFG & UCRXIFG ) != 0 )
|
||||
{
|
||||
/* Get the character from the UART and post it on the queue of Rxed
|
||||
characters. */
|
||||
cChar = UCA0RXBUF;
|
||||
xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
/* If there is a Tx interrupt pending and the tx interrupts are enabled. */
|
||||
if( ( UCA0IFG & UCTXIFG ) != 0 )
|
||||
{
|
||||
/* The previous character has been transmitted. See if there are any
|
||||
further characters waiting transmission. */
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||
{
|
||||
/* There was another character queued - transmit it now. */
|
||||
UCA0TXBUF = cChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There were no other characters to transmit - disable the Tx
|
||||
interrupt. */
|
||||
UCA0IE &= ~UCTXIE;
|
||||
}
|
||||
}
|
||||
|
||||
__bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF );
|
||||
|
||||
/* If writing to a queue caused a task to unblock, and the unblocked task
|
||||
has a priority equal to or above the task that this interrupt interrupted,
|
||||
then lHigherPriorityTaskWoken will have been set to pdTRUE internally within
|
||||
xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this
|
||||
interrupt returns directly to the higher priority unblocked task.
|
||||
|
||||
THIS MUST BE THE LAST THING DONE IN THE ISR. */
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue