From 96d6da4e252b06dcfdc041e7df23e86161c33007 Mon Sep 17 00:00:00 2001 From: rihab kouki Date: Tue, 28 Jul 2020 11:24:49 +0100 Subject: Official ARM version: v5.6.0 --- docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html | 61 +++++++++++------------ 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html') diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html b/docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html index aacfbb5..b7c9827 100644 --- a/docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html +++ b/docs/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html @@ -303,33 +303,33 @@ size of provided memory for data storage

The size of the memory passed with <

The total amount of memory needed is at least block_count * block_size. Memory from the pool can only be allocated/freed in fixed portions of block_size.

Note
This function cannot be called from Interrupt Service Routines.

Code Example

-
#include "cmsis_os2.h" // CMSIS RTOS header file
+
#include "cmsis_os2.h" // CMSIS RTOS header file
/*----------------------------------------------------------------------------
* Memory Pool creation & usage
*---------------------------------------------------------------------------*/
-
#define MEMPOOL_OBJECTS 16 // number of Memory Pool Objects
+
#define MEMPOOL_OBJECTS 16 // number of Memory Pool Objects
-
typedef struct { // object data type
+
typedef struct { // object data type
uint8_t Buf[32];
uint8_t Idx;
} MEM_BLOCK_t;
-
void Thread_MemPool (void *argument); // thread function
-
osThreadId_t tid_Thread_MemPool; // thread id
+
osMemoryPoolId_t mpid_MemPool; // memory pool id
-
osMemoryPoolId_t mpid_MemPool; // memory pool id
+
osThreadId_t tid_Thread_MemPool; // thread id
-
int Init_MemPool (void)
-
{
+
void Thread_MemPool (void *argument); // thread function
-
mpid_MemPool = osMemoryPoolNew(MEMPOOL_OBJECTS,sizeof(MEM_BLOCK_t), NULL);
+
int Init_MemPool (void) {
+
+
mpid_MemPool = osMemoryPoolNew(MEMPOOL_OBJECTS, sizeof(MEM_BLOCK_t), NULL);
if (mpid_MemPool == NULL) {
; // MemPool object not created, handle failure
}
-
tid_Thread_MemPool = osThreadNew (Thread_MemPool,NULL , NULL);
+
tid_Thread_MemPool = osThreadNew(Thread_MemPool, NULL, NULL);
if (tid_Thread_MemPool == NULL) {
return(-1);
}
@@ -337,33 +337,32 @@ size of provided memory for data storage

The size of the memory passed with <

return(0);
}
-
void Thread_MemPool (void *argument)
-
{
-
osStatus_t status;
-
MEM_BLOCK_t *pMem = 0;
+
void Thread_MemPool (void *argument) {
+
MEM_BLOCK_t *pMem;
+
osStatus_t status;
while (1) {
; // Insert thread code here...
-
pMem = (MEM_BLOCK_t *)osMemoryPoolAlloc (mpid_MemPool, NULL); // get Mem Block
-
if (pMem) { // Mem Block was available
-
pMem->Buf[0] = 0x55; // do some work...
-
pMem->Idx = 0;
+
pMem = (MEM_BLOCK_t *)osMemoryPoolAlloc(mpid_MemPool, 0U); // get Mem Block
+
if (pMem != NULL) { // Mem Block was available
+
pMem->Buf[0] = 0x55U; // do some work...
+
pMem->Idx = 0U;
-
status = osMemoryPoolFree (mpid_MemPool, pMem); // free mem block
+
status = osMemoryPoolFree(mpid_MemPool, pMem); // free mem block
switch (status) {
-
case osOK:
-
break;
- -
break;
- -
break;
-
default:
-
break;
+
case osOK:
+
break;
+ +
break;
+ +
break;
+
default:
+
break;
}
}
-
osThreadYield (); // suspend thread
+
osThreadYield(); // suspend thread
}
}
@@ -479,7 +478,7 @@ May be called from NULL or invalid, block points to invalid memory. -
  • osErrorResource: the memory pool specified by parameter mp_id is in an invalid memory pool state.
  • +
  • osErrorResource: the memory pool is in an invalid state.
  • Note
    osMemoryPoolFree may perform certain checks on the block pointer given. But using osMemoryPoolFree with a pointer other than one received from osMemoryPoolAlloc has UNPREDICTED behaviour.
    @@ -614,7 +613,7 @@ This function may be called from NULL or invalid. -
  • osErrorResource: the memory pool specified by parameter mp_id is in an invalid memory pool state.
  • +
  • osErrorResource: the memory pool is in an invalid state.
  • osErrorISR: osMemoryPoolDelete cannot be called from interrupt service routines.
  • Note
    This function cannot be called from Interrupt Service Routines.
    @@ -626,7 +625,7 @@ This function may be called from
      -