Update all the Rx demos to use timers in their uIP task implementation.

This commit is contained in:
Richard Barry 2011-05-13 17:32:30 +00:00
parent 9ad9969536
commit 4e39c05bb6
47 changed files with 1440 additions and 848 deletions

View file

@ -93,6 +93,11 @@
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 7 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 3 )
#define configTIMER_QUEUE_LENGTH 5
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
/*
The interrupt priority used by the kernel itself for the tick interrupt and

View file

@ -12,7 +12,7 @@
<name>General</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>4</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -129,13 +129,17 @@
<name>GenIntSize</name>
<state>1</state>
</option>
<option>
<name>GenRopi</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ICCRX</name>
<archiveVersion>3</archiveVersion>
<data>
<version>10</version>
<version>11</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -369,13 +373,25 @@
<name>IccIntSize</name>
<state>1</state>
</option>
<option>
<name>IccPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AggressiveInlining</name>
<state>0</state>
</option>
<option>
<name>AggressiveUnrolling</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ARX</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>5</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -524,6 +540,14 @@
<name>AsmIntSize</name>
<state>1</state>
</option>
<option>
<name>AsmPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AsmCpuCore</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -581,7 +605,7 @@
<name>ILINK</name>
<archiveVersion>1</archiveVersion>
<data>
<version>0</version>
<version>1</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -807,6 +831,10 @@
<name>IlinkLogUnusedFragments</name>
<state>0</state>
</option>
<option>
<name>IlinkSubnormal</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@ -846,7 +874,7 @@
<name>General</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>4</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -963,13 +991,17 @@
<name>GenIntSize</name>
<state>1</state>
</option>
<option>
<name>GenRopi</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ICCRX</name>
<archiveVersion>3</archiveVersion>
<data>
<version>10</version>
<version>11</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1202,13 +1234,25 @@
<name>IccIntSize</name>
<state>1</state>
</option>
<option>
<name>IccPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AggressiveInlining</name>
<state>0</state>
</option>
<option>
<name>AggressiveUnrolling</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ARX</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>5</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1357,6 +1401,14 @@
<name>AsmIntSize</name>
<state>1</state>
</option>
<option>
<name>AsmPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AsmCpuCore</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -1414,7 +1466,7 @@
<name>ILINK</name>
<archiveVersion>1</archiveVersion>
<data>
<version>0</version>
<version>1</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1640,6 +1692,10 @@
<name>IlinkLogUnusedFragments</name>
<state>0</state>
</option>
<option>
<name>IlinkSubnormal</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@ -1679,7 +1735,7 @@
<name>General</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>4</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1796,13 +1852,17 @@
<name>GenIntSize</name>
<state>1</state>
</option>
<option>
<name>GenRopi</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ICCRX</name>
<archiveVersion>3</archiveVersion>
<data>
<version>10</version>
<version>11</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -2036,13 +2096,25 @@
<name>IccIntSize</name>
<state>1</state>
</option>
<option>
<name>IccPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AggressiveInlining</name>
<state>0</state>
</option>
<option>
<name>AggressiveUnrolling</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>ARX</name>
<archiveVersion>2</archiveVersion>
<data>
<version>3</version>
<version>5</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -2191,6 +2263,14 @@
<name>AsmIntSize</name>
<state>1</state>
</option>
<option>
<name>AsmPosIndRopi</name>
<state>1</state>
</option>
<option>
<name>AsmCpuCore</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -2248,7 +2328,7 @@
<name>ILINK</name>
<archiveVersion>1</archiveVersion>
<data>
<version>0</version>
<version>1</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -2474,6 +2554,10 @@
<name>IlinkLogUnusedFragments</name>
<state>0</state>
</option>
<option>
<name>IlinkSubnormal</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@ -2568,6 +2652,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\tasks.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\timers.c</name>
</file>
</group>
<group>
<name>FreeTCPIP (based on uIP)</name>

View file

@ -1,33 +1,15 @@
@REM This bat file has been generated by the IAR Embeddded Workbench
@REM C-SPY interactive debugger,as an aid to preparing a command
@REM line for running the cspybat command line utility with the
@REM appropriate settings.
@REM This batch file has been generated by the IAR Embedded Workbench
@REM C-SPY Debugger, as an aid to preparing a command line for running
@REM the cspybat command line utility using the appropriate settings.
@REM
@REM After making some adjustments to this file, you can launch cspybat
@REM by typing the name of this file followed by the name of the debug
@REM file (usually an ubrof file). Note that this file is generated
@REM every time a new debug session is initialized, so you may want to
@REM move or rename the file before making changes.
@REM
@REM Note: some command line arguments cannot be properly generated
@REM by this process. Specifically, the plugin which is responsible
@REM for the Terminal I/O window (and other C runtime functionality)
@REM comes in a special version for cspybat, and the name of that
@REM plugin dll is not known when generating this file. It resides in
@REM the $TOOLKIT_DIR$\bin folder and is usually called XXXbat.dll or
@REM XXXlibsupportbat.dll, where XXX is the name of the corresponding
@REM tool chain. Replace the '<libsupport_plugin>' parameter
@REM below with the appropriate file name. Other plugins loaded by
@REM C-SPY are usually not needed by, or will not work in, cspybat
@REM but they are listed at the end of this file for reference.
@REM You can launch cspybat by typing the name of this batch file followed
@REM by the name of the debug file (usually an ELF/DWARF or UBROF file).
@REM Note that this file is generated every time a new debug session
@REM is initialized, so you may want to move or rename the file before
@REM making changes.
@REM
"C:\devtools\IAR Systems\Embedded Workbench 6.0\common\bin\cspybat" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\rxproc.dll" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\rxemue20.dll" %1 --plugin "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\<libsupport_plugin>" --backend -B "--core" "RX600" "-p" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\config\debugger\ior5f562n8.ddf" "--double" "32" "--endian" "l" "--int" "32" "-d" "emue20" "--emu" "jlink" "--drv_communication" "USB" "--verify_download" "all"
"C:\devtools\IAR Systems\Embedded Workbench 6.0\common\bin\cspybat" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\rxproc.dll" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\rxemue20.dll" %1 --plugin "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\bin\rxbat.dll" --backend -B "--core" "RX600" "-p" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rx\config\debugger\ior5f562n8.ddf" "--double" "32" "--endian" "l" "--int" "32" "-d" "emue20" "--emu" "jlink" "--drv_communication" "USB" "--verify_download" "all"
@REM Loaded plugins:
@REM rxLibSupport.dll
@REM C:\devtools\IAR Systems\Embedded Workbench 6.0\common\plugins\CodeCoverage\CodeCoverage.dll
@REM C:\devtools\IAR Systems\Embedded Workbench 6.0\common\plugins\Profiling\Profiling.dll
@REM C:\devtools\IAR Systems\Embedded Workbench 6.0\common\plugins\stack\stack.dll
@REM C:\devtools\IAR Systems\Embedded Workbench 6.0\common\plugins\SymList\SymList.dll

View file

@ -31,7 +31,7 @@
<Wnd1>
<Wnd0>
<Tabs>
<Tab>
<Identity>TabID-20000-3827</Identity>
@ -43,20 +43,20 @@
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd1><Wnd2><Tabs><Tab><Identity>TabID-2655-13188</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd2></Windows>
<SelectedTab>0</SelectedTab></Wnd0><Wnd3><Tabs><Tab><Identity>TabID-2655-13188</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-full.c</Filename><XPos>0</XPos><YPos>53</YPos><SelStart>3048</SelStart><SelEnd>3048</SelEnd></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-full.c</Filename><XPos>0</XPos><YPos>251</YPos><SelStart>12353</SelStart><SelEnd>12353</SelEnd></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>113</YPos><SelStart>6095</SelStart><SelEnd>6104</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\webserver\EMAC.c</Filename><XPos>0</XPos><YPos>134</YPos><SelStart>5833</SelStart><SelEnd>5833</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\uIP_Task.c</Filename><XPos>0</XPos><YPos>226</YPos><SelStart>7106</SelStart><SelEnd>7106</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-blinky.c</Filename><XPos>0</XPos><YPos>87</YPos><SelStart>4804</SelStart><SelEnd>4804</SelEnd></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-00a2ab10><key>iaridepm.enu1</key></Toolbar-00a2ab10><Toolbar-02d473b0><key>debuggergui.enu1</key></Toolbar-02d473b0></Sizes></Row0></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>238</Right><x>-2</x><y>-2</y><xscreen>121</xscreen><yscreen>141</yscreen><sizeHorzCX>72024</sizeHorzCX><sizeHorzCY>143585</sizeHorzCY><sizeVertCX>142857</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
<Top><Row0><Sizes><Toolbar-01335fe0><key>iaridepm.enu1</key></Toolbar-01335fe0><Toolbar-07c10450><key>debuggergui.enu1</key></Toolbar-07c10450></Sizes></Row0></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>238</Right><x>-2</x><y>-2</y><xscreen>121</xscreen><yscreen>141</yscreen><sizeHorzCX>72024</sizeHorzCX><sizeHorzCY>143585</sizeHorzCY><sizeVertCX>142857</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Project>

View file

@ -1,7 +1,7 @@
[E20]
TimeConnected=1285248097
ComuniDllSave=84541440
FfwnsdDllSave=81330176
TimeConnected=1305306990
ComuniDllSave=194838528
FfwnsdDllSave=194969600
ChipName=R5F562N8
CpuMode=0
InputClock=12.500000
@ -10,8 +10,18 @@ JtagClock=10
DebugFlags=0,0
EmulatorMode=0
NeedInit=1
BlockBits=0
B0=0,0
B1=0,0
B2=0,0
B3=0,0
TraceMode=0
TraceOutput=2
TraceCapacity=0
TraceRestart=0
OperatingFrequency=12.500000
[DebugChecksum]
Checksum=188492037
Checksum=-1259593031
[DisAssemblyWindow]
NumStates=_ 1
State 1=_ 1
@ -31,10 +41,25 @@ UseTrigger=1
TriggerName=main
LimitSize=0
ByteLimit=50
[DriverProfiling]
Enabled=0
Source=2
Graph=0
[Stack]
FillEnabled=0
OverflowWarningsEnabled=1
WarningThreshold=90
SpWarningsEnabled=1
WarnLogOnly=1
UseTrigger=1
TriggerName=main
LimitSize=0
ByteLimit=50
[CallStack]
ShowArgs=0
[PowerLog]
LogEnabled=0
GraphEnabled=0
ShowTimeLog=1
ShowTimeSum=0
Title0=Power
Setup0=0 1 0 500 2 0 4 1 0
[Log file]
LoggingEnabled=_ 0
LogFile=_ ""
@ -42,6 +67,13 @@ Category=_ 0
[TermIOLog]
LoggingEnabled=_ 0
LogFile=_ ""
[CallStackLog]
Enabled=0
[DriverProfiling]
Enabled=0
Mode=3
Graph=0
Symbiont=0
[Breakpoints]
Count=0
[Monitor Execution]

View file

@ -3,7 +3,7 @@
<Workspace>
<ConfigDictionary>
<CurrentConfigs><Project>RTOSDemo/Debug-with-optimisation</Project></CurrentConfigs></ConfigDictionary>
<CurrentConfigs><Project>RTOSDemo/Debug</Project></CurrentConfigs></ConfigDictionary>
<Desktop>
<Static>
<Workspace>
@ -33,7 +33,7 @@
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source/Portable Layer</ExpandedNode></NodeDict></Session>
<NodeDict><ExpandedNode>RTOSDemo</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
@ -53,14 +53,14 @@
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-full.c</Filename><XPos>0</XPos><YPos>53</YPos><SelStart>3048</SelStart><SelEnd>3048</SelEnd></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-full.c</Filename><XPos>0</XPos><YPos>44</YPos><SelStart>12353</SelStart><SelEnd>12353</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main-blinky.c</Filename><XPos>0</XPos><YPos>49</YPos><SelStart>4804</SelStart><SelEnd>4804</SelEnd></Tab><ActiveTab>1</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-00a2ab40><key>iaridepm.enu1</key></Toolbar-00a2ab40></Sizes></Row0></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>706</Bottom><Right>351</Right><x>-2</x><y>-2</y><xscreen>331</xscreen><yscreen>284</yscreen><sizeHorzCX>197024</sizeHorzCX><sizeHorzCY>289206</sizeHorzCY><sizeVertCX>210119</sizeVertCX><sizeVertCY>720978</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>232</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>234</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>238289</sizeHorzCY><sizeVertCX>197024</sizeVertCX><sizeVertCY>289206</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
<Top><Row0><Sizes><Toolbar-01335fe0><key>iaridepm.enu1</key></Toolbar-01335fe0></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>706</Bottom><Right>351</Right><x>-2</x><y>-2</y><xscreen>331</xscreen><yscreen>284</yscreen><sizeHorzCX>197024</sizeHorzCX><sizeHorzCY>289206</sizeHorzCY><sizeVertCX>210119</sizeVertCX><sizeVertCY>720978</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>232</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>234</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>238289</sizeHorzCY><sizeVertCX>197024</sizeVertCX><sizeVertCY>289206</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>

View file

@ -57,7 +57,8 @@
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "timers.h"
#include "queue.h"
/* uip includes. */
#include "net/uip.h"
@ -81,6 +82,15 @@
/* Standard constant. */
#define uipTOTAL_FRAME_HEADER_SIZE 54
/* The ARP timer and the periodic timer share a callback function, so the
respective timer IDs are used to determine which timer actually expired. These
constants are assigned to the timer IDs. */
#define uipARP_TIMER 0
#define uipPERIODIC_TIMER 1
/* A block time of zero ticks simply means, "don't block". */
#define uipDONT_BLOCK 0UL
/*-----------------------------------------------------------*/
/*
@ -88,25 +98,29 @@
*/
static void prvSetMACAddress( void );
/*
* Perform any uIP initialisation necessary.
*/
static void prvInitialise_uIP( void );
/*
* The callback function that is assigned to both the periodic timer and the
* ARP timer.
*/
static void prvUIPTimerCallback( xTimerHandle xTimer );
/*
* 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;
/* The queue used to send TCP/IP events to the uIP stack. */
xQueueHandle xEMACEventQueue = NULL;
/*-----------------------------------------------------------*/
void clock_init(void)
{
/* This is done when the scheduler starts. */
}
/*-----------------------------------------------------------*/
clock_time_t clock_time( void )
{
return xTaskGetTickCount();
@ -115,25 +129,14 @@ clock_time_t clock_time( void )
void vuIP_Task( void *pvParameters )
{
portBASE_TYPE i, xDoneSomething;
uip_ipaddr_t xIPAddr;
struct timer periodic_timer, arp_timer;
portBASE_TYPE i;
unsigned long ulNewEvent = 0UL;
unsigned long ulUIP_Events = 0UL;
( 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 );
prvInitialise_uIP();
/* Initialise the MAC. */
vInitEmac();
@ -145,49 +148,51 @@ struct timer periodic_timer, arp_timer;
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 ) )
if( ( ulUIP_Events & uipETHERNET_RX_EVENT ) != 0UL )
{
/* Is there received data ready to be processed? */
uip_len = ( unsigned short ) ulEMACRead();
if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
{
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 )
/* Standard uIP loop taken from the uIP manual. */
if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
{
uip_arp_out();
vEMACWrite();
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();
}
}
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;
}
else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
else
{
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;
ulUIP_Events &= ~uipETHERNET_RX_EVENT;
}
}
if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )
if( ( ulUIP_Events & uipPERIODIC_TIMER_EVENT ) != 0UL )
{
timer_reset( &periodic_timer );
ulUIP_Events &= ~uipPERIODIC_TIMER_EVENT;
for( i = 0; i < UIP_CONNS; i++ )
{
uip_periodic( i );
@ -201,25 +206,82 @@ struct timer periodic_timer, arp_timer;
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 )
/* Call the ARP timer function every 10 seconds. */
if( ( ulUIP_Events & uipARP_TIMER_EVENT ) != 0 )
{
/* 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 );
ulUIP_Events &= ~uipARP_TIMER_EVENT;
uip_arp_timer();
}
if( ulUIP_Events == pdFALSE )
{
xQueueReceive( xEMACEventQueue, &ulNewEvent, portMAX_DELAY );
ulUIP_Events |= ulNewEvent;
}
}
}
/*-----------------------------------------------------------*/
static void prvInitialise_uIP( void )
{
xTimerHandle xARPTimer, xPeriodicTimer;
uip_ipaddr_t xIPAddr;
const unsigned long ul_uIPEventQueueLength = 10UL;
/* Initialise the uIP stack. */
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 queue used to sent TCP/IP events to the uIP stack. */
xEMACEventQueue = xQueueCreate( ul_uIPEventQueueLength, sizeof( unsigned long ) );
/* Create and start the uIP timers. */
xARPTimer = xTimerCreate( "ARPTimer", /* Just a name that is helpful for debugging, not used by the kernel. */
( 10000UL / portTICK_RATE_MS ), /* Timer period. */
pdTRUE, /* Autor-reload. */
( void * ) uipARP_TIMER,
prvUIPTimerCallback
);
xPeriodicTimer = xTimerCreate( "PeriodicTimer",
( 500 / portTICK_RATE_MS ),
pdTRUE, /* Autor-reload. */
( void * ) uipPERIODIC_TIMER,
prvUIPTimerCallback
);
configASSERT( xARPTimer );
configASSERT( xPeriodicTimer );
xTimerStart( xARPTimer, portMAX_DELAY );
xTimerStart( xPeriodicTimer, portMAX_DELAY );
}
/*-----------------------------------------------------------*/
static void prvUIPTimerCallback( xTimerHandle xTimer )
{
static const unsigned long ulARPTimerExpired = uipARP_TIMER_EVENT;
static const unsigned long ulPeriodicTimerExpired = uipPERIODIC_TIMER_EVENT;
/* This is a time callback, so calls to xQueueSend() must not attempt to
block. */
switch( ( int ) pvTimerGetTimerID( xTimer ) )
{
case uipARP_TIMER : xQueueSend( xEMACEventQueue, &ulARPTimerExpired, uipDONT_BLOCK );
break;
case uipPERIODIC_TIMER : xQueueSend( xEMACEventQueue, &ulPeriodicTimerExpired, uipDONT_BLOCK );
break;
default : /* Should not get here. */
break;
}
}
/*-----------------------------------------------------------*/

View file

@ -152,7 +152,7 @@ static void prvResetEverything( void );
/*-----------------------------------------------------------*/
/* Points to the Rx descriptor currently in use. */
static volatile ethfifo *pxCurrentDesc = NULL;
static volatile ethfifo *pxCurrentRxDesc = 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. */
@ -241,23 +241,29 @@ unsigned long ulBytesReceived;
if( ulBytesReceived > 0 )
{
pxCurrentDesc->status &= ~( FP1 | FP0 );
pxCurrentDesc->status |= ACT;
/* 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 );
/* Point uip_buf to the data about ot be processed. */
uip_buf = ( void * ) pxCurrentRxDesc->buf_p;
/* Allocate a new buffer to the descriptor, as uip_buf is now using it's
old descriptor. */
pxCurrentRxDesc->buf_p = ( char * ) prvGetNextBuffer();
/* Prepare the descriptor to go again. */
pxCurrentRxDesc->status &= ~( FP1 | FP0 );
pxCurrentRxDesc->status |= ACT;
/* Move onto the next buffer in the ring. */
pxCurrentRxDesc = pxCurrentRxDesc->next;
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;
}
return ulBytesReceived;
@ -367,7 +373,7 @@ long x;
pxDescriptor->next = ( ethfifo * ) &( xTxDescriptors[ 0 ] );
/* Use the first Rx descriptor to start with. */
pxCurrentDesc = &( xRxDescriptors[ 0 ] );
pxCurrentRxDesc = &( xRxDescriptors[ 0 ] );
}
/*-----------------------------------------------------------*/
@ -439,17 +445,17 @@ static unsigned long prvCheckRxFifoStatus( void )
{
unsigned long ulReturn = 0;
if( ( pxCurrentDesc->status & ACT ) != 0 )
if( ( pxCurrentRxDesc->status & ACT ) != 0 )
{
/* Current descriptor is still active. */
}
else if( ( pxCurrentDesc->status & FE ) != 0 )
else if( ( pxCurrentRxDesc->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;
pxCurrentRxDesc->status &= ~( FP1 | FP0 | FE );
pxCurrentRxDesc->status &= ~( RMAF | RRF | RTLF | RTSF | PRE | CERF );
pxCurrentRxDesc->status |= ACT;
pxCurrentRxDesc = pxCurrentRxDesc->next;
if( EDMAC.EDRRR.LONG == 0x00000000UL )
{
@ -461,9 +467,9 @@ unsigned long ulReturn = 0;
{
/* The descriptor contains a frame. Because of the size of the buffers
the frame should always be complete. */
if( ( pxCurrentDesc->status & FP0 ) == FP0 )
if( ( pxCurrentRxDesc->status & FP0 ) == FP0 )
{
ulReturn = pxCurrentDesc->size;
ulReturn = pxCurrentRxDesc->size;
}
else
{
@ -510,12 +516,13 @@ static void prvConfigureEtherCAndEDMAC( void )
#if __LITTLE_ENDIAN__ == 1
EDMAC.EDMR.BIT.DE = 1;
#endif
EDMAC.RDLAR = ( void * ) pxCurrentDesc; /* Initialaize Rx Descriptor List Address */
EDMAC.RDLAR = ( void * ) pxCurrentRxDesc; /* 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) */
ETHERC.ECMR.BIT.PRM = 0; /* Ensure promiscuous mode is off. */
/* Enable the interrupt... */
_IEN( _ETHER_EINT ) = 1;
@ -527,21 +534,16 @@ __interrupt void vEMAC_ISR_Handler( void )
{
unsigned long ul = EDMAC.EESR.LONG;
long lHigherPriorityTaskWoken = pdFALSE;
extern xSemaphoreHandle xEMACSemaphore;
static long ulTxEndInts = 0;
extern xQueueHandle xEMACEventQueue;
const unsigned long ulRxEvent = uipETHERNET_RX_EVENT;
__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;
}
/* Only return the buffer to the pool once both Txes have completed. */
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
}
@ -549,7 +551,7 @@ static long ulTxEndInts = 0;
if( ul & emacRX_END_INTERRUPT )
{
/* Make sure the Ethernet task is not blocked waiting for a packet. */
xSemaphoreGiveFromISR( xEMACSemaphore, &lHigherPriorityTaskWoken );
xQueueSendFromISR( xEMACEventQueue, &ulRxEvent, &lHigherPriorityTaskWoken );
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
}