Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不穿格子衫的农民
TencentOS Tiny
提交
58314cf3
T
TencentOS Tiny
项目概览
不穿格子衫的农民
/
TencentOS Tiny
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TencentOS Tiny
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
58314cf3
编写于
9月 17, 2019
作者:
S
supowang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix doc
fix doc
上级
65ce348b
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
103 addition
and
375 deletion
+103
-375
README.md
README.md
+5
-2
board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c
board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c
+31
-32
board/TencentOS_tiny_EVB_MX/KEIL/farm_ai_demo/TencentOS_tiny.uvoptx
...entOS_tiny_EVB_MX/KEIL/farm_ai_demo/TencentOS_tiny.uvoptx
+1
-1
doc/TencentOS tiny内核移植指南(KEIL版).md
doc/TencentOS tiny内核移植指南(KEIL版).md
+0
-281
doc/TencentOS-tiny-porting(MacOS_STM32CubeIDE).md
doc/TencentOS-tiny-porting(MacOS_STM32CubeIDE).md
+6
-7
doc/TencentOS-tiny-porting-gcc.md
doc/TencentOS-tiny-porting-gcc.md
+14
-12
doc/TencentOS-tiny-porting-iar.md
doc/TencentOS-tiny-porting-iar.md
+1
-1
doc/TencentOS-tiny-porting-keil.md
doc/TencentOS-tiny-porting-keil.md
+1
-1
doc/TencentOS-tiny-代码目录说明.md
doc/TencentOS-tiny-代码目录说明.md
+34
-0
doc/TencentOS-tiny代码目录.xlsx
doc/TencentOS-tiny代码目录.xlsx
+0
-0
doc/TencentOS-tiny定制开发板入门指南.docx
doc/TencentOS-tiny定制开发板入门指南.docx
+0
-0
doc/picture/introduction/EVB_MX.png
doc/picture/introduction/EVB_MX.png
+0
-0
examples/farm_ai_demo/farm_ai_demo.c
examples/farm_ai_demo/farm_ai_demo.c
+7
-36
examples/farm_ai_demo/farm_ai_demo.h
examples/farm_ai_demo/farm_ai_demo.h
+3
-2
未找到文件。
README.md
浏览文件 @
58314cf3
...
@@ -56,7 +56,7 @@ TencentOS tiny 主体架构图,从下到上主要包括:
...
@@ -56,7 +56,7 @@ TencentOS tiny 主体架构图,从下到上主要包括:
TencentOS tiny目前支持STM32、NXP、华大半导体、国民技术、GD32、Nordic、TI等主流MCU。当前已完成两套官方定制开发板设计,支持全系列STM32 NUCLEO官方评估板内核移植。TencentOS tiny 将携手合作伙伴为物联网终端厂家提供更优质的IoT终端软件解决方案,方便各种物联网设备快速接入腾讯云,共同扩展IoT生态,更好地支撑智慧城市、智能水表、智能家居、智能穿戴、车联网等多种行业应用。
TencentOS tiny目前支持STM32、NXP、华大半导体、国民技术、GD32、Nordic、TI等主流MCU。当前已完成两套官方定制开发板设计,支持全系列STM32 NUCLEO官方评估板内核移植。TencentOS tiny 将携手合作伙伴为物联网终端厂家提供更优质的IoT终端软件解决方案,方便各种物联网设备快速接入腾讯云,共同扩展IoT生态,更好地支撑智慧城市、智能水表、智能家居、智能穿戴、车联网等多种行业应用。
# 二、TencentOS tiny 代码目录
# 二、TencentOS tiny 代码目录
-
[
TencentOS tiny代码目录说明
](
./doc/TencentOS-tiny
代码目录.xlsx
)
-
[
TencentOS tiny代码目录说明
](
./doc/TencentOS-tiny
-代码目录说明.md
)
# 三、TencentOS tiny 参考文档
# 三、TencentOS tiny 参考文档
## 1、移植指南
## 1、移植指南
...
@@ -79,7 +79,10 @@ TencentOS tiny能支持物联网终端设备和业务快速接入[腾讯云物
...
@@ -79,7 +79,10 @@ TencentOS tiny能支持物联网终端设备和业务快速接入[腾讯云物
TencentOS tiny结合腾讯云物联网开发平台IoT Explorer,已经构筑起连接通讯芯片到云开发的能力,加上已经建设完成的国内最大规模LoRa网络,腾讯彻底打通从芯片通讯开发、网络支撑服务,物理设备定义管理,数据分析和多场景应用开发等全链条IoT云开发服务能力,重新定义了物联网开发模式,助力亿级设备多方式多模式低门槛接入腾讯云服务。作为物联网基础设施建设服务者,腾讯将持续打造开放的物联网生态体系,促进物联网生态良性发展。
TencentOS tiny结合腾讯云物联网开发平台IoT Explorer,已经构筑起连接通讯芯片到云开发的能力,加上已经建设完成的国内最大规模LoRa网络,腾讯彻底打通从芯片通讯开发、网络支撑服务,物理设备定义管理,数据分析和多场景应用开发等全链条IoT云开发服务能力,重新定义了物联网开发模式,助力亿级设备多方式多模式低门槛接入腾讯云服务。作为物联网基础设施建设服务者,腾讯将持续打造开放的物联网生态体系,促进物联网生态良性发展。
# 六、TencentOS tiny 快速入门参考
# 六、TencentOS tiny 快速入门参考
TencentOS tiny联合合作伙伴设计了定制开发板,开发者可以基于定制开发板进行快速入门学习,点击下载参考文档
TencentOS tiny联合合作伙伴(南京厚德物联网)设计了定制开发板,如下图:
![](
./doc/picture/introduction/EVB_MX.png
)
-
[
TencentOS tiny定制开发板购买链接
](
https://item.taobao.com/item.htm?id=602421545135
)
,开发者可以基于定制开发板进行快速入门学习,点击下载参考文档
-
[
TencentOS-tiny定制开发板入门指南
](
./doc/TencentOS-tiny定制开发板入门指南.pdf
)
-
[
TencentOS-tiny定制开发板入门指南
](
./doc/TencentOS-tiny定制开发板入门指南.pdf
)
# 七、贡献代码
# 七、贡献代码
...
...
board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c
浏览文件 @
58314cf3
#include "E53_IA1.h"
#include "E53_IA1.h"
#include "stm32l4xx.h"
#include "stm32l4xx.h"
#include "i2c.h"
#include "i2c.h"
#include "string.h"
const
int16_t
POLYNOMIAL
=
0x131
;
const
int16_t
POLYNOMIAL
=
0x131
;
E53_IA1_Data_TypeDef
E53_IA1_Data
;
E53_IA1_Data_TypeDef
E53_IA1_Data
;
...
@@ -161,10 +162,10 @@ void Init_Motor(void)
...
@@ -161,10 +162,10 @@ void Init_Motor(void)
/* GPIO Ports Clock Enable */
/* GPIO Ports Clock Enable */
IA1_Motor_GPIO_CLK_ENABLE
();
IA1_Motor_GPIO_CLK_ENABLE
();
/*Configure GPIO pin Output Level */
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin
(
IA1_Motor_GPIO_Port
,
IA1_Motor_Pin
,
GPIO_PIN_RESET
);
HAL_GPIO_WritePin
(
IA1_Motor_GPIO_Port
,
IA1_Motor_Pin
,
GPIO_PIN_RESET
);
E53_IA1_Data
.
MotorMode
=
0
;
E53_IA1_Data
.
MotorMode
=
0
;
/*Configure GPIO pin : PtPin */
/*Configure GPIO pin : PtPin */
GPIO_InitStruct
.
Pin
=
IA1_Motor_Pin
;
GPIO_InitStruct
.
Pin
=
IA1_Motor_Pin
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
...
@@ -216,7 +217,7 @@ void Init_Light(void)
...
@@ -216,7 +217,7 @@ void Init_Light(void)
/*Configure GPIO pin Output Level */
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin
(
IA1_Light_GPIO_Port
,
IA1_Light_Pin
,
GPIO_PIN_RESET
);
HAL_GPIO_WritePin
(
IA1_Light_GPIO_Port
,
IA1_Light_Pin
,
GPIO_PIN_RESET
);
E53_IA1_Data
.
LightMode
=
0
;
E53_IA1_Data
.
LightMode
=
0
;
/*Configure GPIO pin : PtPin */
/*Configure GPIO pin : PtPin */
GPIO_InitStruct
.
Pin
=
IA1_Light_Pin
;
GPIO_InitStruct
.
Pin
=
IA1_Light_Pin
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
...
@@ -235,9 +236,9 @@ void Init_E53_IA1(void)
...
@@ -235,9 +236,9 @@ void Init_E53_IA1(void)
//printf("E53_sensor_board init!\n");
//printf("E53_sensor_board init!\n");
MX_I2C1_Init
();
MX_I2C1_Init
();
Init_BH1750
();
Init_BH1750
();
Init_SHT30
();
Init_SHT30
();
Init_Motor
();
Init_Motor
();
Init_Light
();
Init_Light
();
memset
((
char
*
)
&
E53_IA1_Data
,
0
,
sizeof
(
E53_IA1_Data
));
memset
((
char
*
)
&
E53_IA1_Data
,
0
,
sizeof
(
E53_IA1_Data
));
}
}
...
@@ -251,40 +252,38 @@ void E53_IA1_Read_Data(void)
...
@@ -251,40 +252,38 @@ void E53_IA1_Read_Data(void)
{
{
char
data
[
3
];
//data array for checksum verification
char
data
[
3
];
//data array for checksum verification
unsigned
char
addr
=
0
;
unsigned
short
tmp
=
0
;
unsigned
short
tmp
=
0
;
float
t
=
0
;
uint16_t
dat
;
uint16_t
dat
;
uint8_t
SHT3X_Fetchcommand_Bbuffer
[
2
]
=
{
0xE0
,
0x00
};
//read the measurement results
uint8_t
SHT3X_Fetchcommand_Bbuffer
[
2
]
=
{
0xE0
,
0x00
};
//read the measurement results
uint8_t
SHT3X_Data_Buffer
[
6
];
//byte 0,1 is temperature byte 4,5 is humidity
uint8_t
SHT3X_Data_Buffer
[
6
];
//byte 0,1 is temperature byte 4,5 is humidity
E53_IA1_Data
.
Lux
=
Convert_BH1750
();
//Read bh1750 sensor data
E53_IA1_Data
.
Lux
=
Convert_BH1750
();
//Read bh1750 sensor data
HAL_I2C_Master_Transmit
(
&
hi2c1
,
SHT30_Addr
<<
1
,
SHT3X_Fetchcommand_Bbuffer
,
2
,
0x10
);
//Read sht30 sensor data
HAL_I2C_Master_Transmit
(
&
hi2c1
,
SHT30_Addr
<<
1
,
SHT3X_Fetchcommand_Bbuffer
,
2
,
0x10
);
//Read sht30 sensor data
HAL_I2C_Master_Receive
(
&
hi2c1
,(
SHT30_Addr
<<
1
)
+
1
,
SHT3X_Data_Buffer
,
6
,
0x10
);
HAL_I2C_Master_Receive
(
&
hi2c1
,(
SHT30_Addr
<<
1
)
+
1
,
SHT3X_Data_Buffer
,
6
,
0x10
);
// /* check tem */
// /* check tem */
data
[
0
]
=
SHT3X_Data_Buffer
[
0
];
data
[
0
]
=
SHT3X_Data_Buffer
[
0
];
data
[
1
]
=
SHT3X_Data_Buffer
[
1
];
data
[
1
]
=
SHT3X_Data_Buffer
[
1
];
data
[
2
]
=
SHT3X_Data_Buffer
[
2
];
data
[
2
]
=
SHT3X_Data_Buffer
[
2
];
tmp
=
SHT3x_CheckCrc
(
data
,
2
,
data
[
2
]);
tmp
=
SHT3x_CheckCrc
(
data
,
2
,
data
[
2
]);
if
(
!
tmp
)
/* value is ture */
if
(
!
tmp
)
/* value is ture */
{
{
dat
=
((
uint16_t
)
data
[
0
]
<<
8
)
|
data
[
1
];
dat
=
((
uint16_t
)
data
[
0
]
<<
8
)
|
data
[
1
];
E53_IA1_Data
.
Temperature
=
SHT3x_CalcTemperatureC
(
dat
);
E53_IA1_Data
.
Temperature
=
SHT3x_CalcTemperatureC
(
dat
);
}
}
// /* check humidity */
// /* check humidity */
data
[
0
]
=
SHT3X_Data_Buffer
[
3
];
data
[
0
]
=
SHT3X_Data_Buffer
[
3
];
data
[
1
]
=
SHT3X_Data_Buffer
[
4
];
data
[
1
]
=
SHT3X_Data_Buffer
[
4
];
data
[
2
]
=
SHT3X_Data_Buffer
[
5
];
data
[
2
]
=
SHT3X_Data_Buffer
[
5
];
tmp
=
SHT3x_CheckCrc
(
data
,
2
,
data
[
2
]);
tmp
=
SHT3x_CheckCrc
(
data
,
2
,
data
[
2
]);
if
(
!
tmp
)
/* value is ture */
if
(
!
tmp
)
/* value is ture */
{
{
dat
=
((
uint16_t
)
data
[
0
]
<<
8
)
|
data
[
1
];
dat
=
((
uint16_t
)
data
[
0
]
<<
8
)
|
data
[
1
];
E53_IA1_Data
.
Humidity
=
SHT3x_CalcRH
(
dat
);
E53_IA1_Data
.
Humidity
=
SHT3x_CalcRH
(
dat
);
}
}
}
}
...
...
board/TencentOS_tiny_EVB_MX/KEIL/farm_ai_demo/TencentOS_tiny.uvoptx
浏览文件 @
58314cf3
...
@@ -426,7 +426,7 @@
...
@@ -426,7 +426,7 @@
<Group>
<Group>
<GroupName>
Drivers/STM32L4xx_HAL_Driver
</GroupName>
<GroupName>
Drivers/STM32L4xx_HAL_Driver
</GroupName>
<tvExp>
1
</tvExp>
<tvExp>
0
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
<RteFlg>
0
</RteFlg>
...
...
doc/TencentOS tiny内核移植指南(KEIL版).md
已删除
100644 → 0
浏览文件 @
65ce348b
# TencentOS tiny 内核移植参考指南(Keil版)
### 一、移植前的准备
1.
##### 准备目标硬件(开发板/芯片/模组)
TencentOS tiny目前主要支持ARM Cortex M核芯片的移植,比如STM32 基于Cortex M核全系列、NXP 基于Cortex M核全系列等。本教程将使用STM32官方Demo开发板 NUCLEO-L073RZ进行示例移植,其他 ARM Cortex M系列开发板和芯片移植方法类似。
调试ARM Cortex M核还需要仿真器, NUCLEO-L073RZ自带ST-Link调试器,如果您的开发板或者芯片模组没有板载仿真器,就需要连接外置的仿真器,如J-Link、U-Link之类的。
2.
##### 准备编译器环境
本移植指南针对的是Keil编译器,所以我们移植内核前需要先安装Keil编译器,能编译ARM Cortex M核的Keil编译器现在也叫MDK,最新版本5.28a,下载地址为:https://www.keil.com/demo/eval/arm.htm
填写注册信息即可下载,下载完成在windows环境下按照提示安装即可,安装完成后需要自行购买软件License,避免32K Flash下载限制。
由于新版本的MDK编译器和芯片支持包是分离的,所以MDK(Keil)安装完成后,还需要安装对应芯片的器件支持包(PACK包),比如本教程示例的NUCLEO-L037RZ开发板的芯片是STM32L073RZ,就需要安装*Keil.STM32L0xx_DFP.2.0.1.pack*系列器件支持包,MDK所有支持芯片的PACK包下载地址为:http://www.keil.com/dd2/Pack/#/eula-container,您只需要根据您的芯片型号下载对应的PACK包即可,当然您也可以在MDK集成开发环境中在线下载安装。
3.
##### 准备芯片对应的裸机工程
移植TencentOS tiny基础内核需要您提前准备一个芯片对应的裸机工程,裸机工程包含基本的芯片启动文件、基础配置(时钟、主频等)、以及串口、基本GPIO驱动用于RTOS测试。
本教程使用ST官方的STM32CubeMX软件来自动化生成MDK裸机工程,STM32CubeMX的下载地址为:
https://www.st.com/content/st_com/zh/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html
安装STM32CubeMx还需要事先安装好JDK环境,您可以在互联网上查找如何安装和配置JDK环境,此处不再赘述。
CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板生成裸机工程了,如果您的芯片不是STM32,而是其他厂商的ARM Cortex M系列,您可以根据产商的指导准备裸机工程,后续的内核移植步骤是一致的。
###### 3.1 首先启动STM32CubeMX,新建工程
![](./picture/porting/cubemx_new_project.png)
###### 3.2 选择MCU型号
![](./picture/porting/cubemx_mcu.png)
如上图所示:通过MCU筛选来找到自己开发板对应的芯片型号,双击后弹出工程配置界面,如下图:
![](./picture/porting/cubemxproset.png)
###### 3.3 Pin设置界面配置时钟源
![](./picture/porting/cubemx_clock_source.png)
###### 3.4 Pin设置界面配置串口
![](./picture/porting/cubemx_uart.png)
###### 3.5 Pin设置界面配置GPIO
![](./picture/porting/cubemx_gpio.png)
###### 3.6 配置总线时钟
![](./picture/porting/cubemx_clock.png)
###### 3.7 工程生成参数配置
![](./picture/porting/cubemx_ide.png)
###### 3.8 代码生成方式配置
![](./picture/porting/cubemx_codeset.png)
###### 3.9 生成工程
![](./picture/porting/cubemx_codepro.png)
###### 3.10 keil下的裸机工程
点击生成代码后,生成的裸机工程效果如下:
![](./picture/porting/cubemx_keil.png)
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
4.
##### 准备TencentOS tiny的源码
TencentOS tiny的源码已经在内网开源,git下载地址为:http://git.code.oa.com/TencentOS_tiny/TencentOS_tiny.git
| 一级目录 | 二级目录|说明 |
| -------- | --------- | --------------- |----------|
| arch | arm | TencentOS tiny适配的IP核架构(含M核中断、调度、tick相关代码) |
| board | NUCLEO_L073RZ | 移植目标芯片的工程文件 |
| kernel | core | TencentOS tiny内核源码|
| | pm | TencentOS tiny低功耗模块源码 |
| osal | cmsis_os | TencentOS tiny提供的cmsis os 适配 |
由于本教程只介绍TencentOS tiny的内核移植,所以这里只需要用到 arch、board、kernel、osal四个目录下的源码。
### 二、内核移植
1.
##### 代码目录规划
!
[](
./picture/porting/porting001.png
)
如图所示,新建TencentOS_tiny主目录,并在主目录下添加四个子目录,其中arch、kernel、osal从代码仓直接拷贝过来即可,而board目录下则放入我们前面生成的裸机工程代码,我们移植的开发板取名叫NUCLEO_L073RZ,裸机代码全部拷贝到下面即可,如下图所示:
!
[](
./picture/porting/porting002.png
)
接下来进入TencentOS_tiny
\b
oard
\N
UCLEO_L073RZ
\M
DK-ARM目录,打开keil工程,我们开始添加TencentOS tiny的内核代码。
2.
##### 添加arch平台代码
!
[](
./picture/porting/toscode001.png
)
tos_cpu.c是TencentOS tiny 的CPU适配文件,包括堆栈初始化,中断适配等,如果您的芯片是ARM Cortex M核,该文件可以不做改动,M0、M3 、M4、M7是通用的,其他IP核需要重新适配;
port_s.S 文件是TencentOS tiny的任务调度汇编代码,主要做弹栈压栈等处理的,port_c.c适配systick等,这两个文件 每个IP核和编译器都是不一样的,如果您的芯片是ARM Cortex M核,我们都已经适配好,比如现在我们移植的芯片是STM32L073RZ,是ARM Cortex M0+核,使用的编译器是KEIL,所以我们选择arch
\a
rm
\a
rm-v7m
\c
ortex-m0+
\a
rmcc下的适配代码,如果你的开发板是STM32F429IG,M4核,编译器是GCC,则可以选择arch
\a
rm
\a
rm-v7m
\c
ortex-m4
\g
cc目录下的适配文件。
3.
##### 添加内核源码
内核源码kerne目录下包含core和pm两个目录,其中core下为基础内核,pm是内核中的低功耗组件;基础移植的时候可以不添加pm目录下的代码,如下图所示,添加基本内核源码:
!
[](
./picture/porting/toscode002.png
)
4.
##### 添加cmsis os源码
cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以简化大家将业务从其他RTOS迁移到TencentOS tiny的工作量。
!
[](
./picture/porting/toscode000.png
)
5.
##### 添加TencentOS tiny头文件目录
添加头文件目录前,我们在要移植的工程目录下新增一个 TOS_CONFIG文件夹,用于存放TencentOS tiny的配置头文件,也就是接下来要新建的tos_config.h文件;
TencentOS tiny所有要添加的头文件目录如下:
!
[](
./picture/porting/toscode003.png
)
6.
##### 新建TencentOS tiny系统配置文件 tos_config.h
*#ifndef TOS_CONFIG_H*
*#define TOS_CONFIG_H*
*#include "stm32l0xx.h" // 目标芯片头文件,用户需要根据情况更改*
*#define TOS_CFG_TASK_PRIO_MAX 10u // 配置TencentOS tiny默认支持的最大优先级数量*
*#define TOS_CFG_ROUND_ROBIN_EN 1u // 配置TencentOS tiny的内核是否开启时间片轮转*
*#define TOS_CFG_OBJECT_VERIFY 0u // 配置TencentOS tiny是否校验指针合法*
*#define TOS_CFG_EVENT_EN 1u // TencentOS tiny 事件模块功能宏*
*#define TOS_CFG_MMBLK_EN 1u //配置TencentOS tiny是否开启内存块管理模块*
*#define TOS_CFG_MMHEAP_EN 1u // 配置TencentOS tiny是否开启动态内存模块*
*#define TOS_CFG_MMHEAP_POOL_SIZE 0x100 // 配置TencentOS tiny动态内存池大小*
*#define TOS_CFG_MUTEX_EN 1u // 配置TencentOS tiny是否开启互斥锁模块*
*#define TOS_CFG_QUEUE_EN 1u // 配置TencentOS tiny是否开启队列模块*
*#define TOS_CFG_TIMER_EN 1u // 配置TencentOS tiny是否开启软件定时器模块*
*#define TOS_CFG_SEM_EN 1u // 配置TencentOS tiny是否开启信号量模块*
*#define TOS_CFG_TICKLESS_EN 0u // 配置Tickless 低功耗模块开关*
*#if (TOS_CFG_QUEUE_EN > 0u)*
*#define TOS_CFG_MSG_EN 1u*
*#else*
*#define TOS_CFG_MSG_EN 0u*
*#endif*
*#define TOS_CFG_MSG_POOL_SIZE 10u // 配置TencentOS tiny消息队列大小*
*#define TOS_CFG_IDLE_TASK_STK_SIZE 64u // 配置TencentOS tiny空闲任务栈大小*
*#define TOS_CFG_CPU_TICK_PER_SECOND 1000u // 配置TencentOS tiny的tick频率*
*#define TOS_CFG_CPU_CLOCK (SystemCoreClock) // 配置TencentOS tiny CPU频率*
*#define TOS_CFG_TIMER_AS_PROC 1u // 配置是否将TIMER配置成函数模式*
*#endif*
按照上面的模板配置好TencentOS tiny的各项功能后,将tos_config.h 文件放入要移植的board工程目录下即可,例如本教程是放到board
\N
UCLEO_L073RZ
\T
OS_CONFIG目录下。
这样,TencentOS tiny的源码就全部添加完毕了。
### 三、创建TencentOS tiny任务,测试移植结果
1.
##### 修改部分代码
###### 修改stm32l0xx_it.c的中断函数
在stm32l0xx_it.c文件中包含 tos.h 头文件
![](
./picture/porting/task001.png
)
在stm32l0xx_it.c文件中的PendSV_Handler函数前添加__weak关键字,因为该函数在TencentOS tiny的调度汇编中已经重新实现;同时在SysTick_Handler函数中添加TencentOS tiny的调度处理函数,如下图所示:
![](./picture/porting/task002.png)
2.
##### 编写TencentOS tiny 测试任务
###### 在mian.c 中添加TencentOS tiny 头文件,编写任务函数
#include "cmsis_os.h"
//task1
#define TASK1_STK_SIZE 256
void task1(void
*
pdata);
osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE);
//task2
#define TASK2_STK_SIZE 256
void task2(void
*
pdata);
osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE);
void task1(void
*
pdata)
{
int count = 1;
while(1)
{
printf("
\r\n
Hello world!
\r\n
###This is task1 ,count is %d
\r\n
", count++);
HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin);
osDelay(2000);
}
}
void task2(void
*
pdata)
{
int count = 1;
while(1)
{
printf("
\r\n
Hello TencentOS !
\r\n
**
*
This is task2 ,count is %d
\r\n
", count++);
osDelay(1000);
}
}
int fputc(int ch, FILE
*
f)
{
if (ch == '
\n
')
{
HAL_UART_Transmit(&huart2, (void
*
)"
\r
", 1,30000);
}
HAL_UART_Transmit(&huart2, (uint8_t
*
)&ch, 1, 0xFFFF);
return ch;
}
如图:
!
[](
./picture/porting/Task003.png
)
继续在main.c 的mian函数中硬件外设初始化代码后添加TencentOS tiny的初始化代码:
osKernelInitialize(); //TOS Tiny kernel initialize
osThreadCreate(osThread(task1), NULL);// Create task1
osThreadCreate(osThread(task2), NULL);// Create task2
osKernelStart();//Start TOS Tiny
如图:
!
[](
./picture/porting/task004.png
)
3.
##### 编译下载测试TencentOS tiny移植结果
!
[](
./picture/porting/task005.png
)
按照上图指示,进行编译下载到开发板即可完成TencentOS tiny的测试,如下图所示,可以看到串口交替打印信息,表示两个任务正在进行调度,切换运行:
!
[](
./picture/porting/task006.png
)
doc/TencentOS
tiny内核移植指南(MacOS STM32CubeIDE版
).md
→
doc/TencentOS
-tiny-porting(MacOS_STM32CubeIDE
).md
浏览文件 @
58314cf3
# TencentOS tiny内核移植指南(MacOS+STM32CubeIDE版)
# TencentOS tiny内核移植指南(MacOS+STM32CubeIDE版)
## 一、工程创建
## 一、工程创建
...
@@ -7,14 +7,13 @@
...
@@ -7,14 +7,13 @@
需要强调的是本文是以
`STM32L431`
芯片为基础的,如果是其它芯片,后面的步骤请做相应的调整。
需要强调的是本文是以
`STM32L431`
芯片为基础的,如果是其它芯片,后面的步骤请做相应的调整。
最后生成的工程目录如下:
最后生成的工程目录如下:
![](
https://main.qcloudimg.com/raw/d692d86434c953c178010acfcbecf7e7.png
)
!
[](
./picture/porting/porting_cubeide_001.png
)
## 二、TencentOS tiny代码准备
## 二、TencentOS tiny代码准备
只需要保留TencentOS这些目录下的代码,其它目录皆可删除。
只需要保留TencentOS这些目录下的代码,其它目录皆可删除。
![](
./picture/porting/porting_cubeide_002
.png
)
![](
https://main.qcloudimg.com/raw/25043ac8b3b6944670867960c4230abb
.png
)
在
`arch`
目录里需要删除的所有代码目录列表
在
`arch`
目录里需要删除的所有代码目录列表
...
@@ -39,15 +38,15 @@ $ mv TencentOS_tiny tiny
...
@@ -39,15 +38,15 @@ $ mv TencentOS_tiny tiny
1.
把代码
`tiny`
拷贝到第一步创建的工程目录里
1.
把代码
`tiny`
拷贝到第一步创建的工程目录里
!
[](
./picture/porting/porting_cubeide_003
.png
)
![](
https://main.qcloudimg.com/raw/c0cd1bc6d8e58f52939e19a3a13db74a
.png
)
刷新工程
刷新工程
!
[](
./picture/porting/porting_cubeide_004
.png
)
![](
https://main.qcloudimg.com/raw/14a6bf4775db3a9bc7162a8eebeddbfd
.png
)
把代码添加到工程里
把代码添加到工程里
!
[](
./picture/porting/porting_cubeide_005
.png
)
![](
https://main.qcloudimg.com/raw/1315cce3621fa7f2ff20a135d4d7bf3a
.png
)
2.
把下列头文件目录添加到工程里
2.
把下列头文件目录添加到工程里
...
...
doc/TencentOS-tiny-porting-gcc.md
浏览文件 @
58314cf3
...
@@ -42,29 +42,29 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
...
@@ -42,29 +42,29 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
![](
https://main.qcloudimg.com/raw/5c6a1eca65dbec90fe73402cc39a2fa4.png
)
![](
https://main.qcloudimg.com/raw/5c6a1eca65dbec90fe73402cc39a2fa4.png
)
#### 3.2 选择MCU型号
#### 3.2 选择MCU型号
![](
https://main.qcloudimg.com/raw/70d3cc4e69c36a9d9707efde2c0e2472.png
)
![](
https://main.qcloudimg.com/raw/70d3cc4e69c36a9d9707efde2c0e2472.png
)
如上图所示:通过MCU筛选来找到自己开发板对应的芯片型号,双击后弹出工程配置界面,如下图:
如上图所示:通过MCU筛选来找到自己开发板对应的芯片型号,双击后弹出工程配置界面,如下图:
![](
https://main.qcloudimg.com/raw/f8f05e6b8ef07fc9d30fa3c51a0c82fe.png
)
![](
https://main.qcloudimg.com/raw/f8f05e6b8ef07fc9d30fa3c51a0c82fe.png
)
#### 3.3 Pin设置界面配置时钟源
#### 3.3 Pin设置界面配置时钟源
![](
https://main.qcloudimg.com/raw/01dcc7684d340dca5d84b88e5b6b707b.png
)
![](
https://main.qcloudimg.com/raw/01dcc7684d340dca5d84b88e5b6b707b.png
)
#### 3.4 Pin设置界面配置串口
#### 3.4 Pin设置界面配置串口
![](
https://main.qcloudimg.com/raw/ffd52f709fd148ba7e654c8ce320d0ad.png
)
![](
https://main.qcloudimg.com/raw/ffd52f709fd148ba7e654c8ce320d0ad.png
)
#### 3.5 Pin设置界面配置GPIO
#### 3.5 Pin设置界面配置GPIO
![](
https://main.qcloudimg.com/raw/278977b909359db187519b8d6a9125d4.png
)
![](
https://main.qcloudimg.com/raw/278977b909359db187519b8d6a9125d4.png
)
#### 3.6 配置总线时钟
#### 3.6 配置总线时钟
![](
https://main.qcloudimg.com/raw/72f3f1ed823d1e57bac1eda0d0487b2f.png
)
![](
https://main.qcloudimg.com/raw/72f3f1ed823d1e57bac1eda0d0487b2f.png
)
#### 3.7 工程生成参数配置
#### 3.7 工程生成参数配置
![](
https://main.qcloudimg.com/raw/4dc67aba66af9240b3811079548c4bdb.png
)
![](
https://main.qcloudimg.com/raw/4dc67aba66af9240b3811079548c4bdb.png
)
...
@@ -75,14 +75,16 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
...
@@ -75,14 +75,16 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
![](
https://main.qcloudimg.com/raw/ecc132f84a548f8802abb7d8aefc8ba9.png
)
![](
https://main.qcloudimg.com/raw/ecc132f84a548f8802abb7d8aefc8ba9.png
)
#### 3.10 编译GCC下的裸机工程
#### 3.10 编译GCC下的裸机工程
点击生成代码后,生成的裸机工程效果如下,在makefile同级目录下打开windows的cmd命令窗口(目录下按shift+鼠标右键,点击在此处打开命令窗口),输入make命令,就可以编译gcc裸机工程了,编译完成后,可以看到生成了elf和bin文件,通过工具就可以下载bin文件到开发板运行了。
点击生成代码后,生成的裸机工程效果如下,在makefile同级目录下打开windows的cmd命令窗口(目录下按shift+鼠标右键,点击在此处打开命令窗口),输入make命令,就可以编译gcc裸机工程了,编译完成后,可以看到生成了elf和bin文件,通过工具就可以下载bin文件到开发板运行了。
![](
https://main.qcloudimg.com/raw/093a8de45e44f255ac8cd8ca859a5a1c.png
)
![](
https://main.qcloudimg.com/raw/093a8de45e44f255ac8cd8ca859a5a1c.png
)
### 4. 准备TencentOS tiny的源码
### 4. 准备TencentOS tiny的源码
TencentOS tiny的源码已经在内网开源,git下载地址为:
[
http://git.code.oa.com/TencentOS_tiny/TencentOS_tiny.git
](
)
TencentOS tiny的源码已经开源,github下载地址为:
[
https://github.com/Tencent/TencentOS-tiny.git
](
)
|一级目录 | 二级目录 | 说明 |
|一级目录 | 二级目录 | 说明 |
|---------|---------|---------|
|---------|---------|---------|
...
@@ -127,7 +129,7 @@ TencentOS tiny的源码已经在内网开源,git下载地址为:[http://git.
...
@@ -127,7 +129,7 @@ TencentOS tiny的源码已经在内网开源,git下载地址为:[http://git.
![](
https://main.qcloudimg.com/raw/d8fd36e0383589d8766809522d434b2b.png
)
![](
https://main.qcloudimg.com/raw/d8fd36e0383589d8766809522d434b2b.png
)
### 4. 添加cmsis os源码
### 4. 添加cmsis os源码
cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以简化大家将业务从其他RTOS迁移到TencentOS tiny的工作量。
cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以简化大家将业务从其他RTOS迁移到TencentOS tiny的工作量。
![](
https://main.qcloudimg.com/raw/f8ed59521bc83d0fdf52d59b195b455b.png
)
![](
https://main.qcloudimg.com/raw/f8ed59521bc83d0fdf52d59b195b455b.png
)
...
@@ -267,17 +269,17 @@ cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以
...
@@ -267,17 +269,17 @@ cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以
osThreadCreate(osThread(task2), NULL);// Create task2
osThreadCreate(osThread(task2), NULL);// Create task2
osKernelStart();//Start TOS Tiny
osKernelStart();//Start TOS Tiny
```
```
如图:
如图:
![](
https://main.qcloudimg.com/raw/9fe99042cc3bdf0b75aff576337343ba.png
)
![](
https://main.qcloudimg.com/raw/9fe99042cc3bdf0b75aff576337343ba.png
)
### 3. 编译下载测试TencentOS tiny移植结果
### 3. 编译下载测试TencentOS tiny移植结果
完成代码编辑后回到TencentOS_tiny
\b
oard
\N
UCLEO_L073RZ目录下,找到makefile文件,该目录下打开cmd命令窗口,输入make命令进行编译,得到bin文件,然后将bin文件通过下载工具下载到开发板即可完成TencentOS tiny的测试,如下图所示,可以看到串口交替打印信息,表示两个任务正在进行调度,切换运行:
完成代码编辑后回到TencentOS_tiny
\b
oard
\N
UCLEO_L073RZ目录下,找到makefile文件,该目录下打开cmd命令窗口,输入make命令进行编译,得到bin文件,然后将bin文件通过下载工具下载到开发板即可完成TencentOS tiny的测试,如下图所示,可以看到串口交替打印信息,表示两个任务正在进行调度,切换运行:
![](
https://main.qcloudimg.com/raw/e64474d46ddb9d622a6e38481c6a7859.png
)
![](
https://main.qcloudimg.com/raw/e64474d46ddb9d622a6e38481c6a7859.png
)
...
...
doc/TencentOS-tiny-porting-iar.md
浏览文件 @
58314cf3
...
@@ -73,7 +73,7 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
...
@@ -73,7 +73,7 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
### 4. 准备TencentOS tiny的源码
### 4. 准备TencentOS tiny的源码
TencentOS tiny的源码已经
在内网开源,git下载地址为:
[
http://git.code.oa.com/TencentOS_tiny/TencentOS_
tiny.git
](
)
TencentOS tiny的源码已经
开源,github下载地址为:
[
https://github.com/Tencent/TencentOS-
tiny.git
](
)
...
...
doc/TencentOS-tiny-porting-keil.md
浏览文件 @
58314cf3
...
@@ -73,7 +73,7 @@ TencentOS tiny目前主要支持ARM Cortex M核芯片的移植,比如STM32 基
...
@@ -73,7 +73,7 @@ TencentOS tiny目前主要支持ARM Cortex M核芯片的移植,比如STM32 基
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
### 4. 准备TencentOS tiny的源码
### 4. 准备TencentOS tiny的源码
TencentOS tiny的源码已经
在内网开源,git下载地址为:
[
http://git.code.oa.com/TencentOS_tiny/TencentOS_
tiny.git
](
)
TencentOS tiny的源码已经
开源,github下载地址为:
[
https://github.com/Tencent/TencentOS-
tiny.git
](
)
...
...
doc/TencentOS-tiny-代码目录说明.md
0 → 100644
浏览文件 @
58314cf3
# TencentOS tiny 代码目录说明
|一级目录 | 二级目录 | 三级目录 |说明 |
|---------|---------|---------|---------|
| arch | arm | |TencentOS tiny适配的IP核架构(含M核中断、调度、tick相关代码) |
| board | TencentOS_tiny_EVB_MX | |TencentOS tiny 定制开发板demo,包含AT适配框架、MQTT协议、安全组件等 |
| component | connectivity | loraWAN | loRaWAN协议栈实现源码及适配层|
| | |Eclipse-Paho-MQTT| MQTT协议栈实现源码及适配层|
| | |TencentCloud_SDK| 腾讯云C-SDK实现源码及适配层|
| | fs | | 文件系统实现源码|
| | security | | mbedtls 安全协议源码 |
| devices | | |TencentOS tiny适配的一些外设驱动(如串口wifi gprs 驱动等) |
| doc | | |TencentOS tiny相关技术文档及开发指南 |
| examples | | |TencentOS tiny提供的功能示例 |
| kernel | core | | TencentOS tiny内核源码|
| | hal | | TencentOS tiny驱动抽象层|
| | pm | | TencentOS tiny低功耗模块源码 |
| net | at | | TencentOS tiny为串口类通信模组提供的AT框架实现层|
| | lora_module_wrapper | | TencentOS tiny为串口类LoraWAN模块提供的移植框架|
| | lwip | | Lwip协议实现源码及适配层 |
| | sal_module_wrapper | | TencentOS tiny为串口类网络模块(wifi gprs)提供的socket移植框架 |
| | tencent_firmware_module_wrapper | | TencentOS tiny提供的腾讯定制模组移植框架 |
| osal | cmsis_os | |TencentOS tiny提供的cmsis os 适配 |
| platform | hal | | TencentOS tiny适配的部分芯片的驱动实现源码|
| | vendor_bsp | | 芯片厂家提供的原厂bsp固件库,如STM32的HAL库|
| test | | |存放TencentOS tiny提供的一些测试代码,含内核及上层模块示例及测试代码 |
| tools | | |存放TencentOS tiny提供的工具,小程序,配置工具等 |
doc/TencentOS-tiny代码目录.xlsx
已删除
100644 → 0
浏览文件 @
65ce348b
文件已删除
doc/TencentOS-tiny定制开发板入门指南.docx
已删除
100644 → 0
浏览文件 @
65ce348b
文件已删除
doc/picture/introduction/EVB_MX.png
0 → 100644
浏览文件 @
58314cf3
1.1 MB
examples/farm_ai_demo/farm_ai_demo.c
浏览文件 @
58314cf3
...
@@ -4,10 +4,8 @@
...
@@ -4,10 +4,8 @@
#include "E53_IA1.h"
#include "E53_IA1.h"
#include "mcu_init.h"
#include "mcu_init.h"
//#define USE_NB_BC35
#define USE_ESP8266
#define USE_ESP8266
int
sock_id
=
0
;
int
sock_id
=
0
;
double
math_keep_ndot
(
double
num
,
char
dot
){
double
math_keep_ndot
(
double
num
,
char
dot
){
...
@@ -42,7 +40,6 @@ static int str_to_hex(const char *bufin, int len, char *bufout)
...
@@ -42,7 +40,6 @@ static int str_to_hex(const char *bufin, int len, char *bufout)
int
mq_dev_report
(
void
)
int
mq_dev_report
(
void
)
{
{
char
*
data
;
char
*
data
;
char
topic
[
50
]
=
{
0
};
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
mqtt_pub_opt_t
pub_opt
;
mqtt_pub_opt_t
pub_opt
;
pub_opt
.
dup
=
0
;
pub_opt
.
dup
=
0
;
...
@@ -52,7 +49,6 @@ int mq_dev_report(void)
...
@@ -52,7 +49,6 @@ int mq_dev_report(void)
pub_opt
.
topic
=
MQTT_PUBLISH_TOPIC
;
pub_opt
.
topic
=
MQTT_PUBLISH_TOPIC
;
// {"motor":0,"light":1,"temperature":22.22,"humidity":55.55,"light_intensity":100.00}
// {"motor":0,"light":1,"temperature":22.22,"humidity":55.55,"light_intensity":100.00}
// printf("motor:%d,light:%d,tem:%f,humi:%f,lux:%f\n",E53_IA1_Data.MotorMode,E53_IA1_Data.LightMode,E53_IA1_Data.Temperature,E53_IA1_Data.Humidity,E53_IA1_Data.Lux);
root
=
cJSON_CreateObject
();
root
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
root
,
"motor"
,
E53_IA1_Data
.
MotorMode
);
cJSON_AddNumberToObject
(
root
,
"motor"
,
E53_IA1_Data
.
MotorMode
);
cJSON_AddNumberToObject
(
root
,
"light"
,
E53_IA1_Data
.
LightMode
);
cJSON_AddNumberToObject
(
root
,
"light"
,
E53_IA1_Data
.
LightMode
);
...
@@ -60,7 +56,6 @@ int mq_dev_report(void)
...
@@ -60,7 +56,6 @@ int mq_dev_report(void)
cJSON_AddNumberToObject
(
root
,
"humidity"
,
math_keep_ndot
((
double
)
E53_IA1_Data
.
Humidity
,
2
));
cJSON_AddNumberToObject
(
root
,
"humidity"
,
math_keep_ndot
((
double
)
E53_IA1_Data
.
Humidity
,
2
));
cJSON_AddNumberToObject
(
root
,
"light_intensity"
,
math_keep_ndot
((
double
)
E53_IA1_Data
.
Lux
,
2
));
cJSON_AddNumberToObject
(
root
,
"light_intensity"
,
math_keep_ndot
((
double
)
E53_IA1_Data
.
Lux
,
2
));
/* formatted print */
/* formatted print */
//data = cJSON_Print(root);
data
=
cJSON_PrintUnformatted
(
root
);
data
=
cJSON_PrintUnformatted
(
root
);
pub_opt
.
topic
=
MQTT_PUBLISH_TOPIC
;
pub_opt
.
topic
=
MQTT_PUBLISH_TOPIC
;
...
@@ -75,25 +70,23 @@ int mq_dev_report(void)
...
@@ -75,25 +70,23 @@ int mq_dev_report(void)
return
0
;
return
0
;
}
}
int
parse_dev_cmd
(
char
*
data
)
int
parse_dev_cmd
(
uint8_t
*
data
)
{
{
//{"motor":0,"light":1}
//{"motor":0,"light":1}
//JSON字符串到cJSON格式
//JSON字符串到cJSON格式
cJSON
*
cjson
=
cJSON_Parse
(
data
);
cJSON
*
cjson
=
cJSON_Parse
(
(
char
*
)
data
);
cJSON
*
cjsonret
=
NULL
;
cJSON
*
cjsonret
=
NULL
;
int
motor
;
int
motor
;
int
light
;
int
light
;
char
*
str
;
char
*
str
;
printf
(
"parse_dev_cmd...
\n
"
);
printf
(
"parse_dev_cmd...
\n
"
);
//判断cJSON_Parse函数返回值确定是否打包成�??
if
(
cjson
==
NULL
){
if
(
cjson
==
NULL
){
printf
(
"json pack into cjson error..."
);
printf
(
"json pack into cjson error..."
);
return
-
1
;
return
-
1
;
}
}
else
{
//打包成功调用cJSON_Print打印输出
else
{
cJSON_Print
(
cjson
);
cJSON_Print
(
cjson
);
}
}
cjsonret
=
NULL
;
cjsonret
=
NULL
;
cjsonret
=
cJSON_GetObjectItem
(
cjson
,
"motor"
);
cjsonret
=
cJSON_GetObjectItem
(
cjson
,
"motor"
);
if
(
cjsonret
!=
NULL
)
if
(
cjsonret
!=
NULL
)
...
@@ -127,7 +120,6 @@ int parse_dev_cmd(char *data)
...
@@ -127,7 +120,6 @@ int parse_dev_cmd(char *data)
light_control
(
0
);
light_control
(
0
);
}
}
}
}
cjsonret
=
cJSON_GetObjectItem
(
cjson
,
"speaker"
);
cjsonret
=
cJSON_GetObjectItem
(
cjson
,
"speaker"
);
if
(
cjsonret
!=
NULL
)
if
(
cjsonret
!=
NULL
)
{
{
...
@@ -142,11 +134,7 @@ int parse_dev_cmd(char *data)
...
@@ -142,11 +134,7 @@ int parse_dev_cmd(char *data)
speaker
(
str
);
speaker
(
str
);
tos_mmheap_free
(
str
);
tos_mmheap_free
(
str
);
}
}
}
}
//delete cjson
//delete cjson
cJSON_Delete
(
cjson
);
cJSON_Delete
(
cjson
);
return
0
;
return
0
;
...
@@ -156,7 +144,6 @@ int mq_dev_receiv(void){
...
@@ -156,7 +144,6 @@ int mq_dev_receiv(void){
static
int
count
=
1
;
static
int
count
=
1
;
uint8_t
read_data
[
100
];
uint8_t
read_data
[
100
];
int
read_len
;
int
read_len
;
char
topic
[
50
];
mqtt_sub_opt_t
sub_opt
;
mqtt_sub_opt_t
sub_opt
;
sub_opt
.
count
=
1
;
sub_opt
.
count
=
1
;
...
@@ -173,10 +160,10 @@ int mq_dev_receiv(void){
...
@@ -173,10 +160,10 @@ int mq_dev_receiv(void){
parse_dev_cmd
(
read_data
);
parse_dev_cmd
(
read_data
);
}
}
count
++
;
count
++
;
return
0
;
}
}
int
mq_dev_subscribe
(
void
){
int
mq_dev_subscribe
(
void
){
char
topic
[
50
];
mqtt_sub_opt_t
sub_opt
;
mqtt_sub_opt_t
sub_opt
;
sub_opt
.
count
=
1
;
sub_opt
.
count
=
1
;
...
@@ -189,7 +176,7 @@ int mq_dev_subscribe(void){
...
@@ -189,7 +176,7 @@ int mq_dev_subscribe(void){
if
(
tos_mqtt_subscribe
(
sock_id
,
&
sub_opt
)
!=
0
)
{
if
(
tos_mqtt_subscribe
(
sock_id
,
&
sub_opt
)
!=
0
)
{
printf
(
"subscribe failed!!!
\n
"
);
printf
(
"subscribe failed!!!
\n
"
);
}
}
return
0
;
}
}
void
ai_demo
(
void
)
void
ai_demo
(
void
)
{
{
...
@@ -201,17 +188,6 @@ void ai_demo(void)
...
@@ -201,17 +188,6 @@ void ai_demo(void)
esp8266_join_ap
(
"test"
,
"12345678"
);
esp8266_join_ap
(
"test"
,
"12345678"
);
#endif
#endif
#ifdef USE_M26
int
m26_sal_init
(
hal_uart_port_t
uart_port
);
m26_power_on
();
m26_sal_init
(
HAL_UART_PORT_0
);
#endif
#ifdef USE_NB_BC35
int
bc35_28_95_sal_init
(
hal_uart_port_t
uart_port
);
bc35_28_95_sal_init
(
HAL_UART_PORT_0
);
#endif
con_opt
.
keep_alive_interval
=
2000
;
con_opt
.
keep_alive_interval
=
2000
;
con_opt
.
cleansession
=
1
;
con_opt
.
cleansession
=
1
;
con_opt
.
username
=
MQTT_USR_NAME
;
con_opt
.
username
=
MQTT_USR_NAME
;
...
@@ -236,15 +212,10 @@ void sensor_read(void){
...
@@ -236,15 +212,10 @@ void sensor_read(void){
}
}
}
}
#define welcomspeak "��ӭTOS"
#define welcomspeak "欢迎TOS"
//#define welcomspeak "��ӭ"
//FD 00 06 01 01 BB B6 D3 AD
void
speaker
(
char
*
str
){
void
speaker
(
char
*
str
){
char
data
[
100
];
uint8_t
data
[
100
];
int16_t
len
=
0
;
int16_t
len
=
0
;
char
code
=
0
;
char
times
=
10
;
int
ret
;
len
=
2
+
strlen
(
str
);
len
=
2
+
strlen
(
str
);
printf
(
"speaker(%s)
\n
"
,
str
);
printf
(
"speaker(%s)
\n
"
,
str
);
...
...
examples/farm_ai_demo/farm_ai_demo.h
浏览文件 @
58314cf3
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
#include "mqtt_wrapper.h"
#include "mqtt_wrapper.h"
void
application_entry
(
void
*
arg
);
extern
void
application_entry
(
void
*
arg
);
extern
void
motor_control
(
char
mode
);
extern
void
light_control
(
char
mode
);
#endif
/* __APP_DEMO_H__ */
#endif
/* __APP_DEMO_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录