mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-01 08:54:14 -04:00
Update version number ready for version 9 release candidate 1.
This commit is contained in:
parent
d7253324cd
commit
d3ba0aa98d
1385 changed files with 1722 additions and 4965 deletions
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
FreeRTOS V8.2.3 - 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!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#include <conio.h>
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions for the x86 port.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* These are the only definitions that can be modified!. */
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) /* This can be made smaller if required. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 1
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 10 )
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
|
||||
/* The maximum number of characters a task name can take,
|
||||
including the null terminator. */
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
|
||||
/* Set the following definitions to 1 to include the component, or zero
|
||||
to exclude the component. */
|
||||
|
||||
/* Include/exclude the stated API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
|
||||
|
||||
/*
|
||||
* The tick count (and times defined in tick count units) can be either a 16bit
|
||||
* or a 32 bit value. See documentation on http://www.FreeRTOS.org to decide
|
||||
* which to use.
|
||||
*/
|
||||
#define configUSE_16_BIT_TICKS 1
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
FreeRTOS V8.2.3 - 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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo program include files. */
|
||||
#include "fileio.h"
|
||||
|
||||
void vDisplayMessage( const char * const pcMessageToPrint )
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
printf( "%s", pcMessageToPrint );
|
||||
fflush( stdout );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vWriteMessageToDisk( const char * const pcMessage )
|
||||
{
|
||||
const char * const pcFileName = "a:\\RTOSlog.txt";
|
||||
const char * const pcSeparator = "\r\n-----------------------\r\n";
|
||||
FILE *pf;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
pf = fopen( pcFileName, "a" );
|
||||
if( pf != NULL )
|
||||
{
|
||||
fwrite( pcMessage, strlen( pcMessage ), ( unsigned short ) 1, pf );
|
||||
fwrite( pcSeparator, strlen( pcSeparator ), ( unsigned short ) 1, pf );
|
||||
fclose( pf );
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vWriteBufferToDisk( const char * const pcBuffer, unsigned long ulBufferLength )
|
||||
{
|
||||
const char * const pcFileName = "a:\\trace.bin";
|
||||
FILE *pf;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
pf = fopen( pcFileName, "wb" );
|
||||
if( pf )
|
||||
{
|
||||
fwrite( pcBuffer, ( size_t ) ulBufferLength, ( unsigned short ) 1, pf );
|
||||
fclose( pf );
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
FreeRTOS V8.2.3 - 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!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#include <i86.h>
|
||||
#include <conio.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 1
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 ) /* This can be made smaller if required. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 1
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 1
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0 /* Do not use this option on the PC port. */
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
|
||||
#define configMAX_PRIORITIES ( 10 )
|
||||
#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 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 0 /* Do not use this option on the PC port. */
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* An example "task switched in" hook macro definition. */
|
||||
#define traceTASK_SWITCHED_IN() xTaskCallApplicationTaskHook( NULL, ( void * ) 0xabcd )
|
||||
|
||||
extern void vMainQueueSendPassed( void );
|
||||
#define traceQUEUE_SEND( pxQueue ) vMainQueueSendPassed()
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
FreeRTOS V8.2.3 - 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!
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V1.01:
|
||||
|
||||
+ Types used updated.
|
||||
+ Add vParTestToggleLED();
|
||||
|
||||
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Use scheduler suspends in place of critical sections.
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "partest.h"
|
||||
#include "task.h"
|
||||
|
||||
#define partstALL_OUTPUTS_OFF ( ( unsigned char ) 0x00 )
|
||||
#define partstMAX_OUTPUT_LED ( ( unsigned char ) 7 )
|
||||
|
||||
/*lint -e956 File scope parameters okay here. */
|
||||
static unsigned short usPortAddress = partstDEFAULT_PORT_ADDRESS;
|
||||
static volatile unsigned char ucCurrentOutputValue = partstALL_OUTPUTS_OFF;
|
||||
/*lint +e956 */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple parallel port IO routines
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
ucCurrentOutputValue = partstALL_OUTPUTS_OFF;
|
||||
|
||||
portOUTPUT_BYTE( usPortAddress, ( unsigned ) partstALL_OUTPUTS_OFF );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, portBASE_TYPE xValue )
|
||||
{
|
||||
unsigned char ucBit = ( unsigned char ) 1;
|
||||
|
||||
if( uxLED <= partstMAX_OUTPUT_LED )
|
||||
{
|
||||
ucBit <<= uxLED;
|
||||
}
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
if( xValue == pdTRUE )
|
||||
{
|
||||
ucBit ^= ( unsigned char ) 0xff;
|
||||
ucCurrentOutputValue &= ucBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucCurrentOutputValue |= ucBit;
|
||||
}
|
||||
|
||||
portOUTPUT_BYTE( usPortAddress, ( unsigned ) ucCurrentOutputValue );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
unsigned char ucBit;
|
||||
|
||||
if( uxLED <= partstMAX_OUTPUT_LED )
|
||||
{
|
||||
ucBit = ( ( unsigned char ) 1 ) << uxLED;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
if( ucCurrentOutputValue & ucBit )
|
||||
{
|
||||
ucCurrentOutputValue &= ~ucBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucCurrentOutputValue |= ucBit;
|
||||
}
|
||||
|
||||
portOUTPUT_BYTE( usPortAddress, ( unsigned ) ucCurrentOutputValue );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
5
FreeRTOS/Demo/PC/ReadMe.txt
Normal file
5
FreeRTOS/Demo/PC/ReadMe.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
If you need the demo that used to be in this directory then download FreeRTOS V8.2.3
|
||||
from http://sourceforge.net/projects/freertos/files/FreeRTOS/ - however it is
|
||||
recommended that the Win32 demo is used instead. See
|
||||
http://www.freertos.org/simple-freertos-demos.html for links to the Win32 demo.
|
||||
|
|
@ -1,568 +0,0 @@
|
|||
/*
|
||||
FreeRTOS V8.2.3 - 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!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates all the demo application tasks and co-routines, then starts the
|
||||
* scheduler.
|
||||
*
|
||||
* Main. c also creates a task called "Print". This only executes every
|
||||
* five seconds but has the highest priority so is guaranteed to get
|
||||
* processor time. Its main function is to check that all the other tasks
|
||||
* are still operational. Nearly all the tasks in the demo application
|
||||
* maintain a unique count that is incremented each time the task successfully
|
||||
* completes its function. Should any error occur within the task the count is
|
||||
* permanently halted. The print task checks the count of each task to ensure
|
||||
* it has changed since the last time the print task executed. If any count is
|
||||
* found not to have changed the print task displays an appropriate message.
|
||||
* If all the tasks are still incrementing their unique counts the print task
|
||||
* displays an "OK" message.
|
||||
*
|
||||
* The LED flash tasks do not maintain a count as they already provide visual
|
||||
* feedback of their status.
|
||||
*
|
||||
* The print task blocks on the queue into which messages that require
|
||||
* displaying are posted. It will therefore only block for the full 5 seconds
|
||||
* if no messages are posted onto the queue.
|
||||
*
|
||||
* Main. c also provides a demonstration of how the trace visualisation utility
|
||||
* can be used, and how the scheduler can be stopped.
|
||||
*
|
||||
* \page MainC main.c
|
||||
* \ingroup DemoFiles
|
||||
* <HR>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "croutine.h"
|
||||
#include "partest.h"
|
||||
#include "serial.h"
|
||||
|
||||
/* Demo file headers. */
|
||||
#include "BlockQ.h"
|
||||
#include "PollQ.h"
|
||||
#include "death.h"
|
||||
#include "crflash.h"
|
||||
#include "flop.h"
|
||||
#include "print.h"
|
||||
#include "comtest.h"
|
||||
#include "fileio.h"
|
||||
#include "semtest.h"
|
||||
#include "integer.h"
|
||||
#include "dynamic.h"
|
||||
#include "mevents.h"
|
||||
#include "crhook.h"
|
||||
#include "blocktim.h"
|
||||
#include "AltBlock.h"
|
||||
#include "GenQTest.h"
|
||||
#include "QPeek.h"
|
||||
#include "countsem.h"
|
||||
#include "AltQTest.h"
|
||||
#include "AltPollQ.h"
|
||||
#include "AltBlckQ.h"
|
||||
#include "RecMutex.h"
|
||||
|
||||
/* Priority definitions for the tasks in the demo application. */
|
||||
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainPRINT_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_BLOCK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainSEMAPHORE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
#define mainPRINT_STACK_SIZE ( ( unsigned short ) 512 )
|
||||
#define mainDEBUG_LOG_BUFFER_SIZE ( ( unsigned short ) 20480 )
|
||||
|
||||
/* The number of flash co-routines to create. */
|
||||
#define mainNUM_FLASH_CO_ROUTINES ( 8 )
|
||||
|
||||
/* Task function for the "Print" task as described at the top of the file. */
|
||||
static void vErrorChecks( void *pvParameters );
|
||||
|
||||
/* Function that checks the unique count of all the other tasks as described at
|
||||
the top of the file. */
|
||||
static void prvCheckOtherTasksAreStillRunning( void );
|
||||
|
||||
/* Key presses can be used to start/stop the trace visualisation utility or stop
|
||||
the scheduler. */
|
||||
static void prvCheckForKeyPresses( void );
|
||||
|
||||
/* Buffer used by the trace visualisation utility so only needed if the trace
|
||||
being used. */
|
||||
#if configUSE_TRACE_FACILITY == 1
|
||||
static char pcWriteBuffer[ mainDEBUG_LOG_BUFFER_SIZE ];
|
||||
#endif
|
||||
|
||||
/* Constant definition used to turn on/off the pre-emptive scheduler. */
|
||||
static const short sUsingPreemption = configUSE_PREEMPTION;
|
||||
|
||||
/* Start the math tasks appropriate to the build. The Borland port does
|
||||
not yet support floating point so uses the integer equivalent. */
|
||||
static void prvStartMathTasks( void );
|
||||
|
||||
/* Check which ever tasks are relevant to this build. */
|
||||
static portBASE_TYPE prvCheckMathTasksAreStillRunning( void );
|
||||
|
||||
/* Used to demonstrate the "task switched in" callback function. */
|
||||
static portBASE_TYPE prvExampleTaskHook( void * pvParameter );
|
||||
|
||||
/* Just used to count the number of times the example task callback function is
|
||||
called, and the number of times a queue send passes. */
|
||||
static unsigned long long uxCheckTaskHookCallCount = 0;
|
||||
static unsigned long long uxQueueSendPassedCount = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
short main( void )
|
||||
{
|
||||
/* Initialise hardware and utilities. */
|
||||
vParTestInitialise();
|
||||
vPrintInitialise();
|
||||
|
||||
/* CREATE ALL THE DEMO APPLICATION TASKS. */
|
||||
prvStartMathTasks();
|
||||
vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM1, ser115200 );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
|
||||
vStartSemaphoreTasks( mainSEMAPHORE_TASK_PRIORITY );
|
||||
vStartDynamicPriorityTasks();
|
||||
vStartMultiEventTasks();
|
||||
vStartQueuePeekTasks();
|
||||
vStartCountingSemaphoreTasks();
|
||||
vStartAltGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
|
||||
vCreateAltBlockTimeTasks();
|
||||
vStartAltBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );
|
||||
vStartAltPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartRecursiveMutexTasks();
|
||||
|
||||
/* Create the "Print" task as described at the top of the file. */
|
||||
xTaskCreate( vErrorChecks, "Print", mainPRINT_STACK_SIZE, NULL, mainPRINT_TASK_PRIORITY, NULL );
|
||||
|
||||
/* This task has to be created last as it keeps account of the number of tasks
|
||||
it expects to see running. */
|
||||
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
||||
|
||||
/* Create the co-routines that flash the LED's. */
|
||||
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
|
||||
|
||||
/* Create the co-routines that communicate with the tick hook. */
|
||||
vStartHookCoRoutines();
|
||||
|
||||
/* Set the scheduler running. This function will not return unless a task
|
||||
calls vTaskEndScheduler(). */
|
||||
vTaskStartScheduler();
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvExampleTaskHook( void * pvParameter )
|
||||
{
|
||||
if( pvParameter != ( void * ) 0xabcd )
|
||||
{
|
||||
/* The parameter did not contain the value we expected, so cause an
|
||||
error to be detected by setting the call count back to zero. */
|
||||
uxCheckTaskHookCallCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Simply increment a number so we know the callback has been executed. */
|
||||
uxCheckTaskHookCallCount++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vMainQueueSendPassed( void )
|
||||
{
|
||||
/* This is just an example implementation of the "queue send" trace hook. */
|
||||
uxQueueSendPassedCount++;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vErrorChecks( void *pvParameters )
|
||||
{
|
||||
TickType_t xExpectedWakeTime;
|
||||
const TickType_t xPrintRate = ( TickType_t ) 5000 / portTICK_PERIOD_MS;
|
||||
const long lMaxAllowableTimeDifference = ( long ) 0;
|
||||
TickType_t xWakeTime;
|
||||
long lTimeDifference;
|
||||
const char *pcReceivedMessage;
|
||||
const char * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r\n";
|
||||
const char * const pcUnexpectedHookValueMsg = "Task hook has unexpected value!\r\n";
|
||||
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Register our callback function. */
|
||||
vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook );
|
||||
|
||||
/* Just for test purposes. */
|
||||
if( xTaskGetApplicationTaskTag( NULL ) != prvExampleTaskHook )
|
||||
{
|
||||
vPrintDisplayMessage( &pcUnexpectedHookValueMsg );
|
||||
}
|
||||
|
||||
/* Loop continuously, blocking, then checking all the other tasks are still
|
||||
running, before blocking once again. This task blocks on the queue of
|
||||
messages that require displaying so will wake either by its time out expiring,
|
||||
or a message becoming available. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Calculate the time we will unblock if no messages are received
|
||||
on the queue. This is used to check that we have not blocked for too long. */
|
||||
xExpectedWakeTime = xTaskGetTickCount();
|
||||
xExpectedWakeTime += xPrintRate;
|
||||
|
||||
/* Block waiting for either a time out or a message to be posted that
|
||||
required displaying. */
|
||||
pcReceivedMessage = pcPrintGetNextMessage( xPrintRate );
|
||||
|
||||
/* Was a message received? */
|
||||
if( pcReceivedMessage == NULL )
|
||||
{
|
||||
/* A message was not received so we timed out, did we unblock at the
|
||||
expected time? */
|
||||
xWakeTime = xTaskGetTickCount();
|
||||
|
||||
/* Calculate the difference between the time we unblocked and the
|
||||
time we should have unblocked. */
|
||||
if( xWakeTime > xExpectedWakeTime )
|
||||
{
|
||||
lTimeDifference = ( long ) ( xWakeTime - xExpectedWakeTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
lTimeDifference = ( long ) ( xExpectedWakeTime - xWakeTime );
|
||||
}
|
||||
|
||||
if( lTimeDifference > lMaxAllowableTimeDifference )
|
||||
{
|
||||
/* We blocked too long - create a message that will get
|
||||
printed out the next time around. If we are not using
|
||||
preemption then we won't expect the timing to be so
|
||||
accurate. */
|
||||
if( sUsingPreemption == pdTRUE )
|
||||
{
|
||||
vPrintDisplayMessage( &pcTaskBlockedTooLongMsg );
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the other tasks are still running, just in case. */
|
||||
prvCheckOtherTasksAreStillRunning();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We unblocked due to a message becoming available. Send the message
|
||||
for printing. */
|
||||
vDisplayMessage( pcReceivedMessage );
|
||||
}
|
||||
|
||||
/* Key presses are used to invoke the trace visualisation utility, or end
|
||||
the program. */
|
||||
prvCheckForKeyPresses();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckForKeyPresses( void )
|
||||
{
|
||||
short sIn;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
#ifdef DEBUG_BUILD
|
||||
/* kbhit can be used in .exe's that are executed from the command
|
||||
line, but not if executed through the debugger. */
|
||||
sIn = 0;
|
||||
#else
|
||||
sIn = kbhit();
|
||||
#endif
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
if( sIn )
|
||||
{
|
||||
/* Key presses can be used to start/stop the trace utility, or end the
|
||||
program. */
|
||||
sIn = getch();
|
||||
switch( sIn )
|
||||
{
|
||||
/* Only define keys for turning on and off the trace if the trace
|
||||
is being used. */
|
||||
#if configUSE_TRACE_FACILITY == 1
|
||||
case 't' : vTaskList( pcWriteBuffer );
|
||||
vWriteMessageToDisk( pcWriteBuffer );
|
||||
break;
|
||||
/* The legacy trace is no longer supported. Use FreeRTOS+Trace instead
|
||||
case 's' : vTaskStartTrace( pcWriteBuffer, mainDEBUG_LOG_BUFFER_SIZE );
|
||||
break;
|
||||
|
||||
case 'e' : {
|
||||
unsigned long ulBufferLength;
|
||||
ulBufferLength = ulTaskEndTrace();
|
||||
vWriteBufferToDisk( pcWriteBuffer, ulBufferLength );
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#endif
|
||||
|
||||
default : vTaskEndScheduler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckOtherTasksAreStillRunning( void )
|
||||
{
|
||||
static short sErrorHasOccurred = pdFALSE;
|
||||
static unsigned long long uxLastHookCallCount = 0, uxLastQueueSendCount = 0;
|
||||
|
||||
if( prvCheckMathTasksAreStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Maths task count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Com test count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Blocking queues count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreAltBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Alt blocking queues count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Polling queue count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreAltPollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Alt polling queue count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xIsCreateTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Incorrect number of tasks running!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Semaphore take count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Dynamic priority count unchanged!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreMultiEventTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in multi events tasks!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreFlashCoRoutinesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in co-routine flash tasks!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreHookCoRoutinesStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in tick hook to co-routine communications!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in block time test tasks!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreAltBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in fast block time test tasks!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in generic queue test task!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreAltGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in fast generic queue test task!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in queue peek test task!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in counting semaphore demo task!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
vDisplayMessage( "Error in recursive mutex tasks!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
/* The hook function associated with this task is called each time the task
|
||||
is switched in. We therefore expect the number of times the callback
|
||||
function has been executed to have increrment since the last time this
|
||||
function executed. */
|
||||
if( uxCheckTaskHookCallCount <= uxLastHookCallCount )
|
||||
{
|
||||
vDisplayMessage( "Error in task hook call count!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
uxLastHookCallCount = uxCheckTaskHookCallCount;
|
||||
}
|
||||
|
||||
/* We would expect some queue sending to occur between calls of this
|
||||
function. */
|
||||
if( uxQueueSendPassedCount <= uxLastQueueSendCount )
|
||||
{
|
||||
vDisplayMessage( "Error in queue send hook call count!\r\n" );
|
||||
sErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
uxLastQueueSendCount = uxQueueSendPassedCount;
|
||||
}
|
||||
|
||||
if( sErrorHasOccurred == pdFALSE )
|
||||
{
|
||||
vDisplayMessage( "OK " );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvStartMathTasks( void )
|
||||
{
|
||||
#ifdef BCC_INDUSTRIAL_PC_PORT
|
||||
/* The Borland project does not yet support floating point. */
|
||||
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
||||
#else
|
||||
vStartMathTasks( tskIDLE_PRIORITY );
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvCheckMathTasksAreStillRunning( void )
|
||||
{
|
||||
#ifdef BCC_INDUSTRIAL_PC_PORT
|
||||
/* The Borland project does not yet support floating point. */
|
||||
return xAreIntegerMathsTaskStillRunning();
|
||||
#else
|
||||
return xAreMathsTaskStillRunning();
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
/* The co-routines are executed in the idle task using the idle task
|
||||
hook. */
|
||||
vCoRoutineSchedule();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -1,43 +0,0 @@
|
|||
40
|
||||
projectIdent
|
||||
0
|
||||
VpeMain
|
||||
1
|
||||
WRect
|
||||
0
|
||||
0
|
||||
6195
|
||||
7168
|
||||
2
|
||||
MProject
|
||||
3
|
||||
MCommand
|
||||
0
|
||||
4
|
||||
MCommand
|
||||
0
|
||||
1
|
||||
5
|
||||
WFileName
|
||||
12
|
||||
rtosdemo.tgt
|
||||
6
|
||||
WVList
|
||||
1
|
||||
7
|
||||
VComponent
|
||||
8
|
||||
WRect
|
||||
0
|
||||
0
|
||||
7168
|
||||
8192
|
||||
0
|
||||
0
|
||||
9
|
||||
WFileName
|
||||
12
|
||||
rtosdemo.tgt
|
||||
0
|
||||
7
|
||||
7
|
|
@ -1,691 +0,0 @@
|
|||
/*
|
||||
This serial port driver is borrowed heavily from DZComm. I have
|
||||
simplified it by removing a lot of the functionality (hardware
|
||||
flow control, etc.). For more details and the full version see
|
||||
http://dzcomm.sourceforge.net
|
||||
*/
|
||||
|
||||
/*
|
||||
FreeRTOS V8.2.3 - 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 <stdlib.h>
|
||||
#include <dos.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "portasm.h"
|
||||
|
||||
#define serMAX_IRQs ( 16 )
|
||||
#define serTRANSMIT_HOLD_EMPTY_INT ( 0x02 )
|
||||
#define serCOM1_STANDARD_IRQ ( ( unsigned char ) 4 )
|
||||
#define serCOM2_STANDARD_IRQ ( ( unsigned char ) 3 )
|
||||
|
||||
|
||||
#define serIMR_8259_0 ( ( unsigned char ) 0x21 )
|
||||
#define serIMR_8259_1 ( ( unsigned char ) 0xa1 )
|
||||
#define serISR_8259_0 ( ( unsigned char ) 0x20 )
|
||||
#define serISR_8259_1 ( ( unsigned char ) 0xa0 )
|
||||
#define serALL_COMS_INTERRUPTS ( ( unsigned char ) 0x0f )
|
||||
#define serALL_MODEM_CTRL_INTERRUPTS ( ( unsigned char ) 0x0f )
|
||||
|
||||
#define serTRANSMIT_HOLD_OFFSET ( 0 )
|
||||
#define serRECEIVE_DATA_OFFSET ( 0 )
|
||||
#define serBAUD_RATE_DIVISOR_LOW_OFFSET ( 0 )
|
||||
#define serBAUD_RATE_DIVISOR_HIGH_OFFSET ( 1 )
|
||||
#define serINTERRUPT_ENABLE_OFFSET ( 1 )
|
||||
#define serINTERRUPT_ID_OFFSET ( 2 )
|
||||
#define serFIFO_CTRL_OFFSET ( 2 )
|
||||
#define serLINE_CTRL_OFFSET ( 3 )
|
||||
#define serMODEM_CTRL_OFFSET ( 4 )
|
||||
#define serLINE_STATUS_OFFSET ( 5 )
|
||||
#define serMODEM_STATUS_OFFSET ( 6 )
|
||||
#define serSCR_OFFSET ( 7 )
|
||||
|
||||
#define serMAX_BAUD ( ( unsigned long ) 115200UL )
|
||||
|
||||
#define serNO_INTERRUPTS ( 0x00 )
|
||||
|
||||
#define vInterruptOn( pxPort, ucInterrupt ) \
|
||||
{ \
|
||||
unsigned char ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \
|
||||
if( !( ucIn & ucInterrupt ) ) \
|
||||
{ \
|
||||
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, ucIn | ucInterrupt ); \
|
||||
} \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define vInterruptOff( pxPort, ucInterrupt ) \
|
||||
{ \
|
||||
unsigned char ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \
|
||||
if( ucIn & ucInterrupt ) \
|
||||
{ \
|
||||
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, ucIn & ~ucInterrupt); \
|
||||
} \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
serCOM1,
|
||||
serCOM2,
|
||||
serCOM3,
|
||||
serCOM4,
|
||||
serCOM5,
|
||||
serCOM6,
|
||||
serCOM7,
|
||||
serCOM8
|
||||
} eCOMPort;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
serNO_PARITY,
|
||||
serODD_PARITY,
|
||||
serEVEN_PARITY,
|
||||
serMARK_PARITY,
|
||||
serSPACE_PARITY
|
||||
} eParity;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
serSTOP_1,
|
||||
serSTOP_2
|
||||
} eStopBits;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
serBITS_5,
|
||||
serBITS_6,
|
||||
serBITS_7,
|
||||
serBITS_8
|
||||
} eDataBits;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ser50,
|
||||
ser75,
|
||||
ser110,
|
||||
ser134,
|
||||
ser150,
|
||||
ser200,
|
||||
ser300,
|
||||
ser600,
|
||||
ser1200,
|
||||
ser1800,
|
||||
ser2400,
|
||||
ser4800,
|
||||
ser9600,
|
||||
ser19200,
|
||||
ser38400,
|
||||
ser57600,
|
||||
ser115200
|
||||
} eBaud;
|
||||
|
||||
/* This *MUST* match the order in the eBaud definition. */
|
||||
unsigned long ulBaudFromEnum[] =
|
||||
{
|
||||
( unsigned long ) 50,
|
||||
( unsigned long ) 75,
|
||||
( unsigned long ) 110,
|
||||
( unsigned long ) 134,
|
||||
( unsigned long ) 150,
|
||||
( unsigned long ) 200,
|
||||
( unsigned long ) 300,
|
||||
( unsigned long ) 600,
|
||||
( unsigned long ) 1200,
|
||||
( unsigned long ) 1800,
|
||||
( unsigned long ) 2400,
|
||||
( unsigned long ) 4800,
|
||||
( unsigned long ) 9600,
|
||||
( unsigned long ) 19200,
|
||||
( unsigned long ) 38400UL,
|
||||
( unsigned long ) 57600UL,
|
||||
( unsigned long ) 115200UL
|
||||
};
|
||||
|
||||
typedef struct xCOM_PORT
|
||||
{
|
||||
unsigned short sPort; /* comm port address eg. 0x3f8 */
|
||||
unsigned char ucIRQ; /* comm IRQ eg. 3 */
|
||||
|
||||
/* Next two fields used for setting up the IRQ routine and
|
||||
* (un)masking the interrupt in certain circumstances.
|
||||
*/
|
||||
unsigned short usIRQVector;
|
||||
unsigned char ucInterruptEnableMast;
|
||||
|
||||
/* Read/Write buffers. */
|
||||
QueueHandle_t xRxedChars;
|
||||
QueueHandle_t xCharsForTx;
|
||||
|
||||
/* This lot are set up to minimise CPU time where accessing the comm
|
||||
* port's registers.
|
||||
*/
|
||||
unsigned short usTransmitHoldReg;
|
||||
unsigned short usReceiveDataRegister;
|
||||
unsigned short usBaudRateDivisorLow;
|
||||
unsigned short usBaudRateDivisorHigh;
|
||||
unsigned short usInterruptEnableReg;
|
||||
unsigned short usInterruptIDReg;
|
||||
unsigned short usFIFOCtrlReg;
|
||||
unsigned short usLineCtrlReg;
|
||||
unsigned short usModemCtrlReg;
|
||||
unsigned short usLineStatusReg;
|
||||
unsigned short usModemStatusReg;
|
||||
unsigned short usSCRReg;
|
||||
unsigned short us8259InterruptServiceReg;
|
||||
unsigned short us8259InterruptMaskReg;
|
||||
|
||||
/* This semaphore does nothing useful except test a feature of the
|
||||
scheduler. */
|
||||
SemaphoreHandle_t xTestSem;
|
||||
|
||||
} xComPort;
|
||||
|
||||
typedef xComPort *xComPortHandle;
|
||||
|
||||
/* A xComPort structure can be associated with each IRQ. Initially none
|
||||
are create/installed. */
|
||||
xComPort *xPortStatus[ serMAX_IRQs ] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* These prototypes are repeated here so we don't have to include the serial header. This allows
|
||||
the xComPortHandle structure details to be private to this file. */
|
||||
xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength );
|
||||
portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, char *pcRxedChar, TickType_t xBlockTime );
|
||||
portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, char cOutChar, TickType_t xBlockTime );
|
||||
portBASE_TYPE xSerialWaitForSemaphore( xComPortHandle xPort );
|
||||
|
||||
static void prvSetupPortHardware( xComPort *pxPort, eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits );
|
||||
static short sComPortISR( const xComPort * const pxPort );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Define an interrupt handler for each slot in the xPortStatus array. */
|
||||
|
||||
#define COM_IRQ_WRAPPER(N) \
|
||||
static void __interrupt COM_IRQ##N##_WRAPPER( void ) \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
if( sComPortISR( xPortStatus[##N##] ) ) \
|
||||
{ \
|
||||
portSWITCH_CONTEXT(); \
|
||||
} \
|
||||
}
|
||||
|
||||
COM_IRQ_WRAPPER( 0 )
|
||||
COM_IRQ_WRAPPER( 1 )
|
||||
COM_IRQ_WRAPPER( 2 )
|
||||
COM_IRQ_WRAPPER( 3 )
|
||||
COM_IRQ_WRAPPER( 4 )
|
||||
COM_IRQ_WRAPPER( 5 )
|
||||
COM_IRQ_WRAPPER( 6 )
|
||||
COM_IRQ_WRAPPER( 7 )
|
||||
COM_IRQ_WRAPPER( 8 )
|
||||
COM_IRQ_WRAPPER( 9 )
|
||||
COM_IRQ_WRAPPER( 10 )
|
||||
COM_IRQ_WRAPPER( 11 )
|
||||
COM_IRQ_WRAPPER( 12 )
|
||||
COM_IRQ_WRAPPER( 13 )
|
||||
COM_IRQ_WRAPPER( 14 )
|
||||
COM_IRQ_WRAPPER( 15 )
|
||||
|
||||
static pxISR xISRs[ serMAX_IRQs ] =
|
||||
{
|
||||
COM_IRQ0_WRAPPER,
|
||||
COM_IRQ1_WRAPPER,
|
||||
COM_IRQ2_WRAPPER,
|
||||
COM_IRQ3_WRAPPER,
|
||||
COM_IRQ4_WRAPPER,
|
||||
COM_IRQ5_WRAPPER,
|
||||
COM_IRQ6_WRAPPER,
|
||||
COM_IRQ7_WRAPPER,
|
||||
COM_IRQ8_WRAPPER,
|
||||
COM_IRQ9_WRAPPER,
|
||||
COM_IRQ10_WRAPPER,
|
||||
COM_IRQ11_WRAPPER,
|
||||
COM_IRQ12_WRAPPER,
|
||||
COM_IRQ13_WRAPPER,
|
||||
COM_IRQ14_WRAPPER,
|
||||
COM_IRQ15_WRAPPER
|
||||
};
|
||||
|
||||
static pxISR xOldISRs[ serMAX_IRQs ] = { NULL };
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength )
|
||||
{
|
||||
xComPort *pxPort;
|
||||
|
||||
/* Create a structure to handle this port. */
|
||||
pxPort = ( xComPort * ) pvPortMalloc( sizeof( xComPort ) );
|
||||
|
||||
if( pxPort != NULL )
|
||||
{
|
||||
/* Create the queues used by the comtest task. */
|
||||
pxPort->xRxedChars = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( char ) );
|
||||
pxPort->xCharsForTx = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( char ) );
|
||||
|
||||
/* Create the test semaphore. This does nothing useful except test a feature of the scheduler. */
|
||||
vSemaphoreCreateBinary( pxPort->xTestSem );
|
||||
|
||||
prvSetupPortHardware( pxPort, ePort, eWantedBaud, eWantedParity, eWantedDataBits, eWantedStopBits );
|
||||
|
||||
return pxPort;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupPortHardware( xComPort *pxPort, eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits )
|
||||
{
|
||||
short sIn;
|
||||
unsigned long ulDivisor;
|
||||
unsigned char ucDivisorLow;
|
||||
unsigned char ucDivisorHigh;
|
||||
unsigned char ucCommParam;
|
||||
|
||||
/* IRQ numbers - standard */
|
||||
if( ( ePort == serCOM1 ) || ( ePort == serCOM3 ) || ( ePort == serCOM5 ) || ( ePort == serCOM7 ) )
|
||||
{
|
||||
pxPort->ucIRQ = serCOM1_STANDARD_IRQ;
|
||||
pxPort->sPort = 0x3f8;
|
||||
}
|
||||
else
|
||||
{
|
||||
pxPort->ucIRQ = serCOM2_STANDARD_IRQ;
|
||||
pxPort->sPort = 0x2f8;
|
||||
}
|
||||
|
||||
/* Set up variables in port making it easy to see which sIn/o address is which */
|
||||
pxPort->usTransmitHoldReg = pxPort->sPort + serTRANSMIT_HOLD_OFFSET;
|
||||
pxPort->usReceiveDataRegister = pxPort->sPort + serRECEIVE_DATA_OFFSET;
|
||||
pxPort->usBaudRateDivisorLow = pxPort->sPort + serBAUD_RATE_DIVISOR_LOW_OFFSET;
|
||||
pxPort->usBaudRateDivisorHigh = pxPort->sPort + serBAUD_RATE_DIVISOR_HIGH_OFFSET;
|
||||
pxPort->usInterruptEnableReg = pxPort->sPort + serINTERRUPT_ENABLE_OFFSET;
|
||||
pxPort->usInterruptIDReg = pxPort->sPort + serINTERRUPT_ID_OFFSET;
|
||||
pxPort->usFIFOCtrlReg = pxPort->sPort + serFIFO_CTRL_OFFSET;
|
||||
pxPort->usLineCtrlReg = pxPort->sPort + serLINE_CTRL_OFFSET;
|
||||
pxPort->usModemCtrlReg = pxPort->sPort + serMODEM_CTRL_OFFSET;
|
||||
pxPort->usLineStatusReg = pxPort->sPort + serLINE_STATUS_OFFSET;
|
||||
pxPort->usModemStatusReg = pxPort->sPort + serMODEM_STATUS_OFFSET;
|
||||
pxPort->usSCRReg = pxPort->sPort + serSCR_OFFSET;
|
||||
|
||||
/* Set communication parameters. */
|
||||
ulDivisor = serMAX_BAUD / ulBaudFromEnum[ eWantedBaud ];
|
||||
ucDivisorLow = ( unsigned char ) ulDivisor & ( unsigned char ) 0xff;
|
||||
ucDivisorHigh = ( unsigned char ) ( ( ( unsigned short ) ulDivisor >> 8 ) & 0xff );
|
||||
|
||||
switch( eWantedParity )
|
||||
{
|
||||
case serNO_PARITY: ucCommParam = 0x00;
|
||||
break;
|
||||
case serODD_PARITY: ucCommParam = 0x08;
|
||||
break;
|
||||
case serEVEN_PARITY: ucCommParam = 0x18;
|
||||
break;
|
||||
case serMARK_PARITY: ucCommParam = 0x28;
|
||||
break;
|
||||
case serSPACE_PARITY: ucCommParam = 0x38;
|
||||
break;
|
||||
default: ucCommParam = 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( eWantedDataBits )
|
||||
{
|
||||
case serBITS_5: ucCommParam |= 0x00;
|
||||
break;
|
||||
case serBITS_6: ucCommParam |= 0x01;
|
||||
break;
|
||||
case serBITS_7: ucCommParam |= 0x02;
|
||||
break;
|
||||
case serBITS_8: ucCommParam |= 0x03;
|
||||
break;
|
||||
default: ucCommParam |= 0x03;
|
||||
break;
|
||||
}
|
||||
|
||||
if( eWantedStopBits == serSTOP_2 )
|
||||
{
|
||||
ucCommParam |= 0x04;
|
||||
}
|
||||
|
||||
/* Reset UART into known state - Thanks to Bradley Town */
|
||||
portOUTPUT_BYTE( pxPort->usLineCtrlReg, 0x00 ); /* Access usTransmitHoldReg/RBR/usInterruptEnableReg */
|
||||
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, 0x00 ); /* Disable interrupts from UART */
|
||||
portOUTPUT_BYTE( pxPort->usModemCtrlReg, 0x04 ); /* Enable some multi-port cards */
|
||||
|
||||
/* Code based on stuff from SVAsync lib. Clear UART Status and data registers
|
||||
setting up FIFO if possible */
|
||||
sIn = portINPUT_BYTE( pxPort->usSCRReg );
|
||||
portOUTPUT_BYTE( pxPort->usSCRReg, 0x55 );
|
||||
|
||||
if( portINPUT_BYTE( pxPort->usSCRReg ) == 0x55 )
|
||||
{
|
||||
/* The chip is better than an 8250 */
|
||||
portOUTPUT_BYTE( pxPort->usSCRReg, sIn ); /* Set usSCRReg back to what it was before */
|
||||
portINPUT_BYTE( pxPort->usSCRReg); /* Give slow motherboards a chance */
|
||||
|
||||
/* Try and start the FIFO. It appears that some chips need a two call
|
||||
protocol, but those that don't seem to work even if you do start it twice.
|
||||
The first call is simply to start it, the second starts it and sets an 8
|
||||
byte FIFO trigger level. */
|
||||
portOUTPUT_BYTE( pxPort->usFIFOCtrlReg, 0x01 );
|
||||
portINPUT_BYTE( pxPort->usFIFOCtrlReg ); /* Give slow motherboards a chance to catch up */
|
||||
portOUTPUT_BYTE( pxPort->usFIFOCtrlReg, 0x87 );
|
||||
|
||||
/* Check that the FIFO initialised */
|
||||
if( ( portINPUT_BYTE( pxPort->usInterruptIDReg ) & 0xc0 ) != 0xc0 )
|
||||
{
|
||||
/* It didn't so we assume it isn't there but disable it to be on the
|
||||
safe side. */
|
||||
portOUTPUT_BYTE( pxPort->usInterruptIDReg, 0xfe );
|
||||
}
|
||||
}
|
||||
|
||||
/* End of (modified) SVAsync code.
|
||||
Set interrupt parameters calculating mask for 8259 controller's
|
||||
IMR and number of interrupt handler for given irq level */
|
||||
if (pxPort->ucIRQ <= 7)
|
||||
{
|
||||
/* if 0<=irq<=7 first IMR address used */
|
||||
pxPort->ucInterruptEnableMast = ~(0x01 << pxPort->ucIRQ);
|
||||
pxPort->usIRQVector = pxPort->ucIRQ + 8;
|
||||
pxPort->us8259InterruptMaskReg = serIMR_8259_0;
|
||||
pxPort->us8259InterruptServiceReg = serISR_8259_0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pxPort->ucInterruptEnableMast = ~( 0x01 << ( pxPort->ucIRQ % 8 ) );
|
||||
pxPort->usIRQVector = 0x70 + ( pxPort->ucIRQ - 8) ;
|
||||
pxPort->us8259InterruptMaskReg = serIMR_8259_1;
|
||||
pxPort->us8259InterruptServiceReg = serISR_8259_1;
|
||||
}
|
||||
|
||||
/* Set Port Toggle to usBaudRateDivisorLow/usBaudRateDivisorHigh registers
|
||||
to set baud rate */
|
||||
portOUTPUT_BYTE( pxPort->usLineCtrlReg, ucCommParam | 0x80 );
|
||||
portOUTPUT_BYTE( pxPort->usBaudRateDivisorLow, ucDivisorLow );
|
||||
portOUTPUT_BYTE( pxPort->usBaudRateDivisorHigh, ucDivisorHigh );
|
||||
|
||||
/* reset usLineCtrlReg and Port Toggleout */
|
||||
portOUTPUT_BYTE( pxPort->usLineCtrlReg, ucCommParam & 0x7F );
|
||||
|
||||
portENTER_CRITICAL();
|
||||
|
||||
if( xPortStatus[ pxPort->ucIRQ ] == NULL )
|
||||
{
|
||||
xPortStatus[ pxPort->ucIRQ ] = pxPort;
|
||||
}
|
||||
|
||||
xOldISRs[ pxPort->ucIRQ ] = _dos_getvect( pxPort->usIRQVector );
|
||||
_dos_setvect( pxPort->usIRQVector, xISRs[ pxPort->ucIRQ ] );
|
||||
|
||||
/* enable interrupt pxPort->ucIRQ level */
|
||||
portOUTPUT_BYTE( pxPort->us8259InterruptMaskReg, portINPUT_BYTE( pxPort->us8259InterruptMaskReg ) & pxPort->ucInterruptEnableMast );
|
||||
|
||||
/* And allow interrupts again now the hairy bit's done */
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* This version does not allow flow control. */
|
||||
portOUTPUT_BYTE( pxPort->usModemCtrlReg, serALL_MODEM_CTRL_INTERRUPTS );
|
||||
|
||||
/* enable all communication's interrupts */
|
||||
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, serALL_COMS_INTERRUPTS );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static short sComPortISR( const xComPort * const pxPort )
|
||||
{
|
||||
short sInterruptID;
|
||||
char cIn, cOut;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
extern void vComTestUnsuspendTask( void );
|
||||
|
||||
portOUTPUT_BYTE( pxPort->us8259InterruptMaskReg, ( portINPUT_BYTE( pxPort->us8259InterruptMaskReg) | ~pxPort->ucInterruptEnableMast ) );
|
||||
|
||||
/* Decide which UART has issued the interrupt */
|
||||
sInterruptID = portINPUT_BYTE( pxPort->usInterruptIDReg );
|
||||
|
||||
/* service whatever requests the calling UART may have. The top 4 bits are
|
||||
either unused or indicate the presence of a functioning FIFO, which we don't
|
||||
need to know. So trim them off to simplify the switch statement below. */
|
||||
sInterruptID &= 0x0f;
|
||||
do
|
||||
{
|
||||
switch( sInterruptID )
|
||||
{
|
||||
case 0x0c: /* Timeout
|
||||
Called when FIFO not up to trigger level but no activity for
|
||||
a while. Handled exactly as RDAINT, see below for
|
||||
description. */
|
||||
do
|
||||
{
|
||||
cIn = ( char ) portINPUT_BYTE( pxPort->usReceiveDataRegister );
|
||||
xQueueSendFromISR( pxPort->xRxedChars, &cIn, &xHigherPriorityTaskWoken );
|
||||
|
||||
/* Also release the semaphore - this does nothing interesting and is just a test.
|
||||
We first attempt to unsuspend the task to check the scheduler correctely detects
|
||||
this as an invalid call, then give the semaphore for real. */
|
||||
vComTestUnsuspendTask();
|
||||
xSemaphoreGiveFromISR( pxPort->xTestSem, &xHigherPriorityTaskWoken );
|
||||
|
||||
} while( portINPUT_BYTE( pxPort->usLineStatusReg ) & 0x01 );
|
||||
break;
|
||||
|
||||
case 0x06: /* LSINT */
|
||||
portINPUT_BYTE( pxPort->usLineStatusReg );
|
||||
break;
|
||||
|
||||
case 0x04: /* RDAINT */
|
||||
/* The usInterruptIDReg flag tested above stops when the
|
||||
FIFO is below the trigger level rather than empty, whereas
|
||||
this flag allows one to empty it: (do loop because there
|
||||
must be at least one to read by virtue of having got here.) */
|
||||
do
|
||||
{
|
||||
cIn = ( char ) portINPUT_BYTE( pxPort->usReceiveDataRegister );
|
||||
xQueueSendFromISR( pxPort->xRxedChars, &cIn, &xHigherPriorityTaskWoken );
|
||||
|
||||
/* Also release the semaphore - this does nothing interesting and is just a test.
|
||||
We first attempt to unsuspend the task to check the scheduler correctely detects
|
||||
this as an invalid call, then give the semaphore for real. */
|
||||
vComTestUnsuspendTask();
|
||||
xSemaphoreGiveFromISR( pxPort->xTestSem, &xHigherPriorityTaskWoken );
|
||||
|
||||
} while( portINPUT_BYTE( pxPort->usLineStatusReg ) & 0x01 );
|
||||
break;
|
||||
|
||||
case 0x02: /* serTRANSMIT_HOLD_EMPTY_INT */
|
||||
if( xQueueReceiveFromISR( pxPort->xCharsForTx, &cOut, &xHigherPriorityTaskWoken ) != pdTRUE )
|
||||
{
|
||||
/* Queue empty, nothing to send */
|
||||
vInterruptOff( pxPort, serTRANSMIT_HOLD_EMPTY_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
portOUTPUT_BYTE( pxPort->usTransmitHoldReg, ( short ) cOut );
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x00: /* MSINT */
|
||||
portINPUT_BYTE( pxPort->usModemStatusReg );
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the next instruction, trimming as above */
|
||||
sInterruptID = portINPUT_BYTE( pxPort->usInterruptIDReg ) & 0x0f;
|
||||
|
||||
} while( !( sInterruptID & 0x01 ) );
|
||||
|
||||
if( pxPort->ucIRQ > 7 )
|
||||
{
|
||||
portOUTPUT_BYTE( 0xA0, 0x60 + ( pxPort->ucIRQ & 0x07 ) );
|
||||
portOUTPUT_BYTE( 0x20, 0x62);
|
||||
}
|
||||
else
|
||||
{
|
||||
portOUTPUT_BYTE( 0x20, 0x60 + pxPort->ucIRQ );
|
||||
}
|
||||
|
||||
portOUTPUT_BYTE( pxPort->us8259InterruptMaskReg, portINPUT_BYTE( pxPort->us8259InterruptMaskReg ) & pxPort->ucInterruptEnableMast );
|
||||
|
||||
/* If posting any of the characters to a queue woke a task that was blocked on
|
||||
the queue we may want to return to the task just woken (depending on its
|
||||
priority relative to the task this ISR interrupted. */
|
||||
return xHigherPriorityTaskWoken;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, char *pcRxedChar, TickType_t xBlockTime )
|
||||
{
|
||||
/* Get the next character from the buffer, note that this routine is only
|
||||
called having checked that the is (at least) one to get */
|
||||
if( xQueueReceive( pxPort->xRxedChars, pcRxedChar, xBlockTime ) )
|
||||
{
|
||||
return pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, char cOutChar, TickType_t xBlockTime )
|
||||
{
|
||||
if( xQueueSend( pxPort->xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
vInterruptOn( pxPort, serTRANSMIT_HOLD_EMPTY_INT );
|
||||
|
||||
return pdPASS;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialPutString( xComPortHandle pxPort, const char * const pcString, unsigned short usStringLength )
|
||||
{
|
||||
char * pcNextChar;
|
||||
const TickType_t xNoBlock = ( TickType_t ) 0;
|
||||
|
||||
/* Stop warnings. */
|
||||
( void ) usStringLength;
|
||||
|
||||
pcNextChar = ( char * ) pcString;
|
||||
while( *pcNextChar )
|
||||
{
|
||||
xSerialPutChar( pxPort, *pcNextChar, xNoBlock );
|
||||
pcNextChar++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xSerialWaitForSemaphore( xComPortHandle xPort )
|
||||
{
|
||||
const TickType_t xBlockTime = ( TickType_t ) 0xffff;
|
||||
|
||||
/* This function does nothing interesting, but test the
|
||||
semaphore from ISR mechanism. */
|
||||
return xSemaphoreTake( xPort->xTestSem, xBlockTime );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialClose( xComPortHandle xPort )
|
||||
{
|
||||
portENTER_CRITICAL();
|
||||
|
||||
/* Turn off the interrupts. */
|
||||
portOUTPUT_BYTE( xPort->usModemCtrlReg, serNO_INTERRUPTS );
|
||||
portOUTPUT_BYTE( xPort->usInterruptEnableReg, serNO_INTERRUPTS );
|
||||
|
||||
/* Put back the original ISR. */
|
||||
_dos_setvect( xPort->usIRQVector, xOldISRs[ xPort->ucIRQ ] );
|
||||
|
||||
/* Remove the reference in the array of xComPort structures. */
|
||||
xPortStatus[ xPort->ucIRQ ] = NULL;
|
||||
|
||||
/* Delete the queues. */
|
||||
vQueueDelete( xPort->xRxedChars );
|
||||
vQueueDelete( xPort->xCharsForTx );
|
||||
|
||||
vPortFree( ( void * ) xPort );
|
||||
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue