MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / run

Method run

examples/net_web_server/net_web_server.cpp:82–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 */
81
82 void run() {
83
84 // declare the RTC that that stack requires. it's used for cache timeouts, DHCP lease expiry
85 // and such like so it does not have to be calibrated for accuracy. A few seconds here or there
86 // over a 24 hour period isn't going to make any difference. Start it ticking at zero which is
87 // some way back in 2000 but that doesn't matter to us
88
89 Rtc<RtcLsiClockFeature<Rtc32kHzLsiFrequencyProvider>,RtcSecondInterruptFeature> rtc;
90 rtc.setTick(0);
91
92 // create the RTC time provider for the file system. if writes are made to the card then
93 // this provider will be used to timestamp them.
94
95 _timeProvider=new RtcTimeProvider(rtc);
96
97 // declare the SD card and check for error. the card must be inserted at this point
98
99 _sdcard=new SdioDmaSdCard;
100
101 if(errorProvider.hasError())
102 error();
103
104 // initialise a file system for the card. FAT16 and FAT32 are supported. the card must
105 // already be formatted.
106
107 if(!FileSystem::getInstance(*_sdcard,*_timeProvider,_fs))
108 error();
109
110 // declare an instance of the network stack
111
112 MyNetworkStack::Parameters params;
113 _net=new MyNetworkStack;
114
115 // the stack requires the RTC
116
117 params.base_rtc=&rtc;
118
119 // It's nice to give the DHCP client a host name because then it'll show up in DHCP
120 // 'active leases' page. In a home router this is often called 'attached devices'
121
122 params.dhcp_hostname="stm32plus";
123
124 // increase the number of connections per server
125
126 params.tcp_maxConnectionsPerServer=10;
127
128 // Initialise the stack. This will reset the PHY, initialise the MAC
129 // and attempt to create a link to our link partner. Ensure your cable
130 // is plugged in when you run this or be prepared to handle the error
131
132 if(!_net->initialise(params))
133 error();
134
135 // start the ethernet MAC Tx/Rx DMA channels
136 // this will trigger the DHCP transaction
137
138 if(!_net->startup())
139 error();

Callers 1

mainFunction · 0.45

Calls 7

tcpCreateServerMethod · 0.80
waitMethod · 0.80
setTickMethod · 0.45
hasErrorMethod · 0.45
initialiseMethod · 0.45
startupMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected