mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Continue work on the SmartFusion demo.
This commit is contained in:
parent
505bee983c
commit
b42d4da7db
|
@ -28,7 +28,7 @@
|
|||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cross.cortexm3.exe.debug.1071303895" name="GNU C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cross.cortexm3.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cross.cortexm3.exe.debug.option.optimization.level.510955399" name="Optimization Level" superClass="gnu.c.compiler.cross.cortexm3.exe.debug.option.optimization.level" valueType="enumerated"/>
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cross.cortexm3.exe.debug.option.debugging.level.779446663" name="Debug Level" superClass="gnu.c.compiler.cross.cortexm3.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1134958080" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1134958080" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1656219383" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cross.cortexm3.exe.debug.1468299398" name="GNU C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cross.cortexm3.exe.debug">
|
||||
|
@ -439,6 +439,9 @@
|
|||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cross.cortexm3.exe.debug.option.debugging.level.455246761" name="Debug Level" superClass="gnu.c.compiler.cross.cortexm3.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1331265337" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeTCPIP/apps/httpd}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/WebServer}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeTCPIP}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/Common_Demo_Tasks/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeRTOS_Source/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeRTOS_Source/portable/GCC/ARM_CM3}""/>
|
||||
|
@ -469,7 +472,7 @@
|
|||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="main-blinky.c|FreeTCPIP|WebServer|MicroSemi_Code/drivers/mss_uart|MicroSemi_Code/drivers/mss_spi|MicroSemi_Code/drivers/mss_pdma|MicroSemi_Code/drivers/mss_ethernet_mac|MicroSemi_Code/drivers/mss_ace|MicroSemi_Code/drivers/mac|Debug/FreeRTOS_Source/portable/GCC/ARM_CM3|Debug/FreeRTOS_Source/portable/MemMang" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
<entry excluding="WebServer/httpd-fsdata.c|main-blinky.c|MicroSemi_Code/drivers/mss_uart|MicroSemi_Code/drivers/mss_spi|MicroSemi_Code/drivers/mss_pdma|MicroSemi_Code/drivers/mss_ethernet_mac|MicroSemi_Code/drivers/mss_ace|MicroSemi_Code/drivers/mac|Debug/FreeRTOS_Source/portable/GCC/ARM_CM3|Debug/FreeRTOS_Source/portable/MemMang" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 45 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
|
@ -138,5 +138,25 @@ to exclude the API function. */
|
|||
#define vPortSVCHandler SVC_Handler
|
||||
#define xPortSysTickHandler SysTick_Handler
|
||||
|
||||
/* MAC address configuration. */
|
||||
#define configMAC_ADDR0 0x00
|
||||
#define configMAC_ADDR1 0x12
|
||||
#define configMAC_ADDR2 0x13
|
||||
#define configMAC_ADDR3 0x10
|
||||
#define configMAC_ADDR4 0x15
|
||||
#define configMAC_ADDR5 0x11
|
||||
|
||||
/* IP address configuration. */
|
||||
#define configIP_ADDR0 192
|
||||
#define configIP_ADDR1 168
|
||||
#define configIP_ADDR2 0
|
||||
#define configIP_ADDR3 200
|
||||
|
||||
/* Netmask configuration. */
|
||||
#define configNET_MASK0 255
|
||||
#define configNET_MASK1 255
|
||||
#define configNET_MASK2 255
|
||||
#define configNET_MASK3 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
|
|
|
@ -159,3 +159,21 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
long lParTestGetLEDState( unsigned long ulLED )
|
||||
{
|
||||
long lReturn = pdFALSE;
|
||||
|
||||
if( ulLED < partstMAX_LEDS )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( ( ulGPIOState & ( 1UL << ulLED ) ) == 0UL )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
@ -51,12 +51,6 @@
|
|||
licensing and training services.
|
||||
*/
|
||||
|
||||
/* Hardware specific includes. */
|
||||
#include <iorx62n.h>
|
||||
#include "typedefine.h"
|
||||
#include "r_ether.h"
|
||||
#include "phy.h"
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
@ -65,95 +59,8 @@
|
|||
/* uIP includes. */
|
||||
#include "net/uip.h"
|
||||
|
||||
/* The time to wait between attempts to obtain a free buffer. */
|
||||
#define emacBUFFER_WAIT_DELAY_ms ( 3 / portTICK_RATE_MS )
|
||||
|
||||
/* The number of times emacBUFFER_WAIT_DELAY_ms should be waited before giving
|
||||
up on attempting to obtain a free buffer all together. */
|
||||
#define emacBUFFER_WAIT_ATTEMPTS ( 30 )
|
||||
|
||||
/* The number of Rx descriptors. */
|
||||
#define emacNUM_RX_DESCRIPTORS 8
|
||||
|
||||
/* The number of Tx descriptors. When using uIP there is not point in having
|
||||
more than two. */
|
||||
#define emacNUM_TX_BUFFERS 2
|
||||
|
||||
/* The total number of EMAC buffers to allocate. */
|
||||
#define emacNUM_BUFFERS ( emacNUM_RX_DESCRIPTORS + emacNUM_TX_BUFFERS )
|
||||
|
||||
/* The time to wait for the Tx descriptor to become free. */
|
||||
#define emacTX_WAIT_DELAY_ms ( 10 / portTICK_RATE_MS )
|
||||
|
||||
/* The total number of times to wait emacTX_WAIT_DELAY_ms for the Tx descriptor to
|
||||
become free. */
|
||||
#define emacTX_WAIT_ATTEMPTS ( 50 )
|
||||
|
||||
/* Only Rx end and Tx end interrupts are used by this driver. */
|
||||
#define emacTX_END_INTERRUPT ( 1UL << 21UL )
|
||||
#define emacRX_END_INTERRUPT ( 1UL << 18UL )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The buffers and descriptors themselves. */
|
||||
#pragma data_alignment=32
|
||||
volatile ethfifo xRxDescriptors[ emacNUM_RX_DESCRIPTORS ];
|
||||
|
||||
#pragma data_alignment=32
|
||||
volatile ethfifo xTxDescriptors[ emacNUM_TX_BUFFERS ];
|
||||
|
||||
#pragma data_alignment=32
|
||||
char xEthernetBuffers[ emacNUM_BUFFERS ][ UIP_BUFSIZE ];
|
||||
|
||||
|
||||
/* Used to indicate which buffers are free and which are in use. If an index
|
||||
contains 0 then the corresponding buffer in xEthernetBuffers is free, otherwise
|
||||
the buffer is in use or about to be used. */
|
||||
static unsigned char ucBufferInUse[ emacNUM_BUFFERS ];
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Initialise both the Rx and Tx descriptors.
|
||||
*/
|
||||
static void prvInitialiseDescriptors( void );
|
||||
|
||||
/*
|
||||
* Return a pointer to a free buffer within xEthernetBuffers.
|
||||
*/
|
||||
static unsigned char *prvGetNextBuffer( void );
|
||||
|
||||
/*
|
||||
* Return a buffer to the list of free buffers.
|
||||
*/
|
||||
static void prvReturnBuffer( unsigned char *pucBuffer );
|
||||
|
||||
/*
|
||||
* Examine the status of the next Rx FIFO to see if it contains new data.
|
||||
*/
|
||||
static unsigned long prvCheckRxFifoStatus( void );
|
||||
|
||||
/*
|
||||
* Setup the microcontroller for communication with the PHY.
|
||||
*/
|
||||
static void prvResetMAC( void );
|
||||
|
||||
/*
|
||||
* Configure the Ethernet interface peripherals.
|
||||
*/
|
||||
static void prvConfigureEtherCAndEDMAC( void );
|
||||
|
||||
/*
|
||||
* Something has gone wrong with the descriptor usage. Reset all the buffers
|
||||
* and descriptors.
|
||||
*/
|
||||
static void prvResetEverything( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Points to the Rx descriptor currently in use. */
|
||||
static volatile ethfifo *pxCurrentDesc = NULL;
|
||||
|
||||
/* The buffer used by the uIP stack to both receive and send. This points to
|
||||
one of the Ethernet buffers when its actually in use. */
|
||||
unsigned char *uip_buf = NULL;
|
||||
|
@ -162,103 +69,17 @@ unsigned char *uip_buf = NULL;
|
|||
|
||||
void vInitEmac( void )
|
||||
{
|
||||
/* Software reset. */
|
||||
prvResetMAC();
|
||||
|
||||
/* Set the Rx and Tx descriptors into their initial state. */
|
||||
prvInitialiseDescriptors();
|
||||
|
||||
/* Set the MAC address into the ETHERC */
|
||||
ETHERC.MAHR = ( ( unsigned long ) configMAC_ADDR0 << 24UL ) |
|
||||
( ( unsigned long ) configMAC_ADDR1 << 16UL ) |
|
||||
( ( unsigned long ) configMAC_ADDR2 << 8UL ) |
|
||||
( unsigned long ) configMAC_ADDR3;
|
||||
|
||||
ETHERC.MALR.BIT.MA = ( ( unsigned long ) configMAC_ADDR4 << 8UL ) |
|
||||
( unsigned long ) configMAC_ADDR5;
|
||||
|
||||
/* Perform rest of interface hardware configuration. */
|
||||
prvConfigureEtherCAndEDMAC();
|
||||
|
||||
/* Nothing received yet, so uip_buf points nowhere. */
|
||||
uip_buf = NULL;
|
||||
|
||||
/* Initialize the PHY */
|
||||
phy_init();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vEMACWrite( void )
|
||||
{
|
||||
long x;
|
||||
|
||||
/* Wait until the second transmission of the last packet has completed. */
|
||||
for( x = 0; x < emacTX_WAIT_ATTEMPTS; x++ )
|
||||
{
|
||||
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
|
||||
{
|
||||
/* Descriptor is still active. */
|
||||
vTaskDelay( emacTX_WAIT_DELAY_ms );
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Is the descriptor free after waiting for it? */
|
||||
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
|
||||
{
|
||||
/* Something has gone wrong. */
|
||||
prvResetEverything();
|
||||
}
|
||||
|
||||
/* Setup both descriptors to transmit the frame. */
|
||||
xTxDescriptors[ 0 ].buf_p = ( char * ) uip_buf;
|
||||
xTxDescriptors[ 0 ].bufsize = uip_len;
|
||||
xTxDescriptors[ 1 ].buf_p = ( char * ) uip_buf;
|
||||
xTxDescriptors[ 1 ].bufsize = uip_len;
|
||||
|
||||
/* uip_buf is being sent by the Tx descriptor. Allocate a new buffer
|
||||
for use by the stack. */
|
||||
uip_buf = prvGetNextBuffer();
|
||||
|
||||
/* Clear previous settings and go. */
|
||||
xTxDescriptors[0].status &= ~( FP1 | FP0 );
|
||||
xTxDescriptors[0].status |= ( FP1 | FP0 | ACT );
|
||||
xTxDescriptors[1].status &= ~( FP1 | FP0 );
|
||||
xTxDescriptors[1].status |= ( FP1 | FP0 | ACT );
|
||||
|
||||
EDMAC.EDTRR.LONG = 0x00000001;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
unsigned long ulEMACRead( void )
|
||||
{
|
||||
unsigned long ulBytesReceived;
|
||||
|
||||
ulBytesReceived = prvCheckRxFifoStatus();
|
||||
|
||||
if( ulBytesReceived > 0 )
|
||||
{
|
||||
pxCurrentDesc->status &= ~( FP1 | FP0 );
|
||||
pxCurrentDesc->status |= ACT;
|
||||
|
||||
if( EDMAC.EDRRR.LONG == 0x00000000L )
|
||||
{
|
||||
/* Restart Ethernet if it has stopped */
|
||||
EDMAC.EDRRR.LONG = 0x00000001L;
|
||||
}
|
||||
|
||||
/* Mark the pxDescriptor buffer as free as uip_buf is going to be set to
|
||||
the buffer that contains the received data. */
|
||||
prvReturnBuffer( uip_buf );
|
||||
|
||||
uip_buf = ( void * ) pxCurrentDesc->buf_p;
|
||||
|
||||
/* Move onto the next buffer in the ring. */
|
||||
pxCurrentDesc = pxCurrentDesc->next;
|
||||
}
|
||||
unsigned long ulBytesReceived = 0UL;
|
||||
|
||||
return ulBytesReceived;
|
||||
}
|
||||
|
@ -266,292 +87,9 @@ unsigned long ulBytesReceived;
|
|||
|
||||
long lEMACWaitForLink( void )
|
||||
{
|
||||
long lReturn;
|
||||
|
||||
/* Set the link status. */
|
||||
switch( phy_set_autonegotiate() )
|
||||
{
|
||||
/* Half duplex link */
|
||||
case PHY_LINK_100H:
|
||||
ETHERC.ECMR.BIT.DM = 0;
|
||||
ETHERC.ECMR.BIT.RTM = 1;
|
||||
lReturn = pdPASS;
|
||||
break;
|
||||
|
||||
case PHY_LINK_10H:
|
||||
ETHERC.ECMR.BIT.DM = 0;
|
||||
ETHERC.ECMR.BIT.RTM = 0;
|
||||
lReturn = pdPASS;
|
||||
break;
|
||||
|
||||
|
||||
/* Full duplex link */
|
||||
case PHY_LINK_100F:
|
||||
ETHERC.ECMR.BIT.DM = 1;
|
||||
ETHERC.ECMR.BIT.RTM = 1;
|
||||
lReturn = pdPASS;
|
||||
break;
|
||||
|
||||
case PHY_LINK_10F:
|
||||
ETHERC.ECMR.BIT.DM = 1;
|
||||
ETHERC.ECMR.BIT.RTM = 0;
|
||||
lReturn = pdPASS;
|
||||
break;
|
||||
|
||||
default:
|
||||
lReturn = pdFAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if( lReturn == pdPASS )
|
||||
{
|
||||
/* Enable receive and transmit. */
|
||||
ETHERC.ECMR.BIT.RE = 1;
|
||||
ETHERC.ECMR.BIT.TE = 1;
|
||||
|
||||
/* Enable EDMAC receive */
|
||||
EDMAC.EDRRR.LONG = 0x1;
|
||||
}
|
||||
long lReturn = 0;
|
||||
|
||||
return lReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitialiseDescriptors( void )
|
||||
{
|
||||
volatile ethfifo *pxDescriptor;
|
||||
long x;
|
||||
|
||||
for( x = 0; x < emacNUM_BUFFERS; x++ )
|
||||
{
|
||||
/* Ensure none of the buffers are shown as in use at the start. */
|
||||
ucBufferInUse[ x ] = pdFALSE;
|
||||
}
|
||||
|
||||
/* Initialise the Rx descriptors. */
|
||||
for( x = 0; x < emacNUM_RX_DESCRIPTORS; x++ )
|
||||
{
|
||||
pxDescriptor = &( xRxDescriptors[ x ] );
|
||||
pxDescriptor->buf_p = &( xEthernetBuffers[ x ][ 0 ] );
|
||||
|
||||
pxDescriptor->bufsize = UIP_BUFSIZE;
|
||||
pxDescriptor->size = 0;
|
||||
pxDescriptor->status = ACT;
|
||||
pxDescriptor->next = ( ethfifo * ) &xRxDescriptors[ x + 1 ];
|
||||
|
||||
/* Mark this buffer as in use. */
|
||||
ucBufferInUse[ x ] = pdTRUE;
|
||||
}
|
||||
|
||||
/* The last descriptor points back to the start. */
|
||||
pxDescriptor->status |= DL;
|
||||
pxDescriptor->next = ( ethfifo * ) &xRxDescriptors[ 0 ];
|
||||
|
||||
/* Initialise the Tx descriptors. */
|
||||
for( x = 0; x < emacNUM_TX_BUFFERS; x++ )
|
||||
{
|
||||
pxDescriptor = &( xTxDescriptors[ x ] );
|
||||
|
||||
/* A buffer is not allocated to the Tx descriptor until a send is
|
||||
actually required. */
|
||||
pxDescriptor->buf_p = NULL;
|
||||
|
||||
pxDescriptor->bufsize = UIP_BUFSIZE;
|
||||
pxDescriptor->size = 0;
|
||||
pxDescriptor->status = 0;
|
||||
pxDescriptor->next = ( ethfifo * ) &xTxDescriptors[ x + 1 ];
|
||||
}
|
||||
|
||||
/* The last descriptor points back to the start. */
|
||||
pxDescriptor->status |= DL;
|
||||
pxDescriptor->next = ( ethfifo * ) &( xTxDescriptors[ 0 ] );
|
||||
|
||||
/* Use the first Rx descriptor to start with. */
|
||||
pxCurrentDesc = &( xRxDescriptors[ 0 ] );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static unsigned char *prvGetNextBuffer( void )
|
||||
{
|
||||
long x;
|
||||
unsigned char *pucReturn = NULL;
|
||||
unsigned long ulAttempts = 0;
|
||||
|
||||
while( pucReturn == NULL )
|
||||
{
|
||||
/* Look through the buffers to find one that is not in use by
|
||||
anything else. */
|
||||
for( x = 0; x < emacNUM_BUFFERS; x++ )
|
||||
{
|
||||
if( ucBufferInUse[ x ] == pdFALSE )
|
||||
{
|
||||
ucBufferInUse[ x ] = pdTRUE;
|
||||
pucReturn = ( unsigned char * ) &( xEthernetBuffers[ x ][ 0 ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Was a buffer found? */
|
||||
if( pucReturn == NULL )
|
||||
{
|
||||
ulAttempts++;
|
||||
|
||||
if( ulAttempts >= emacBUFFER_WAIT_ATTEMPTS )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Wait then look again. */
|
||||
vTaskDelay( emacBUFFER_WAIT_DELAY_ms );
|
||||
}
|
||||
}
|
||||
|
||||
return pucReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvReturnBuffer( unsigned char *pucBuffer )
|
||||
{
|
||||
unsigned long ul;
|
||||
|
||||
/* Return a buffer to the pool of free buffers. */
|
||||
for( ul = 0; ul < emacNUM_BUFFERS; ul++ )
|
||||
{
|
||||
if( &( xEthernetBuffers[ ul ][ 0 ] ) == ( void * ) pucBuffer )
|
||||
{
|
||||
ucBufferInUse[ ul ] = pdFALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvResetEverything( void )
|
||||
{
|
||||
/* Temporary code just to see if this gets called. This function has not
|
||||
been implemented. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static unsigned long prvCheckRxFifoStatus( void )
|
||||
{
|
||||
unsigned long ulReturn = 0;
|
||||
|
||||
if( ( pxCurrentDesc->status & ACT ) != 0 )
|
||||
{
|
||||
/* Current descriptor is still active. */
|
||||
}
|
||||
else if( ( pxCurrentDesc->status & FE ) != 0 )
|
||||
{
|
||||
/* Frame error. Clear the error. */
|
||||
pxCurrentDesc->status &= ~( FP1 | FP0 | FE );
|
||||
pxCurrentDesc->status &= ~( RMAF | RRF | RTLF | RTSF | PRE | CERF );
|
||||
pxCurrentDesc->status |= ACT;
|
||||
pxCurrentDesc = pxCurrentDesc->next;
|
||||
|
||||
if( EDMAC.EDRRR.LONG == 0x00000000UL )
|
||||
{
|
||||
/* Restart Ethernet if it has stopped. */
|
||||
EDMAC.EDRRR.LONG = 0x00000001UL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The descriptor contains a frame. Because of the size of the buffers
|
||||
the frame should always be complete. */
|
||||
if( ( pxCurrentDesc->status & FP0 ) == FP0 )
|
||||
{
|
||||
ulReturn = pxCurrentDesc->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do not expect to get here. */
|
||||
prvResetEverything();
|
||||
}
|
||||
}
|
||||
|
||||
return ulReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvResetMAC( void )
|
||||
{
|
||||
/* Ensure the EtherC and EDMAC are enabled. */
|
||||
SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;
|
||||
vTaskDelay( 100 / portTICK_RATE_MS );
|
||||
|
||||
EDMAC.EDMR.BIT.SWR = 1;
|
||||
|
||||
/* Crude wait for reset to complete. */
|
||||
vTaskDelay( 500 / portTICK_RATE_MS );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvConfigureEtherCAndEDMAC( void )
|
||||
{
|
||||
/* Initialisation code taken from Renesas example project. */
|
||||
|
||||
/* TODO: Check bit 5 */
|
||||
ETHERC.ECSR.LONG = 0x00000037; /* Clear all ETHERC statuS BFR, PSRTO, LCHNG, MPD, ICD */
|
||||
|
||||
/* Set the EDMAC interrupt priority. */
|
||||
_IPR( _ETHER_EINT ) = configKERNEL_INTERRUPT_PRIORITY;
|
||||
|
||||
/* TODO: Check bit 5 */
|
||||
/* Enable interrupts of interest only. */
|
||||
EDMAC.EESIPR.LONG = emacTX_END_INTERRUPT | emacRX_END_INTERRUPT;
|
||||
ETHERC.RFLR.LONG = 1518; /* Ether payload is 1500+ CRC */
|
||||
ETHERC.IPGR.LONG = 0x00000014; /* Intergap is 96-bit time */
|
||||
|
||||
/* EDMAC */
|
||||
EDMAC.EESR.LONG = 0x47FF0F9F; /* Clear all ETHERC and EDMAC status bits */
|
||||
#if __LITTLE_ENDIAN__ == 1
|
||||
EDMAC.EDMR.BIT.DE = 1;
|
||||
#endif
|
||||
EDMAC.RDLAR = ( void * ) pxCurrentDesc; /* Initialaize Rx Descriptor List Address */
|
||||
EDMAC.TDLAR = ( void * ) &( xTxDescriptors[ 0 ] );/* Initialaize Tx Descriptor List Address */
|
||||
EDMAC.TRSCER.LONG = 0x00000000; /* Copy-back status is RFE & TFE only */
|
||||
EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */
|
||||
EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */
|
||||
EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */
|
||||
|
||||
/* Enable the interrupt... */
|
||||
_IEN( _ETHER_EINT ) = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#pragma vector = VECT_ETHER_EINT
|
||||
__interrupt void vEMAC_ISR_Handler( void )
|
||||
{
|
||||
unsigned long ul = EDMAC.EESR.LONG;
|
||||
long lHigherPriorityTaskWoken = pdFALSE;
|
||||
extern xSemaphoreHandle xEMACSemaphore;
|
||||
static long ulTxEndInts = 0;
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
/* Has a Tx end occurred? */
|
||||
if( ul & emacTX_END_INTERRUPT )
|
||||
{
|
||||
++ulTxEndInts;
|
||||
if( ulTxEndInts >= 2 )
|
||||
{
|
||||
/* Only return the buffer to the pool once both Txes have completed. */
|
||||
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
|
||||
ulTxEndInts = 0;
|
||||
}
|
||||
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
|
||||
}
|
||||
|
||||
/* Has an Rx end occurred? */
|
||||
if( ul & emacRX_END_INTERRUPT )
|
||||
{
|
||||
/* Make sure the Ethernet task is not blocked waiting for a packet. */
|
||||
xSemaphoreGiveFromISR( xEMACSemaphore, &lHigherPriorityTaskWoken );
|
||||
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
|
||||
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,54 +52,54 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
This simple demo project runs on the STM32 Discovery board, which is
|
||||
populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
demo is configured to include malloc failure, idle and stack overflow hook
|
||||
functions.
|
||||
|
||||
The idle hook function:
|
||||
The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
Memory is only allocated from this heap during initialisation, and this demo
|
||||
only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
bytes of heap space unallocated.
|
||||
|
||||
The main() Function:
|
||||
main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
scheduler.
|
||||
|
||||
The Queue Send Task:
|
||||
The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
200 milliseconds, before sending the value 100 to the queue that was created
|
||||
within main(). Once the value is sent, the task loops back around to block for
|
||||
another 200 milliseconds.
|
||||
|
||||
The Queue Receive Task:
|
||||
The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
attempt to read data from the queue that was created within main(). When data
|
||||
is received, the task checks the value of the data, and if the value equals
|
||||
the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
the queue receive function specifies that the task should be held in the Blocked
|
||||
state indefinitely to wait for data to be available on the queue. The queue
|
||||
receive task will only leave the Blocked state when the queue send task writes
|
||||
to the queue. As the queue send task writes to the queue every 200
|
||||
milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
|
||||
The LED Software Timer and the Button Interrupt:
|
||||
The user button B1 is configured to generate an interrupt each time it is
|
||||
pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
uses a callback function that is defined to just turn the red LED off.
|
||||
Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
remain on until a full five seconds pass without the button being pressed.
|
||||
* This simple demo project runs on the STM32 Discovery board, which is
|
||||
* populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
* makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
* STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
* FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
* demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
* demo is configured to include malloc failure, idle and stack overflow hook
|
||||
* functions.
|
||||
*
|
||||
* The idle hook function:
|
||||
* The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
* remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
* application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
* Memory is only allocated from this heap during initialisation, and this demo
|
||||
* only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
* bytes of heap space unallocated.
|
||||
*
|
||||
* The main() Function:
|
||||
* main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
* scheduler.
|
||||
*
|
||||
* The Queue Send Task:
|
||||
* The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
* file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
* 200 milliseconds, before sending the value 100 to the queue that was created
|
||||
* within main(). Once the value is sent, the task loops back around to block for
|
||||
* another 200 milliseconds.
|
||||
*
|
||||
* The Queue Receive Task:
|
||||
* The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
* in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
* attempt to read data from the queue that was created within main(). When data
|
||||
* is received, the task checks the value of the data, and if the value equals
|
||||
* the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
* the queue receive function specifies that the task should be held in the Blocked
|
||||
* state indefinitely to wait for data to be available on the queue. The queue
|
||||
* receive task will only leave the Blocked state when the queue send task writes
|
||||
* to the queue. As the queue send task writes to the queue every 200
|
||||
* milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
* milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
*
|
||||
* The LED Software Timer and the Button Interrupt:
|
||||
* The user button B1 is configured to generate an interrupt each time it is
|
||||
* pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
* LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
* uses a callback function that is defined to just turn the red LED off.
|
||||
* Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
* remain on until a full five seconds pass without the button being pressed.
|
||||
*/
|
||||
|
||||
/* Kernel includes. */
|
||||
|
@ -319,6 +319,7 @@ static void prvSetupHardware( void )
|
|||
MSS_GPIO_set_outputs( ulGPIOState );
|
||||
|
||||
/* Setup the GPIO and the NVIC for the switch used in this simple demo. */
|
||||
NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
NVIC_EnableIRQ( GPIO8_IRQn );
|
||||
MSS_GPIO_config( MSS_GPIO_8, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_NEGATIVE );
|
||||
MSS_GPIO_enable_irq( MSS_GPIO_8 );
|
||||
|
|
|
@ -52,54 +52,54 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
This simple demo project runs on the STM32 Discovery board, which is
|
||||
populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
demo is configured to include malloc failure, idle and stack overflow hook
|
||||
functions.
|
||||
|
||||
The idle hook function:
|
||||
The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
Memory is only allocated from this heap during initialisation, and this demo
|
||||
only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
bytes of heap space unallocated.
|
||||
|
||||
The main() Function:
|
||||
main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
scheduler.
|
||||
|
||||
The Queue Send Task:
|
||||
The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
200 milliseconds, before sending the value 100 to the queue that was created
|
||||
within main(). Once the value is sent, the task loops back around to block for
|
||||
another 200 milliseconds.
|
||||
|
||||
The Queue Receive Task:
|
||||
The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
attempt to read data from the queue that was created within main(). When data
|
||||
is received, the task checks the value of the data, and if the value equals
|
||||
the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
the queue receive function specifies that the task should be held in the Blocked
|
||||
state indefinitely to wait for data to be available on the queue. The queue
|
||||
receive task will only leave the Blocked state when the queue send task writes
|
||||
to the queue. As the queue send task writes to the queue every 200
|
||||
milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
|
||||
The LED Software Timer and the Button Interrupt:
|
||||
The user button B1 is configured to generate an interrupt each time it is
|
||||
pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
uses a callback function that is defined to just turn the red LED off.
|
||||
Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
remain on until a full five seconds pass without the button being pressed.
|
||||
* This simple demo project runs on the STM32 Discovery board, which is
|
||||
* populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
* makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
* STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
* FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
* demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
* demo is configured to include malloc failure, idle and stack overflow hook
|
||||
* functions.
|
||||
*
|
||||
* The idle hook function:
|
||||
* The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
* remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
* application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
* Memory is only allocated from this heap during initialisation, and this demo
|
||||
* only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
* bytes of heap space unallocated.
|
||||
*
|
||||
* The main() Function:
|
||||
* main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
* scheduler.
|
||||
*
|
||||
* The Queue Send Task:
|
||||
* The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
* file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
* 200 milliseconds, before sending the value 100 to the queue that was created
|
||||
* within main(). Once the value is sent, the task loops back around to block for
|
||||
* another 200 milliseconds.
|
||||
*
|
||||
* The Queue Receive Task:
|
||||
* The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
* in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
* attempt to read data from the queue that was created within main(). When data
|
||||
* is received, the task checks the value of the data, and if the value equals
|
||||
* the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
* the queue receive function specifies that the task should be held in the Blocked
|
||||
* state indefinitely to wait for data to be available on the queue. The queue
|
||||
* receive task will only leave the Blocked state when the queue send task writes
|
||||
* to the queue. As the queue send task writes to the queue every 200
|
||||
* milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
* milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
*
|
||||
* The LED Software Timer and the Button Interrupt:
|
||||
* The user button B1 is configured to generate an interrupt each time it is
|
||||
* pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
* LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
* uses a callback function that is defined to just turn the red LED off.
|
||||
* Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
* remain on until a full five seconds pass without the button being pressed.
|
||||
*/
|
||||
|
||||
/* Kernel includes. */
|
||||
|
@ -472,3 +472,21 @@ volatile size_t xFreeStackSpace;
|
|||
reduced accordingly. */
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
char *pcGetTaskStatusMessage( void )
|
||||
{
|
||||
/* Not bothered about a critical section here although technically because of
|
||||
the task priorities the pointer could change it will be atomic if not near
|
||||
atomic and its not critical. */
|
||||
if( pcStatusMessage == NULL )
|
||||
{
|
||||
return "All tasks running without error";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( char * ) pcStatusMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
284
Demo/CORTEX_A2F200_SoftConsole/uIP_Task.c
Normal file
284
Demo/CORTEX_A2F200_SoftConsole/uIP_Task.c
Normal file
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The 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. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <string.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* uip includes. */
|
||||
#include "net/uip.h"
|
||||
#include "net/uip_arp.h"
|
||||
#include "apps/httpd/httpd.h"
|
||||
#include "sys/timer.h"
|
||||
#include "net/clock-arch.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "ParTest.h"
|
||||
|
||||
#include "EMAC.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* How long to wait before attempting to connect the MAC again. */
|
||||
#define uipINIT_WAIT ( 100 / portTICK_RATE_MS )
|
||||
|
||||
/* Shortcut to the header within the Rx buffer. */
|
||||
#define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
|
||||
|
||||
/* Standard constant. */
|
||||
#define uipTOTAL_FRAME_HEADER_SIZE 54
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Setup the MAC address in the MAC itself, and in the uIP stack.
|
||||
*/
|
||||
static void prvSetMACAddress( void );
|
||||
|
||||
/*
|
||||
* Port functions required by the uIP stack.
|
||||
*/
|
||||
void clock_init( void );
|
||||
clock_time_t clock_time( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The semaphore used by the ISR to wake the uIP task. */
|
||||
xSemaphoreHandle xEMACSemaphore = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void clock_init(void)
|
||||
{
|
||||
/* This is done when the scheduler starts. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
clock_time_t clock_time( void )
|
||||
{
|
||||
return xTaskGetTickCount();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vuIP_Task( void *pvParameters )
|
||||
{
|
||||
portBASE_TYPE i, xDoneSomething;
|
||||
uip_ipaddr_t xIPAddr;
|
||||
struct timer periodic_timer, arp_timer;
|
||||
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise the uIP stack. */
|
||||
timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
|
||||
timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
|
||||
uip_init();
|
||||
uip_ipaddr( &xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
|
||||
uip_sethostaddr( &xIPAddr );
|
||||
uip_ipaddr( &xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );
|
||||
uip_setnetmask( &xIPAddr );
|
||||
prvSetMACAddress();
|
||||
httpd_init();
|
||||
|
||||
/* Create the semaphore used to wake the uIP task. */
|
||||
vSemaphoreCreateBinary( xEMACSemaphore );
|
||||
|
||||
/* Initialise the MAC. */
|
||||
vInitEmac();
|
||||
|
||||
while( lEMACWaitForLink() != pdPASS )
|
||||
{
|
||||
vTaskDelay( uipINIT_WAIT );
|
||||
}
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
xDoneSomething = pdFALSE;
|
||||
|
||||
/* Is there received data ready to be processed? */
|
||||
uip_len = ( unsigned short ) ulEMACRead();
|
||||
|
||||
if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
|
||||
{
|
||||
/* Standard uIP loop taken from the uIP manual. */
|
||||
if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
|
||||
{
|
||||
uip_arp_ipin();
|
||||
uip_input();
|
||||
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if( uip_len > 0 )
|
||||
{
|
||||
uip_arp_out();
|
||||
vEMACWrite();
|
||||
}
|
||||
|
||||
xDoneSomething = pdTRUE;
|
||||
}
|
||||
else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
|
||||
{
|
||||
uip_arp_arpin();
|
||||
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if( uip_len > 0 )
|
||||
{
|
||||
vEMACWrite();
|
||||
}
|
||||
|
||||
xDoneSomething = pdTRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )
|
||||
{
|
||||
timer_reset( &periodic_timer );
|
||||
for( i = 0; i < UIP_CONNS; i++ )
|
||||
{
|
||||
uip_periodic( i );
|
||||
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if( uip_len > 0 )
|
||||
{
|
||||
uip_arp_out();
|
||||
vEMACWrite();
|
||||
}
|
||||
}
|
||||
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
if( timer_expired( &arp_timer ) )
|
||||
{
|
||||
timer_reset( &arp_timer );
|
||||
uip_arp_timer();
|
||||
}
|
||||
|
||||
xDoneSomething = pdTRUE;
|
||||
}
|
||||
|
||||
if( xDoneSomething == pdFALSE )
|
||||
{
|
||||
/* We did not receive a packet, and there was no periodic
|
||||
processing to perform. Block for a fixed period. If a packet
|
||||
is received during this period we will be woken by the ISR
|
||||
giving us the Semaphore. */
|
||||
xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 20 );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetMACAddress( void )
|
||||
{
|
||||
struct uip_eth_addr xAddr;
|
||||
|
||||
/* Configure the MAC address in the uIP stack. */
|
||||
xAddr.addr[ 0 ] = configMAC_ADDR0;
|
||||
xAddr.addr[ 1 ] = configMAC_ADDR1;
|
||||
xAddr.addr[ 2 ] = configMAC_ADDR2;
|
||||
xAddr.addr[ 3 ] = configMAC_ADDR3;
|
||||
xAddr.addr[ 4 ] = configMAC_ADDR4;
|
||||
xAddr.addr[ 5 ] = configMAC_ADDR5;
|
||||
uip_setethaddr( xAddr );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationProcessFormInput( char *pcInputString )
|
||||
{
|
||||
char *c;
|
||||
|
||||
/* Only interested in processing form input if this is the IO page. */
|
||||
c = strstr( pcInputString, "io.shtml" );
|
||||
|
||||
if( c )
|
||||
{
|
||||
/* Is there a command in the string? */
|
||||
c = strstr( pcInputString, "?" );
|
||||
if( c )
|
||||
{
|
||||
/* Turn the LED's on or off in accordance with the check box status. */
|
||||
if( strstr( c, "LED0=1" ) != NULL )
|
||||
{
|
||||
/* Turn the LEDs on. */
|
||||
vParTestSetLED( 7, 1 );
|
||||
vParTestSetLED( 8, 1 );
|
||||
vParTestSetLED( 9, 1 );
|
||||
vParTestSetLED( 10, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn the LEDs off. */
|
||||
vParTestSetLED( 7, 0 );
|
||||
vParTestSetLED( 8, 0 );
|
||||
vParTestSetLED( 9, 0 );
|
||||
vParTestSetLED( 10, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commands to turn LEDs off are not always explicit. */
|
||||
vParTestSetLED( 7, 0 );
|
||||
vParTestSetLED( 8, 0 );
|
||||
vParTestSetLED( 9, 0 );
|
||||
vParTestSetLED( 10, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue