// Provide libspace for current thread
void *__user_perthread_libspace(void)
{
    osThreadId_t id;
    uint32_t     n;

    if (os_kernel_is_active() != 0U) {
        id = osThreadGetId();
        for (n = 0U; n < (uint32_t)OS_THREAD_LIBSPACE_NUM; n++) {
            if (os_libspace_id[n] == NULL) {
                os_libspace_id[n] = id;
            }
            if (os_libspace_id[n] == id) {
                break;
            }
        }
        if (n == (uint32_t)OS_THREAD_LIBSPACE_NUM) {
            (void)osRtxErrorNotify(osRtxErrorClibSpace, id);
        }
    } else {
        n = OS_THREAD_LIBSPACE_NUM;
    }

    //lint -e{9087} "cast between pointers to different object types"
    return (void *)&os_libspace[n][0];
}
示例#2
0
void *__user_perthread_libspace (void) {
  osThreadId_t id;
  uint32_t     n;

  if (!os_kernel_is_active()) {
    return (void *)&os_libspace[OS_THREAD_LIBSPACE_NUM][0];
  }

  id = osThreadGetId();
  for (n = 0U; n < OS_THREAD_LIBSPACE_NUM; n++) {
    if (os_libspace_id[n] == NULL) {
      os_libspace_id[n] = id;
      return (void *)&os_libspace[n][0];
    }
    if (os_libspace_id[n] == id) {
      return (void *)&os_libspace[n][0];
    }
  }

  if (n == OS_THREAD_LIBSPACE_NUM) {
    osRtxErrorNotify(osRtxErrorClibSpace, id);
  }

  return (void *)&os_libspace[n][0];
}
/* Release mutex */
__USED void _mutex_release(mutex *m)
{
    if (os_kernel_is_active() != 0U) {
        (void)osMutexRelease(*m);
    }
}
/* Acquire mutex */
__USED void _mutex_acquire(mutex *m)
{
    if (os_kernel_is_active() != 0U) {
        (void)osMutexAcquire(*m, osWaitForever);
    }
}
示例#5
0
void _mutex_release(mutex *m) {
  if (os_kernel_is_active()) {
    osMutexRelease(*m);
  }
}
示例#6
0
void _mutex_acquire(mutex *m) {
  if (os_kernel_is_active()) {
    osMutexAcquire(*m, osWaitForever);
  }
}