fix doc
fix doc
This commit is contained in:
@@ -56,7 +56,7 @@ TencentOS tiny 主体架构图,从下到上主要包括:
|
||||
TencentOS tiny目前支持STM32、NXP、华大半导体、国民技术、GD32、Nordic、TI等主流MCU。当前已完成两套官方定制开发板设计,支持全系列STM32 NUCLEO官方评估板内核移植。TencentOS tiny 将携手合作伙伴为物联网终端厂家提供更优质的IoT终端软件解决方案,方便各种物联网设备快速接入腾讯云,共同扩展IoT生态,更好地支撑智慧城市、智能水表、智能家居、智能穿戴、车联网等多种行业应用。
|
||||
|
||||
# 二、TencentOS tiny 代码目录
|
||||
- [TencentOS tiny代码目录说明](./doc/TencentOS-tiny代码目录.xlsx)
|
||||
- [TencentOS tiny代码目录说明](./doc/TencentOS-tiny-代码目录说明.md)
|
||||
|
||||
# 三、TencentOS tiny 参考文档
|
||||
## 1、移植指南
|
||||
@@ -79,7 +79,10 @@ TencentOS tiny能支持物联网终端设备和业务快速接入[腾讯云物
|
||||
TencentOS tiny结合腾讯云物联网开发平台IoT Explorer,已经构筑起连接通讯芯片到云开发的能力,加上已经建设完成的国内最大规模LoRa网络,腾讯彻底打通从芯片通讯开发、网络支撑服务,物理设备定义管理,数据分析和多场景应用开发等全链条IoT云开发服务能力,重新定义了物联网开发模式,助力亿级设备多方式多模式低门槛接入腾讯云服务。作为物联网基础设施建设服务者,腾讯将持续打造开放的物联网生态体系,促进物联网生态良性发展。
|
||||
|
||||
# 六、TencentOS tiny 快速入门参考
|
||||
TencentOS tiny联合合作伙伴设计了定制开发板,开发者可以基于定制开发板进行快速入门学习,点击下载参考文档
|
||||
TencentOS tiny联合合作伙伴(南京厚德物联网)设计了定制开发板,如下图:
|
||||

|
||||
|
||||
- [TencentOS tiny定制开发板购买链接](https://item.taobao.com/item.htm?id=602421545135),开发者可以基于定制开发板进行快速入门学习,点击下载参考文档
|
||||
- [TencentOS-tiny定制开发板入门指南](./doc/TencentOS-tiny定制开发板入门指南.pdf)
|
||||
|
||||
# 七、贡献代码
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "E53_IA1.h"
|
||||
#include "stm32l4xx.h"
|
||||
#include "i2c.h"
|
||||
#include "string.h"
|
||||
|
||||
const int16_t POLYNOMIAL = 0x131;
|
||||
E53_IA1_Data_TypeDef E53_IA1_Data;
|
||||
@@ -161,10 +162,10 @@ void Init_Motor(void)
|
||||
/* GPIO Ports Clock 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);
|
||||
E53_IA1_Data.MotorMode=0;
|
||||
/*Configure GPIO pin : PtPin */
|
||||
E53_IA1_Data.MotorMode=0;
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = IA1_Motor_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
@@ -216,7 +217,7 @@ void Init_Light(void)
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
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 */
|
||||
GPIO_InitStruct.Pin = IA1_Light_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
@@ -235,9 +236,9 @@ void Init_E53_IA1(void)
|
||||
//printf("E53_sensor_board init!\n");
|
||||
MX_I2C1_Init();
|
||||
Init_BH1750();
|
||||
Init_SHT30();
|
||||
Init_Motor();
|
||||
Init_Light();
|
||||
Init_SHT30();
|
||||
Init_Motor();
|
||||
Init_Light();
|
||||
memset((char *)&E53_IA1_Data,0,sizeof(E53_IA1_Data));
|
||||
}
|
||||
|
||||
@@ -251,40 +252,38 @@ void E53_IA1_Read_Data(void)
|
||||
{
|
||||
|
||||
char data[3]; //data array for checksum verification
|
||||
unsigned char addr = 0;
|
||||
unsigned short tmp = 0;
|
||||
float t = 0;
|
||||
uint16_t dat;
|
||||
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
|
||||
uint16_t dat;
|
||||
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
|
||||
|
||||
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_Receive(&hi2c1,(SHT30_Addr<<1)+1,SHT3X_Data_Buffer,6,0x10);
|
||||
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);
|
||||
|
||||
// /* check tem */
|
||||
// /* check tem */
|
||||
data[0] = SHT3X_Data_Buffer[0];
|
||||
data[1] = SHT3X_Data_Buffer[1];
|
||||
data[2] = SHT3X_Data_Buffer[2];
|
||||
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
{
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Temperature = SHT3x_CalcTemperatureC( dat );
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Temperature = SHT3x_CalcTemperatureC( dat );
|
||||
}
|
||||
|
||||
// /* check humidity */
|
||||
data[0] = SHT3X_Data_Buffer[3];
|
||||
// /* check humidity */
|
||||
data[0] = SHT3X_Data_Buffer[3];
|
||||
data[1] = SHT3X_Data_Buffer[4];
|
||||
data[2] = SHT3X_Data_Buffer[5];
|
||||
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
{
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Humidity = SHT3x_CalcRH( dat );
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Humidity = SHT3x_CalcRH( dat );
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -426,7 +426,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32L4xx_HAL_Driver</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
@@ -1,281 +0,0 @@
|
||||
# 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,新建工程
|
||||
|
||||

|
||||
|
||||
###### 3.2 选择MCU型号
|
||||
|
||||

|
||||
|
||||
如上图所示:通过MCU筛选来找到自己开发板对应的芯片型号,双击后弹出工程配置界面,如下图:
|
||||
|
||||

|
||||
|
||||
###### 3.3 Pin设置界面配置时钟源
|
||||
|
||||

|
||||
|
||||
###### 3.4 Pin设置界面配置串口
|
||||
|
||||

|
||||
|
||||
###### 3.5 Pin设置界面配置GPIO
|
||||
|
||||

|
||||
|
||||
###### 3.6 配置总线时钟
|
||||
|
||||

|
||||
|
||||
###### 3.7 工程生成参数配置
|
||||
|
||||

|
||||
|
||||
###### 3.8 代码生成方式配置
|
||||
|
||||

|
||||
|
||||
###### 3.9 生成工程
|
||||
|
||||

|
||||
|
||||
###### 3.10 keil下的裸机工程
|
||||
|
||||
点击生成代码后,生成的裸机工程效果如下:
|
||||
|
||||

|
||||
|
||||
这样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. ##### 代码目录规划
|
||||
|
||||

|
||||
|
||||
如图所示,新建TencentOS_tiny主目录,并在主目录下添加四个子目录,其中arch、kernel、osal从代码仓直接拷贝过来即可,而board目录下则放入我们前面生成的裸机工程代码,我们移植的开发板取名叫NUCLEO_L073RZ,裸机代码全部拷贝到下面即可,如下图所示:
|
||||
|
||||

|
||||
|
||||
接下来进入TencentOS_tiny\board\NUCLEO_L073RZ\MDK-ARM目录,打开keil工程,我们开始添加TencentOS tiny的内核代码。
|
||||
|
||||
2. ##### 添加arch平台代码
|
||||
|
||||

|
||||
|
||||
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\arm\arm-v7m\cortex-m0+\armcc下的适配代码,如果你的开发板是STM32F429IG,M4核,编译器是GCC,则可以选择arch\arm\arm-v7m\cortex-m4\gcc目录下的适配文件。
|
||||
|
||||
3. ##### 添加内核源码
|
||||
|
||||
内核源码kerne目录下包含core和pm两个目录,其中core下为基础内核,pm是内核中的低功耗组件;基础移植的时候可以不添加pm目录下的代码,如下图所示,添加基本内核源码:
|
||||
|
||||

|
||||
|
||||
4. ##### 添加cmsis os源码
|
||||
|
||||
cmsis os是TencentOS tiny为了兼容cmsis标准而适配的OS抽象层,可以简化大家将业务从其他RTOS迁移到TencentOS tiny的工作量。
|
||||
|
||||

|
||||
|
||||
5. ##### 添加TencentOS tiny头文件目录
|
||||
|
||||
添加头文件目录前,我们在要移植的工程目录下新增一个 TOS_CONFIG文件夹,用于存放TencentOS tiny的配置头文件,也就是接下来要新建的tos_config.h文件;
|
||||
|
||||
TencentOS tiny所有要添加的头文件目录如下:
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
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\NUCLEO_L073RZ\TOS_CONFIG目录下。
|
||||
|
||||
这样,TencentOS tiny的源码就全部添加完毕了。
|
||||
|
||||
### 三、创建TencentOS tiny任务,测试移植结果
|
||||
|
||||
1. ##### 修改部分代码
|
||||
###### 修改stm32l0xx_it.c的中断函数
|
||||
在stm32l0xx_it.c文件中包含 tos.h 头文件
|
||||

|
||||
|
||||
在stm32l0xx_it.c文件中的PendSV_Handler函数前添加__weak关键字,因为该函数在TencentOS tiny的调度汇编中已经重新实现;同时在SysTick_Handler函数中添加TencentOS tiny的调度处理函数,如下图所示:
|
||||
|
||||

|
||||
|
||||
|
||||
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\nHello 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\nHello 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;
|
||||
}
|
||||
|
||||
|
||||
如图:
|
||||
|
||||

|
||||
|
||||
继续在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
|
||||
|
||||
如图:
|
||||
|
||||

|
||||
|
||||
3. ##### 编译下载测试TencentOS tiny移植结果
|
||||
|
||||

|
||||
|
||||
按照上图指示,进行编译下载到开发板即可完成TencentOS tiny的测试,如下图所示,可以看到串口交替打印信息,表示两个任务正在进行调度,切换运行:
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# TencentOS tiny内核移植指南(MacOS+STM32CubeIDE版)
|
||||
# TencentOS tiny内核移植指南(MacOS+STM32CubeIDE版)
|
||||
|
||||
## 一、工程创建
|
||||
|
||||
@@ -7,14 +7,13 @@
|
||||
需要强调的是本文是以`STM32L431`芯片为基础的,如果是其它芯片,后面的步骤请做相应的调整。
|
||||
|
||||
最后生成的工程目录如下:
|
||||
|
||||

|
||||

|
||||
|
||||
## 二、TencentOS tiny代码准备
|
||||
|
||||
只需要保留TencentOS这些目录下的代码,其它目录皆可删除。
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
在`arch`目录里需要删除的所有代码目录列表
|
||||
@@ -39,15 +38,15 @@ $ mv TencentOS_tiny tiny
|
||||
|
||||
1. 把代码`tiny`拷贝到第一步创建的工程目录里
|
||||
|
||||

|
||||

|
||||
|
||||
刷新工程
|
||||
|
||||

|
||||

|
||||
|
||||
把代码添加到工程里
|
||||
|
||||

|
||||

|
||||
|
||||
2. 把下列头文件目录添加到工程里
|
||||
|
@@ -82,7 +82,9 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
|
||||
|
||||
### 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]()
|
||||
|
||||
|一级目录 | 二级目录 | 说明 |
|
||||
|---------|---------|---------|
|
||||
|
@@ -73,7 +73,7 @@ CubeMX安装完成后,我们就可以使用CubeMX来给NUCLEO-L037RZ开发板
|
||||
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
|
||||
|
||||
### 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]()
|
||||
|
||||
|
||||
|
||||
|
@@ -73,7 +73,7 @@ TencentOS tiny目前主要支持ARM Cortex M核芯片的移植,比如STM32 基
|
||||
这样NUCLEO-L073RZ裸机工程生成完成,该工程可直接编译并烧写在板子上运行。
|
||||
|
||||
### 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]()
|
||||
|
||||
|
||||
|
||||
|
34
doc/TencentOS-tiny-代码目录说明.md
Normal file
34
doc/TencentOS-tiny-代码目录说明.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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提供的工具,小程序,配置工具等 |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
doc/picture/introduction/EVB_MX.png
Normal file
BIN
doc/picture/introduction/EVB_MX.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
@@ -4,10 +4,8 @@
|
||||
#include "E53_IA1.h"
|
||||
#include "mcu_init.h"
|
||||
|
||||
//#define USE_NB_BC35
|
||||
#define USE_ESP8266
|
||||
|
||||
|
||||
int sock_id = 0;
|
||||
|
||||
double math_keep_ndot(double num,char dot){
|
||||
@@ -42,7 +40,6 @@ static int str_to_hex(const char *bufin, int len, char *bufout)
|
||||
int mq_dev_report(void)
|
||||
{
|
||||
char *data;
|
||||
char topic[50]={0};
|
||||
cJSON *root = NULL;
|
||||
mqtt_pub_opt_t pub_opt;
|
||||
pub_opt.dup = 0;
|
||||
@@ -52,7 +49,6 @@ int mq_dev_report(void)
|
||||
pub_opt.topic = MQTT_PUBLISH_TOPIC;
|
||||
|
||||
// {"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();
|
||||
cJSON_AddNumberToObject(root, "motor",E53_IA1_Data.MotorMode);
|
||||
cJSON_AddNumberToObject(root, "light",E53_IA1_Data.LightMode);
|
||||
@@ -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, "light_intensity",math_keep_ndot((double)E53_IA1_Data.Lux,2));
|
||||
/* formatted print */
|
||||
//data = cJSON_Print(root);
|
||||
data=cJSON_PrintUnformatted(root);
|
||||
|
||||
pub_opt.topic = MQTT_PUBLISH_TOPIC;
|
||||
@@ -75,25 +70,23 @@ int mq_dev_report(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_dev_cmd(char *data)
|
||||
int parse_dev_cmd(uint8_t *data)
|
||||
{
|
||||
//{"motor":0,"light":1}
|
||||
//JSON字符串到cJSON格式
|
||||
cJSON* cjson = cJSON_Parse(data);
|
||||
cJSON* cjson = cJSON_Parse((char *)data);
|
||||
cJSON *cjsonret=NULL;
|
||||
int motor;
|
||||
int light;
|
||||
char *str;
|
||||
printf("parse_dev_cmd...\n");
|
||||
//判断cJSON_Parse函数返回值确定是否打包成<E58C85>??
|
||||
if(cjson == NULL){
|
||||
printf("json pack into cjson error...");
|
||||
return -1;
|
||||
}
|
||||
else{//打包成功调用cJSON_Print打印输出
|
||||
else{
|
||||
cJSON_Print(cjson);
|
||||
}
|
||||
|
||||
cjsonret = NULL;
|
||||
cjsonret = cJSON_GetObjectItem(cjson,"motor");
|
||||
if(cjsonret!=NULL)
|
||||
@@ -127,7 +120,6 @@ int parse_dev_cmd(char *data)
|
||||
light_control(0);
|
||||
}
|
||||
}
|
||||
|
||||
cjsonret = cJSON_GetObjectItem(cjson,"speaker");
|
||||
if(cjsonret!=NULL)
|
||||
{
|
||||
@@ -142,11 +134,7 @@ int parse_dev_cmd(char *data)
|
||||
speaker(str);
|
||||
tos_mmheap_free(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//delete cjson
|
||||
cJSON_Delete(cjson);
|
||||
return 0;
|
||||
@@ -156,7 +144,6 @@ int mq_dev_receiv(void){
|
||||
static int count = 1;
|
||||
uint8_t read_data[100];
|
||||
int read_len;
|
||||
char topic[50];
|
||||
mqtt_sub_opt_t sub_opt;
|
||||
|
||||
sub_opt.count = 1;
|
||||
@@ -173,10 +160,10 @@ int mq_dev_receiv(void){
|
||||
parse_dev_cmd(read_data);
|
||||
}
|
||||
count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mq_dev_subscribe(void){
|
||||
char topic[50];
|
||||
mqtt_sub_opt_t sub_opt;
|
||||
|
||||
sub_opt.count = 1;
|
||||
@@ -189,7 +176,7 @@ int mq_dev_subscribe(void){
|
||||
if (tos_mqtt_subscribe(sock_id, &sub_opt) != 0) {
|
||||
printf("subscribe failed!!!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
void ai_demo(void)
|
||||
{
|
||||
@@ -201,17 +188,6 @@ void ai_demo(void)
|
||||
esp8266_join_ap("test", "12345678");
|
||||
#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.cleansession = 1;
|
||||
con_opt.username = MQTT_USR_NAME;
|
||||
@@ -236,15 +212,10 @@ void sensor_read(void){
|
||||
}
|
||||
}
|
||||
|
||||
#define welcomspeak "<EFBFBD><EFBFBD>ӭTOS"
|
||||
//#define welcomspeak "<22><>ӭ"
|
||||
//FD 00 06 01 01 BB B6 D3 AD
|
||||
#define welcomspeak "欢迎TOS"
|
||||
void speaker(char *str){
|
||||
char data[100];
|
||||
uint8_t data[100];
|
||||
int16_t len=0;
|
||||
char code=0;
|
||||
char times=10;
|
||||
int ret;
|
||||
|
||||
len=2+strlen(str);
|
||||
printf("speaker(%s)\n",str);
|
||||
|
@@ -9,7 +9,8 @@
|
||||
|
||||
#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__ */
|
||||
|
||||
|
Reference in New Issue
Block a user