Skip to content

Commit 5db75d1

Browse files
committed
- Added osMemoryPool functions.
1 parent f68f407 commit 5db75d1

3 files changed

Lines changed: 530 additions & 1 deletion

File tree

ARM.CMSIS-FreeRTOS.pdsc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<license>License/license.txt</license>
99

1010
<releases>
11+
<release version="10.2.1-dev2">
12+
- Added implementation of the osMemoryPool functions using FreeRTOS
13+
</release>
1114
<release version="10.2.1-dev1">
1215
- Updated to FreeRTOS 10.2.1
1316
</release>
@@ -659,6 +662,7 @@
659662
</RTE_Components_h>
660663
<files>
661664
<file category="doc" name="CMSIS/Documentation/General/html/index.html"/>
665+
<file category="header" name="CMSIS/RTOS2/FreeRTOS/Include/freertos_mpool.h"/>
662666
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c"/>
663667
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/ARM/clib_arm.c" condition="ARMCC"/>
664668
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/ARM/clib_arm.c" condition="ARMCC6"/>
@@ -676,6 +680,7 @@
676680
</RTE_Components_h>
677681
<files>
678682
<file category="doc" name="CMSIS/Documentation/General/html/index.html"/>
683+
<file category="header" name="CMSIS/RTOS2/FreeRTOS/Include/freertos_mpool.h"/>
679684
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c"/>
680685
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/ARM/clib_arm.c" condition="ARMCC"/>
681686
<file category="source" name="CMSIS/RTOS2/FreeRTOS/Source/ARM/clib_arm.c" condition="ARMCC6"/>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* --------------------------------------------------------------------------
2+
* Copyright (c) 2013-2019 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Name: freertos_mpool.h
19+
* Purpose: CMSIS RTOS2 wrapper for FreeRTOS
20+
*
21+
*---------------------------------------------------------------------------*/
22+
23+
#ifndef FREERTOS_MPOOL_H_
24+
#define FREERTOS_MPOOL_H_
25+
26+
#include <stdint.h>
27+
#include "FreeRTOS.h"
28+
#include "semphr.h"
29+
30+
/* Memory Pool implementation definitions */
31+
#define MPOOL_STATUS 0x5EED0000U
32+
#define MPOOL_SEM StaticSemaphore_t
33+
34+
/* Memory Block header */
35+
typedef struct {
36+
void *next; /* Pointer to next block */
37+
} MPOOL_BLOCK;
38+
39+
/* Memory Pool control block */
40+
typedef struct MemPoolDef_t {
41+
MPOOL_BLOCK *head; /* Pointer to head block */
42+
MPOOL_SEM sem; /* Pool semaphore object */
43+
uint8_t *mem_arr; /* Pool memory array */
44+
uint32_t mem_sz; /* Pool memory array size */
45+
const
46+
char *name; /* Pointer to name string */
47+
uint32_t bl_sz; /* Size of a single block */
48+
uint32_t bl_cnt; /* Number of blocks */
49+
uint32_t n; /* Block allocation index */
50+
volatile
51+
uint32_t status; /* Object status flags */
52+
} MemPool_t;
53+
54+
/* No need to hide static object type, just align to coding style */
55+
#define StaticMemPool_t MemPool_t
56+
57+
/* Define memory pool control block size */
58+
#define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t))
59+
60+
/* Define size of the byte array required to create count of blocks of given size */
61+
#define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count))
62+
63+
#endif /* FREERTOS_MPOOL_H_ */

0 commit comments

Comments
 (0)