提交 ec7f0a5c 编写于 作者: C caiyan.cai 提交者: yilu.myl

release version:rel_3.3.0-20210508_1030

Signed-off-by: Ncaiyan.cai <caiyan.cai@alibaba-inc.com>
上级 3ba54483

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -9,7 +9,7 @@ SDL正式支持Windows,Mac OS X,Linux,iOS和Android。在源代码中可
SDL用C编写,可与C ++一起使用,并且有绑定可用于其他几种语言,包括C#和Python。
# 版权信息
## 版权信息
> zlib license
## 目录结构
......@@ -221,7 +221,7 @@ SDL用C编写,可与C ++一起使用,并且有绑定可用于其他几种语
* udisplay
# 常用配置
```shell
```yaml
def_config: # 组件的可配置项
__ALIOS__: 1
LOAD_JPG: 1
......@@ -288,11 +288,11 @@ aos install SDL2
## 步骤6 烧录固件
上述步骤执行后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/build_image.html)来烧录固件。
上述步骤执行后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/burn_image.html)来烧录固件。
## 步骤7 打开串口
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](_haa_s100__quick__start.html)
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](https://g.alicdn.com/alios-things-3.3/doc/view_log.html)
当串口终端打开成功后,可在串口中输入help来查看已添加的测试命令。
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
......@@ -50,7 +50,7 @@ static void sound_example_getvol(int argc, char **argv)
return;
}
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
/* reg args: fun, cmd, description*/
ALIOS_CLI_CMD_REGISTER(sound_example_install_driver, sound_install_driver, sound install driver test example)
ALIOS_CLI_CMD_REGISTER(sound_example_wav, sound_wav, sound wav player test example)
......
......@@ -32,7 +32,7 @@ AI Agent作为AI的代理引擎框架,支持不同推理引擎的注册,对
* ucloud_ai
# 常用配置
```sh
```yaml
def_config: # 组件的可配置项
CONFIG_UCLOUD_AI_ENGINE_ENABLE: 1
```
......@@ -144,16 +144,16 @@ ENDPOINT默认使用“oss-cn-shanghai-internal.aliyuncs.com”,BUCKET请使
address: 0xB32000
```
上述步骤执行后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/build_image.html)来烧录固件。
上述步骤执行后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/burn_image.html)来烧录固件。
## 步骤7 打开串口
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](_haa_s100__quick__start.html)
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](https://g.alicdn.com/alios-things-3.3/doc/view_log.html)
当串口终端打开成功后,可在串口中输入help来查看已添加的测试命令。
## ai_agent示例测试
## 步骤8 示例测试
测试步骤:
```sh
......@@ -162,7 +162,7 @@ $ netmgr -t wifi -c {ssid} {password} # 请将ssid修改为您路由器的WiFi
$ aiagent -e ucloud-ai -m {0 ~ 14} # 测试AI用例
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai init # 初始化ucloud-ai引擎,在执行下面的测试命令前,该命令需要优先执行,仅需执行一次即可
```
......@@ -172,7 +172,7 @@ aiagent -e ucloud-ai init # 初始化ucloud-ai引擎,在执行下面的测试
aiagent init successfully!
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 0 # 人脸比对
```
......@@ -184,7 +184,7 @@ confidence: 84.6
location at x: 159, y: 76, w: 143, h: 194
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 1 # 人物动漫化
```
......@@ -195,7 +195,7 @@ Generate human anime style result:
url: http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/person-image-cartoonizer/4F10FBB8-19DC-476B-A51D-458CD180A24F_07f2_20210331-142711.jpg?Expires=1617202631&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=YCLva1stK27Cn657nMeYhgFt7h4%3D
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 2 # 表情识别
```
......@@ -206,7 +206,7 @@ Recognize expression result:
type: anger, probability: 1.0
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 3 # 目标检测
```
......@@ -227,7 +227,7 @@ Detect object result:
type: mouse, Score: 0.2, x: 660, y: 479, w: 750, h: 528
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 4 # 主体检测
```
......@@ -238,7 +238,7 @@ Detect main body result:
main body location x: 1, y: 31, w: 461, h: 528
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 5 # 通用分割
```
......@@ -249,7 +249,7 @@ Segment common image result:
url: http://viapi-cn-shanghai-dha-segmenter.oss-cn-shanghai.aliyuncs.com/upload/result_humansegmenter/2021-3-31/invi_humansegmenter_016172056326493133388_avpTpm.jpg?Expires=1617207432&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=WREOAoBUIvpLSyygGxKPfi82HfI%3D
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 6 # 面部分割
```
......@@ -261,7 +261,7 @@ image url: http://viapi-cn-shanghai-dha-segmenter.oss-cn-shanghai.aliyuncs.com/u
location at x: 153, y: 66, w: 160, h: 209
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 7 # 身份证证明识别
```
......@@ -281,7 +281,7 @@ face location: x2: 0, y2: 0
face location: x3: 0, y3: 0
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 8 # 身份证反面识别
```
......@@ -294,7 +294,7 @@ issue: 杭州市公安局余杭分局
end date: 20231010
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 9 # 银行卡识别
```
......@@ -310,7 +310,7 @@ card number: 6212262315007683105
valid date: 07/26
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 10 # 文本识别
```
......@@ -347,7 +347,7 @@ probability: 1.0
text area: left: 261, top: 193, weight: 104, height: 18
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 11 # 垃圾分类
```
......@@ -361,7 +361,7 @@ category: 可回收垃圾
category score: 1.0
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 12 # 水果检测
```
......@@ -374,7 +374,7 @@ fruit score: 0.8
fruit location: x: 214, y: 44, w: 509, h: 438
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 13 # 图像人体擦除
```
......@@ -385,7 +385,7 @@ Erase person result:
url: http://algo-app-isr-lab-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/remove-person/2021-03-31_15%3A34%3A17.959810_person_org.jpg?Expires=1617206658&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=jFwwnSYOw2fXev1%2Fm5az4JBa%2B5Q%3D
```
### CLI命令行输入:
**CLI命令行输入:**
```sh
aiagent -e ucloud-ai -m 14 # 风格迁移
```
......
......@@ -5,7 +5,7 @@
#include "aiagent_service.h"
#include "aiagent_common.h"
#include "ulog/ulog.h"
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
......@@ -571,7 +571,7 @@ static void aiagent_comp_example(int argc, char **argv)
return;
}
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
/* reg args: fun, cmd, description*/
ALIOS_CLI_CMD_REGISTER(aiagent_comp_example, aiagent, aiagent component base example)
#endif
......@@ -3,7 +3,11 @@
[更正文档](https://gitee.com/alios-things/ble_host/edit/rel_3.3.0/README.md) &emsp;&emsp;&emsp;&emsp; [贡献说明](https://g.alicdn.com/alios-things-3.3/doc/contribute_doc.html)
# 概述
AliOS Things 3.3提供支持符合蓝牙4.0/4.2/5.0核心协议规范的BLE Host软件协议栈组件,方便用户使用蓝牙BLE功能。<br />ble_host组件功能框图如下图红色部分:<br />![image.png](https://img.alicdn.com/imgextra/i1/O1CN018Gd9qR2ALhGFNkTT9_!!6000000008187-2-tps-830-730.png#align=left&display=inline&height=461&margin=%5Bobject%20Object%5D&name=image.png&originHeight=922&originWidth=1932&size=259937&status=done&style=none&width=966#align=left&display=inline&height=537&margin=%5Bobject%20Object%5D&originHeight=730&originWidth=830&status=done&style=none&width=611#align=left&display=inline&height=730&margin=%5Bobject%20Object%5D&originHeight=730&originWidth=830&status=done&style=none&width=830)<br />
AliOS Things 3.3提供支持符合蓝牙4.0/4.2/5.0核心协议规范的BLE Host软件协议栈组件,方便用户使用蓝牙BLE功能。<br />ble_host组件功能框图如下图红色部分:
<div align=left display=flex>
<img src="https://img.alicdn.com/imgextra/i1/O1CN018Gd9qR2ALhGFNkTT9_!!6000000008187-2-tps-830-730.png#align=left&display=inline&height=461&margin=%5Bobject%20Object%5D&name=image.png&originHeight=922&originWidth=1932&size=259937&status=done&style=none&width=966#align=left&display=inline&height=537&margin=%5Bobject%20Object%5D&originHeight=730&originWidth=830&status=done&style=none&width=611#align=left&display=inline&height=730&margin=%5Bobject%20Object%5D&originHeight=730&originWidth=830&status=done&style=none&width=830" style="max-width:800px;" />
</div>
## 功能支持
ble_host组件主要支持如下功能:
......@@ -31,7 +35,7 @@ ble_host组件主要支持如下功能:
## 目录结构
```sh
```tree
|-- ble_profiles #BLE服务
|-- bt_crypto #BLE安全
|-- bt_defconfig #BLE配置项
......@@ -102,7 +106,7 @@ ble_host组件主要支持如下功能:
### ble_stack_init
BLE模块初始化。<br />**函数原型**
```
``` c
int ble_stack_init(init_param_t *param)
```
**输入参数**
......@@ -117,7 +121,7 @@ int ble_stack_init(init_param_t *param)
### ble_stack_event_register
注册BLE协议栈事件回调函数。<br />注意:入参不能是一个局部变量。<br />**函数原型**
```
``` c
int ble_stack_event_register(ble_event_cb_t *callback)
```
**输入参数**
......@@ -131,7 +135,7 @@ int ble_stack_event_register(ble_event_cb_t *callback)
### ble_stack_adv_start
打开BLE广播功能。<br />**函数原型**
```
``` c
int ble_stack_adv_start(adv_param_t *param)
```
**输入参数**
......@@ -153,7 +157,7 @@ int ble_stack_adv_start(adv_param_t *param)
### ble_stack_adv_stop
关闭BLE广播功能。<br />**函数原型**
```
``` c
int ble_stack_adv_stop()
```
**输入参数**
......@@ -166,7 +170,7 @@ int ble_stack_adv_stop()
### ble_stack_scan_start
打开BLE扫描功能。<br />**函数原型**
```
``` c
int ble_stack_scan_start(const scan_param_t *param)
```
**输入参数**
......@@ -183,7 +187,7 @@ int ble_stack_scan_start(const scan_param_t *param)
### ble_stack_scan_stop
关闭BLE扫描功能。<br />异步事件,扫描结果在注册的事件回调函数中返回,返回事件EVENT_GAP_DEV_FIND<br />**函数原型**
```
``` c
int ble_stack_scan_stop()
```
**输入参数**
......@@ -196,7 +200,7 @@ int ble_stack_scan_stop()
### ble_stack_gatt_mtu_get
获取一个连接的当前MTU大小<br />**函数原型**
```
``` c
int ble_stack_gatt_mtu_get(int16_t conn_handle)
```
**输入参数**
......@@ -209,7 +213,7 @@ int ble_stack_gatt_mtu_get(int16_t conn_handle)
### ble_stack_gatt_registe_service
注册一个GATT服务<br />**函数原型**
```
``` c
int ble_stack_gatt_registe_service(gatt_service *s, gatt_attr_t attrs[], uint16_t attr_num)
```
**输入参数**
......@@ -226,7 +230,7 @@ int ble_stack_gatt_registe_service(gatt_service *s, gatt_attr_t attrs[], uint16_
### ble_stack_gatt_notificate
GATT服务某个属性值上报,此上报方式无需GATT Client回复<br />**函数原型**
```
``` c
int ble_stack_gatt_notificate(int16_t conn_handle, uint16_t char_handle, const uint8_t *data, uint16_t len)
```
**输入参数**
......@@ -242,7 +246,7 @@ int ble_stack_gatt_notificate(int16_t conn_handle, uint16_t char_handle, const u
### ble_stack_gatt_indicate
GATT服务某个属性值上报,此上报方式GATT Client回复confirm。<br />**函数原型**
```
``` c
int ble_stack_gatt_indicate(int16_t conn_handle, int16_t char_handle, const uint8_t *data, uint16_t len)
```
**输入参数**
......@@ -258,7 +262,7 @@ int ble_stack_gatt_indicate(int16_t conn_handle, int16_t char_handle, const uint
### ble_stack_gatt_mtu_exchange
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />GATT协商MTU大小,协商大小由配置项CONFIG_BT_L2CAP_RX_MTU与CONFIG_BT_L2CAP_TX_MTU的最小值以及对端设备的回复决定。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_MTU_EXCHANGE<br />**函数原型**
```
``` c
int ble_stack_gatt_mtu_exchange(int16_t conn_handle)
```
......@@ -275,7 +279,7 @@ int ble_stack_gatt_mtu_exchange(int16_t conn_handle)
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />GATT服务或者属性项发现。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件根据入参不同而不同
**函数原型**
```
``` c
int ble_stack_gatt_discovery(int16_t conn_handle,
gatt_discovery_type_en type,
uuid_t *uuid,
......@@ -296,7 +300,7 @@ int ble_stack_gatt_discovery(int16_t conn_handle,
### ble_stack_gatt_read
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />GATT读取某个属性项的属性值<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CHAR_READ_CB<br />**函数原型**
```
``` c
int ble_stack_gatt_read(int16_t conn_handle, uint16_t attr_handle, uint16_t offset)
```
**输入参数**
......@@ -311,7 +315,7 @@ int ble_stack_gatt_read(int16_t conn_handle, uint16_t attr_handle, uint16_t offs
### ble_stack_gatt_read_multiple
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />GATT读取多个属性项的属性值<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CHAR_READ_CB<br />**函数原型**
```
``` c
int ble_stack_gatt_read_multiple(int16_t conn_handle, uint16_t attr_count, uint16_t attr_handle[])
```
**输入参数**
......@@ -326,7 +330,7 @@ int ble_stack_gatt_read_multiple(int16_t conn_handle, uint16_t attr_count, uint1
### ble_stack_gatt_write
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />GATT写入某个属性项的属性值<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CHAR_WRITE_CB<br />**函数原型**
```
``` c
int ble_stack_gatt_write(int16_t conn_handle, uint16_t attr_handle, uint8_t *data, uint16_t len, uint16_t offset, gatt_write_en type)
```
**输入参数**
......@@ -344,7 +348,7 @@ int ble_stack_gatt_write(int16_t conn_handle, uint16_t attr_handle, uint8_t *dat
### ble_stack_gatt_read_multiple
GATT Client功能,确保配置项CONFIG_BT_GATT_CLIENT配置。<br />此函数用于GATT读取多个属性项的属性值。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CHAR_READ_CB<br />**函数原型**
```
``` c
int ble_stack_gatt_read_multiple(int16_t conn_handle, uint16_t attr_count, uint16_t attr_handle[])
```
**输入参数**
......@@ -359,7 +363,7 @@ int ble_stack_gatt_read_multiple(int16_t conn_handle, uint16_t attr_count, uint1
### ble_stack_connect
BLE连接功能,确保配置项CONFIG_BT_CONN配置。<br />此函数用于BLE连接某个设备。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CONN_CHANGE<br />**函数原型**
```
``` c
int ble_stack_connect(dev_addr_t *peer_addr, conn_param_t *param, uint8_t auto_connect)
```
**输入参数**
......@@ -378,7 +382,7 @@ int ble_stack_connect(dev_addr_t *peer_addr, conn_param_t *param, uint8_t auto_c
### ble_stack_disconnect
BLE连接功能,确保配置项CONFIG_BT_CONN配置。<br />此函数用于BLE断开某个设备的连接。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GATT_CONN_CHANGE<br />**函数原型**
```
``` c
int ble_stack_disconnect(int16_t conn_handle)
```
**输入参数**
......@@ -391,7 +395,7 @@ int ble_stack_disconnect(int16_t conn_handle)
### ble_stack_connect_param_update
BLE连接功能,确保配置项CONFIG_BT_CONN配置。<br />此函数用于BLE修改某个连接的连接参数。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GAP_CONN_PARAM_UPDATE<br />**函数原型**
```
``` c
int ble_stack_connect_param_update(int16_t conn_handle, conn_param_t *param)
```
**输入参数**
......@@ -408,7 +412,7 @@ int ble_stack_connect_param_update(int16_t conn_handle, conn_param_t *param)
### ble_stack_security
BLE连接功能,确保配置项CONFIG_BT_CONN配置。<br />此函数用于BLE修改某个连接的安全参数。<br />异步事件,执行结果在注册的事件回调函数中返回,返回事件EVENT_GAP_CONN_SECURITY_CHANGE<br />**函数原型**
```
``` c
int ble_stack_security(int16_t conn_handle, security_en level)
```
**输入参数**
......@@ -422,7 +426,7 @@ int ble_stack_security(int16_t conn_handle, security_en level)
### ble_stack_iocapability_set
BLE SMP配对功能,确保配置项CONFIG_BT_SMP配置。<br />此函数用于设置BLE设备设备的IO能力,这个设置会在BLE SMP配对被使用。<br />**函数原型**
```
``` c
int ble_stack_iocapability_set(uint8_t io_cap)
```
**输入参数**
......@@ -435,7 +439,7 @@ int ble_stack_iocapability_set(uint8_t io_cap)
### ble_stack_smp_cancel
BLE SMP配对功能,确保配置项CONFIG_BT_SMP配置。<br />此函数用于取消当前BLE的SMP配对请求。<br />**函数原型**
```
``` c
int ble_stack_smp_cancel(int16_t conn_handle)
```
**输入参数**
......@@ -448,7 +452,7 @@ int ble_stack_smp_cancel(int16_t conn_handle)
### ble_stack_smp_passkey_entry
BLE SMP配对功能,确保配置项CONFIG_BT_SMP配置。<br />此函数用于SMP Passkey模式下输入当前passkey,当接收到EVENT_SMP_PASSKEY_ENTER后调用。<br />**函数原型**
```
``` c
int ble_stack_smp_passkey_entry(int16_t conn_handle, uint32_t passkey)
```
**输入参数**
......@@ -462,7 +466,7 @@ int ble_stack_smp_passkey_entry(int16_t conn_handle, uint32_t passkey)
### ble_stack_smp_passkey_confirm
BLE SMP配对功能,确保配置项CONFIG_BT_SMP配置。<br />此函数用于SMP Passkey模式下确认当前的passkey是否正确,当接收到EVENT_SMP_PASSKEY_CONFIRM后调用。<br />**函数原型**
```
``` c
int ble_stack_smp_passkey_confirm(int16_t conn_handle)
```
**输入参数**
......@@ -475,7 +479,7 @@ int ble_stack_smp_passkey_confirm(int16_t conn_handle)
### ble_stack_dev_unpair
BLE SMP配对功能,确保配置项CONFIG_BT_SMP配置。<br />此函数用于解除某台已SMP配对的设备的配对,如果连接存在则断开连接。<br />**函数原型**
```
``` c
int ble_stack_dev_unpair(dev_addr_t *peer_addr)
```
**输入参数**
......@@ -488,22 +492,51 @@ int ble_stack_dev_unpair(dev_addr_t *peer_addr)
**返回值**<br />`0:`成功, `其他值`:失败。<br />
# 使用示例
## 案例工具
本用例测试过程中使用到的工具有:
- 串口工具
- NRF Connect(手机)
组件使用示例相关的代码下载、编译和固件烧录均依赖AliOS Things配套的开发工具 **alios-studio** ,所以首先需要参考[《aos-studio使用说明之搭建开发环境》](https://g.alicdn.com/alios-things-3.3/doc/setup_env.html),下载安装 **alios-studio**
待开发环境搭建完成后,可以按照以下步骤进行示例的测试。
## 步骤1 创建或打开工程
## 案例修改
以helloworld的案例为例,修改solutions/helloworld_demo/package.yaml的depends,增加ble_host,如下
```
**打开已有工程**
如果用于测试的案例工程已存在,可参考[《aos-studio使用说明之打开工程》](https://g.alicdn.com/alios-things-3.3/doc/open_project.html)打开已有工程。
**创建新的工程**
组件的示例代码可以通过编译链接到AliOS Things的任意案例(solution)来运行,这里选择helloworld_demo案例。helloworld_demo案例相关的源代码下载可参考[《aos-studio使用说明之创建工程》](https://g.alicdn.com/alios-things-3.3/doc/create_project.html)
## 步骤2 添加组件
案例下载完成后,需要在helloworld_demo组件的package.yaml中添加对组件的依赖:
```yaml
depends:
- ble_host: master
- ble_host: dev_aos
```
<br />修改solutions/helloworld_demo/helloworld_demo.c,如下:<br />**头文件修改**
## 步骤3 下载组件
在已安装了 **alios-studio** 的开发环境工具栏中,选择Terminal -> New Terminal启动终端,并且默认工作路径为当前工程的workspace,此时在终端命令行中输入:
```shell
aos install ble_host
```
上述命令执行成功后,组件源码则被下载到了./components/ble_host路径中。
## 步骤4 添加示例
修改solutions/helloworld_demo/helloworld_demo.c,如下:
**头文件修改**
```c
#include <aos/ble.h>
#include <atomic.h>
#include <bluetooth/bluetooth.h>
......@@ -511,8 +544,9 @@ depends:
#include <bluetooth/uuid.h>
```
<br />**代码修改**
```
**代码修改**
```c
#define EXAMPLE_BLE_DEV_NAME "HaaS BLE"
#define DEVICE_ADDR {0xE8,0x3B,0xE3,0x88,0xB4,0xC8}
......@@ -546,27 +580,53 @@ int application_start(int argc, char *argv[])
```
## 编译烧录
在solutions/helloworld_demo中执行aos make,编译成功后烧录进haas100开发板。<br />
## 步骤5 编译固件
在示例代码已经添加至组件的配置文件,并且helloworld_demo已添加了对该组件的依赖后,就可以编译helloworld_demo案例来生成固件了,具体编译方法可参考[《aos-studio使用说明之编译固件》](https://g.alicdn.com/alios-things-3.3/doc/build_project.html)
## 步骤6 烧录固件
helloworld_demo案例的固件生成后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/burn_image.html)来烧录固件。
## 运行观测
打开串口工具,在串口工具中输入ble,可看到ble的cli命令集。<br />![image.png](https://img.alicdn.com/imgextra/i1/O1CN01Vm24En1Hnoi4vJ9lC_!!6000000000803-2-tps-1932-922.png#align=left&display=inline&height=461&margin=%5Bobject%20Object%5D&name=image.png&originHeight=922&originWidth=1932&size=259937&status=done&style=none&width=966#align=left&display=inline&height=293&margin=%5Bobject%20Object%5D&originHeight=922&originWidth=1932&status=done&style=none&width=614#align=left&display=inline&height=922&margin=%5Bobject%20Object%5D&originHeight=922&originWidth=1932&status=done&style=none&width=1932)<br />
## 步骤7 打开串口
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](https://g.alicdn.com/alios-things-3.3/doc/view_log.html)
当串口终端打开成功后,可在串口中输入help来查看已添加的测试命令。
## 步骤8 测试示例
打开串口工具,在串口工具中输入ble,可看到ble的cli命令集。<br />
<div align=left display=flex>
<img src="https://img.alicdn.com/imgextra/i1/O1CN01Vm24En1Hnoi4vJ9lC_!!6000000000803-2-tps-1932-922.png#align=left&display=inline&height=461&margin=%5Bobject%20Object%5D&name=image.png&originHeight=922&originWidth=1932&size=259937&status=done&style=none&width=966#align=left&display=inline&height=293&margin=%5Bobject%20Object%5D&originHeight=922&originWidth=1932&status=done&style=none&width=614#align=left&display=inline&height=922&margin=%5Bobject%20Object%5D&originHeight=922&originWidth=1932&status=done&style=none&width=1932" style="max-width:800px;" />
</div>
**BLE广播与连接测试**
## BLE广播与连接示例
在串口工具中输入ble adv start 020106,可以在串口日志中看到如下打印
```
```sh
adv_type:0;adv_interval_min:160 (*0.625)ms;adv_interval_max:240 (*0.625)ms
Advertising started
```
<br />此时在手机端打开NRF Connect工具并搜索广播包,可以看到设备。<br />![image.png](https://img.alicdn.com/imgextra/i2/O1CN01CZZkJl1ThCNOYmP1f_!!6000000002413-2-tps-700-1268.png#align=left&display=inline&height=520&margin=%5Bobject%20Object%5D&name=image.png&originHeight=1268&originWidth=700&size=482965&status=done&style=none&width=287#align=left&display=inline&height=828&margin=%5Bobject%20Object%5D&originHeight=1268&originWidth=700&status=done&style=none&width=457#align=left&display=inline&height=949&margin=%5Bobject%20Object%5D&originHeight=1268&originWidth=700&status=done&style=none&width=524)<br />
<br />点击连接,可以看到Generic Access(GAP)和Generic Attribute(GATT)2个服务,点击GAP服务的Device Name的读取按键(下图红色圈中的箭头),可以读取到数值“HaaS BLE”<br />![image.png](https://img.alicdn.com/imgextra/i3/O1CN01jK0smX1FJvdIip6ZO_!!6000000000467-2-tps-696-726.png#align=left&display=inline&height=363&margin=%5Bobject%20Object%5D&name=image.png&originHeight=726&originWidth=696&size=250340&status=done&style=none&width=348#align=left&display=inline&height=469&margin=%5Bobject%20Object%5D&originHeight=726&originWidth=696&status=done&style=none&width=450#align=left&display=inline&height=548&margin=%5Bobject%20Object%5D&originHeight=726&originWidth=696&status=done&style=none&width=525)<br />
<br />此时在手机端打开NRF Connect工具并搜索广播包,可以看到设备。
<div align=left display=flex>
<img src="https://img.alicdn.com/imgextra/i2/O1CN01CZZkJl1ThCNOYmP1f_!!6000000002413-2-tps-700-1268.png#align=left&display=inline&height=520&margin=%5Bobject%20Object%5D&name=image.png&originHeight=1268&originWidth=700&size=482965&status=done&style=none&width=287#align=left&display=inline&height=828&margin=%5Bobject%20Object%5D&originHeight=1268&originWidth=700&status=done&style=none&width=457#align=left&display=inline&height=949&margin=%5Bobject%20Object%5D&originHeight=1268&originWidth=700&status=done&style=none&width=524" style="max-width:800px;" />
</div>
<br />点击连接,可以看到Generic Access(GAP)和Generic Attribute(GATT)2个服务,点击GAP服务的Device Name的读取按键(下图红色圈中的箭头),可以读取到数值“HaaS BLE”<br />
<div align=left display=flex>
<img src="https://img.alicdn.com/imgextra/i3/O1CN01jK0smX1FJvdIip6ZO_!!6000000000467-2-tps-696-726.png#align=left&display=inline&height=363&margin=%5Bobject%20Object%5D&name=image.png&originHeight=726&originWidth=696&size=250340&status=done&style=none&width=348#align=left&display=inline&height=469&margin=%5Bobject%20Object%5D&originHeight=726&originWidth=696&status=done&style=none&width=450#align=left&display=inline&height=548&margin=%5Bobject%20Object%5D&originHeight=726&originWidth=696&status=done&style=none&width=525" style="max-width:800px;" />
</div>
# 常见问题
```
Q:此协议栈是否支持蓝牙音乐播放
A:不支持经典蓝牙功能,仅支持BLE功能
Q:常见的GATT Service是否支持
A:支持,包括BAS,DIS,HIDS等等,详情请参考ble_host/ble_profiles文件下的实现。
```
......@@ -387,8 +387,9 @@ int ble_stack_init(init_param_t *param)
slist_init(&ble_dev.cb_list);
ble_stack_setting_load();
#if AOS_COMP_CLI
cli_reg_cmd_ble();
#endif
ble_dev.is_init = 1;
return ret;
......
......@@ -15,7 +15,9 @@
#include <stdlib.h>
#include <string.h>
#include <aos/ble.h>
#include <aos/cli.h>
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
#include <misc/byteorder.h>
#include <ble_os.h>
......@@ -2219,6 +2221,7 @@ static void cmd_ble_func(char *wbuf, int wbuf_len, int argc, char **argv)
}
}
#if AOS_COMP_CLI
void cli_reg_cmd_ble(void)
{
static const struct cli_command cmd_info = {
......@@ -2229,3 +2232,4 @@ void cli_reg_cmd_ble(void)
aos_cli_register_command(&cmd_info);
}
#endif /* AOS_COMP_CLI */
......@@ -29,7 +29,9 @@
#include <aos/ble.h>
#include <common/log.h>
#include <conn_internal.h>
#include <aos/cli.h>
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
// #include <yoc/hrs.h>
/** @brief Callback called when command is entered.
......@@ -3265,6 +3267,7 @@ static void cmd_ble_func(char *wbuf, int wbuf_len, int argc, char **argv)
}
}
#if AOS_COMP_CLI
void cli_reg_cmd_ble(void)
{
static const struct cli_command cmd_info = {
......@@ -3275,3 +3278,4 @@ void cli_reg_cmd_ble(void)
aos_cli_register_command(&cmd_info);
}
#endif /* AOS_COMP_CLI */
......@@ -251,11 +251,19 @@ enum k_poll_modes {
#define popcount(x) __builtin_popcount(x)
extern int ffs32_lsb(uint32_t i);
extern int ffs32_msb(uint32_t i);
static inline unsigned int find_msb_set(uint32_t op)
{
if (op == 0) {
return 0;
}
return 32 - __builtin_clz(op);
}
#define find_msb_set(x) ffs32_msb(x)
#define find_lsb_set(x) ffs32_lsb(x)
static inline unsigned int find_lsb_set(uint32_t op)
{
return __builtin_ffs(op);
}
#define k_thread_foreach(...)
......@@ -275,7 +283,7 @@ extern int ffs32_msb(uint32_t i);
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) \
((unsigned long) (sizeof(array) / sizeof((array)[0])))
((unsigned long) (sizeof(array) / sizeof((array)[0])))
#endif
typedef kbuf_queue_t _queue_t;
......
......@@ -15,14 +15,18 @@
#include <netmgr.h>
#include <netmgr_wifi.h>
#include <ble_netconfig.h>
#include <aos/cli.h>
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
#include "uservice/eventid.h"
#include "vfsdev/wifi_dev.h"
#define BLE_NETCFG_TAG "BLE_NETCFG"
#if AOS_COMP_CLI
#define BLE_NETCFG_CLI 1
#endif
#define BLE_NETCFG_LOG_ERROR(fmt, ...) LOGE(BLE_NETCFG_TAG, fmt, ##__VA_ARGS__)
#define BLE_NETCFG_LOG_WARNING(fmt, ...) LOGE(BLE_NETCFG_TAG, fmt, ##__VA_ARGS__)
......@@ -54,10 +58,11 @@ static char dev_name[128] = {'0'};
typedef struct {
uint8_t inited;
uint8_t started;
uint8_t ssid_recved;
uint8_t ssid_update; /* 标识是否需要触发配网流程 */
uint8_t ssid_recved; /* 标识ssid与passwd是否包含有效信息 */
uint8_t ssid[256];
uint8_t passwd[256];
uint8_t devinfo_recved;
uint8_t devinfo_recved; /* 标识product_key、device_name与device_secret是否包含有效信息 */
uint8_t product_key[32];
uint8_t device_name[64];
uint8_t device_secret[64];
......@@ -105,7 +110,7 @@ static void BLE_NetCfg_wifi_connect_handle(void)
BLE_NetCfg_Info *netCfg_info = BLE_NetCfg_get_info();
while (1) {
if (netCfg_info->ssid_recved) {
if (netCfg_info->ssid_update == 1 && netCfg_info->ssid_recved == 1) {
memset(&netmgr_params, 0, sizeof(netmgr_connect_params_t));
strncpy(netmgr_params.params.wifi_params.ssid, netCfg_info->ssid, NETMGR_SSID_MAX_LEN);
strncpy(netmgr_params.params.wifi_params.pwd, netCfg_info->passwd, NETMGR_PWD_MAX_LEN);
......@@ -119,11 +124,11 @@ static void BLE_NetCfg_wifi_connect_handle(void)
if (ret == 0) {
netCfg_info->callback(BLE_NETCFG_EVENT_SUCCESS, BLE_NETCFG_SUCCESS, NULL);
} else {
netCfg_info->callback(BLE_NETCFG_EVENT_FAILED, BLE_NETCFG_COMMON_FAILED, NULL);
netCfg_info->callback(BLE_NETCFG_EVENT_FAILED, BLE_NETCFG_COMMON_FAILED, NULL);
}
}
netCfg_info->ssid_recved = 0;
netCfg_info->ssid_update = 0;
}
if (netCfg_info->need_adv) {
......@@ -236,6 +241,7 @@ static void BLE_NetCfg_Parse(uint8_t *buf, uint16_t len)
netCfg_info->passwd[pwd_len] = 0;
netCfg_info->ssid_recved = 1;
netCfg_info->ssid_update = 1;
/* 消息接收完毕 */
BLE_NETCFG_LOG_INFO("%s: NetConf SSID = %s, PWD = %s", __func__, netCfg_info->ssid, netCfg_info->passwd);
......@@ -794,6 +800,7 @@ BLE_NETCFG_STATE BLE_NetCfg_wifi_set(char *ssid, char *passwd)
strcpy(netCfg_info->ssid, ssid);
strcpy(netCfg_info->passwd, passwd);
netCfg_info->ssid_recved = 1;
netCfg_info->ssid_update = 1;
return BLE_NETCFG_SUCCESS;
}
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
#include "uservice/uservice.h"
......@@ -144,6 +144,6 @@ static void netcfg_comp_example(int argc, char **argv)
}
}
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
ALIOS_CLI_CMD_REGISTER(netcfg_comp_example, netcfg_example, netcfg component base example);
#endif
@page cjson cJSON
@page cjson cjson
[更正文档](https://gitee.com/alios-things/cjson/edit/rel_3.3.0/README.md) &emsp;&emsp;&emsp;&emsp; [贡献说明](https://g.alicdn.com/alios-things-3.3/doc/contribute_doc.html)
......@@ -116,42 +116,71 @@ cJSON_bool cJSON_IsObject(const cJSON * const item);
|item |待判断的JSON结构体|
# 使用示例
示例代码参考example/cjson_example.c,以运行helloworld_demo为例,具体步骤如下:
## 添加示例代码
cjson组件的package.yaml中添加example
组件使用示例相关的代码下载、编译和固件烧录均依赖AliOS Things配套的开发工具 **alios-studio** ,所以首先需要参考[《aos-studio使用说明之搭建开发环境》](https://g.alicdn.com/alios-things-3.3/doc/setup_env.html),下载安装 **alios-studio**
待开发环境搭建完成后,可以按照以下步骤进行示例的测试。
## 步骤1 创建或打开工程
**打开已有工程**
如果用于测试的案例工程已存在,可参考[《aos-studio使用说明之打开工程》](https://g.alicdn.com/alios-things-3.3/doc/open_project.html)打开已有工程。
**创建新的工程**
组件的示例代码可以通过编译链接到AliOS Things的任意案例(solution)来运行,这里选择helloworld_demo案例。helloworld_demo案例相关的源代码下载可参考[《aos-studio使用说明之创建工程》](https://g.alicdn.com/alios-things-3.3/doc/create_project.html)
## 步骤2 添加组件
案例下载完成后,需要在helloworld_demo组件的package.yaml中添加对组件的依赖:
```yaml
depends:
- cjson: dev_aos
```
## 步骤3 下载组件
在已安装了 **alios-studio** 的开发环境工具栏中,选择Terminal -> New Terminal启动终端,并且默认工作路径为当前工程的workspace,此时在终端命令行中输入:
```shell
aos install cjson
```
上述命令执行成功后,组件源码则被下载到了./components/cjson路径中。
## 步骤4 添加示例
在cjson组件的package.yaml中添加[example示例代码](https://gitee.com/alios-things/cjson/tree/rel_3.3.0/example)
```
source_file:
- "src/*.c"
- "example/cjson_example.c"
```
## 添加组件
helloworld_demo组件的package.yaml中添加
```
depends:
- cjson: master
```
## 步骤5 编译固件
## 编译
```sh
cd solutions/helloworld_demo && aos make
```
其中具体单板还需要先配置环境:
```sh
aos make helloworld_demo@haas100 -c config
```
在示例代码已经添加至组件的配置文件,并且helloworld_demo已添加了对该组件的依赖后,就可以编译helloworld_demo案例来生成固件了,具体编译方法可参考[《aos-studio使用说明之编译固件》](https://g.alicdn.com/alios-things-3.3/doc/build_project.html)
## 步骤6 烧录固件
helloworld_demo案例的固件生成后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/burn_image.html)来烧录固件。
## 步骤7 打开串口
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](https://g.alicdn.com/alios-things-3.3/doc/view_log.html)
当串口终端打开成功后,可在串口中输入help来查看已添加的测试命令。
## 烧录固件
参考具体板子的快速开始文档。
## 步骤8 测试示例
## 示例测试
CLI命令行输入:
```
cjson_example
```
## 关键日志
**关键日志**
CLI日志:
```
Checking monitor "Awesome 4K"
......
......@@ -20,7 +20,7 @@
THE SOFTWARE.
*/
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include <stdio.h>
#include <cJSON.h>
#include <aos/cli.h>
......
......@@ -13,7 +13,7 @@
> Apache license v2.0
## 目录结构
```sh
```tree
├── include
│ └── aos
│ └── cli.h # cli的对外AOS API
......@@ -58,59 +58,59 @@
# 常用配置
系统中相关配置已有默认值,如需修改配置,在相应app下的package.yaml中**def_config**节点修改。例如:若运行的app为helloworld_demo,则在helloworld_demo下的package.yaml中修改:
> cli 输入缓冲区大小: 默认256 bytes,即cli单次可接收的输入最大字节数
```sh
```yaml
def_config:
CLI_INBUF_SIZE: 256
```
> cli 输出缓冲区大小: 默认512 bytes,即cli命令中单个printf输出的最大字节数
```sh
```yaml
def_config:
CLI_OUTBUF_SIZE: 512
```
> 可注册的cli命令最大值,默认最多可注册128个命令(通过help命令查看)
```sh
```yaml
def_config:
CLI_MAX_COMMANDS: 128
```
> 单个cli命令可带参数的最大值,默认最多可带16个参数
```sh
```yaml
def_config:
CLI_MAX_ARG_NUM: 16
```
> 可连续执行的cli命令数量(命令中间用分号;间隔),默认为4个
```sh
```yaml
def_config:
CLI_MAX_ONCECMD_NUM: 4
```
> cli后台任务的优先级,默认为60
```sh
```yaml
def_config:
CLI_TASK_PRIORITY: 60
```
> cli后台任务的栈大小,默认为2KB(2048Bytes)
```sh
```yaml
def_config:
CLI_CONFIG_STACK_SIZE: 2048
```
> cli使用telnet接管输入输出,此功能默认不开
```sh
```yaml
def_config:
CLI_TELNET_ENABLE: 0
```
> cli使用uagent接管输入输出,即cli日志输入输出在远程诊断终端上,此功能默认不开
```sh
```yaml
def_config:
CLI_UAGENT_ENABLE: 0
```
> cli输出增加不可见字符,用于SmartTrace工具中,此功能默认关闭
```sh
```yaml
def_config:
CLI_SEPRATED_CONSOLE: 0
```
> cli使能文件系统操作命令,此功能默认不开
```sh
```yaml
def_config:
CLI_IOBOX_ENABLE: 0
```
......@@ -228,7 +228,7 @@ void test_cmd3(int32_t argc, char **argv)
*/
ALIOS_CLI_CMD_REGISTER(test_cmd3, test3, show test3 info)
```
### 代码示例
**代码示例**
helloworld_demo注册cli命令,修改helloworld.c如下:
```C
#include "aos/init.h"
......@@ -311,11 +311,11 @@ ALIOS_CLI_CMD_REGISTER(test_cmd3, test3, show test3 info)
## 步骤6 烧录固件
helloworld_demo案例的固件生成后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/build_image.html)来烧录固件。
helloworld_demo案例的固件生成后,可参考[《aos-studio使用说明之烧录固件》](https://g.alicdn.com/alios-things-3.3/doc/burn_image.html)来烧录固件。
## 步骤7 打开串口
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](_haa_s100__quick__start.html)
固件烧录完成后,可以通过串口查看示例的运行结果,打开串口的具体方法可参考[《aos-studio使用说明之查看日志》](https://g.alicdn.com/alios-things-3.3/doc/view_log.html)
## 步骤8 测试示例
......
......@@ -28,7 +28,7 @@
> Apache license v2.0
## 目录结构
```sh
```tree
├── mutex.cpp # AOS: Mutex类
├── queue.cpp # AOS: Queue类
├── semaphore.cpp # AOS: Semaphore类
......@@ -62,12 +62,14 @@
- 使用AliOS Things自定义类需要先声明AOS命令空间
> using namespace AOS;
- 各自定义类相关说明参见如下链接:
@ref cpp_aos_workqueue
@ref cpp_aos_timer
@ref cpp_aos_thread
@ref cpp_aos_sem
@ref cpp_aos_queue
@ref cpp_aos_mutex
- 参考 [cpp_aos_workqueue](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__workqueue.html)
- 参考 [cpp_aos_timer](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__timer.html)
- 参考 [cpp_aos_thread](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__thread.html)
- 参考 [cpp_aos_sem](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__sem.html)
- 参考 [cpp_aos_queue](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__queue.html)
- 参考 [cpp_aos_mutex](https://g.alicdn.com/alios-things-3.3/doc/group__cpp__aos__mutex.html)
# 使用示例
组件使用示例相关的代码下载、编译和固件烧录均依赖AliOS Things配套的开发工具 **alios-studio** ,所以首先需要参考[《aos-studio使用说明之搭建开发环境》](https://g.alicdn.com/alios-things-3.3/doc/setup_env.html),下载安装 **alios-studio**
......@@ -77,7 +79,7 @@
- 需要首先调用cpp_init初始化cpp基础功能,添加对cplusplus组件的依赖后aos_component_init中自动会调用
- 需要关注相应的c++ 编译选项
标准C++使用示例参考**example/cpp_standard**,AliOS自定义类使用参考**example/cpp_aos**
标准C++使用示例参考**[example/cpp_standard](https://gitee.com/alios-things/cplusplus/tree/rel_3.3.0/example/cpp_standard)**,AliOS自定义类使用参考**example/cpp_aos**
## 步骤1 创建或打开工程
......@@ -91,7 +93,7 @@
## 步骤2 添加cplusplus组件
> helloworld_demo组件的package.yaml中添加
```sh
```yaml
depends:
- cplusplus: dev_aos # helloworld_demo中引入cplusplus组件
```
......@@ -109,7 +111,7 @@ aos install cplusplus
上述命令执行成功后,组件源码则被下载到了./components/cplusplus路径中。
## 步骤4 添加示例代码
> cplusplus组件的package.yaml中添加example
> cplusplus组件的package.yaml中[example示例代码](https://gitee.com/alios-things/cplusplus/tree/rel_3.3.0/example):
```sh
source_file:
- example/cpp_aos/*.c
......@@ -118,7 +120,7 @@ source_file:
- example/cpp_standard/*.cpp
```
其中由于example/cpp_aos/basic_test.cpp要测试**catch**异常功能,需要编译选项加入**-fexceptions**。在实际使用中不使用该选项有利于降低空间大小。
```sh
```yaml
build_config:
cxxflag: '-fexceptions'
```
......@@ -138,7 +140,7 @@ helloworld_demo案例的固件生成后,可参考[《aos-studio使用说明之
当串口终端打开成功后,可在串口中输入help来查看已添加的测试命令。
## 步骤8 测试示例
### 运行标准C++示例
**运行标准C++示例**
> CLI命令行输入:
```sh
......@@ -159,7 +161,7 @@ atomic test ok
```
说明:上面是主要模块运行成功的日志打印,屏蔽了一些中间输出,以及hellworld_demo自身的循环输出,实际运行如果没有出现**test error**字样即代表功能运行正常。
### 运行aos封装类
**运行aos封装类**
> CLI命令行输入:
```sh
......
......@@ -7,7 +7,7 @@
#include <iostream>
#include <stdio.h>
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
......@@ -37,7 +37,7 @@ static void cpp_aos_example(int argc, char **argv)
return;
}
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
/* reg args: fun, cmd, description*/
ALIOS_CLI_CMD_REGISTER(cpp_aos_example, cpp_aos, basic aos cpp api example)
#endif
......@@ -4,7 +4,7 @@
#include "aos/kernel.h"
#include <aos_cpp.h>
#include <stdio.h>
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
#include "aos/cli.h"
#endif
......@@ -35,7 +35,7 @@ void cpp_standard_example(int argc, char *argv[])
atomic_test();
}
#ifdef AOS_COMP_CLI
#if AOS_COMP_CLI
/* reg args: fun, cmd, description*/
ALIOS_CLI_CMD_REGISTER(cpp_standard_example,
cpp_stand,
......
......@@ -5,52 +5,70 @@
#include <stdint.h>
#include <k_api.h>
/** @defgroup cpp_aos_api cplusplus
* @ingroup aos_components
* @{
*/
/**
* @}
*/
/** @defgroup cpp_aos_mutex
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
#define Mutex_WAIT_FOREVER 0xFFFFFFFFU
/**
* @brief Mutex Class.
*
*/
class Mutex
{
public:
/**
* This function will create a mutex
* @brief This function will create a mutex
* @param[in] name name of the mutex
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t create(const name_t *name);
/**
* This function will delete a mutex
* @brief This function will delete a mutex
* @param[in] NULL
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t destroy(void);
/**
* This function will lock mutex
* @brief This function will lock mutex
* @param[in] millisec millisec to be wait for before lock
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t lock(uint32_t millisec);
/**
* This function will unlock a mutex
* @brief This function will unlock a mutex
* @param[in] NULL
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t unlock(void);
/**
* This function will get a Mutex struct pointer
* @brief This function will get a Mutex struct pointer
* @param[in] none
* @return Mutex struct pointer
*/
kmutex_t *self(void);
private:
/**
* @brief a Queue buffer
*/
kmutex_t _mutex_def;
};
......
......@@ -6,17 +6,23 @@
#include <k_api.h>
/** @defgroup cpp_aos_queue
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
#define Queue_WAIT_FOREVER 0xFFFFFFFFU
/**
* @brief Queue Class.
*
*/
class Queue
{
public:
/**
* This function will create a buf-queue
* @brief This function will create a buf-queue
* @param[in] name name of the queue
* @param[in] buf pointer to the buf
* @param[in] size size of the buf
......@@ -27,14 +33,14 @@ namespace AOS {
size_t max_msg);
/**
* This function will delete a queue
* @brief This function will delete a queue
* @param[in] NULL
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t destory(void);
/**
* This function will send a msg at the end of queue
* @brief This function will send a msg at the end of queue
* @param[in] msg pointer to msg to be send
* @param[in] size size of the msg
* @return the operation status, RHINO_SUCCESS is OK, others is error
......@@ -42,7 +48,7 @@ namespace AOS {
kstat_t send(void *msg, size_t size);
/**
* This function will receive msg form aqueue
* @brief This function will receive msg form aqueue
* @param[out] msg pointer to the buf to save msg
* @param[out] size size of received msg
* @param[in] millisec millisec to wait before receiving msg
......@@ -51,14 +57,14 @@ namespace AOS {
kstat_t receive(void *msg, size_t *size, uint32_t millisec);
/**
* This function will reset queue
* @brief This function will reset queue
* @param[in] NULL
* @return the operation status, RHINO_SUCCESS is OK, others is error
*/
kstat_t flush(void);
/**
* This function will get information of a queue
* @brief This function will get information of a queue
* @param[out] free free size of the queue buf
* @param[out] total total size of the queue buf
* @return the operation status, RHINO_SUCCESS is OK, others is error
......@@ -66,13 +72,16 @@ namespace AOS {
kstat_t info_get(kbuf_queue_info_t *info);
/**
* This function will get a Queue struct pointer
* @brief This function will get a Queue struct pointer
* @param[in] none
* @return Queue struct pointer
*/
kbuf_queue_t *self(void);
private:
/**
* @brief a Queue buffer
*/
kbuf_queue_t _buf_queue_def;
};
......
......@@ -6,12 +6,18 @@
#include <k_api.h>
/** @defgroup cpp_aos_sem
* @{
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
#define Semaphore_WAIT_FOREVER 0xFFFFFFFFU
/**
* @brief Semaphore Class.
*
*/
class Semaphore
{
public:
......@@ -73,6 +79,9 @@ namespace AOS {
ksem_t *self(void);
private:
/**
* @brief a Queue buffer
*/
ksem_t _sem_def;
};
......
......@@ -6,12 +6,18 @@
#include <k_api.h>
/** @defgroup cpp_aos_thread
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
#define Thread_WAIT_FOREVER 0xFFFFFFFFU
/**
* @brief thread Class.
*
*/
class thread
{
public:
......@@ -132,6 +138,9 @@ namespace AOS {
#endif
private:
/**
* @brief a Queue buffer
*/
ktask_t *p_thread_def;
};
......
......@@ -6,12 +6,18 @@
#include <k_api.h>
/** @defgroup cpp_aos_timer
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
#define Timer_WAIT_FOREVER 0xFFFFFFFFU
/**
* @brief Timer Class.
*
*/
class Timer
{
public:
......@@ -55,6 +61,9 @@ namespace AOS {
ktimer_t *self(void);
private:
/**
* @brief a Queue buffer
*/
ktimer_t _timer_def;
};
......
......@@ -6,10 +6,16 @@
#include <k_api.h>
/** @defgroup cpp_aos_workqueue
* @ingroup cpp_aos_api
* @{
*/
namespace AOS {
/**
* @brief WorkQueue Class.
*
*/
class WorkQueue
{
public:
......@@ -84,6 +90,9 @@ namespace AOS {
kwork_t *self(void);
private:
/**
* @brief a Queue buffer
*/
kwork_t _work_def;
};
......
/**************************************************************************//**
* @file ARMCM0.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM0 Device
* @version V5.3.1
* @date 09. July 2018
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
#ifndef ARMCM0_H
#define ARMCM0_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------- Interrupt Number Definition ------------------------ */
typedef enum IRQn
{
/* ------------------- Processor Exceptions Numbers ----------------------------- */
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
SVCall_IRQn = -5, /* 11 SV Call Interrupt */
PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
SysTick_IRQn = -1, /* 15 System Tick Interrupt */
/* ------------------- Processor Interrupt Numbers ------------------------------ */
Interrupt0_IRQn = 0,
Interrupt1_IRQn = 1,
Interrupt2_IRQn = 2,
Interrupt3_IRQn = 3,
Interrupt4_IRQn = 4,
Interrupt5_IRQn = 5,
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
} IRQn_Type;
/* ================================================================================ */
/* ================ Processor and Core Peripheral Section ================ */
/* ================================================================================ */
/* ------- Start of section using anonymous unions and disabling warnings ------- */
#if defined (__CC_ARM)
#pragma push
#pragma anon_unions
#elif defined (__ICCARM__)
#pragma language=extended
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#elif defined (__GNUC__)
/* anonymous unions are enabled by default */
#elif defined (__TMS470__)
/* anonymous unions are enabled by default */
#elif defined (__TASKING__)
#pragma warning 586
#elif defined (__CSMC__)
/* anonymous unions are enabled by default */
#else
#warning Not supported compiler type
#endif
/* -------- Configuration of Core Peripherals ----------------------------------- */
#define __CM0_REV 0x0000U /* Core revision r0p0 */
#define __MPU_PRESENT 0U /* no MPU present */
#define __VTOR_PRESENT 0U /* no VTOR present */
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include "core_cm0.h" /* Processor and core peripherals */
#include "system_ARMCM0.h" /* System Header */
/* -------- End of section using anonymous unions and disabling warnings -------- */
#if defined (__CC_ARM)
#pragma pop
#elif defined (__ICCARM__)
/* leave anonymous unions enabled */
#elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
#pragma clang diagnostic pop
#elif defined (__GNUC__)
/* anonymous unions are enabled by default */
#elif defined (__TMS470__)
/* anonymous unions are enabled by default */
#elif defined (__TASKING__)
#pragma warning restore
#elif defined (__CSMC__)
/* anonymous unions are enabled by default */
#else
#warning Not supported compiler type
#endif
#ifdef __cplusplus
}
#endif
#endif /* ARMCM0_H */
/******************************************************************************
* @file cachel1_armv7.h
* @brief CMSIS Level 1 Cache API for Armv7-M and later
* @version V1.0.0
* @date 03. March 2020
******************************************************************************/
/*
* Copyright (c) 2020 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef ARM_CACHEL1_ARMV7_H
#define ARM_CACHEL1_ARMV7_H
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_CacheFunctions Cache Functions
\brief Functions that configure Instruction and Data cache.
@{
*/
/* Cache Size ID Register Macros */
#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos)
#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos )
#ifndef __SCB_DCACHE_LINE_SIZE
#define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */
#endif
#ifndef __SCB_ICACHE_LINE_SIZE
#define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */
#endif
/**
\brief Enable I-Cache
\details Turns on I-Cache
*/
__STATIC_FORCEINLINE void SCB_EnableICache (void)
{
#if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)
if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */
__DSB();
__ISB();
SCB->ICIALLU = 0UL; /* invalidate I-Cache */
__DSB();
__ISB();
SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */
__DSB();
__ISB();
#endif
}
/**
\brief Disable I-Cache
\details Turns off I-Cache
*/
__STATIC_FORCEINLINE void SCB_DisableICache (void)
{
#if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)
__DSB();
__ISB();
SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */
SCB->ICIALLU = 0UL; /* invalidate I-Cache */
__DSB();
__ISB();
#endif
}
/**
\brief Invalidate I-Cache
\details Invalidates I-Cache
*/
__STATIC_FORCEINLINE void SCB_InvalidateICache (void)
{
#if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)
__DSB();
__ISB();
SCB->ICIALLU = 0UL;
__DSB();
__ISB();
#endif
}
/**
\brief I-Cache Invalidate by address
\details Invalidates I-Cache for the given address.
I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity.
I-Cache memory blocks which are part of given address + given size are invalidated.
\param[in] addr address
\param[in] isize size of memory block (in number of bytes)
*/
__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize)
{
#if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)
if ( isize > 0 ) {
int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U));
uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */;
__DSB();
do {
SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */
op_addr += __SCB_ICACHE_LINE_SIZE;
op_size -= __SCB_ICACHE_LINE_SIZE;
} while ( op_size > 0 );
__DSB();
__ISB();
}
#endif
}
/**
\brief Enable D-Cache
\details Turns on D-Cache
*/
__STATIC_FORCEINLINE void SCB_EnableDCache (void)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
uint32_t ccsidr;
uint32_t sets;
uint32_t ways;
if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */
SCB->CSSELR = 0U; /* select Level 1 data cache */
__DSB();
ccsidr = SCB->CCSIDR;
/* invalidate D-Cache */
sets = (uint32_t)(CCSIDR_SETS(ccsidr));
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) |
((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways-- != 0U);
} while(sets-- != 0U);
__DSB();
SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */
__DSB();
__ISB();
#endif
}
/**
\brief Disable D-Cache
\details Turns off D-Cache
*/
__STATIC_FORCEINLINE void SCB_DisableDCache (void)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
uint32_t ccsidr;
uint32_t sets;
uint32_t ways;
SCB->CSSELR = 0U; /* select Level 1 data cache */
__DSB();
SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */
__DSB();
ccsidr = SCB->CCSIDR;
/* clean & invalidate D-Cache */
sets = (uint32_t)(CCSIDR_SETS(ccsidr));
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) |
((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways-- != 0U);
} while(sets-- != 0U);
__DSB();
__ISB();
#endif
}
/**
\brief Invalidate D-Cache
\details Invalidates D-Cache
*/
__STATIC_FORCEINLINE void SCB_InvalidateDCache (void)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
uint32_t ccsidr;
uint32_t sets;
uint32_t ways;
SCB->CSSELR = 0U; /* select Level 1 data cache */
__DSB();
ccsidr = SCB->CCSIDR;
/* invalidate D-Cache */
sets = (uint32_t)(CCSIDR_SETS(ccsidr));
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) |
((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways-- != 0U);
} while(sets-- != 0U);
__DSB();
__ISB();
#endif
}
/**
\brief Clean D-Cache
\details Cleans D-Cache
*/
__STATIC_FORCEINLINE void SCB_CleanDCache (void)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
uint32_t ccsidr;
uint32_t sets;
uint32_t ways;
SCB->CSSELR = 0U; /* select Level 1 data cache */
__DSB();
ccsidr = SCB->CCSIDR;
/* clean D-Cache */
sets = (uint32_t)(CCSIDR_SETS(ccsidr));
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) |
((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways-- != 0U);
} while(sets-- != 0U);
__DSB();
__ISB();
#endif
}
/**
\brief Clean & Invalidate D-Cache
\details Cleans and Invalidates D-Cache
*/
__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
uint32_t ccsidr;
uint32_t sets;
uint32_t ways;
SCB->CSSELR = 0U; /* select Level 1 data cache */
__DSB();
ccsidr = SCB->CCSIDR;
/* clean & invalidate D-Cache */
sets = (uint32_t)(CCSIDR_SETS(ccsidr));
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) |
((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways-- != 0U);
} while(sets-- != 0U);
__DSB();
__ISB();
#endif
}
/**
\brief D-Cache Invalidate by address
\details Invalidates D-Cache for the given address.
D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity.
D-Cache memory blocks which are part of given address + given size are invalidated.
\param[in] addr address
\param[in] dsize size of memory block (in number of bytes)
*/
__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
if ( dsize > 0 ) {
int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U));
uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */;
__DSB();
do {
SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */
op_addr += __SCB_DCACHE_LINE_SIZE;
op_size -= __SCB_DCACHE_LINE_SIZE;
} while ( op_size > 0 );
__DSB();
__ISB();
}
#endif
}
/**
\brief D-Cache Clean by address
\details Cleans D-Cache for the given address
D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity.
D-Cache memory blocks which are part of given address + given size are cleaned.
\param[in] addr address
\param[in] dsize size of memory block (in number of bytes)
*/
__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
if ( dsize > 0 ) {
int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U));
uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */;
__DSB();
do {
SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */
op_addr += __SCB_DCACHE_LINE_SIZE;
op_size -= __SCB_DCACHE_LINE_SIZE;
} while ( op_size > 0 );
__DSB();
__ISB();
}
#endif
}
/**
\brief D-Cache Clean and Invalidate by address
\details Cleans and invalidates D_Cache for the given address
D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity.
D-Cache memory blocks which are part of given address + given size are cleaned and invalidated.
\param[in] addr address (aligned to 32-byte boundary)
\param[in] dsize size of memory block (in number of bytes)
*/
__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
if ( dsize > 0 ) {
int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U));
uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */;
__DSB();
do {
SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */
op_addr += __SCB_DCACHE_LINE_SIZE;
op_size -= __SCB_DCACHE_LINE_SIZE;
} while ( op_size > 0 );
__DSB();
__ISB();
}
#endif
}
/*@} end of CMSIS_Core_CacheFunctions */
#endif /* ARM_CACHEL1_ARMV7_H */
此差异已折叠。
此差异已折叠。
此差异已折叠。
/**************************************************************************//**
* @file cmsis_compiler.h
* @brief CMSIS compiler generic header file
* @version V5.1.0
* @date 09. October 2018
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
#ifndef __CMSIS_COMPILER_H
#define __CMSIS_COMPILER_H
#include <stdint.h>
/*
* Arm Compiler 4/5
*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*
* Arm Compiler 6.6 LTM (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
#include "cmsis_armclang_ltm.h"
/*
* Arm Compiler above 6.10.1 (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
#include "cmsis_armclang.h"
/*
* GNU Compiler
*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*
* IAR Compiler
*/
#elif defined ( __ICCARM__ )
#include <cmsis_iccarm.h>
/*
* TI Arm Compiler
*/
#elif defined ( __TI_ARM__ )
#include <cmsis_ccs.h>
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __attribute__((packed))
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __attribute__((packed))
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
/*
* TASKING Compiler
*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __packed__
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __packed__
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __packed__
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __packed__ T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __align(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
/*
* COSMIC Compiler
*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#ifndef __ASM
#define __ASM _asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
// NO RETURN is automatically detected hence no warning here
#define __NO_RETURN
#endif
#ifndef __USED
#warning No compiler specific solution for __USED. __USED is ignored.
#define __USED
#endif
#ifndef __WEAK
#define __WEAK __weak
#endif
#ifndef __PACKED
#define __PACKED @packed
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT @packed struct
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION @packed union
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
@packed struct T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
#define __ALIGNED(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
#else
#error Unknown compiler.
#endif
#endif /* __CMSIS_COMPILER_H */
此差异已折叠。
此差异已折叠。
/**************************************************************************//**
* @file cmsis_version.h
* @brief CMSIS Core(M) Version definitions
* @version V5.0.4
* @date 23. July 2019
******************************************************************************/
/*
* Copyright (c) 2009-2019 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CMSIS_VERSION_H
#define __CMSIS_VERSION_H
/* CMSIS Version definitions */
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
#define __CM_CMSIS_VERSION_SUB ( 4U) /*!< [15:0] CMSIS Core(M) sub version */
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*
* Copyright (C) 2017-2020 Alibaba Group Holding Limited
*/
/******************************************************************************
* @file csi_core_cmsis.h
* @brief Header File for csi_core
* @version V1.0
* @date 12. June 2020
******************************************************************************/
#ifndef _CSI_CORE_CMSIS_H_
#define _CSI_CORE_CMSIS_H_
#include <stddef.h>
#include <cmsis_gcc.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------- Interrupt Number Definition ------------------------ */
typedef enum IRQn
{
/* ------------------- Processor Exceptions Numbers ----------------------------- */
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
SVCall_IRQn = -5, /* 11 SV Call Interrupt */
PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
SysTick_IRQn = -1, /* 15 System Tick Interrupt */
/* ------------------- Processor Interrupt Numbers ------------------------------ */
Interrupt0_IRQn = 0,
Interrupt1_IRQn = 1,
Interrupt2_IRQn = 2,
Interrupt3_IRQn = 3,
Interrupt4_IRQn = 4,
Interrupt5_IRQn = 5,
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
} IRQn_Type;
#if defined(__CPU_CORTEXM0__)
#define __CM0_REV 0x0000U /* Core revision r0p0 */
#define __MPU_PRESENT 0U /* no MPU present */
#define __VTOR_PRESENT 0U /* no VTOR present */
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include <../../CMSIS/Core/Include/core_cm0.h>
#elif defined(__CPU_CORTEXM0PLUS__)
#define __CM0PLUS_REV 0x0001U /* Core revision r0p1 */
#define __MPU_PRESENT 0U /* no MPU present */
#define __VTOR_PRESENT 0U /* no VTOR present */
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include <core_cm0plus.h>
#elif defined(__CPU_CORTEXM1__)
#define __CM1_REV 0x0100U /* Core revision r1p0 */
#define __MPU_PRESENT 0U /* no MPU present */
#define __VTOR_PRESENT 0U /* no VTOR present */
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include <core_cm1.h>
#elif defined(__CPU_CORTEXM23__)
#define __CM23_REV 0x0100U /* Core revision r1p0 */
#define __SAUREGION_PRESENT 0U /* SAU regions are not present */
#define __MPU_PRESENT 1U /* MPU is present */
#define __VTOR_PRESENT 1U /* VTOR is present */
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include <core_cm23.h>
#elif defined(__CPU_CORTEXM33__)
#define __CM33_REV 0x0000U /* Core revision r0p1 */
#define __SAUREGION_PRESENT 0U /* SAU regions present */
#define __MPU_PRESENT 1U /* MPU present */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 0U /* no FPU present */
#define __DSP_PRESENT 0U /* no DSP extension present */
#include <core_cm33.h>
#elif defined(__CPU_CORTEXM35P__)
#define __CM35P_REV 0x0000U /* Core revision r0p0 */
#define __SAUREGION_PRESENT 0U /* SAU regions present */
#define __MPU_PRESENT 1U /* MPU present */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 0U /* no FPU present */
#define __DSP_PRESENT 0U /* no DSP extension present */
#include <core_cm35p.h>
#elif defined(__CPU_CORTEXM3__)
#define __CM3_REV 0x0201U /* Core revision r2p1 */
#define __MPU_PRESENT 1U /* MPU present */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include <core_cm3.h>
#elif defined(__CPU_CORTEXM4__)
#define __CM4_REV 0x0001U /* Core revision r0p1 */
#define __MPU_PRESENT 1U /* MPU present */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 0U /* no FPU present */
#include <core_cm4.h>
#elif defined(__CPU_CORTEXM55__)
#define __CM55_REV 0x0001U /* Core revision r0p1 */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __MPU_PRESENT 1U /* MPU present */
#define __FPU_PRESENT 1U /* FPU present */
#define __FPU_DP 1U /* double precision FPU */
#define __DSP_PRESENT 1U /* DSP extension present */
#define __SAUREGION_PRESENT 1U /* SAU regions present */
#define __PMU_PRESENT 1U /* PMU present */
#define __PMU_NUM_EVENTCNT 8U /* PMU Event Counters */
#define __ICACHE_PRESENT 1U /* Instruction Cache present */
#define __DCACHE_PRESENT 1U /* Data Cache present */
#include <core_cm55.h>
#elif defined(__CPU_CORTEXM7__)
#define __CM7_REV 0x0000U /* Core revision r0p0 */
#define __MPU_PRESENT 1U /* MPU present */
#define __VTOR_PRESENT 1U /* VTOR present */
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 0U /* no FPU present */
#define __FPU_DP 0U /* unused */
#define __ICACHE_PRESENT 1U /* Instruction Cache present */
#define __DCACHE_PRESENT 1U /* Data Cache present */
#define __DTCM_PRESENT 1U /* Data Tightly Coupled Memory present */
#include <core_cm7.h>
#endif
__STATIC_INLINE uint32_t csi_coret_config(uint32_t ticks, int32_t IRQn)
{
return SysTick_Config(ticks);
}
__STATIC_INLINE uint32_t csi_coret_get_load(void)
{
return SysTick->LOAD;
}
__STATIC_INLINE uint32_t csi_coret_get_value(void)
{
return SysTick->VAL;
}
__STATIC_INLINE void csi_coret_clear_irq(void)
{
}
#ifdef __GNUC__
#define __ALWAYS_STATIC_INLINE __attribute__((always_inline)) static inline
__STATIC_INLINE size_t csi_irq_save(void)
{
uint32_t result;
result = __get_PRIMASK();
__disable_irq();
return (result);
}
__STATIC_INLINE void csi_irq_restore(size_t irq_state)
{
__set_PRIMASK(irq_state);
}
#else
static inline __asm size_t csi_irq_save(void)
{
MRS R0, PRIMASK
CPSID I
BX LR
return 0;
}
static inline __asm void csi_irq_restore(size_t irq_state)
{
MSR PRIMASK, R0
BX LR
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* _CSI_CORE_H_ */
/******************************************************************************
* @file mpu_armv7.h
* @brief CMSIS MPU API for Armv7-M MPU
* @version V5.1.2
* @date 25. May 2020
******************************************************************************/
/*
* Copyright (c) 2017-2020 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef ARM_MPU_ARMV7_H
#define ARM_MPU_ARMV7_H
#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes
#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes
#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes
#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes
#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes
#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte
#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes
#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes
#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes
#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes
#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes
#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes
#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes
#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes
#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes
#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte
#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes
#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes
#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes
#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes
#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes
#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes
#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes
#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes
#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes
#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte
#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes
#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes
#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access
#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only
#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only
#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access
#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only
#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access
/** MPU Region Base Address Register Value
*
* \param Region The region to be configured, number 0 to 15.
* \param BaseAddress The base address for the region.
*/
#define ARM_MPU_RBAR(Region, BaseAddress) \
(((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
((Region) & MPU_RBAR_REGION_Msk) | \
(MPU_RBAR_VALID_Msk))
/**
* MPU Memory Access Attributes
*
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
* \param IsShareable Region is shareable between multiple bus masters.
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
*/
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
(((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
(((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
(((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk))
/**
* MPU Region Attribute and Size Register Value
*
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
* \param SubRegionDisable Sub-region disable field.
* \param Size Region size of the region to be configured, for example 4K, 8K.
*/
#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \
((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
(((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \
(((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \
(((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \
(((MPU_RASR_ENABLE_Msk))))
/**
* MPU Region Attribute and Size Register Value
*
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
* \param IsShareable Region is shareable between multiple bus masters.
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
* \param SubRegionDisable Sub-region disable field.
* \param Size Region size of the region to be configured, for example 4K, 8K.
*/
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
/**
* MPU Memory Access Attribute for strongly ordered memory.
* - TEX: 000b
* - Shareable
* - Non-cacheable
* - Non-bufferable
*/
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
/**
* MPU Memory Access Attribute for device memory.
* - TEX: 000b (if shareable) or 010b (if non-shareable)
* - Shareable or non-shareable
* - Non-cacheable
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
*
* \param IsShareable Configures the device memory as shareable or non-shareable.
*/
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
/**
* MPU Memory Access Attribute for normal memory.
* - TEX: 1BBb (reflecting outer cacheability rules)
* - Shareable or non-shareable
* - Cacheable or non-cacheable (reflecting inner cacheability rules)
* - Bufferable or non-bufferable (reflecting inner cacheability rules)
*
* \param OuterCp Configures the outer cache policy.
* \param InnerCp Configures the inner cache policy.
* \param IsShareable Configures the memory as shareable or non-shareable.
*/
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U))
/**
* MPU Memory Access Attribute non-cacheable policy.
*/
#define ARM_MPU_CACHEP_NOCACHE 0U
/**
* MPU Memory Access Attribute write-back, write and read allocate policy.
*/
#define ARM_MPU_CACHEP_WB_WRA 1U
/**
* MPU Memory Access Attribute write-through, no write allocate policy.
*/
#define ARM_MPU_CACHEP_WT_NWA 2U
/**
* MPU Memory Access Attribute write-back, no write allocate policy.
*/
#define ARM_MPU_CACHEP_WB_NWA 3U
/**
* Struct for a single MPU Region
*/
typedef struct {
uint32_t RBAR; //!< The region base address register value (RBAR)
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
} ARM_MPU_Region_t;
/** Enable the MPU.
* \param MPU_Control Default access permissions for unconfigured regions.
*/
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
{
__DMB();
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
#endif
__DSB();
__ISB();
}
/** Disable the MPU.
*/
__STATIC_INLINE void ARM_MPU_Disable(void)
{
__DMB();
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
#endif
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
__DSB();
__ISB();
}
/** Clear and disable the given MPU region.
* \param rnr Region number to be cleared.
*/
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
{
MPU->RNR = rnr;
MPU->RASR = 0U;
}
/** Configure an MPU region.
* \param rbar Value for RBAR register.
* \param rasr Value for RASR register.
*/
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
{
MPU->RBAR = rbar;
MPU->RASR = rasr;
}
/** Configure the given MPU region.
* \param rnr Region number to be configured.
* \param rbar Value for RBAR register.
* \param rasr Value for RASR register.
*/
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
{
MPU->RNR = rnr;
MPU->RBAR = rbar;
MPU->RASR = rasr;
}
/** Memcopy with strictly ordered memory access, e.g. for register targets.
* \param dst Destination data is copied to.
* \param src Source data is copied from.
* \param len Amount of data words to be copied.
*/
__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
{
uint32_t i;
for (i = 0U; i < len; ++i)
{
dst[i] = src[i];
}
}
/** Load the given number of MPU regions from a table.
* \param table Pointer to the MPU configuration table.
* \param cnt Amount of regions to be configured.
*/
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
{
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
while (cnt > MPU_TYPE_RALIASES) {
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
table += MPU_TYPE_RALIASES;
cnt -= MPU_TYPE_RALIASES;
}
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
}
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册