<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                經過上面的步驟,我們的工程基本就添加完成,但是要想LwIP跑起來,還需一些頭文件的支持,分別是lwipopts.h、cc.h、pref.h等。 lwipopts.h就是用于配置LwIP的相關參數的,一般來說LwIP默認會有參數的配置,存放在opt.h文件中,如果用戶沒有在lwipopts.h文件進行配置,那么LwIP就會使用opt.h默認的參數,注意,在移植的時候出現定義某些參數是非常重要的,這對我們LwIP的性能至關重要,甚至在配置錯誤的時候能直接導致LwIP的運行崩潰,下面一起來看看lwipopts.h文件的內容,這個文件的內容是由我們自己添加進來的,這里僅僅是介紹一部分配置。 我們先在工程的User文件夾下面新建一個arch文件夾,用于存放與底層接口相關的文件,然后打開LwIP的contrib包,把路徑“contrib-2.1.0\\examples\\example\_app”下的lwipopts.h文件拷貝到arch文件夾中;為了方便,我們把cc.h于pref.h也添加進來,這兩個文件也是存放在LwIP的contrib包中,路徑為“contrib-2.1.0\\ports\\unix\\port\\include\\arch”,我們把這些拷貝到arch中,并且將工程的頭文件路徑添加進去,這樣子就能對LwIP進行配置了,具體見圖 7?9。 ![](https://box.kancloud.cn/08942d95d44778e9631db3bc03c88338_475x152.png) 然后我們打開lwipopts.h,并在文件內部寫入以下配置,具體見代碼清單 7?1: ``` 1 #ifndef __LWIPOPTS_H__ 2 #define __LWIPOPTS_H__ 3 4 /** 5 * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain 6 * critical regions during buffer allocation, deallocation and memory 7 * allocation and deallocation. 8 */ 9 #define SYS_LIGHTWEIGHT_PROT 0 10 11 /** 12 * NO_SYS==1: Provides VERY minimal functionality. Otherwise, 13 * use lwIP facilities. 14 */ 15 #define NO_SYS 1 (1) 16 17 /** 18 * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 19 * Mainly for compatibility to old versions. 20 */ 21 #define NO_SYS_NO_TIMERS 0 22 23 /* ---------- Memory options ---------- */ 24 /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which 25 lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 26 byte alignment -> define MEM_ALIGNMENT to 2. */ 27 #define MEM_ALIGNMENT 4 (2) 28 29 /* MEM_SIZE: the size of the heap memory. If the application will send 30 a lot of data that needs to be copied, this should be set high. */ 31 #define MEM_SIZE (30*1024) (3) 32 33 /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application 34 sends a lot of data out of ROM (or other static memory), this 35 should be set high. */ 36 #define MEMP_NUM_PBUF 50 37 /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One 38 per active UDP "connection". */ 39 #define MEMP_NUM_UDP_PCB 6 40 /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP 41 connections. */ 42 #define MEMP_NUM_TCP_PCB 10 43 /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP 44 connections. */ 45 #define MEMP_NUM_TCP_PCB_LISTEN 6 46 /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP 47 segments. */ 48 #define MEMP_NUM_TCP_SEG 12 49 /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active 50 timeouts. */ 51 #define MEMP_NUM_SYS_TIMEOUT 10 52 53 54 /* ---------- Pbuf options ---------- */ 55 /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ 56 #define PBUF_POOL_SIZE 10 (4) 57 58 /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ 59 #define PBUF_POOL_BUFSIZE 500 (5) 60 61 62 /* ---------- TCP options ---------- */ 63 #define LWIP_TCP 1 64 #define TCP_TTL 255 65 66 /* Controls if TCP should queue segments that arrive out of 67 order. Define to 0 if your device is low on memory. */ 68 #define TCP_QUEUE_OOSEQ 0 69 70 /* TCP Maximum segment size. */ 71 #define TCP_MSS (1500 - 40) (6) 72 73 /* TCP sender buffer space (bytes). */ 74 #define TCP_SND_BUF (4*TCP_MSS) (7) 75 76 /* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least 77 as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ 78 79 #define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS) 80 81 /* TCP receive window. */ 82 #define TCP_WND (2*TCP_MSS) (8) 83 84 85 /* ---------- ICMP options ---------- */ 86 #define LWIP_ICMP 1 87 88 89 /* ---------- DHCP options ---------- */ 90 /* Define LWIP_DHCP to 1 if you want DHCP configuration of 91 interfaces. DHCP is not implemented in lwIP 0.5.1, however, so 92 turning this on does currently not work. */ 93 #define LWIP_DHCP 1 94 95 96 /* ---------- UDP options ---------- */ 97 #define LWIP_UDP 1 98 #define UDP_TTL 255 99 100 101 /* ---------- Statistics options ---------- */ 102 #define LWIP_STATS 0 103 #define LWIP_PROVIDE_ERRNO 1 104 105 /* ---------- link callback options ---------- */ 106 /* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface 107 * whenever the link changes (i.e., link down) 108 */ 109 #define LWIP_NETIF_LINK_CALLBACK 0 110 /* 111 -------------------------------------- 112 ---------- Checksum options ---------- 113 -------------------------------------- 114 */ 115 116 /*The STM32F4x7 allows comput 117 ing and verifying the IP, UDP, TCP and ICMP checksums by hardware: 118 - To use this feature let the following define uncommented. 119 - To disable it and process by CPU comment the the checksum. 120 */ 121 #define CHECKSUM_BY_HARDWARE 122 123 124 #ifdef CHECKSUM_BY_HARDWARE 125 /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ 126 #define CHECKSUM_GEN_IP 0 127 /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ 128 #define CHECKSUM_GEN_UDP 0 129 /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ 130 #define CHECKSUM_GEN_TCP 0 131 /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ 132 #define CHECKSUM_CHECK_IP 0 133 /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ 134 #define CHECKSUM_CHECK_UDP 0 135 /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ 136 #define CHECKSUM_CHECK_TCP 0 137 /*CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ 138 #define CHECKSUM_GEN_ICMP 0 139 #else 140 /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ 141 #define CHECKSUM_GEN_IP 1 142 /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ 143 #define CHECKSUM_GEN_UDP 1 144 /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ 145 #define CHECKSUM_GEN_TCP 1 146 /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ 147 #define CHECKSUM_CHECK_IP 1 148 /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ 149 #define CHECKSUM_CHECK_UDP 1 150 /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ 151 #define CHECKSUM_CHECK_TCP 1 152 /*CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/ 153 #define CHECKSUM_GEN_ICMP 1 154 #endif 155 156 157 /* 158 ---------------------------------------------- 159 ---------- Sequential layer options ---------- 160 ---------------------------------------------- 161 */ 162 /** 163 * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) 164 */ 165 #define LWIP_NETCONN 0 (9) 166 167 /* 168 ------------------------------------ 169 ---------- Socket options ---------- 170 ------------------------------------ 171 */ 172 /** 173 * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) 174 */ 175 #define LWIP_SOCKET 0 (10) 176 177 178 /* 179 ---------------------------------------- 180 ---------- Lwip Debug options ---------- 181 ---------------------------------------- 182 */ 183 //#define LWIP_DEBUG 1 184 185 #endif /* __LWIPOPTS_H__ */ 186 187 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ``` (1):NO_SYS表示無操作系統模擬層,這個宏非常重要,因為無操作系統與有操作系統的移植和編寫是完全不一樣的,我們現在是無操作系統移植,所以將這個宏定義為1。 (2):內存對齊,按照4字節對齊。 (3):堆內存的大小。如果應用程序將發送很多需要復制的數據應該設置得大一點。 (4):PBUF_POOL內存池中內存塊數量。 (5):PBUF_POOL內存池中每個內存塊大小。 (6):TCP協議報文最大長度。 (7):允許TCP協議使用的最大發送緩沖區空間(字節)。 (8):TCP接收窗口大小。 (9)(10):因為現在是無操作系統,就不使能NETCONN API和Socket API編程。 cc.h文件中包含處理器相關的變量類型、數據結構及字節對齊的相關宏。 LwIP中使用的基本變量類型均以位數進行命名,為抽象的變量類型定義,開發者需要根據所用處理器及編譯器特性進行定義,一般我們直接將變量直接定義為C語言的基本類型,如unsigned char、int等,這樣子可以保證LwIP協議棧就與平臺無關了。除此之外我們還可以定義大小端模式,輸出調試的宏等,cc.h文件內容具體見代碼清單 7 2: ``` 1 #ifndef __CC_H__ 2 #define __CC_H__ 3 4 #include "stdio.h" 5 6 #include "main.h" 7 8 #define LWIP_NO_STDINT_H 1 9 10 typedef unsigned char u8_t; 11 typedef signed char s8_t; 12 typedef unsigned short u16_t; 13 typedef signed short s16_t; 14 typedef unsigned long u32_t; 15 typedef signed long s32_t; 16 typedef u32_t mem_ptr_t; 17 typedef int sys_prot_t; 18 19 20 #define U16_F "hu" 21 #define S16_F "d" 22 #define X16_F "hx" 23 #define U32_F "u" 24 #define S32_F "d" 25 #define X32_F "x" 26 #define SZT_F "uz" 27 28 29 30 /* 選擇小端模式 */ 31 #define BYTE_ORDER LITTLE_ENDIAN 32 33 /* define compiler specific symbols */ 34 #if defined (__ICCARM__) 35 36 #define PACK_STRUCT_BEGIN 37 #define PACK_STRUCT_STRUCT 38 #define PACK_STRUCT_END 39 #define PACK_STRUCT_FIELD(x) x 40 #define PACK_STRUCT_USE_INCLUDES 41 42 #elif defined (__CC_ARM) 43 44 #define PACK_STRUCT_BEGIN __packed 45 #define PACK_STRUCT_STRUCT 46 #define PACK_STRUCT_END 47 #define PACK_STRUCT_FIELD(x) x 48 49 #elif defined (__GNUC__) 50 51 #define PACK_STRUCT_BEGIN 52 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 53 #define PACK_STRUCT_END 54 #define PACK_STRUCT_FIELD(x) x 55 56 #elif defined (__TASKING__) 57 58 #define PACK_STRUCT_BEGIN 59 #define PACK_STRUCT_STRUCT 60 #define PACK_STRUCT_END 61 #define PACK_STRUCT_FIELD(x) x 62 63 #endif 64 65 66 #define LWIP_PLATFORM_ASSERT(x) do {printf(x);}while(0) 67 68 69 extern u32_t sys_now(void); 70 71 #endif /* __CC_H__ */ ``` perf.h文件是與系統統計與測量相關的頭文件,我們暫時無需使用任何統計與測量功能,因此該頭文件的量宏定義直接為空即可,具體見代碼清單 7?3: ``` 1 #ifndef __PERF_H__ 2 #define __PERF_H__ 3 4 #define PERF_START /* null definition */ 5 #define PERF_STOP(x) /* null definition */ 6 7 #endif /* __PERF_H__ */ ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看