...
Type of network buffer | Size |
Receive Large Buffer | 1518 + Alignment |
Transmit Large Buffer | 1618 + Alignment |
Transmit Small Buffer | 156 + Alignment |
Table of Contents |
---|
All μC/TCP-IP device drivers require a configuration structure for each device that must be compiled into your driver. You must place all device configuration structures and declarations within a pair of files named net_dev_cfg.c
and net_dev_cfg.h
.
Micrium provides sample configuration code free of charge; however, most sample code will likely require modification depending on the combination of compiler, processor, evaluation board, and device hardware used.
Memory Configuration
The first step in creating a device driver configuration for µC/TCP-IP begins with the memory configuration structure. This section describes the memory configuration settings for most device drivers, and should provide you an in-depth understanding of memory configuration. You will also discover which settings to modify in order to enhance the performances of the driver.
The listing below shows a sample memory configuration structure.
µC/TCP-IP Memory Management
Memory is allocated to µC/TCP-IP device drivers through the µC/LIB memory module. You must enable and configure the size of the µC/LIB memory heap available to the system. The following configuration constants should be defined from within lib_cfg.h
and set to match the application requirements.
#define LIB_MEM_CFG_ALLOC_EN DEF_ENABLED
#define LIB_MEM_CFG_HEAP_SIZE 58000
The heap size is specified in bytes. If the heap size is not configured large enough, an error will be returned during the Network Protocol Stack initialization, or during interface addition.
Since the needed heap size is related to the stack configuration (net_cfg.h
) and is specific to each device driver, it’s not possible to provide an exact formula to calculate it. Thus to optimize the heap size, you should try different heap size until no error is returned for all interfaces added.
Note: The memory module must be initialized by the application by calling Mem_Init()
prior to calling Net_Init()
. We recommend initializing the memory module before calling OSStart()
, or near the top of the startup task.