Skip to content

Commit

Permalink
实现OSTaskChangePrio函数
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterywolf committed Aug 25, 2020
1 parent e568f90 commit 06c455d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
- 修改`OS_TMR`结构体`.Remain``.Match`成员变量赋值的bug
- 实现3.06版本中新增的`OSTmrSet`函数

### 2020-8-25

- 实现`OSTaskChangePrio`函数,目前兼容层仅1个API没有实现




Expand Down Expand Up @@ -392,6 +396,14 @@



## v0.8.0

**[add]** 实现`OSTaskChangePrio`函数,目前兼容层仅1个API没有实现





# TODO

1. OS_TCB
Expand Down
5 changes: 2 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,11 @@ int main(void) /*RT-Thread main线程*/


# 3 接口
## 3.1 没有实现兼容的API(仅2个
## 3.1 没有实现兼容的API(仅1个

虽然RT-Thread没有任务内建消息队列、任务内建信号量、任务内建寄存器机制,但是本兼容层均已实现,可以正常兼容。但由于RT-Thread没有提供相关接口,**以下μCOS-III API无法兼容**

```c
void OSTaskChangePrio (OS_TCB *p_tcb, OS_PRIO prio_new, OS_ERR *p_err);
void OSTaskTimeQuantaSet (OS_TCB *p_tcb, OS_TICK time_quanta, OS_ERR *p_err);
```
Expand Down Expand Up @@ -817,7 +816,7 @@ INIT_COMPONENT_EXPORT(rt_ucosiii_autoinit);
1. RTX5操作系统兼容层暨CMSIS-RTOSv2接口规范:
> https://github.com/mysterywolf/RT-Thread-wrapper-of-RTX5
> https://github.com/RT-Thread-packages/CMSIS/tree/master/RTOS2/RT-Thread/src
Expand Down
2 changes: 1 addition & 1 deletion uCOS-III_Wrapper/uCOS-III/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ typedef enum os_err {
OS_ERR_STK_OVF = 28210u,

OS_ERR_T = 29000u,
// OS_ERR_TASK_CHANGE_PRIO_ISR = 29001u,
OS_ERR_TASK_CHANGE_PRIO_ISR = 29001u,
OS_ERR_TASK_CREATE_ISR = 29002u,
OS_ERR_TASK_DEL = 29003u, /*原版3.03/3.08中仅定义未使用*/
OS_ERR_TASK_DEL_IDLE = 29004u,
Expand Down
2 changes: 1 addition & 1 deletion uCOS-III_Wrapper/uCOS-III/os_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
#define OS_CFG_STAT_TASK_EN 1u /* Enable (1) or Disable(0) the statistics task */
#define OS_CFG_STAT_TASK_STK_CHK_EN 1u /* Check task stacks from statistic task */

#define OS_CFG_TASK_CHANGE_PRIO_EN 0u /* 只读,该功能无法兼容 Include code for OSTaskChangePrio() */
#define OS_CFG_TASK_CHANGE_PRIO_EN 1u /* Include code for OSTaskChangePrio() */
#define OS_CFG_TASK_DEL_EN 1u /* Include code for OSTaskDel() */
#define OS_CFG_TASK_Q_EN 1u /* Include code for OSTaskQXXXX() */
#define OS_CFG_TASK_Q_PEND_ABORT_EN 1u /* Include code for OSTaskQPendAbort() */
Expand Down
31 changes: 31 additions & 0 deletions uCOS-III_Wrapper/uCOS-III/os_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,37 @@ void OSTaskChangePrio (OS_TCB *p_tcb,
OS_PRIO prio_new,
OS_ERR *p_err)
{
rt_uint8_t rt_priority;
rt_priority = prio_new;

#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return;
}
#endif

#if (OS_CFG_ARG_CHK_EN > 0u)
if ((p_tcb != (OS_TCB *)0) && (p_tcb->TaskState == OS_TASK_STATE_DEL)) {
*p_err = OS_ERR_STATE_INVALID;
return;
}
#endif

#if (OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u)
if (OSIntNestingCtr > 0u) { /* Not allowed to call from an ISR */
*p_err = OS_ERR_TASK_CHANGE_PRIO_ISR;
return;
}
#endif

if (prio_new >= (OS_CFG_PRIO_MAX - 1u)) { /* Cannot set to Idle Task priority */
*p_err = OS_ERR_PRIO_INVALID;
return;
}

rt_thread_control(&(p_tcb->Task), RT_THREAD_CTRL_CHANGE_PRIORITY, &rt_priority);
*p_err = OS_ERR_NONE;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions wiki_CN.html

Large diffs are not rendered by default.

0 comments on commit 06c455d

Please sign in to comment.