コード例 #1
0
ファイル: cmsis_os.c プロジェクト: 0110/stm32f103playground
/**
 * @brief   Allocate an object clearing it.
 */
void *osPoolCAlloc(osPoolId pool_id) {
  void *object;

  object = chPoolAllocI((memory_pool_t *)pool_id);
  memset(object, 0, pool_id->mp_object_size);
  return object;
}
コード例 #2
0
ファイル: pios_queue.c プロジェクト: EvalZero/TauLabs
/**
 *
 * @brief   Appends an item to a queue from ISR context.
 *
 * @param[in] queuep       pointer to instance of @p struct pios_queue
 * @param[in] itemp        pointer to item which will be appended to the queue
 * @param[in] timeout_ms   timeout for appending item to queue in milliseconds
 *
 * @returns true on success or false on timeout or failure
 *
 */
bool PIOS_Queue_Send_FromISR(struct pios_queue *queuep, const void *itemp, bool *wokenp)
{
	chSysLockFromIsr();
	void *buf = chPoolAllocI(&queuep->mp);
	if (buf == NULL)
	{
		chSysUnlockFromIsr();
		return false;
	}

	memcpy(buf, itemp, queuep->mp.mp_object_size);

	msg_t result = chMBPostI(&queuep->mb, (msg_t)buf);

	if (result != RDY_OK)
	{
		chPoolFreeI(&queuep->mp, buf);
		chSysUnlockFromIsr();
		return false;
	}

	chSysUnlockFromIsr();

	return true;
}
コード例 #3
0
/**
 * @brief   Allocates an object from a memory pool.
 *
 * @param[in] mp        pointer to a @p MemoryPool structure
 * @return              The pointer to the allocated object.
 * @retval NULL         if pool is empty.
 *
 * @api
 */
void *chPoolAlloc(MemoryPool *mp) {
  void *objp;

  chSysLock();
  objp = chPoolAllocI(mp);
  chSysUnlock();
  return objp;
}
コード例 #4
0
ファイル: chmempools.c プロジェクト: hmchen1/ChibiOS
/**
 * @brief   Allocates an object from a memory pool.
 * @pre     The memory pool must be already been initialized.
 *
 * @param[in] mp        pointer to a @p memory_pool_t structure
 * @return              The pointer to the allocated object.
 * @retval NULL         if pool is empty.
 *
 * @api
 */
void *chPoolAlloc(memory_pool_t *mp) {
  void *objp;

  chSysLock();
  objp = chPoolAllocI(mp);
  chSysUnlock();
  return objp;
}
コード例 #5
0
ファイル: cmsis_os.c プロジェクト: 0110/stm32f103playground
/**
 * @brief   Allocate an object.
 */
void *osPoolAlloc(osPoolId pool_id) {
  void *object;

  syssts_t sts = chSysGetStatusAndLockX();
  object = chPoolAllocI((memory_pool_t *)pool_id);
  chSysRestoreStatusX(sts);

  return object;
}
コード例 #6
0
ファイル: chmempools.c プロジェクト: rusefi/ChibiOS
/**
 * @brief   Allocates an object from a guarded memory pool.
 * @pre     The guarded memory pool must already be initialized.
 *
 * @param[in] gmp       pointer to a @p guarded_memory_pool_t structure
 * @param[in] timeout   the number of ticks before the operation timeouts,
 *                      the following special values are allowed:
 *                      - @a TIME_IMMEDIATE immediate timeout.
 *                      - @a TIME_INFINITE no timeout.
 *                      .
 * @return              The pointer to the allocated object.
 * @retval NULL         if the operation timed out.
 *
 * @sclass
 */
void *chGuardedPoolAllocTimeoutS(guarded_memory_pool_t *gmp,
                                 sysinterval_t timeout) {
  msg_t msg;

  msg = chSemWaitTimeoutS(&gmp->sem, timeout);
  if (msg != MSG_OK) {
    return NULL;
  }

  return chPoolAllocI(&gmp->pool);
}
コード例 #7
0
ファイル: ch.cpp プロジェクト: viktorradnai/ChibiOS
void *MemoryPool::allocI(void) {

    return chPoolAllocI(&pool);
}