simplified it by removing a lot of the functionality (hardware \r
flow control, etc.). For more details and the full version see\r
http://dzcomm.sourceforge.net\r
+*/\r
\r
+/*\r
+ FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\r
\r
- FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
-\r
- This file is part of the FreeRTOS distribution.\r
+ This file is part of the FreeRTOS distribution.\r
\r
- FreeRTOS is free software; you can redistribute it and/or modify it under \r
- the terms of the GNU General Public License (version 2) as published by the \r
- Free Software Foundation and modified by the FreeRTOS exception.\r
- **NOTE** The exception to the GPL is included to allow you to distribute a\r
- combined work that includes FreeRTOS without being obliged to provide the \r
- source code for proprietary components outside of the FreeRTOS kernel. \r
- Alternative commercial license and support terms are also available upon \r
- request. See the licensing section of http://www.FreeRTOS.org for full \r
- license details.\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation and modified by the FreeRTOS exception.\r
+ **NOTE** The exception to the GPL is included to allow you to distribute a\r
+ combined work that includes FreeRTOS without being obliged to provide the\r
+ source code for proprietary components outside of the FreeRTOS kernel.\r
+ Alternative commercial license and support terms are also available upon\r
+ request. See the licensing section of http://www.FreeRTOS.org for full\r
+ license details.\r
\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- more details.\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ more details.\r
\r
- You should have received a copy of the GNU General Public License along\r
- with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
- Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+ You should have received a copy of the GNU General Public License along\r
+ with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
\r
\r
- ***************************************************************************\r
- * *\r
- * Looking for a quick start? Then check out the FreeRTOS eBook! *\r
- * See http://www.FreeRTOS.org/Documentation for details *\r
- * *\r
- ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * The FreeRTOS eBook and reference manual are available to purchase for a *\r
+ * small fee. Help yourself get started quickly while also helping the *\r
+ * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *\r
+ * *\r
+ ***************************************************************************\r
\r
- 1 tab == 4 spaces!\r
+ 1 tab == 4 spaces!\r
\r
- Please ensure to read the configuration and relevant port sections of the\r
- online documentation.\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and\r
- contact details.\r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
+ contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety\r
- critical systems.\r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
+ critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting,\r
- licensing and training services.\r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
+ licensing and training services.\r
*/\r
\r
-/*\r
-Changes from V1.00:\r
- \r
- + Call to the more efficient portSWITCH_CONTEXT() replaces the call to \r
- taskYIELD() in the ISR.\r
-\r
-Changes from V1.2.0:\r
-\r
- + Added vSerialPutString().\r
-\r
-Changes from V1.2.3\r
-\r
- + The function xPortInitMinimal() has been renamed to \r
- xSerialPortInitMinimal() and the function xPortInit() has been renamed\r
- to xSerialPortInit().\r
-\r
-Changes From V2.0.0\r
-\r
- + Use portTickType in place of unsigned pdLONG for delay periods.\r
- + cQueueReieveFromISR() used in place of xQueueReceive() in ISR.\r
-*/\r
\r
\r
#include <stdlib.h>\r
\r
#define serMAX_IRQs ( 16 )\r
#define serTRANSMIT_HOLD_EMPTY_INT ( 0x02 )\r
-#define serCOM1_STANDARD_IRQ ( ( unsigned portCHAR ) 4 )\r
-#define serCOM2_STANDARD_IRQ ( ( unsigned portCHAR ) 3 )\r
+#define serCOM1_STANDARD_IRQ ( ( unsigned char ) 4 )\r
+#define serCOM2_STANDARD_IRQ ( ( unsigned char ) 3 )\r
\r
\r
-#define serIMR_8259_0 ( ( unsigned portCHAR ) 0x21 )\r
-#define serIMR_8259_1 ( ( unsigned portCHAR ) 0xa1 )\r
-#define serISR_8259_0 ( ( unsigned portCHAR ) 0x20 )\r
-#define serISR_8259_1 ( ( unsigned portCHAR ) 0xa0 )\r
-#define serALL_COMS_INTERRUPTS ( ( unsigned portCHAR ) 0x0f )\r
-#define serALL_MODEM_CTRL_INTERRUPTS ( ( unsigned portCHAR ) 0x0f )\r
+#define serIMR_8259_0 ( ( unsigned char ) 0x21 )\r
+#define serIMR_8259_1 ( ( unsigned char ) 0xa1 )\r
+#define serISR_8259_0 ( ( unsigned char ) 0x20 )\r
+#define serISR_8259_1 ( ( unsigned char ) 0xa0 )\r
+#define serALL_COMS_INTERRUPTS ( ( unsigned char ) 0x0f )\r
+#define serALL_MODEM_CTRL_INTERRUPTS ( ( unsigned char ) 0x0f )\r
\r
#define serTRANSMIT_HOLD_OFFSET ( 0 )\r
#define serRECEIVE_DATA_OFFSET ( 0 )\r
#define serMODEM_STATUS_OFFSET ( 6 )\r
#define serSCR_OFFSET ( 7 )\r
\r
-#define serMAX_BAUD ( ( unsigned portLONG ) 115200UL )\r
+#define serMAX_BAUD ( ( unsigned long ) 115200UL )\r
\r
#define serNO_INTERRUPTS ( 0x00 )\r
\r
#define vInterruptOn( pxPort, ucInterrupt ) \\r
{ \\r
- unsigned portCHAR ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \\r
+ unsigned char ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \\r
if( !( ucIn & ucInterrupt ) ) \\r
{ \\r
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, ucIn | ucInterrupt ); \\r
\r
#define vInterruptOff( pxPort, ucInterrupt ) \\r
{ \\r
- unsigned portCHAR ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \\r
+ unsigned char ucIn = portINPUT_BYTE( pxPort->usInterruptEnableReg ); \\r
if( ucIn & ucInterrupt ) \\r
{ \\r
portOUTPUT_BYTE( pxPort->usInterruptEnableReg, ucIn & ~ucInterrupt); \\r
} eBaud;\r
\r
/* This *MUST* match the order in the eBaud definition. */\r
-unsigned portLONG ulBaudFromEnum[] = \r
+unsigned long ulBaudFromEnum[] = \r
{ \r
- ( unsigned portLONG ) 50, \r
- ( unsigned portLONG ) 75, \r
- ( unsigned portLONG ) 110, \r
- ( unsigned portLONG ) 134, \r
- ( unsigned portLONG ) 150, \r
- ( unsigned portLONG ) 200, \r
- ( unsigned portLONG ) 300, \r
- ( unsigned portLONG ) 600, \r
- ( unsigned portLONG ) 1200, \r
- ( unsigned portLONG ) 1800, \r
- ( unsigned portLONG ) 2400, \r
- ( unsigned portLONG ) 4800, \r
- ( unsigned portLONG ) 9600, \r
- ( unsigned portLONG ) 19200, \r
- ( unsigned portLONG ) 38400UL,\r
- ( unsigned portLONG ) 57600UL,\r
- ( unsigned portLONG ) 115200UL\r
+ ( unsigned long ) 50, \r
+ ( unsigned long ) 75, \r
+ ( unsigned long ) 110, \r
+ ( unsigned long ) 134, \r
+ ( unsigned long ) 150, \r
+ ( unsigned long ) 200, \r
+ ( unsigned long ) 300, \r
+ ( unsigned long ) 600, \r
+ ( unsigned long ) 1200, \r
+ ( unsigned long ) 1800, \r
+ ( unsigned long ) 2400, \r
+ ( unsigned long ) 4800, \r
+ ( unsigned long ) 9600, \r
+ ( unsigned long ) 19200, \r
+ ( unsigned long ) 38400UL,\r
+ ( unsigned long ) 57600UL,\r
+ ( unsigned long ) 115200UL\r
};\r
\r
typedef struct xCOM_PORT\r
{ \r
- unsigned portSHORT sPort; /* comm port address eg. 0x3f8 */\r
- unsigned portCHAR ucIRQ; /* comm IRQ eg. 3 */\r
+ unsigned short sPort; /* comm port address eg. 0x3f8 */\r
+ unsigned char ucIRQ; /* comm IRQ eg. 3 */\r
\r
/* Next two fields used for setting up the IRQ routine and\r
* (un)masking the interrupt in certain circumstances.\r
*/\r
- unsigned portSHORT usIRQVector;\r
- unsigned portCHAR ucInterruptEnableMast;\r
+ unsigned short usIRQVector;\r
+ unsigned char ucInterruptEnableMast;\r
\r
/* Read/Write buffers. */\r
xQueueHandle xRxedChars; \r
/* This lot are set up to minimise CPU time where accessing the comm\r
* port's registers.\r
*/\r
- unsigned portSHORT usTransmitHoldReg; \r
- unsigned portSHORT usReceiveDataRegister;\r
- unsigned portSHORT usBaudRateDivisorLow; \r
- unsigned portSHORT usBaudRateDivisorHigh;\r
- unsigned portSHORT usInterruptEnableReg;\r
- unsigned portSHORT usInterruptIDReg;\r
- unsigned portSHORT usFIFOCtrlReg;\r
- unsigned portSHORT usLineCtrlReg;\r
- unsigned portSHORT usModemCtrlReg;\r
- unsigned portSHORT usLineStatusReg;\r
- unsigned portSHORT usModemStatusReg;\r
- unsigned portSHORT usSCRReg;\r
- unsigned portSHORT us8259InterruptServiceReg;\r
- unsigned portSHORT us8259InterruptMaskReg;\r
+ unsigned short usTransmitHoldReg; \r
+ unsigned short usReceiveDataRegister;\r
+ unsigned short usBaudRateDivisorLow; \r
+ unsigned short usBaudRateDivisorHigh;\r
+ unsigned short usInterruptEnableReg;\r
+ unsigned short usInterruptIDReg;\r
+ unsigned short usFIFOCtrlReg;\r
+ unsigned short usLineCtrlReg;\r
+ unsigned short usModemCtrlReg;\r
+ unsigned short usLineStatusReg;\r
+ unsigned short usModemStatusReg;\r
+ unsigned short usSCRReg;\r
+ unsigned short us8259InterruptServiceReg;\r
+ unsigned short us8259InterruptMaskReg;\r
\r
/* This semaphore does nothing useful except test a feature of the\r
scheduler. */\r
/* These prototypes are repeated here so we don't have to include the serial header. This allows\r
the xComPortHandle structure details to be private to this file. */\r
xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength );\r
-portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, portCHAR *pcRxedChar, portTickType xBlockTime );\r
-portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, portCHAR cOutChar, portTickType xBlockTime );\r
+portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, char *pcRxedChar, portTickType xBlockTime );\r
+portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, char cOutChar, portTickType xBlockTime );\r
portBASE_TYPE xSerialWaitForSemaphore( xComPortHandle xPort );\r
\r
static void prvSetupPortHardware( xComPort *pxPort, eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits );\r
-static portSHORT sComPortISR( const xComPort * const pxPort );\r
+static short sComPortISR( const xComPort * const pxPort );\r
\r
/*-----------------------------------------------------------*/\r
\r
if( pxPort != NULL )\r
{\r
/* Create the queues used by the comtest task. */\r
- pxPort->xRxedChars = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );\r
- pxPort->xCharsForTx = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );\r
+ pxPort->xRxedChars = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( char ) );\r
+ pxPort->xCharsForTx = xQueueCreate( uxBufferLength, ( unsigned portBASE_TYPE ) sizeof( char ) );\r
\r
/* Create the test semaphore. This does nothing useful except test a feature of the scheduler. */\r
vSemaphoreCreateBinary( pxPort->xTestSem );\r
\r
static void prvSetupPortHardware( xComPort *pxPort, eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits )\r
{\r
-portSHORT sIn;\r
-unsigned portLONG ulDivisor;\r
-unsigned portCHAR ucDivisorLow;\r
-unsigned portCHAR ucDivisorHigh;\r
-unsigned portCHAR ucCommParam;\r
+short sIn;\r
+unsigned long ulDivisor;\r
+unsigned char ucDivisorLow;\r
+unsigned char ucDivisorHigh;\r
+unsigned char ucCommParam;\r
\r
/* IRQ numbers - standard */\r
if( ( ePort == serCOM1 ) || ( ePort == serCOM3 ) || ( ePort == serCOM5 ) || ( ePort == serCOM7 ) )\r
\r
/* Set communication parameters. */\r
ulDivisor = serMAX_BAUD / ulBaudFromEnum[ eWantedBaud ];\r
- ucDivisorLow = ( unsigned portCHAR ) ulDivisor & ( unsigned portCHAR ) 0xff;\r
- ucDivisorHigh = ( unsigned portCHAR ) ( ( ( unsigned portSHORT ) ulDivisor >> 8 ) & 0xff );\r
+ ucDivisorLow = ( unsigned char ) ulDivisor & ( unsigned char ) 0xff;\r
+ ucDivisorHigh = ( unsigned char ) ( ( ( unsigned short ) ulDivisor >> 8 ) & 0xff );\r
\r
switch( eWantedParity )\r
{ \r
}\r
/*-----------------------------------------------------------*/\r
\r
-static portSHORT sComPortISR( const xComPort * const pxPort )\r
+static short sComPortISR( const xComPort * const pxPort )\r
{\r
-portSHORT sInterruptID;\r
-portCHAR cIn, cOut;\r
+short sInterruptID;\r
+char cIn, cOut;\r
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
extern void vComTestUnsuspendTask( void );\r
\r
description. */\r
do\r
{\r
- cIn = ( portCHAR ) portINPUT_BYTE( pxPort->usReceiveDataRegister ); \r
+ cIn = ( char ) portINPUT_BYTE( pxPort->usReceiveDataRegister ); \r
xQueueSendFromISR( pxPort->xRxedChars, &cIn, &xHigherPriorityTaskWoken );\r
\r
/* Also release the semaphore - this does nothing interesting and is just a test.\r
must be at least one to read by virtue of having got here.) */\r
do\r
{\r
- cIn = ( portCHAR ) portINPUT_BYTE( pxPort->usReceiveDataRegister ); \r
+ cIn = ( char ) portINPUT_BYTE( pxPort->usReceiveDataRegister ); \r
xQueueSendFromISR( pxPort->xRxedChars, &cIn, &xHigherPriorityTaskWoken );\r
\r
/* Also release the semaphore - this does nothing interesting and is just a test.\r
} \r
else \r
{ \r
- portOUTPUT_BYTE( pxPort->usTransmitHoldReg, ( portSHORT ) cOut ); \r
+ portOUTPUT_BYTE( pxPort->usTransmitHoldReg, ( short ) cOut ); \r
}\r
break;\r
\r
}\r
/*-----------------------------------------------------------*/\r
\r
-portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, portCHAR *pcRxedChar, portTickType xBlockTime )\r
+portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, char *pcRxedChar, portTickType xBlockTime )\r
{\r
/* Get the next character from the buffer, note that this routine is only \r
called having checked that the is (at least) one to get */\r
}\r
/*-----------------------------------------------------------*/\r
\r
-portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, portCHAR cOutChar, portTickType xBlockTime )\r
+portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, char cOutChar, portTickType xBlockTime )\r
{\r
if( xQueueSend( pxPort->xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )\r
{\r
}\r
/*-----------------------------------------------------------*/\r
\r
-void vSerialPutString( xComPortHandle pxPort, const portCHAR * const pcString, unsigned portSHORT usStringLength )\r
+void vSerialPutString( xComPortHandle pxPort, const char * const pcString, unsigned short usStringLength )\r
{\r
-portCHAR * pcNextChar;\r
+char * pcNextChar;\r
const portTickType xNoBlock = ( portTickType ) 0;\r
\r
/* Stop warnings. */\r
( void ) usStringLength;\r
\r
- pcNextChar = ( portCHAR * ) pcString;\r
+ pcNextChar = ( char * ) pcString;\r
while( *pcNextChar )\r
{\r
xSerialPutChar( pxPort, *pcNextChar, xNoBlock );\r