nRF51 SDK - S120 SoftDevice
|
The Memory Manager for nRF51 manages static buffers of fixed sizes in RAM. These buffers can be requested for usage, and freed when the application no longer needs them.
The Memory Manager allocates memory of different sizes. The application that requests the memory does not need to have knowledge of how the memory allocation is handled internally.
The Memory Manager defines three pools of buffer sizes, small, medium, and large. The size of each buffer in the pool and the number of available buffers can be configured based on the application needs. The default configurations are:
Parameter | Default value |
---|---|
MEMORY_MANAGER_SMALL_BLOCK_SIZE | 128 |
MEMORY_MANAGER_SMALL_BLOCK_COUNT | 4 |
MEMORY_MANAGER_MEDIUM_BLOCK_SIZE | 512 |
MEMORY_MANAGER_MEDIUM_BLOCK_COUNT | 3 |
MEMORY_MANAGER_LARGE_BLOCK_COUNT | 2056 |
MEMORY_MANAGER_LARGE_BLOCK_SIZE | 1 |
You can disable any of the pools by setting the buffer count for that pool category to zero. For example, if your application does not need large buffers, define MEMORY_MANAGER_LARGE_BLOCK_COUNT to 0.
The application does not need to be aware of which pool was used to allocate the requested memory. The requested memory can be of any size; the application does not need to request a buffer that is equal to the size of one of the pool block sizes. For example, if the Memory Manager uses the default configuration specified above and the application requests a memory buffer of size 480, the Memory Manager determines which pool is most suitable for this size of memory. In this example, the medium block is best suited. However, if no buffers in the medium buffer pool are available, the Memory Manager will attempt to provide the buffer from the next block pool. Therefore, in this example, the application would be assigned a buffer from the large buffer pool.
See the flow chart below for the buffer allocation algorithm that is used. The function that is used to allocate a buffer is called nrf51_sdk_mem_alloc
The following configuration parameters should be defined in sdk_config.h
.
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module. API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
Maximum number of memory blocks identified as small blocks.
Restriction | Value |
---|---|
Minimum value | 0 |
Maximum value | 255 |
Dependencies | None |
Maximum number of memory blocks identified as medium blocks.
Restriction | Value |
---|---|
Minimum value | 0 |
Maximum value | 255 |
Dependencies | None |
Maximum number of memory blocks identified as large blocks.
Restriction | Value |
---|---|
Minimum value | 0 |
Maximum value | 255 |
Dependencies | None |
The size of each memory block identified as small block. The size should be a multiple of the word size.
Restriction | Value |
---|---|
Minimum value | 32 |
Maximum value | MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - 1 |
Dependencies | MEMORY_MANAGER_MEDIUM_BLOCK_SIZE |
Size of each memory block identified as medium block. The size should be a multiple of the word size.
Restriction | Value |
---|---|
Minimum value | MEMORY_MANAGER_SMALL_BLOCK_SIZE + 1 |
Maximum value | MEMORY_MANAGER_LARGE_BLOCK_SIZE - 1 |
Dependencies | MEMORY_MANAGER_LARGE_BLOCK_SIZE, MEMORY_MANAGER_SMALL_BLOCK_SIZE |
The size of each memory block identified as large block. The size should be a multiple of the word size.
Restriction | Value |
---|---|
Minimum value | MEMORY_MANAGER_MEDIUM_BLOCK_SIZE + 1 |
Maximum value | Any value based on availability of RAM. |
Dependencies | MEMORY_MANAGER_LARGE_BLOCK_SIZE |