mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add serial test code (not yet complete).
This commit is contained in:
parent
3ea597543a
commit
3a8161372d
|
@ -65,7 +65,7 @@
|
|||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 25000000 )
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 64000000 )
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 90 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 24000 ) )
|
||||
|
|
|
@ -2,17 +2,19 @@ RM := rm -rf
|
|||
|
||||
FREERTOS_SOURCE_DIR=./../../../Source
|
||||
PORT_SOURCE_DIR=./../../../Source/portable/GCC/ColdFire_V2
|
||||
COMMON_DEMO_CODE_DIR=./../../Common/Minimal
|
||||
COMMON_DEMO_SOURCE_DIR=./../../Common/Minimal
|
||||
OUTPUT_DIR=./bin
|
||||
CPU=528x
|
||||
LINKER_SCRIPT=m5282evb-ram-hosted.ld
|
||||
OUTPUT_FILENAME=RTOSDemo.elf
|
||||
CC=m68k-elf-gcc
|
||||
AS=m68K-elf-as
|
||||
VPATH=$(FREERTOS_SOURCE_DIR) : $(PORT_SOURCE_DIR) : $(COMMON_DEMO_CODE_DIR) : $(FREERTOS_SOURCE_DIR)/portable/MemMang : . : ./ParTest
|
||||
VPATH=$(FREERTOS_SOURCE_DIR) : $(PORT_SOURCE_DIR) : $(COMMON_DEMO_SOURCE_DIR) : $(FREERTOS_SOURCE_DIR)/portable/MemMang : . : ./ParTest : ./serial
|
||||
|
||||
OBJS = $(OUTPUT_DIR)/portasm.o \
|
||||
$(OUTPUT_DIR)/main.o \
|
||||
$(OUTPUT_DIR)/serial.o \
|
||||
$(OUTPUT_DIR)/comtest.o \
|
||||
$(OUTPUT_DIR)/flash.o \
|
||||
$(OUTPUT_DIR)/ParTest.o \
|
||||
$(OUTPUT_DIR)/BlockQ.o \
|
||||
|
@ -36,7 +38,7 @@ C_DEPS = $(OBJS:.o=.d)
|
|||
|
||||
CFLAGS= -I"$(FREERTOS_SOURCE_DIR)/include" \
|
||||
-I"include" \
|
||||
-I"$(COMMON_DEMO_CODE_DIR)/../include" \
|
||||
-I"$(COMMON_DEMO_SOURCE_DIR)/../include" \
|
||||
-I"$(PORT_SOURCE_DIR)" \
|
||||
-I./MCF5282 \
|
||||
-I. \
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "QPeek.h"
|
||||
#include "recmutex.h"
|
||||
#include "IntQueue.h"
|
||||
#include "comtest2.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -99,7 +100,12 @@ error has been detected. */
|
|||
/* The LED controlled by the 'check' task. */
|
||||
#define mainCHECK_LED ( 3 )
|
||||
|
||||
/* Contest constants - there is no free LED for the comtest. */
|
||||
#define mainCOM_TEST_BAUD_RATE ( ( unsigned portLONG ) 115200 )
|
||||
#define mainCOM_TEST_LED ( 5 )
|
||||
|
||||
/* Task priorities. */
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
|
@ -108,7 +114,6 @@ error has been detected. */
|
|||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
|
||||
/*
|
||||
* Configure the hardware for the demo.
|
||||
*/
|
||||
|
@ -137,6 +142,7 @@ int main( void )
|
|||
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
|
||||
vStartQueuePeekTasks();
|
||||
vStartRecursiveMutexTasks();
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
|
||||
|
||||
/* Create the check task. */
|
||||
xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
@ -157,7 +163,7 @@ int main( void )
|
|||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
unsigned ulTicksToWait = mainNO_ERROR_PERIOD;
|
||||
unsigned ulTicksToWait = mainNO_ERROR_PERIOD, ulError = 0;
|
||||
portTickType xLastExecutionTime;
|
||||
|
||||
( void ) pvParameters;
|
||||
|
@ -174,37 +180,46 @@ portTickType xLastExecutionTime;
|
|||
/* Has an error been found in any task? */
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x01UL;
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x02UL;
|
||||
}
|
||||
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x04UL;
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x10UL;
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x20UL;
|
||||
}
|
||||
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x40UL;
|
||||
}
|
||||
else if( xIsCreateTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x80UL;
|
||||
}
|
||||
else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
ulError |= 0x100UL;
|
||||
}
|
||||
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulError |= 0x200UL;
|
||||
}
|
||||
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulError |= 0x400UL;
|
||||
}
|
||||
|
||||
if( ulError != 0 )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
}
|
||||
|
@ -216,6 +231,15 @@ portTickType xLastExecutionTime;
|
|||
|
||||
void prvSetupHardware( void )
|
||||
{
|
||||
/* Multiply 8Mhz reference crystal by 8 to achieve system clock of 64Mhz. */
|
||||
MCF_CLOCK_SYNCR = MCF_CLOCK_SYNCR_MFD( 2 );
|
||||
|
||||
/* Wait for PLL to lock. */
|
||||
while( !( MCF_CLOCK_SYNSR & MCF_CLOCK_SYNSR_LOCK ) )
|
||||
{
|
||||
__asm__ volatile ( "NOP" );
|
||||
}
|
||||
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
224
Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/serial/serial.c
Normal file
224
Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/serial/serial.c
Normal file
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
FreeRTOS.org V5.0.3 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
* SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
|
||||
* and even write all or part of your application on your behalf. *
|
||||
* See http://www.OpenRTOS.com for details of the services we provide to *
|
||||
* expedite your project. *
|
||||
* *
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
|
||||
/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER.
|
||||
|
||||
NOTE: This driver is primarily to test the scheduler functionality. It does
|
||||
not effectively use the buffers or DMA and is therefore not intended to be
|
||||
an example of an efficient driver. */
|
||||
|
||||
/* Standard include file. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "serial.h"
|
||||
|
||||
/* Hardware definitions. */
|
||||
#define serNO_PARITY ( ( unsigned portCHAR ) 0x10 << 3 )
|
||||
#define ser8DATA_BITS ( ( unsigned portCHAR ) 0x11 )
|
||||
#define ser1STOP_BIT ( ( unsigned portCHAR ) 0x111 )
|
||||
#define serSYSTEM_CLOCK ( ( unsigned portCHAR ) 0xdd )
|
||||
#define serTX_OUTPUT ( ( unsigned portCHAR ) 0x04 )
|
||||
#define serRX_INPUT ( ( unsigned portCHAR ) 0x08 )
|
||||
#define serTX_ENABLE ( ( unsigned portCHAR ) 0x04 )
|
||||
#define serRX_ENABLE ( ( unsigned portCHAR ) 0x01 )
|
||||
#define serTX_INT ( ( unsigned portCHAR ) 0x01 )
|
||||
#define serRX_INT ( ( unsigned portCHAR ) 0x02 )
|
||||
|
||||
|
||||
/* The queues used to communicate between tasks and ISR's. */
|
||||
static xQueueHandle xRxedChars;
|
||||
static xQueueHandle xCharsForTx;
|
||||
|
||||
/* Flag used to indicate the tx status. */
|
||||
static portBASE_TYPE xTxHasEnded;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The UART interrupt handler. */
|
||||
void __attribute__( ( interrupt ) ) __cs3_isr_interrupt_78( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||
{
|
||||
const unsigned portLONG ulBaudRateDivisor = ( configCPU_CLOCK_HZ / ( 32 * ulWantedBaud ) );
|
||||
|
||||
/* Create the queues used by the com test task. */
|
||||
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
|
||||
/* Set the pins to UART mode. */
|
||||
MCF_PAD_PUAPAR |= ( serTX_OUTPUT | serRX_INPUT );
|
||||
|
||||
/* Configure the UART. */
|
||||
MCF_UART1_UMR1 = serNO_PARITY | ser8DATA_BITS;
|
||||
MCF_UART1_UMR2 = ser1STOP_BIT;
|
||||
MCF_UART1_UCSR = serSYSTEM_CLOCK;
|
||||
|
||||
MCF_UART1_UBG1 = ( unsigned portCHAR ) ( ( ulBaudRateDivisor >> 8UL ) & 0xffUL );
|
||||
MCF_UART1_UBG2 = ( unsigned portCHAR ) ( ulBaudRateDivisor & 0xffUL );
|
||||
|
||||
/* Reset the peripheral before turning it on. */
|
||||
MCF_UART1_UCR = MCF_UART_UCR_RESET_MR;
|
||||
MCF_UART1_UCR = MCF_UART_UCR_RESET_RX;
|
||||
MCF_UART1_UCR = MCF_UART_UCR_RESET_TX;
|
||||
MCF_UART1_UCR = MCF_UART_UCR_RESET_ERROR;
|
||||
MCF_UART1_UCR = serTX_ENABLE | serRX_ENABLE;
|
||||
|
||||
/* Configure the interrupt controller. Run the UARTs above the kernel
|
||||
interrupt priority for demo purposes. */
|
||||
MCF_INTC0_ICR14 = ( ( configKERNEL_INTERRUPT_PRIORITY + 1 ) | ( 1 << 3 ) );
|
||||
MCF_INTC0_IMRL &= ~MCF_INTC_IMRL_INT_MASK14;
|
||||
|
||||
/* The Tx interrupt is not enabled until there is data to send. */
|
||||
MCF_UART0_UIMR = serRX_INT;
|
||||
|
||||
/* Only a single port is implemented so we don't need to return anything. */
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
|
||||
{
|
||||
/* Only one port is supported. */
|
||||
( void ) pxPort;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
|
||||
{
|
||||
/* Only one port is supported. */
|
||||
( void ) pxPort;
|
||||
|
||||
/* Return false if after the block time there is no room on the Tx queue. */
|
||||
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* A critical section should not be required as xTxHasEnded will not be
|
||||
written to by the ISR if it is already 0 (is this correct?). */
|
||||
if( xTxHasEnded )
|
||||
{
|
||||
xTxHasEnded = pdFALSE;
|
||||
MCF_UART0_UIMR = serRX_INT | serTX_INT;
|
||||
}
|
||||
|
||||
return pdPASS;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialClose( xComPortHandle xPort )
|
||||
{
|
||||
( void ) xPort;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void __cs3_isr_interrupt_78( void )
|
||||
{
|
||||
unsigned portCHAR ucChar;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE, xDoneSomething = pdTRUE;
|
||||
|
||||
while( xDoneSomething != pdFALSE )
|
||||
{
|
||||
xDoneSomething = pdFALSE;
|
||||
|
||||
/* Does the tx buffer contain space? */
|
||||
if( ( MCF_UART0_USR & MCF_UART_USR_TXRDY ) != 0x00 )
|
||||
{
|
||||
/* Are there any characters queued to be sent? */
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &ucChar, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||
{
|
||||
/* Send the next char. */
|
||||
MCF_UART0_UTB = ucChar;
|
||||
xDoneSomething = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn off the Tx interrupt until such time as another character
|
||||
is being transmitted. */
|
||||
MCF_UART0_UIMR = serRX_INT;
|
||||
}
|
||||
}
|
||||
|
||||
if( MCF_UART0_USR & MCF_UART_USR_RXRDY )
|
||||
{
|
||||
ucChar = MCF_UART0_URB;
|
||||
xQueueSendFromISR( xRxedChars, &ucChar, &xHigherPriorityTaskWoken );
|
||||
xDoneSomething = pdTRUE;
|
||||
}
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue