add cosit api

This commit is contained in:
supowang 2024-01-17 12:51:35 +08:00
parent f468283f6e
commit 5ec723a2a6
21 changed files with 6601 additions and 0 deletions

54
osal/cosit/.gitignore vendored Normal file
View File

@ -0,0 +1,54 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
.DS_Store

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

201
osal/cosit/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

18
osal/cosit/README.md Normal file
View File

@ -0,0 +1,18 @@
# Cross-Operating System Interface on ioT
#### 介绍
围绕物联网操作系统的内核抽象层接口、应用接口和硬件抽象层接口,制定接口实现
#### 软件架构
![输入图片说明](IoT%20OS%E8%BD%AF%E4%BB%B6%E6%9E%B6%E6%9E%84.png)
#### 参与贡献
1. Fork 本仓库
2. 新建分支
3. 提交代码
4. 新建 Pull Request

View File

View File

@ -0,0 +1,105 @@
定义的API/宏/枚举常量等统一采用前缀**cos**以保证命名空间的独立性不会与其他SDK/BSP内的名称重复。注意API采用小写cos_xxx 宏/枚举采用大写COS_XXX.
# 设计目标
标准的设计目标要达到,开发者只需要查看一个模块的标准文档,就能了解模块的功能是什么,如何使用,使用时的注意事项。开发者不需要查看代码具体实现,甚至不需要查看其他资料,就可以进行应用的开发,并最终可以无缝迁移到支持该标准的平台。
# 命名规则
### 命名风格
统一采用linux命名风格即API字母全小写字段之间加下划线分割。如`cos_task_create/cos_mutex_create/cos_queue_send` 。
宏和枚举变量采用全大写和下划线分割的形式,如`COS_WAIT_FOREVER` 。
### API命名
遵循名词在前,动词在后。
`cos_<component>_[feature]_<action>`
cos标准的统一前缀
component: 必选的组件名称。如task/mutex/queue
feature: 可选的组件内部子特性或子名称如task组件内的name/priority
action: 必选的, API的动作如get/set/send/recv/
命名举例
- cos_task_create
- cos_task_name_get
- cos_mutex_lock
### API术语
一些API命名时术语可以参考行业各家OS的术语及其他标准CMSIS/POSIX的术语。可以使用行业内标准缩写。
**create/delete**
每次调用都会创建一个新的实例的情形使用create且句柄作为出参。删除实例使用delete。
```C
cos_status_t cos_task_create(cos_task_t *task, cos_task_entry_t fn, void *arg, cos_task_attr_t *attr)
cos_status_t cos_task_delete(cos_task_t task)
```
**init/deinit**
只能进行一次的初始化如接口初始化硬件初始化等使用init句柄作为入参且句柄可省略。 反初始化使用deinit
```C
cos_status_t cos_init(void)
void cos_deinit(void)
```
# 数据类型
关于API使用的基本数据类型统一采用标准数据类型。
对于基本正数采用stdint.h中定义的数据类型
- int8_t
- uint8_t
- int16_t
- uint16_t
- int32_t
- uint32_t
- int64_t
- uint64_t
- uintptr_t
- intprt_t
和长度相关的数据类型
- size_t
- ssize_t
基本指针类型,不做限制如
- char *
- void *
内核对象的句柄
- cos_xxx_t *
如cos_task_t/cos_mutex_t/cos_sem_t/cos_queue_t等。
统一的错误码类型
- cos_status_t
其他
- bool
# 错误码
标准应采用统一的错误码,支持可扩展。采用`cos_status_t`数据类型所有的错误码均为负值。返回0代表成功。
一些例外如类似read/write API返回ssize_t类型> 0 代表长度,< 0代表失败
# 模块描述
标准中对一个功能模块的描述,应包含以下这些内容。
## 模块功能描述
包括解释模块功能是什么,阐述工作原理,使用功能的场景及其注意事项。
## 模块常量定义
包括模块定义的宏和枚举常量,命名全大写和下划线,统一**cos_**前缀。
## 模块数据类型定义
包括模块定义的复合数据类型。全小写,统一**cos_**前缀。
## 模块API描述内容
对一个API的描述需要完整清晰表达没有歧义。包括如下内容章节。
1. API名称和简短说明
2. API原型
API的原型申明和应该使用该API时需要包含的头文件。
3. API的详细描述
4. API的参数
包括参数名称,参数类型,参数方向,参数详细描述这几个要素。
5. API的返回值
包括API的返回值及其代表的含义。
6. API的使用注意
包括API的使用注意事项例如能否在中断上下文中使用等。
7. 使用举例
给出使用该API的例子。

View File

@ -0,0 +1,704 @@
## 5.4. 互斥量
互斥量又称互斥锁,一般用于共享资源的互斥排他性访问保护。
互斥量在任意时刻处于且仅会处于解锁或锁定状态,当一个任务获取到一把锁后(互斥量锁定),其他任务再尝试获得这把锁时会失败或进入阻塞状态,当该任务释放持有的锁时(互斥量解锁),会唤醒一个正阻塞等待此互斥量的任务,被唤醒的任务将会获取这把锁。
在多任务运行环境中,有些共享资源不具有多线程可重入性,对于这类不希望被多任务同时访问的资源(临界资源),可以采用互斥量来进行保护。
### 5.4.1. 常量
#### 5.4.1.1. COS_MUTEX_NEST
```c
#define COS_MUTEX_NEST (0x1u << 0)
```
互斥锁支持嵌套锁。
### 5.4.2. 类型
#### 5.4.2.1. cos_mutex_t
互斥锁的句柄,代表一个互斥锁。可以通过句柄对互斥锁进行操作,如创建、申请、释放、销毁。
```c
typedef void * cos_mutex_t;
```
### 5.4.3. 函数
#### 5.4.3.1. cos_mutex_create
互斥锁创建
**函数原型**
```c
cos_status_t cos_mutex_create(cos_mutex_t *mutex, char *name, uint32_t options);
```
**描述**
创建一个新的互斥锁并初始化新的互斥锁的句柄由参数mutex返回后续对互斥锁的操作可以通过参数mutex进行。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|出参|互斥锁句柄|
|name|入参|互斥锁名称|
|options|入参|互斥锁选项,如是否支持嵌套锁|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
|COS_ERR_PARAM|非法参数|
**注意**
此函数不能在中断上下文中使用。
#### 5.4.3.2. cos_mutex_init
初始化一个互斥锁
**函数原型**
```c
cos_status_t cos_mutex_init(cos_mutex_t mutex, char *name, uint32_t options);
```
**描述**
初始化一个新的互斥锁。
与创建一个互斥锁类型,区别是互斥锁的控制块内存由调用者传入,一般用于静态分配内存的场景。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|入参|互斥锁的句柄|
|name|入参|互斥锁名称|
|options|入参|互斥锁选项,如是否支持嵌套锁|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
|COS_ERR_PARAM|非法参数|
**注意**
此函数不能在中断上下文中使用。
#### 5.4.3.3. cos_mutex_delete
删除动态创建的互斥锁
**函数原型**
```c
cos_status_t cos_mutex_delete(cos_mutex_t mutex);
```
**描述**
销毁互斥锁。系统会唤醒所有等待该互斥锁的任务,返回互斥锁已经被销毁,然后销毁回收其资源。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|cos_mutex_t|入参|互斥锁的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.4.3.4. cos_mutex_deinit
销毁静态创建的互斥锁
**函数原型**
```c
cos_status_t cos_mutex_deinit(cos_mutex_t mutex);
```
**描述**
销毁静态创建的互斥锁。系统会唤醒所有等待该互斥锁的任务,返回互斥锁已经被销毁。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|cos_mutex_t|入参|互斥锁的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.4.3.5. cos_mutex_lock
互斥锁上锁
**函数原型**
```c
cos_status_t cos_mutex_lock(cos_mutex_t mutex, cos_tick_t timeout);
```
**描述**
申请互斥锁。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|入参|互斥锁的句柄|
|timeout|入参|申请超时时间单位为tick|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_TIMEOUT|申请超时|
|COS_ERR_DESTROY|申请的互斥锁已被销毁|
|COS_ERR_MUTEX_NESTING|已经拥有互斥锁,嵌套申请|
**注意**
此函数不能在中断上下文中使用。
#### 5.4.3.6. cos_mutex_unlock
互斥锁解锁
**函数原型**
```c
cos_status_t cos_mutex_unlock(cos_mutex_t mutex);
```
**描述**
互斥锁解锁。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|mutex|入参|互斥锁的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_DESTROY|释放的互斥锁已被销毁|
|COS_ERR_MUTEX_NOT_OWNER|未持有该互斥锁|
|COS_ERR_MUTEX_NESTING|已经释放互斥锁,但还在嵌套中|
### 5.4.4. 示例
```c
```
## 5.5. 信号量
信号量是一种实现任务间同步的机制,一般用于多个任务间有限资源竞争访问。
通常来说一个信号量中持有一个整形数值用以表示可用资源的数量。当一个信号量的可用资源数量大于0时任务尝试获取该信号量成功信号量的可用资源数减一当一个信号量的可用资源数等于0时任务尝试获取该信号量失败或进入阻塞状态。信号量的这一模式当可用资源数为1时可将其用于资源的互斥访问或者解决生产者-消费者问题中的资源生产-消费问题。编程实例章节会演示生产者-消费者问题的解决范式。
### 5.5.1. 常量
#### 5.5.1.1. COS_SEM_NO_MAX
```c
#define COS_SEM_NO_MAX (uint32_t)-1
```
信号量无最大值,可以用作计数信号量。
### 5.5.2. 类型
#### 5.5.2.1. cos_sem_t
```c
typedef void * cos_sem_t;
```
信号量的句柄,代表一个信号量。可以通过句柄对信号量进行操作,如创建、等待、释放、销毁。
### 5.5.3. 函数
#### 5.5.3.1. cos_sem_create
创建一个信号量
**函数原型**
```c
cos_status_t cos_sem_create(cos_sem_t *sem, char *name, uint32_t init_count, uint32_t max_count);
```
**描述**
创建一个新的信号量并初始化新的信号量的句柄由参数sem返回后续对信号量的操作可以通过参数sem进行。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|出参|信号量句柄|
|name|入参|信号量的名称|
|init_count|入参|信号量初始值|
|max_count|入参|信号量最大值|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
|COS_ERR_PARAM|非法参数|
**注意**
此函数不能在中断上下文中使用。
#### 5.5.3.2. cos_sem_init
初始化一个信号量
**函数原型**
```c
cos_status_t cos_sem_init(cos_sem_t sem, char *name, uint32_t init_count, uint32_t max_count);
```
**描述**
初始化一个信号量
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量句柄|
|name|入参|信号量的名称|
|init_count|入参|信号量初始值|
|max_count|入参|信号量最大值|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
|COS_ERR_PARAM|非法参数|
**注意**
此函数不能在中断上下文中使用。
#### 5.5.3.3. cos_sem_delete
删除动态创建的信号量
**函数原型**
```c
cos_status_t cos_sem_delete(cos_sem_t sem);
```
**描述**
删除动态创建的信号量。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.5.3.4. cos_sem_deinit
销毁静态创建的信号量
**函数原型**
```c
cos_status_t cos_sem_deinit(cos_sem_t sem);
```
**描述**
销毁静态创建的信号量。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.5.3.5. cos_sem_wait
等待信号量
**函数原型**
```c
cos_status_t cos_sem_wait(cos_sem_t *sem, cos_tick_t timeout);
```
**描述**
等待信号量。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量的句柄|
|timeout|入参|申请超时时间单位为tick|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_TIMEOUT|申请超时|
|COS_ERR_DESTROY|申请的信号量已被销毁|
**注意**
此函数不能在中断上下文中使用。
#### 5.5.3.6. cos_sem_release
释放信号量
**函数原型**
```c
cos_status_t cos_sem_release(cos_sem_t sem);
```
**描述**
释放信号量。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_DESTROY|释放的信号量已被销毁|
#### 5.5.3.7. cos_sem_release_all
释放信号量
**函数原型**
```c
cos_status_t cos_sem_release_all(cos_sem_t sem);
```
**描述**
释放信号量,并唤醒所有等待该信号量的任务。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|sem|入参|信号量的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_DESTROY|释放的信号量已被销毁|
### 5.5.4. 示例
```c
```
## 5.6. 事件
事件提供了一种任务间实现同步和信息传递的机制。一般来说,一个事件中包含了一个旗标,这个旗标的每一位表示一个“事件”。
一个任务可以等待一个或者多个“事件”的发生,其他任务在一定的业务条件下可以通过写入特定“事件”唤醒等待此“事件”的任务,实现一种类似信号的编程范式。
### 5.6.1. 常量
#### 5.6.1.1. COS_EVENT_WAIT_ANY
```c
#define COS_EVENT_WAIT_ANY (0x1u << 0)
```
等待事件时,用于指定等待其中任意一个。
#### 5.6.1.2. COS_EVENT_WAIT_ALL
```c
#define COS_EVENT_WAIT_ALL (0x1u << 1)
```
等待事件时,用于指定等待所有事件。
#### 5.6.1.3. COS_EVENT_WAIT_CLR
```c
#define COS_EVENT_WAIT_CLR (0x1u << 2)
```
等待事件时,用于指定等待后清除该事件。
#### 5.6.1.4. COS_EVENT_RELEASE_KEEP
```c
#define COS_EVENT_RELEASE_KEEP (0x1u << 3)
```
释放事件时,用于指定释放后是否保留该事件。
### 5.6.2. 类型
#### 5.6.2.1. cos_event_t
```c
typedef void * cos_event_t;
```
事件的句柄,代表一个事件。可以通过句柄对事件进行操作,如创建、等待、释放、销毁。
#### 5.6.2.2. cos_event_flag_t
```c
typedef uint32_t cos_event_flag_t;
```
用于存储事件标志。
### 5.6.3. 函数
#### 5.6.3.1. cos_event_create
事件创建
**函数原型**
```c
cos_status_t cos_event_create(cos_event_t *event, char *name, cos_event_flag_t init_flag);
```
**描述**
创建一个新的事件并初始化新的事件的句柄由参数event返回后续对事件的操作可以通过参数event进行。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|出参|事件的句柄|
|name|入参|事件的名称|
|init_flag|入参|事件初始化标志|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
**注意**
此函数不能在中断上下文中使用。
#### 5.6.3.2. cos_event_init
初始化一个事件
**函数原型**
```c
cos_status_t cos_event_init(cos_event_t event, char *name, cos_event_flag_t init_flag);
```
**描述**
初始化一个事件
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|入参|事件的句柄|
|name|入参|事件的名称|
|init_flag|入参|事件初始化标志|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_NOMEM|内存不足|
**注意**
此函数不能在中断上下文中使用。
#### 5.6.3.3. cos_event_delete
删除动态创建的事件
**函数原型**
```c
cos_status_t cos_event_delete(cos_event_t event);
```
**描述**
删除动态创建的事件。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|入参|事件的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.6.3.4. cos_event_deinit
销毁事件
**函数原型**
```c
cos_status_t cos_event_deinit(cos_event_t event);
```
**描述**
销毁静态创建的事件。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|入参|事件的句柄|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
#### 5.6.3.5. cos_event_wait
等待一个或多个事件。
**函数原型**
```c
cos_status_t cos_event_wait(cos_event_t event, cos_event_flag_t expect_flag, cos_tick_t timeout, cos_event_flag_t *match_flag, uint32_t options);
```
**描述**
等待一个或多个事件。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|入参|事件的句柄|
|expect_flag|入参|期望等到的事件|
|timeout|入参|申请超时时间单位为tick|
|match_flag|出参|事件的匹配结果|
|options|入参|事件匹配选项(任意一个匹配或者全部匹配)|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_ISR|在中断上下文中调用|
|COS_ERR_TIMEOUT|申请超时|
|COS_ERR_DESTROY|事件已被销毁|
**注意**
此函数不能在中断上下文中使用。
#### 5.6.3.6. cos_event_release
释放事件
**函数原型**
```c
cos_status_t cos_event_release(cos_event_t event, cos_event_flag_t flag, uint32_t options);
```
**描述**
释放事件。
**参数**
|参数名称|参数方向|描述|
|:----:|:----:|:----:|
|event|入参|事件的句柄|
|expect_flag|入参|释放的事件|
|options|入参|事件释放选项,释放后是否保留|
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
|错误码|描述|
|:---:|:---:|
|COS_ERR|未知错误|
|COS_ERR_DESTROY|事件已被销毁|
### 5.6.4. 示例
```c
```

View File

@ -0,0 +1,191 @@
# 邮箱
消息邮箱Mail Box是实时操作系统中一种典型的线程间通信方法邮箱用于线程间通信特点是开销比较低效率较高。
## 类型
```C
typedef void * cos_mb_t;
```
邮箱控制块是操作系统用于管理邮箱的一个数据结构cos_mb_t是邮箱的句柄。
## 函数
### cos_mb_create
创建邮箱
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_create(const char* name, size_t msg_size,
uint8_t flagcos_mb_t* mb);
```
**描述**
创建一个邮箱,由系统动态为邮箱申请内存空间,并返回邮箱的句柄。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| name | const char* | 入参 | 邮箱名称 |
| msg_size | sizebt | 入参 | 邮箱容量 |
| flag | uint8_t | 入参 | 邮箱标志,如: COS_IPC_FLAG_FIFO 或 COS_IPC_FLAG_PRIO |
| mb | cos_mb_t | 出参 | 邮箱句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERROR_MEM | 内存不足 |
### cos_mb_delete
删除邮箱
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_delete(cos_mb_t mb);
```
**描述**
删除一个邮箱。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mb | cos_mb_t | 入参 | 邮箱的句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mb_init
初始化邮箱
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_init(const char* name, void *msgpool, size_t msg_size,
size_t max_msgs, cos_mb_t mb);
```
**描述**
创建一个静态邮箱,由编译器提前为邮箱在编译时分配内存空间。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | --------------------------- |
| name | const char* | 入参 | 邮箱的名称 |
| msgpool | void* | 入参 | 缓冲区指针 |
| msg_size | size_t | 入参 | 邮箱容量 |
| flag | uint8_t | 入参 | 邮箱工作方式 cos_IPC_FLAG_FIFO 或 cos_IPC_FLAG_PRIO |
| mb | cos_mb_t | 出参 | 邮箱句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mb_deinit
删除邮箱
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_deinit(cos_mb_t mb);
```
**描述**
去初始化一个邮箱。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mb | cos_mb_t | 入参 | 邮箱的句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mb_send
发送邮件
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_send(cos_mb_t mbuint32_t value);
```
**描述**
发送邮件,当邮箱中的邮件已经满时,发送邮件的线程或者中断程序会收到 cos_ERROR_mb_FULL 的返回值。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mb | cos_mb_t | 入参 | 邮箱的句柄 |
| value | uint32_t | 入参 | 邮件内容 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERROR_mb_FULL | 邮箱中的邮已满 |
### cos_mb_recive
接收邮件
原型
```C
#include <cos_mb.h>
cos_status_t cos_mb_recv(cos_mb_t mbuint32_t* value,
int32_t timeout);
```
**描述**
当邮箱中有邮件时,接收者才能接收邮件,否则接收者会根据超时时间设置,或挂起在邮箱的等待线程队列上,或直接返回。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mb | cos_mb_t | 入参 | 邮箱的句柄 |
| value | void* | 入参 | 邮件内容 |
| timeout | int32_t | 入参 | 指定的超时时间 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERROR_mb_TIMEOUT | 超时 |

View File

@ -0,0 +1,198 @@
# 消息队列
消息队列Message Queue是一种常见的异步任务间通讯方式用于在任务与任务间任务与中断间传递不定长的数据。任务能够从队列里面读取消息当队列中的消息为空时挂起读取任务当队列中有新消息时挂起的读取任务被唤醒并处理新消息。任务也能够往队列里写入消息当队列已经写满消息时挂起写入任务当队列中有空闲消息节点时挂起的写入任务被唤醒并写入消息。
## 类型
```C
typedef struct cos_messagequeue* cos_mq_t;
```
消息队列控制块消息队列控制块是操作系统用于管理消息队列的一个数据机构由结构体cos_messagequeue表示cos_mq_t是消息队列的句柄。
## 函数
### cos_mq_create
创建消息队列
原型
```C
#include <cos_mq.h>
cos_status_t cos_mq_create(const char* name, size_t msg_size,
size_t max_msgs, uint8_t flagcos_mq_t* mq);
```
**描述**
创建一个消息队列,由系统动态为消息队列申请内存空间,并返回消息队列的句柄。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| name | const char* | 入参 | 消息队列的名称 |
| msg_size | size_t | 入参 | 单条消息的最大长度 |
| max_msgs | size_t | 入参 | 消息队列的最大个数 |
| flag | uint8_t | 入参 | 消息队列工作方式 COS_IPC_FLAG_FIFO 或 COS_IPC_FLAG_PRIO |
| mq | cos_mq_t | 出参 | 消息队列句柄 |
**返回值**
函数执行成功返回COS_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERR_NOMEM | 内存不足 |
| COS_ERR_ISR | 在中断上下文中调用 |
| COS_ERR | 未知错误 |
### cos_mq_init
创建消息队列
init
```C
#include <cos_mq.h>
cos_status_t cos_mq_init(const char* name, void *msgpool, size_t msg_size,
size_t max_msgs, cos_mq_t mq);
```
**描述**
创建一个静态消息队列,由编译器提前为消息队列在编译时分配内存空间。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | --------------------------- |
| name | const char* | 入参 | 消息队列的名称 |
| msgpool | void* | 入参 | 指向存放消息的缓冲区的指针 |
| msg_size | size_t | 入参 | 单条消息的最大长度,单位字节 |
| flag | uint8_t | 入参 | 消息队列工作方式 cos_IPC_FLAG_FIFO 或 cos_IPC_FLAG_PRIO |
| mq | cos_mq_t | 出参 | 消息队列句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mq_delete
删除消息队列
原型
```C
#include <cos_mq.h>
cos_status_t cos_mq_delete(cos_mq_t mq);
```
**描述**
删除一个消息队列。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mq | cos_mq_t | 入参 | 消息队列的句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mq_deinit
去初始化消息队列
原型
```C
#include <cos_mq.h>
cos_status_t cos_mq_deinit(cos_mq_t mq);
```
**描述**
去初始化一个消息队列。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mq | cos_mq_t | 入参 | 消息队列的句柄 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
### cos_mq_send
发送消息
原型
```C
#include <cos_mq.h>
cos_status_t cos_mq_send(cos_mq_t mqvoid* buffer, size_t size);
```
**描述**
发送消息,线程或者中断服务程序都可以给消息队列发送消息。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mq | cos_mq_t | 入参 | 消息队列的句柄 |
| buffer | void* | 入参 | 消息内容 |
| size | size_t | 入参 | 消息大小 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERROR_MQ_DELETED | 线程挂起时消息队列已被删除 |
| COS_ERROR_MQ_FULL | 消息队列已满 |
### cos_mq_recive
接收消息
原型
```C
#include <cos_mq.h>
cos_status_t cos_mq_recv(cos_mq_t mqvoid* buffer,
size_t sizeint32_t timeout);
```
**描述**
当消息队列中有消息时,接收者才能接收消息,否则接收者会根据超时时间设置,或挂起在消息队列的等待线程队列上,或直接返回。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| mq | cos_mq_t | 入参 | 消息队列的句柄 |
| buffer | void* | 入参 | 消息内容 |
| size | size_t | 入参 | 消息大小 |
| timeout | int32_t | 入参 | 指定的超时时间 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| COS_ERROR_PARAM | 非法参数 |
| COS_ERROR_MQ_TIMEOUT | 超时 |
| COS_ERROR_PARAM | 消息队列已满 |
| COS_ERROR_MQ_DELETED | 线程挂起时消息队列已被删除 |

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
# 工作队列
工作队列workqueue是一种转移任务执行环境的工具例如当系统产生一个中断时我们可以在中断处理函数里做一些紧急地操作然后将另外一些不那么紧急而且需要一定时间的任务封装成函数交给工作队列执行此时该函数的执行环境就从 中断环境 变成了 线程环境,即中断处理 “下半部”。
## 类型
```C
typedef struct cos_workqueue* cos_wq_t;
```
工作队列控制块工作队列控制块是操作系统用于管理工作队列的一个数据结构由结构体cos_workqueue表示cos_wq_t是工作队列的句柄工作队列结构体主要保存了当前系统工作队列的相关信息如:当前工作项,工作队列的链表,工作队列所使用的线程等。
```C
typedef struct cos_work* cos_work_t;
```
工作项控制块,工作项控制块用于管理该任务,保存了该任务相关的信息,如:任务函数,用户数据等,当该工作项被执行时就会调用该任务函数。
```C
typedef void cos_work_handle_t(void *arg);
```
工作项控制块,工作项控制块用于管理该任务,保存了该任务相关的信息,如:任务函数,用户数据等,当该工作项被执行时就会调用该任务函数。
## 函数
### cos_work_init
初始化工作项
原型
```C
#include <cos_wq.h>
cos_status_t cos_work_init(cos_work_t work, cos_work_handle_t work_func, void *work_data);
```
**描述**
该接口初始化 work 指针指向的工作项,并绑定回调函数 work_func 以及用户自定义数据 work_data。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| work | cos_work_t | 入参 | 工作项 |
| work_func | cos_work_handle_t | 入参 | 工作项的回调函数 |
| work_data | size_t | 入参 | 用户自定义数据,回调函数参数 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |
### cos_work_dowork
触发work
原型
```C
#include <cos_wq.h>
cos_status_t cos_work_dowork(cos_work_t work, cos_tick_t time);
```
**描述**
work触发函数由系统默认工作队列来执行。若 time 大于 0则提交过程会延时 time 个 ticks 。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| work | cos_work_t | 入参 | 工作项 |
| time | cos_tick_t | 入参 | 提交延时,以 tick 为单位 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |
### cos_work_submit
向 queue 提交work
原型
```C
#include <cos_wq.h>
cos_status_t cos_work_submit(cos_wq_t wq, cos_work_t work, cos_tick_t time);
```
**描述**
将 work 指向的工作项提交到 queue 指向的工作队列中,若 time 大于 0则该提交延时 time 个 tick 之后执行。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| wq | cos_wq_t | 入参 | 工作队列 |
| work | cos_work_t | 入参 | 工作项 |
| time | cos_tick_t | 入参 | 提交延时,以 tick 为单位 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |
### cos_work_cancel
取消指定工作项
原型
```C
#include <cos_wq.h>
cos_status_t cos_work_cancel(cos_wq_t queue, cos_work_t work);
```
**描述**
从 queue 指向的工作队列中将 work 指向的工作项移除。
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| queue | cos_wq_t | 入参 | 工作队列 |
| work | cos_work_t | 入参 | 工作项 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |
| cos_ERROR_BUSY | 该工作项正在执行 |
### cos_workqueue_create
工作队列创建函数
原型
```C
#include <cos_wq.h>
cos_status_t cos_workqueue_create(cos_wq_t* wq, const char *name uint16_t stack_size, uint8_t priority);
```
**描述**
该函数创建并初始化一个工作队列,利用参数 namestack_size 和 priority 创建工作队列内部线程,最终返回创建的工作队列。下表描述了该函数的输入参数与返回值
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| wq | cos_wq_t | 出参 | 工作队列控制块 |
| name | const char * | 入参 | 线程名字 |
| stack_size | uint16_t | 入参 | 线程栈大小 |
| priority | uint8_t | 入参 | 线程优先级 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |
### cos_workqueue_destroy
工作队列销毁函数
原型
```C
#include <cos_wq.h>
cos_status_t cos_workqueue_destroy(cos_wq_t wq);
```
**描述**
销毁指定工作队列
**参数**
| 参数名称 | 参数类型 | 参数方向 | 描述 |
| ----------- | ----------- | ------------------ | ------------------ |
| wq | cos_wq_t | 入参 | 工作队列控制块 |
**返回值**
函数执行成功返回cos_OK失败则返回错误码均为负值
| 参数名称 | 描述 |
| ----------- | ------------------ |
| cos_ERROR_PARAM | 非法参数 |

1612
osal/cosit/include/cosit.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) XXXX
*
* SPDX-License-Identifier: XXXX
*
* Version: 1.0.0
*
* Change log:
*
* Date Author Note
* 2022-07-12 all first version
*/
#ifndef _COSIT_PORT_TYPES_H
#define _COSIT_PORT_TYPES_H
//#define COS_USE_AOS /* AliOS Things */
//#define COS_USE_TOS /* TencentOS-tiny */
//#define COS_USE_RTTHREAD /* RT-Thread */
/* 提供统一的内核对象类型名称为调用静态内存API前先开辟合适大小的内存同时屏蔽底层OS的差异
* APIcos_task_init, cos_timer_init, cos_mb_init, cos_mq_init, cos_work_init,
* cos_mutex_init, cos_sem_init, cos_event_init
* 使API时需要此头文件
*
* 使
* cos_sem_real_t test_sem;
* ret = cos_sem_init((cos_sem_t)&test_sem, "test_sem", 1, 0xffff);
* cos_sem_wait((cos_sem_t)&test_sem, COS_WAIT_FOREVER);
*/
#ifdef COS_USE_AOS
#include <k_api.h>
/* 提供底层OS内核对象的真实数据类型, 用于 */
typedef ktask_t cos_task_real_t;
typedef ktimer_t cos_timer_real_t;
typedef kmutex_t cos_mutex_real_t;
typedef ksem_t cos_sem_real_t;
typedef kevent_t cos_event_real_t;
typedef kbuf_queue_t cos_mq_real_t;
typedef kqueue_t cos_mb_real_t;
typedef kwork_t cos_work_real_t;
typedef kworkqueue_t cos_wq_real_t;
#elif defined (COS_USE_TOS)
#include "tos_k.h"
typedef k_task_t cos_task_real_t;
typedef k_timer_t cos_timer_real_t;
typedef k_mutex_t cos_mutex_real_t;
typedef k_sem_t cos_sem_real_t;
typedef k_event_t cos_event_real_t;
typedef k_mail_q_t cos_mq_real_t;
typedef k_msg_q_t cos_mb_real_t;
#elif defined (COS_USE_RTTHREAD)
#else
#warning "The underlying OS is not defined, so you should take care of the real type of kernel object."
#endif
#endif /*_COSIT_PORT_TYPES_H*/

View File

@ -0,0 +1,15 @@
# 5月7日会议结论
1、API前缀统一为COS
- 对应更新API前缀 @RTT
2、消息邮箱API5月11日前提交 @RTT
3、头文件5月11日在群里讨论确定 @阿里、腾讯、RTT、展锐
4、create/delete, init/deinit分开两对写 @阿里、腾讯、RTT
5、通用错误码不带上模块名各个Owner分别更新API @阿里、腾讯、RTT
**下次会议5月31日对焦实现进展**

View File

@ -0,0 +1,24 @@
# 5月31日会议结论
进展
1. 腾讯实现了任务管理;下次会议可以完成
2. RTT实现了消息队列、邮箱下次会议可以完成
Issue:
1. 在头文件里补充错误码 @阿里
2. COS_EVENT_RELEASE_KEEP腾讯check下是否说明了该API的功能@腾讯
3. 所有静态的API如何隐藏底层具体OS内核的数据类型例如cos_mutex_init/cos_sem_init等调研其他标准如何实现@阿里
会上讨论的技术结论:
1. 内核对象的参数均为第一个参数,大家保持一致。 比如cos_mq_create/cos_mq_init的 mq参数cos_mb_create/cos_mb_init的mb参数。
2. timeout参数统一使用cos_tick_t类型代表tick。
3. 不支持的一些API的子特性 统一返回错误码COS_ERR_NOTSUPPORT。
其他
1. 测试套件—等API适配完成后确定API没问题再进行
**下次会议6月14日**

View File

@ -0,0 +1,14 @@
# 6月14日会议结论
进展
1. 腾讯:基本已经完成
2. RTT部分完成
结论:
1. 后续迁移到基金会的代码库初期先fork一份Gitee的仍保留
2. 目标7月底基金会峰会发布标准及相关demo。
3. 腾讯计划在3-4款开发板实现RTT计划在1款开发板实现阿里1款开发板实现。
4. 测试套采用greatest.h开源框架
**下次会议6月28日**

View File

@ -0,0 +1,12 @@
# 6月28日会议结论
进展
1. 腾讯消息邮箱、消息队列需要等API确认完后再实现正在写测试例
2. RTT还缺工作队列
3. 阿里:都实现了
结论:
1. 静态初始化隔离底层OS。建议方式:定义统一的宏用户来开buffer。新开一个头文件feature.h @李进良
2. 新增cos_sem_t、获取tick值、信号量唤醒release-all的issue跟踪讨论@腾讯
**下次会议7月12日**

View File

@ -0,0 +1,13 @@
# 7月12日会议结论
7月26日发布方案
1. 各家确定届时参会的同事名单@腾讯、RTT、展锐
2. 发布视频画面,有发布特效;最终显示“《物联网操作系统内核接口规范 1.0》正式发布”
3. 补充各家的标准实现情况@腾讯、RTT
结论:
1. 数量类型抽象https://gitee.com/IoTOSSWG-atom/cosit/issues/I5EYUC?from=project-issue@尽良 发起PR进行更新
2. 补充消息队列工作方式 COS_IPC_FLAG_FIFO、 COS_IPC_FLAG_PRIO这两个常量的定义 @RTT
**下次会议:峰会之后确定**

View File

@ -0,0 +1,779 @@
#include "cosit.h"
#include <tos_k.h>
static cos_status_t errno_knl2cosit(k_err_t err)
{
switch (err) {
case K_ERR_NONE: return COS_OK;
case K_ERR_IN_IRQ: return COS_ERR_ISR;
default: return COS_ERR;
}
}
cos_tick_t cos_ms_to_tick(uint64_t ms)
{
return tos_millisec2tick((k_time_t)ms);
}
uint64_t cos_tick_to_ms(cos_tick_t tick)
{
return tos_tick2millisec((k_tick_t)tick);
}
void cos_task_attr_init(cos_task_attr_t *attr)
{
if (!attr) {
return;
}
attr->name = "default_task";
attr->stack_size = 512;
attr->priority = 5;
attr->tick = 10;
}
cos_status_t cos_task_create(cos_task_t *task, cos_task_entry_t fn, void *arg, cos_task_attr_t *attr)
{
k_err_t err;
k_stack_t *task_stack;
if (!attr) {
return COS_ERR_PARAM;
}
#if TOS_CFG_TASK_DYNAMIC_CREATE_EN > 0u
err = tos_task_create_dyn((k_task_t **)task, attr->name, (k_task_entry_t)fn, arg,
(k_prio_t)attr->priority, attr->stack_size,
(k_timeslice_t)attr->tick);
return errno_knl2cosit(err);
#endif
*task = (cos_task_t)tos_mmheap_alloc(sizeof(k_task_t));
if (!task) {
return COS_ERR_NOMEM;
}
task_stack = (k_stack_t *)tos_mmheap_alloc(attr->stack_size);
if (!task_stack) {
tos_mmheap_free(task);
return COS_ERR_NOMEM;
}
err = tos_task_create((k_task_t *)*task, attr->name, (k_task_entry_t)fn, arg,
(k_prio_t)attr->priority, task_stack, attr->stack_size,
(k_timeslice_t)attr->tick);
if (err != K_ERR_NONE) {
tos_mmheap_free(task);
tos_mmheap_free(task_stack);
}
return errno_knl2cosit(err);
}
cos_status_t cos_task_delete(cos_task_t task)
{
k_err_t err;
k_task_t *the_task = (k_task_t *)task;
#if TOS_CFG_TASK_DYNAMIC_CREATE_EN > 0u
err = tos_task_destroy_dyn(the_task);
return errno_knl2cosit(err);
#endif
err = tos_task_destroy(the_task);
tos_mmheap_free(the_task->stk_base);
tos_mmheap_free(task);
return errno_knl2cosit(err);
}
cos_status_t cos_task_init(cos_task_t task, cos_task_entry_t fn, void *arg,
cos_task_attr_t *attr, void *stack_buf)
{
k_err_t err;
err = tos_task_create((k_task_t *)task, attr->name, (k_task_entry_t)fn,
arg, attr->priority, (k_stack_t *)stack_buf,
attr->stack_size, attr->tick);
return errno_knl2cosit(err);
}
cos_status_t cos_task_deinit(cos_task_t task)
{
return errno_knl2cosit(tos_task_destroy((k_task_t *)task));
}
void cos_task_exit(int32_t status)
{
tos_task_destroy(K_NULL);
}
cos_status_t cos_task_suspend(cos_task_t task)
{
return errno_knl2cosit(tos_task_suspend((k_task_t *)task));
}
cos_status_t cos_task_resume(cos_task_t task)
{
return errno_knl2cosit(tos_task_resume((k_task_t *)task));
}
cos_status_t cos_task_yield(void)
{
tos_task_yield();
return COS_OK;
}
cos_task_t cos_task_self(void)
{
return (cos_task_t)tos_task_curr_task_get();
}
cos_status_t cos_task_get_name(cos_task_t task, char *buf, size_t buf_size)
{
k_task_t *the_task = task;
if (!the_task || !buf) {
return COS_ERR_PARAM;
}
strncpy(the_task->name, buf, buf_size);
return COS_OK;
}
cos_task_t cos_task_find(const char *name)
{
return (cos_task_t)tos_task_find(name);
}
cos_status_t cos_task_sleep(cos_tick_t tick)
{
return errno_knl2cosit(tos_task_delay((k_tick_t)tick));
}
cos_status_t cos_task_wakeup(cos_task_t task)
{
//todo
return COS_ERR;
}
cos_status_t cos_task_get_priority(cos_task_t task, uint8_t *priority)
{
k_task_t *the_task = task;
if (!the_task || !priority) {
return COS_ERR_PARAM;
}
*priority = the_task->prio;
return COS_OK;
}
cos_status_t cos_task_set_priority(cos_task_t task, uint8_t priority)
{
return tos_task_prio_change((k_task_t *)task, (k_prio_t)priority);
}
#if TOS_CFG_ROUND_ROBIN_EN > 0u
cos_status_t cos_task_get_time_slice(cos_task_t task, cos_tick_t *time_slice)
{
k_task_t *the_task = task;
if (!the_task || !time_slice) {
return COS_ERR_PARAM;
}
*time_slice = the_task->timeslice;
return COS_OK;
}
cos_status_t cos_task_set_time_slice(cos_task_t task, cos_tick_t time_slice)
{
tos_robin_timeslice_set((k_task_t *)task, (k_timeslice_t)time_slice);
return COS_OK;
}
#else
cos_status_t cos_task_get_time_slice(cos_task_t task, cos_tick_t *time_slice)
{
return COS_ERR;
}
cos_status_t cos_task_set_time_slice(cos_task_t task, cos_tick_t time_slice)
{
return COS_ERR;
}
#endif /* TOS_CFG_ROUND_ROBIN_EN */
#if TOS_CFG_TIMER_EN > 0u
cos_status_t cos_timer_create(cos_timer_t *timer, const char *name, cos_timer_cb_t cb,
void *arg, cos_tick_t initial, cos_tick_t period, uint32_t options)
{
k_err_t err;
k_timer_t **the_timer = (k_timer_t **)timer;
err = tos_timer_create_dyn(the_timer, (k_tick_t)initial, (k_tick_t)period,
(k_timer_callback_t)cb, arg, TOS_OPT_TIMER_PERIODIC);
if (err != K_ERR_NONE) {
return errno_knl2cosit(err);
}
if (options == COS_TIMER_OPTION_ACTIVATE) {
err = tos_timer_start(*the_timer);
return errno_knl2cosit(err);
}
return COS_OK;
}
cos_status_t cos_timer_delete(cos_timer_t timer)
{
return errno_knl2cosit(tos_timer_destroy_dyn((k_timer_t *)timer));
}
cos_status_t cos_timer_init(cos_timer_t timer, const char *name, cos_timer_cb_t cb,
void *arg, cos_tick_t initial, cos_tick_t period, uint32_t options)
{
k_err_t err;
k_timer_t *the_timer = (k_timer_t *)timer;
err = tos_timer_create(the_timer, (k_tick_t)initial, (k_tick_t)period,
(k_timer_callback_t)cb, arg, TOS_OPT_TIMER_PERIODIC);
if (err != K_ERR_NONE) {
return errno_knl2cosit(err);
}
if (options == COS_TIMER_OPTION_ACTIVATE) {
err = tos_timer_start(the_timer);
return errno_knl2cosit(err);
}
return COS_OK;
}
cos_status_t cos_timer_deinit(cos_timer_t timer)
{
return errno_knl2cosit(tos_timer_destroy((k_timer_t *)timer));
}
cos_status_t cos_timer_start(cos_timer_t timer)
{
return errno_knl2cosit(tos_timer_start((k_timer_t *)timer));
}
cos_status_t cos_timer_stop(cos_timer_t timer)
{
return errno_knl2cosit(tos_timer_stop((k_timer_t *)timer));
}
cos_status_t cos_timer_change(cos_timer_t timer, cos_tick_t initial, cos_tick_t period)
{
k_err_t err;
k_timer_t *the_timer = (k_timer_t *)timer;
err = tos_timer_delay_change(the_timer, (k_tick_t)initial);
if (err != K_ERR_NONE) {
return errno_knl2cosit(err);
}
return errno_knl2cosit(tos_timer_period_change(the_timer, (k_tick_t)period));
}
cos_status_t cos_timer_get_time(cos_timer_t timer, cos_tick_t *remaining, cos_tick_t *period)
{
//todo
return COS_ERR;
}
#else
cos_status_t cos_timer_create(cos_timer_t *timer, const char *name, cos_timer_cb_t cb,
void *arg, cos_tick_t initial, cos_tick_t period, uint32_t options)
{
return COS_ERR;
}
cos_status_t cos_timer_delete(cos_timer_t timer)
{
return COS_ERR;
}
cos_status_t cos_timer_init(cos_timer_t timer, const char *name, cos_timer_cb_t cb,
void *arg, cos_tick_t initial, cos_tick_t period, uint32_t options)
{
return COS_ERR;
}
cos_status_t cos_timer_deinit(cos_timer_t timer)
{
return COS_ERR;
}
cos_status_t cos_timer_start(cos_timer_t timer)
{
return COS_ERR;
}
cos_status_t cos_timer_stop(cos_timer_t timer)
{
return COS_ERR;
}
cos_status_t cos_timer_change(cos_timer_t timer, cos_tick_t initial, cos_tick_t period)
{
return COS_ERR;
}
cos_status_t cos_timer_get_time(cos_timer_t timer, cos_tick_t *remaining, cos_tick_t *period)
{
return COS_ERR;
}
#endif /* TOS_CFG_TIMER_EN */
void *cos_malloc(size_t size)
{
return tos_mmheap_alloc(size);
}
void *cos_realloc(void *ptr, size_t new_size)
{
return tos_mmheap_realloc(ptr, new_size);
}
void *cos_calloc(size_t count, size_t size)
{
return tos_mmheap_calloc(count, size);
}
cos_status_t cos_malloc_align(void **memptr, size_t size, size_t alignment)
{
#if TOS_CFG_MMHEAP_EN > 0u
if (!memptr) {
return COS_ERR_PARAM;
}
*memptr = tos_mmheap_aligned_alloc(size, alignment);
return *memptr == NULL ? COS_ERR : COS_OK;
#else
return COS_ERR;
#endif
}
void cos_free(void *ptr)
{
tos_mmheap_free(ptr);
}
#if TOS_CFG_MESSAGE_QUEUE_EN > 0u
cos_status_t cos_mb_create(const char* name, size_t msg_size,
uint8_t flag, cos_mb_t *mb)
{
}
cos_status_t cos_mb_delete(cos_mb_t mb)
{
}
cos_status_t cos_mb_init(const char* name, size_t msg_size,
uint8_t flag, cos_mb_t *mb)
{
//todo
//tos适配需要用户传入pool
}
cos_status_t cos_mb_deinit(cos_mb_t mb)
{
}
cos_status_t cos_mb_send(cos_mb_t mb, uint32_t value)
{
return errno_knl2cosit(tos_msg_q_post((k_msg_q_t *)mb, (void *)value));
}
cos_status_t cos_mb_recv(cos_mb_t mb, uint32_t* value,
int32_t timeout)
{
//note: value需要用户传入二级指针这里是否应该使用二级指针明示
return errno_knl2cosit(tos_msg_q_pend((k_msg_q_t *)mb, (void**)value, (k_tick_t)timeout));
}
#else
cos_status_t cos_mb_create(const char* name, size_t msg_size,
uint8_t flag, cos_mb_t *mb)
{
}
cos_status_t cos_mb_delete(cos_mb_t mb)
{
}
cos_status_t cos_mb_init(const char* name, size_t msg_size,
uint8_t flag, cos_mb_t *mb)
{
}
cos_status_t cos_mb_deinit(cos_mb_t mb)
{
}
cos_status_t cos_mb_send(cos_mb_t mb, uint32_t value)
{
}
cos_status_t cos_mb_recv(cos_mb_t mb, uint32_t* value,
int32_t timeout)
{
}
#endif
#if TOS_CFG_MAIL_QUEUE_EN > 0u
cos_status_t cos_mq_create(const char* name, size_t msg_size,
size_t max_msgs, uint8_t flag, cos_mq_t* mq)
{
}
cos_status_t cos_mq_delete(cos_mq_t mq)
{
}
cos_status_t cos_mq_init(const char* name, void *msgpool, size_t msg_size,
size_t max_msgs, cos_mq_t mq)
{
return errno_knl2cosit(tos_mail_q_create((k_mail_q_t *)mq, msgpool, max_msgs, msg_size));
}
cos_status_t cos_mq_deinit(cos_mq_t mq)
{
return errno_knl2cosit(tos_mail_q_destroy((k_mail_q_t *)mq));
}
cos_status_t cos_mq_send(cos_mq_t mq, void* buffer, size_t size)
{
return errno_knl2cosit(tos_mail_q_post((k_mail_q_t *)mq, buffer, size));
}
cos_status_t cos_mq_recv(cos_mq_t mq, void* buffer,
size_t size, int32_t timeout)
{
//todo
// tos中size是出参用来传递接收到的内容大小而COSIT API是入参表示缓冲区大小.
size_t recv_size;
return errno_knl2cosit(tos_mail_q_pend((k_mail_q_t *)mq, buffer, &recv_size, (k_tick_t)timeout));
}
#else
cos_status_t cos_mq_create(const char* name, size_t msg_size,
size_t max_msgs, uint8_t flag, cos_mq_t* mq)
{
return COS_ERR;
}
cos_status_t cos_mq_delete(cos_mq_t mq)
{
return COS_ERR;
}
cos_status_t cos_mq_init(const char* name, void *msgpool, size_t msg_size,
size_t max_msgs, cos_mq_t mq)
{
return COS_ERR;
}
cos_status_t cos_mq_deinit(cos_mq_t mq)
{
return COS_ERR;
}
cos_status_t cos_mq_send(cos_mq_t mq, void* buffer, size_t size)
{
return COS_ERR;
}
cos_status_t cos_mq_recv(cos_mq_t mq, void* buffer,
size_t size, int32_t timeout)
{
return COS_ERR;
}
#endif
cos_status_t cos_work_init(cos_work_t work, cos_work_handle_t work_func, void *work_data)
{
return COS_ERR;
}
cos_status_t cos_work_dowork(cos_work_t work, cos_tick_t time)
{
return COS_ERR;
}
cos_status_t cos_work_submit(cos_wq_t wq, cos_work_t work, cos_tick_t time)
{
return COS_ERR;
}
cos_status_t cos_work_cancel(cos_wq_t wq, cos_work_t work)
{
return COS_ERR;
}
cos_status_t cos_workqueue_create(cos_wq_t* wq, const char *name, uint16_t stack_size, uint8_t priority)
{
return COS_ERR;
}
cos_status_t cos_workqueue_destroy(cos_wq_t wq)
{
return COS_ERR;
}
#if TOS_CFG_MUTEX_EN > 0u
cos_status_t cos_mutex_create(cos_mutex_t *mutex, char *name, uint32_t options)
{
return errno_knl2cosit(tos_mutex_create_dyn((k_mutex_t **)mutex));
}
cos_status_t cos_mutex_delete(cos_mutex_t mutex)
{
return errno_knl2cosit(tos_mutex_destroy_dyn((k_mutex_t *)mutex));
}
cos_status_t cos_mutex_init(cos_mutex_t mutex, char *name, uint32_t options)
{
return errno_knl2cosit(tos_mutex_create((k_mutex_t *)mutex));
}
cos_status_t cos_mutex_deinit(cos_mutex_t mutex)
{
return errno_knl2cosit(tos_mutex_destroy((k_mutex_t *)mutex));
}
cos_status_t cos_mutex_lock(cos_mutex_t mutex, cos_tick_t timeout)
{
return errno_knl2cosit(tos_mutex_pend_timed((k_mutex_t *)mutex, (k_tick_t)timeout));
}
cos_status_t cos_mutex_unlock(cos_mutex_t mutex)
{
return errno_knl2cosit(tos_mutex_post((k_mutex_t *)mutex));
}
#else
cos_status_t cos_mutex_create(cos_mutex_t *mutex, char *name, uint32_t options)
{
return COS_ERR;
}
cos_status_t cos_mutex_delete(cos_mutex_t mutex)
{
return COS_ERR;
}
cos_status_t cos_mutex_init(cos_mutex_t mutex, char *name, uint32_t options)
{
return COS_ERR;
}
cos_status_t cos_mutex_deinit(cos_mutex_t mutex)
{
return COS_ERR;
}
cos_status_t cos_mutex_lock(cos_mutex_t mutex, cos_tick_t timeout)
{
return COS_ERR;
}
cos_status_t cos_mutex_unlock(cos_mutex_t mutex)
{
return COS_ERR;
}
#endif /* TOS_CFG_MUTEX_EN */
#if TOS_CFG_SEM_EN > 0u
cos_status_t cos_sem_create(cos_sem_t *sem, char *name, uint32_t init_count, uint32_t max_count)
{
return errno_knl2cosit(tos_sem_create_max_dyn((k_sem_t **)sem, (k_sem_cnt_t)init_count, (k_sem_cnt_t)max_count));
}
cos_status_t cos_sem_delete(cos_sem_t sem)
{
return errno_knl2cosit(tos_sem_destroy_dyn((k_sem_t *)sem));
}
cos_status_t cos_sem_init(cos_sem_t sem, char *name, uint32_t init_count, uint32_t max_count)
{
return errno_knl2cosit(tos_sem_create_max((k_sem_t *)sem, (k_sem_cnt_t)init_count, (k_sem_cnt_t)max_count));
}
cos_status_t cos_sem_deinit(cos_sem_t sem)
{
return errno_knl2cosit(tos_sem_destroy((k_sem_t *)sem));
}
cos_status_t cos_sem_wait(cos_sem_t *sem, cos_tick_t timeout)
{
return errno_knl2cosit(tos_sem_pend((k_sem_t *)sem, (k_tick_t)timeout));
}
cos_status_t cos_sem_release(cos_sem_t sem)
{
return errno_knl2cosit(tos_sem_post((k_sem_t *)sem));
}
#else
cos_status_t cos_sem_create(cos_sem_t *sem, char *name, uint32_t init_count, uint32_t max_count)
{
return COS_ERR;
}
cos_status_t cos_sem_delete(cos_sem_t sem)
{
return COS_ERR;
}
cos_status_t cos_sem_init(cos_sem_t sem, char *name, uint32_t init_count, uint32_t max_count)
{
return COS_ERR;
}
cos_status_t cos_sem_deinit(cos_sem_t sem)
{
return COS_ERR;
}
cos_status_t cos_sem_wait(cos_sem_t *sem, cos_tick_t timeout)
{
return COS_ERR;
}
cos_status_t cos_sem_release(cos_sem_t sem)
{
return COS_ERR;
}
#endif /* TOS_CFG_SEM_EN */
#if TOS_CFG_EVENT_EN > 0
cos_status_t cos_event_create(cos_event_t *event, char *name, cos_event_flag_t init_flag)
{
return errno_knl2cosit(tos_event_create_dyn((k_event_t **)event, (k_event_flag_t)init_flag));
}
cos_status_t cos_event_delete(cos_event_t event)
{
return errno_knl2cosit(tos_event_destroy_dyn((k_event_t *)event));
}
cos_status_t cos_event_init(cos_event_t event, char *name, cos_event_flag_t init_flag)
{
return errno_knl2cosit(tos_event_create((k_event_t *)event, (k_event_flag_t)init_flag));
}
cos_status_t cos_event_deinit(cos_event_t event)
{
return errno_knl2cosit(tos_event_destroy((k_event_t *)event));
}
cos_status_t cos_event_wait(cos_event_t event, cos_event_flag_t expect_flag, cos_tick_t timeout, cos_event_flag_t *match_flag, uint32_t options)
{
k_opt_t opt;
if (options == COS_EVENT_WAIT_ANY) {
opt |= TOS_OPT_EVENT_PEND_ANY;
} else if (options == COS_EVENT_WAIT_ALL) {
opt |= TOS_OPT_EVENT_PEND_ALL;
}
if (options == COS_EVENT_WAIT_CLR) {
opt |= TOS_OPT_EVENT_PEND_CLR;
}
return errno_knl2cosit(tos_event_pend((k_event_t *)event,
(k_event_flag_t)expect_flag, (k_event_flag_t *)match_flag,
(k_tick_t)timeout, opt));
}
cos_status_t cos_event_release(cos_event_t event, cos_event_flag_t flag, uint32_t options)
{
if (options == COS_EVENT_RELEASE_KEEP) {
return errno_knl2cosit(tos_event_post_keep((k_event_t *)event, (k_event_flag_t)flag));
} else {
return errno_knl2cosit(tos_event_post((k_event_t *)event, (k_event_flag_t)flag));
}
}
#else
cos_status_t cos_event_create(cos_event_t *event, char *name, cos_event_flag_t init_flag)
{
return COS_ERR;
}
cos_status_t cos_event_delete(cos_event_t event)
{
return COS_ERR;
}
cos_status_t cos_event_init(cos_event_t event, char *name, cos_event_flag_t init_flag)
{
return COS_ERR;
}
cos_status_t cos_event_deinit(cos_event_t event)
{
return COS_ERR;
}
cos_status_t cos_event_wait(cos_event_t event, cos_event_flag_t expect_flag, cos_tick_t timeout, cos_event_flag_t *match_flag, uint32_t options)
{
return COS_ERR;
}
cos_status_t cos_event_release(cos_event_t event, cos_event_flag_t flag, uint32_t options)
{
return COS_ERR;
}
#endif

View File

@ -0,0 +1,13 @@
Copyright (c) 2011-2018 Scott Vokes <vokes.s@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

File diff suppressed because it is too large Load Diff