diff --git a/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.c b/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.c new file mode 100644 index 00000000..69549059 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.c @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ +#include "e53_sc1.h" +#include "i2c.h" + +void iot_explorer_handle_power_switch(int power_switch) +{ + if (0 == power_switch){ + if(LED_IS_OPEN){ + printf("iot-explorer close the light\r\n"); + LED_CLOSE; + }else{ + printf("the light already closed\r\n"); + } + }else{ + if(LED_IS_OPEN){ + printf("iot-explorer already opened\r\n"); + }else{ + printf("the light closed already\r\n"); + LED_OPEN; + } + } +} + +void key1_handle_power_switch(void) +{ + if(LED_IS_OPEN){ + printf("key1 close the light\r\n"); + LED_CLOSE; + }else{ + printf("key1 open the light\r\n"); + LED_OPEN; + } +} + +/*************************************************************** +* 函数名称: Init_BH1750 +* 说 明: 写命令初始化BH1750 +* 参 数: 无 +* 返 回 值: 无 +***************************************************************/ +static void Init_BH1750(void) +{ + uint8_t t_Data = 0x01; + HAL_I2C_Master_Transmit(&hi2c2,BH1750_Addr,&t_Data,1,0xff); +} + +/*************************************************************** +* 函数名称: Start_BH1750 +* 说 明: 启动BH1750 +* 参 数: 无 +* 返 回 值: 无 +***************************************************************/ +static void Start_BH1750(void) +{ + uint8_t t_Data = 0x10; + HAL_I2C_Master_Transmit(&hi2c2,BH1750_Addr,&t_Data,1,0xff); +} + +/*************************************************************** +* 函数名称: Convert_BH1750 +* 说 明: 数值转换 +* 参 数: 无 +* 返 回 值: 光强值 +***************************************************************/ +static float Convert_BH1750(void) +{ + float result_lx; + uint8_t BUF[2]; + int result; + Start_BH1750(); + HAL_Delay(180); + HAL_I2C_Master_Receive(&hi2c2, BH1750_Addr+1,BUF,2,0xff); + result=BUF[0]; + result=(result<<8)+BUF[1]; //Synthetic Digital Illumination Intensity Data + result_lx=(float)(result/1.2); + return result_lx; +} + +float e53_scl_read_data(void) +{ + return Convert_BH1750(); +} + +int e53_sc1_init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /*Configure GPIO pin : LED_Pin */ + GPIO_InitStruct.Pin = LED_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); + + Init_BH1750(); + + return 0; +} + +#if 0 +// 硬件定时器参考代码 +TIM_HandleTypeDef TIM3_Handler; //定时器句柄 +static uint32_t pwm_count = 0; + +//定时器溢出时间计算方法:Tout=((arr+1)*(psc+1))/Ft us. +//Ft=定时器工作频率,单位:Mhz +void TIM3_Init(uint16_t arr,uint16_t psc) //arr:自动重装值 psc:时钟预分频数 +{ + TIM3_Handler.Instance=TIM3; //通用定时器3 + TIM3_Handler.Init.Prescaler=psc; //分频系数 + TIM3_Handler.Init.CounterMode=TIM_COUNTERMODE_UP; //向上计数器 + TIM3_Handler.Init.Period=arr; //自动装载值 + TIM3_Handler.Init.ClockDivision=TIM_CLOCKDIVISION_DIV1;//时钟分频因子 + HAL_TIM_Base_Init(&TIM3_Handler); //时基初始化 + + //HAL_TIM_Base_Start_IT(&TIM3_Handler); //使能定时器3和定时器3更新中断:TIM_IT_UPDATE + //HAL_TIM_Base_Stop_IT(&TIM3_Handler); +} + + //TIM3_Init(1, 719); + +void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) +{ + if(htim->Instance==TIM3) + { + __HAL_RCC_TIM3_CLK_ENABLE(); //使能TIM3时钟 + HAL_NVIC_SetPriority(TIM3_IRQn,1,3); //设置中断优先级,抢占优先级1,子优先级3 + HAL_NVIC_EnableIRQ(TIM3_IRQn); //开启ITM3中断 + } +} + +void TIM3_IRQHandler(void) +{ + HAL_TIM_IRQHandler(&TIM3_Handler); +} + +void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) +{ + if(htim==(&TIM3_Handler)) + { + if(pwm_count < light_pwm) + { + set_light(true); + } else { + set_light(false); + } + if(pwm_count >= 100) + { + pwm_count = 0; + } + pwm_count++; + } +} +#endif diff --git a/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.h b/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.h new file mode 100644 index 00000000..29e9bddf --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/BSP/Hardware/E53_SC1/e53_sc1.h @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ +#ifndef _E53_SC1_H_ +#define _E53_SC1_H_ + +#include "tos_k.h" +#include "stdbool.h" + +#define LED_Pin GPIO_PIN_2 +#define LED_GPIO_Port GPIOB + +#define LED_OPEN HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET) +#define LED_CLOSE HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET) +#define LED_IS_OPEN HAL_GPIO_ReadPin(LED_GPIO_Port, LED_Pin) + +#define BH1750_Addr 0x46 +#define LIGHT_MAX_NAME_LEN 32 + +#if 0 +typedef enum{ + LIGHT_LEVEL_LOW = 0, + LIGTH_LEVEL_MID = 1, + LIGTH_LEVEL_HIGH = 2, + LIGTH_LEVEL_BUTT, +}E_LIGTH_LEVEL; +#endif + +int e53_sc1_init(void); + +float e53_scl_read_data(void); + +void iot_explorer_handle_power_switch(int power_switch); + +void key1_handle_power_switch(void); +#endif /* _E53_SC1_H_ */ diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/README.md b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/README.md new file mode 100644 index 00000000..d4d1d820 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/README.md @@ -0,0 +1,2 @@ +## 编译说明 +1. 若使用STM32硬件定时器,请拷贝`TencentOS-tiny\board\TencentOS_tiny_EVB_G0\KEIL\mqtt_iot_explorer_e53_light\stm32g0xx_hal_conf.h`到TencentOS-tiny\board\TencentOS_tiny_EVB_G0\BSP\Inc\`目录下。 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx new file mode 100644 index 00000000..9320102e --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx @@ -0,0 +1,1184 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + TencentOS_Tiny + 0x4 + ARM-ADS + + 8000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 6 + + + + + + + + + + + STLink\ST-LINKIII-KEIL_SWO.dll + + + + 0 + ST-LINKIII-KEIL_SWO + -U1A4C11000B14324D434D4E00 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(0BC11477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32G0xx_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32G070RBTx$CMSIS\Flash\STM32G0xx_128.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32G0xx_128 -FS08000000 -FL020000 -FP0($$Device:STM32G070RBTx$CMSIS\Flash\STM32G0xx_128.FLM)) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 0 + 0 + 2 + 10000000 + + + + + + Application/MDK-ARM + 0 + 0 + 0 + 0 + + 1 + 1 + 2 + 0 + 0 + 0 + startup_stm32g070xx.s + startup_stm32g070xx.s + 0 + 0 + + + + + Application/User + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\gpio.c + gpio.c + 0 + 0 + + + 2 + 3 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\main.c + main.c + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\mcu_init.c + mcu_init.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\stm32g0xx_hal_msp.c + stm32g0xx_hal_msp.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\usart.c + usart.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\adc.c + adc.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\i2c.c + i2c.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\spi.c + spi.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + .\demo\stm32g0xx_it_demo.c + stm32g0xx_it_demo.c + 0 + 0 + + + + + Drivers/STM32G0xx_HAL_Driver + 0 + 0 + 0 + 0 + + 3 + 11 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal.c + stm32g0xx_hal.c + 0 + 0 + + + 3 + 12 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_cortex.c + stm32g0xx_hal_cortex.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_dma.c + stm32g0xx_hal_dma.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_dma_ex.c + stm32g0xx_hal_dma_ex.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_exti.c + stm32g0xx_hal_exti.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_flash.c + stm32g0xx_hal_flash.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_flash_ex.c + stm32g0xx_hal_flash_ex.c + 0 + 0 + + + 3 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_gpio.c + stm32g0xx_hal_gpio.c + 0 + 0 + + + 3 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_pwr.c + stm32g0xx_hal_pwr.c + 0 + 0 + + + 3 + 20 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_pwr_ex.c + stm32g0xx_hal_pwr_ex.c + 0 + 0 + + + 3 + 21 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_rcc.c + stm32g0xx_hal_rcc.c + 0 + 0 + + + 3 + 22 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_rcc_ex.c + stm32g0xx_hal_rcc_ex.c + 0 + 0 + + + 3 + 23 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_tim.c + stm32g0xx_hal_tim.c + 0 + 0 + + + 3 + 24 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_tim_ex.c + stm32g0xx_hal_tim_ex.c + 0 + 0 + + + 3 + 25 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_uart.c + stm32g0xx_hal_uart.c + 0 + 0 + + + 3 + 26 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_uart_ex.c + stm32g0xx_hal_uart_ex.c + 0 + 0 + + + 3 + 27 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_rcc.c + stm32g0xx_ll_rcc.c + 0 + 0 + + + 3 + 28 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_adc.c + stm32g0xx_hal_adc.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_adc_ex.c + stm32g0xx_hal_adc_ex.c + 0 + 0 + + + 3 + 30 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_adc.c + stm32g0xx_ll_adc.c + 0 + 0 + + + 3 + 31 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_i2c.c + stm32g0xx_hal_i2c.c + 0 + 0 + + + 3 + 32 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_i2c_ex.c + stm32g0xx_hal_i2c_ex.c + 0 + 0 + + + 3 + 33 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_spi.c + stm32g0xx_hal_spi.c + 0 + 0 + + + 3 + 34 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_spi_ex.c + stm32g0xx_hal_spi_ex.c + 0 + 0 + + + + + Drivers/CMSIS + 0 + 0 + 0 + 0 + + 4 + 35 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\system_stm32g0xx.c + system_stm32g0xx.c + 0 + 0 + + + + + tos/arch + 0 + 0 + 0 + 0 + + 5 + 36 + 1 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c + tos_cpu.c + 0 + 0 + + + 5 + 37 + 1 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\cortex-m0+\armcc\port_c.c + port_c.c + 0 + 0 + + + 5 + 38 + 2 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\cortex-m0+\armcc\port_s.S + port_s.S + 0 + 0 + + + + + tos/kernel + 0 + 0 + 0 + 0 + + 6 + 39 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_event.c + tos_event.c + 0 + 0 + + + 6 + 40 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_global.c + tos_global.c + 0 + 0 + + + 6 + 41 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mmblk.c + tos_mmblk.c + 0 + 0 + + + 6 + 42 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mmheap.c + tos_mmheap.c + 0 + 0 + + + 6 + 43 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mutex.c + tos_mutex.c + 0 + 0 + + + 6 + 44 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_pend.c + tos_pend.c + 0 + 0 + + + 6 + 45 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_robin.c + tos_robin.c + 0 + 0 + + + 6 + 46 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sched.c + tos_sched.c + 0 + 0 + + + 6 + 47 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sem.c + tos_sem.c + 0 + 0 + + + 6 + 48 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sys.c + tos_sys.c + 0 + 0 + + + 6 + 49 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_task.c + tos_task.c + 0 + 0 + + + 6 + 50 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_tick.c + tos_tick.c + 0 + 0 + + + 6 + 51 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_time.c + tos_time.c + 0 + 0 + + + 6 + 52 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_timer.c + tos_timer.c + 0 + 0 + + + 6 + 53 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_binary_heap.c + tos_binary_heap.c + 0 + 0 + + + 6 + 54 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_char_fifo.c + tos_char_fifo.c + 0 + 0 + + + 6 + 55 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_completion.c + tos_completion.c + 0 + 0 + + + 6 + 56 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_countdownlatch.c + tos_countdownlatch.c + 0 + 0 + + + 6 + 57 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mail_queue.c + tos_mail_queue.c + 0 + 0 + + + 6 + 58 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_message_queue.c + tos_message_queue.c + 0 + 0 + + + 6 + 59 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_mail_queue.c + tos_priority_mail_queue.c + 0 + 0 + + + 6 + 60 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_message_queue.c + tos_priority_message_queue.c + 0 + 0 + + + 6 + 61 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_queue.c + tos_priority_queue.c + 0 + 0 + + + 6 + 62 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_ring_queue.c + tos_ring_queue.c + 0 + 0 + + + 6 + 63 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_stopwatch.c + tos_stopwatch.c + 0 + 0 + + + + + tos/cmsis + 0 + 0 + 0 + 0 + + 7 + 64 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\cmsis_os\cmsis_os.c + cmsis_os.c + 0 + 0 + + + + + tos/config + 1 + 0 + 0 + 0 + + 8 + 65 + 5 + 0 + 0 + 0 + ..\..\TOS_CONFIG\tos_config.h + tos_config.h + 0 + 0 + + + + + examples + 1 + 0 + 0 + 0 + + 9 + 66 + 1 + 0 + 0 + 0 + ..\..\..\..\components\utils\JSON\src\cJSON.c + cJSON.c + 0 + 0 + + + 9 + 67 + 1 + 0 + 0 + 0 + .\demo\mqtt_iot_explorer_e53_light.c + mqtt_iot_explorer_e53_light.c + 0 + 0 + + + 9 + 68 + 1 + 0 + 0 + 0 + .\demo\stm32g0xx_key.c + stm32g0xx_key.c + 0 + 0 + + + + + hal + 1 + 0 + 0 + 0 + + 10 + 69 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\hal\st\stm32g0xx\src\tos_hal_uart.c + tos_hal_uart.c + 0 + 0 + + + + + at + 1 + 0 + 0 + 0 + + 11 + 70 + 1 + 0 + 0 + 0 + ..\..\..\..\net\at\src\tos_at.c + tos_at.c + 0 + 0 + + + 11 + 71 + 1 + 0 + 0 + 0 + ..\..\..\..\net\tencent_firmware_module_wrapper\tencent_firmware_module_wrapper.c + tencent_firmware_module_wrapper.c + 0 + 0 + + + + + devices + 1 + 0 + 0 + 0 + + 12 + 72 + 1 + 0 + 0 + 0 + ..\..\..\..\devices\esp8266_tencent_firmware\esp8266_tencent_firmware.c + esp8266_tencent_firmware.c + 0 + 0 + + + + + hardware + 1 + 0 + 0 + 0 + + 13 + 73 + 1 + 0 + 0 + 0 + ..\..\BSP\Hardware\OLED\oled.c + oled.c + 0 + 0 + + + 13 + 74 + 1 + 0 + 0 + 0 + ..\..\BSP\Hardware\E53_SC1\e53_sc1.c + e53_sc1.c + 0 + 0 + + + + + ::CMSIS + 0 + 0 + 0 + 1 + + +
diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx new file mode 100644 index 00000000..ba773f0e --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx @@ -0,0 +1,848 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + TencentOS_Tiny + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + STM32G070RBTx + STMicroelectronics + Keil.STM32G0xx_DFP.1.2.0 + http://www.keil.com/pack/ + IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") + + + + + + + + + + + + + + + $$Device:STM32G070RBTx$CMSIS\SVD\STM32G070.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + NUCLEO_STM32G070RB\ + NUCLEO_STM32G070RB + 1 + 0 + 1 + 1 + 1 + + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 0 + + + SARMCM3.DLL + -REMAP + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4101 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x9000 + + + 1 + 0x8000000 + 0x20000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x20000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x9000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + USE_HAL_DRIVER,STM32G070xx,USE_HAL_DRIVER,STM32G070xx + + ..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Inc\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32G0xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m0+\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\kernel\hal\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\..\..\net\at\include;..\..\..\..\net\tencent_firmware_module_wrapper;..\..\..\..\devices\esp8266_tencent_firmware;..\..\BSP\Hardware\CH20;..\..\BSP\Hardware\OLED;..\..\BSP\Hardware\E53_SC1;..\..\..\..\components\utils\JSON\include + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + Application/MDK-ARM + + + startup_stm32g070xx.s + 2 + startup_stm32g070xx.s + + + + + Application/User + + + gpio.c + 1 + ..\..\BSP\Src\gpio.c + + + main.c + 1 + ..\..\BSP\Src\main.c + + + mcu_init.c + 1 + ..\..\BSP\Src\mcu_init.c + + + stm32g0xx_hal_msp.c + 1 + ..\..\BSP\Src\stm32g0xx_hal_msp.c + + + usart.c + 1 + ..\..\BSP\Src\usart.c + + + adc.c + 1 + ..\..\BSP\Src\adc.c + + + i2c.c + 1 + ..\..\BSP\Src\i2c.c + + + spi.c + 1 + ..\..\BSP\Src\spi.c + + + stm32g0xx_it_demo.c + 1 + .\demo\stm32g0xx_it_demo.c + + + + + Drivers/STM32G0xx_HAL_Driver + + + stm32g0xx_hal.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal.c + + + stm32g0xx_hal_cortex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_cortex.c + + + stm32g0xx_hal_dma.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_dma.c + + + stm32g0xx_hal_dma_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_dma_ex.c + + + stm32g0xx_hal_exti.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_exti.c + + + stm32g0xx_hal_flash.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_flash.c + + + stm32g0xx_hal_flash_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_flash_ex.c + + + stm32g0xx_hal_gpio.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_gpio.c + + + stm32g0xx_hal_pwr.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_pwr.c + + + stm32g0xx_hal_pwr_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_pwr_ex.c + + + stm32g0xx_hal_rcc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_rcc.c + + + stm32g0xx_hal_rcc_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_rcc_ex.c + + + stm32g0xx_hal_tim.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_tim.c + + + stm32g0xx_hal_tim_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_tim_ex.c + + + stm32g0xx_hal_uart.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_uart.c + + + stm32g0xx_hal_uart_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_uart_ex.c + + + stm32g0xx_ll_rcc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_rcc.c + + + stm32g0xx_hal_adc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_adc.c + + + stm32g0xx_hal_adc_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_adc_ex.c + + + stm32g0xx_ll_adc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_adc.c + + + stm32g0xx_hal_i2c.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_i2c.c + + + stm32g0xx_hal_i2c_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_i2c_ex.c + + + stm32g0xx_hal_spi.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_spi.c + + + stm32g0xx_hal_spi_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_spi_ex.c + + + + + Drivers/CMSIS + + + system_stm32g0xx.c + 1 + ..\..\BSP\Src\system_stm32g0xx.c + + + + + tos/arch + + + tos_cpu.c + 1 + ..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c + + + port_c.c + 1 + ..\..\..\..\arch\arm\arm-v7m\cortex-m0+\armcc\port_c.c + + + port_s.S + 2 + ..\..\..\..\arch\arm\arm-v7m\cortex-m0+\armcc\port_s.S + + + + + tos/kernel + + + tos_event.c + 1 + ..\..\..\..\kernel\core\tos_event.c + + + tos_global.c + 1 + ..\..\..\..\kernel\core\tos_global.c + + + tos_mmblk.c + 1 + ..\..\..\..\kernel\core\tos_mmblk.c + + + tos_mmheap.c + 1 + ..\..\..\..\kernel\core\tos_mmheap.c + + + tos_mutex.c + 1 + ..\..\..\..\kernel\core\tos_mutex.c + + + tos_pend.c + 1 + ..\..\..\..\kernel\core\tos_pend.c + + + tos_robin.c + 1 + ..\..\..\..\kernel\core\tos_robin.c + + + tos_sched.c + 1 + ..\..\..\..\kernel\core\tos_sched.c + + + tos_sem.c + 1 + ..\..\..\..\kernel\core\tos_sem.c + + + tos_sys.c + 1 + ..\..\..\..\kernel\core\tos_sys.c + + + tos_task.c + 1 + ..\..\..\..\kernel\core\tos_task.c + + + tos_tick.c + 1 + ..\..\..\..\kernel\core\tos_tick.c + + + tos_time.c + 1 + ..\..\..\..\kernel\core\tos_time.c + + + tos_timer.c + 1 + ..\..\..\..\kernel\core\tos_timer.c + + + tos_binary_heap.c + 1 + ..\..\..\..\kernel\core\tos_binary_heap.c + + + tos_char_fifo.c + 1 + ..\..\..\..\kernel\core\tos_char_fifo.c + + + tos_completion.c + 1 + ..\..\..\..\kernel\core\tos_completion.c + + + tos_countdownlatch.c + 1 + ..\..\..\..\kernel\core\tos_countdownlatch.c + + + tos_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_mail_queue.c + + + tos_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_message_queue.c + + + tos_priority_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + tos_priority_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_message_queue.c + + + tos_priority_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_queue.c + + + tos_ring_queue.c + 1 + ..\..\..\..\kernel\core\tos_ring_queue.c + + + tos_stopwatch.c + 1 + ..\..\..\..\kernel\core\tos_stopwatch.c + + + + + tos/cmsis + + + cmsis_os.c + 1 + ..\..\..\..\osal\cmsis_os\cmsis_os.c + + + + + tos/config + + + tos_config.h + 5 + ..\..\TOS_CONFIG\tos_config.h + + + + + examples + + + cJSON.c + 1 + ..\..\..\..\components\utils\JSON\src\cJSON.c + + + mqtt_iot_explorer_e53_light.c + 1 + .\demo\mqtt_iot_explorer_e53_light.c + + + stm32g0xx_key.c + 1 + .\demo\stm32g0xx_key.c + + + + + hal + + + tos_hal_uart.c + 1 + ..\..\..\..\platform\hal\st\stm32g0xx\src\tos_hal_uart.c + + + + + at + + + tos_at.c + 1 + ..\..\..\..\net\at\src\tos_at.c + + + tencent_firmware_module_wrapper.c + 1 + ..\..\..\..\net\tencent_firmware_module_wrapper\tencent_firmware_module_wrapper.c + + + + + devices + + + esp8266_tencent_firmware.c + 1 + ..\..\..\..\devices\esp8266_tencent_firmware\esp8266_tencent_firmware.c + + + + + hardware + + + oled.c + 1 + ..\..\BSP\Hardware\OLED\oled.c + + + e53_sc1.c + 1 + ..\..\BSP\Hardware\E53_SC1\e53_sc1.c + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + + + + + TencentOS_tiny_EVB_G0 + 0 + 1 + + + + +
diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/mqtt_iot_explorer_e53_light.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/mqtt_iot_explorer_e53_light.c new file mode 100644 index 00000000..94d9f1b8 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/mqtt_iot_explorer_e53_light.c @@ -0,0 +1,229 @@ +#include "tos_k.h" +#include "esp8266_tencent_firmware.h" +#include "tencent_firmware_module_wrapper.h" +#include "e53_sc1.h" +#include "oled.h" +#include "cJSON.h" + +extern void stm32g0xx_key_init(void); + +#define PRODUCT_ID "LRKSCAZLF1" +#define DEVICE_NAME "techo_test01" +#define DEVICE_KEY "UOgIWiO8kcVkgif6FO3tJQ==" + +#define YOUR_WIFI_SSID "iot-explorer" +#define YOUR_WIFI_PWD "iot-explorer" + +// 数据模板支持数据增量上报 +#define REPORT_LX_DATA_TEMPLATE "{\\\"method\\\":\\\"report\\\"\\,\\\"clientToken\\\":\\\"00000001\\\"\\,\\\"params\\\":{\\\"lx\\\":%.0f}}" +#define REPORT_POWER_SWITCH_DATA_TEMPLATE "{\\\"method\\\":\\\"report\\\"\\,\\\"clientToken\\\":\\\"00000001\\\"\\,\\\"params\\\":{\\\"power_switch\\\":%d}}" + +#define MAIL_SIZE 256 +#define MAIL_MAX 10 +static uint8_t mail_pool[MAIL_MAX * MAIL_SIZE]; +static k_mail_q_t mail_q; + +static bool key_pressed_flag = false; +void key1_handler_callback(void) +{ + key1_handle_power_switch(); + // 在主循环中进行数据上报 + key_pressed_flag = true; +} + +static void default_message_handler(mqtt_message_t* msg) +{ + int payload_len = 0; + + printf("callback:\r\n"); + printf("---------------------------------------------------------\r\n"); + printf("\ttopic:%s\r\n", msg->topic); + printf("\tpayload:%s\r\n", msg->payload); + printf("---------------------------------------------------------\r\n"); + + payload_len = strlen(msg->payload); + if (payload_len > MAIL_SIZE){ + printf("too long payload\r\n"); + return; + } + + tos_mail_q_post(&mail_q, msg->payload, MAIL_SIZE); +} + +static char report_reply_topic_name[TOPIC_NAME_MAX_SIZE] = {0}; +static char report_topic_name[TOPIC_NAME_MAX_SIZE] = {0}; +static char payload[256] = {0}; +static void mqtt_demo_task(void) +{ + int ret = 0; + int size = 0; + mqtt_state_t state; + + char *product_id = PRODUCT_ID; + char *device_name = DEVICE_NAME; + char *key = DEVICE_KEY; + + device_info_t dev_info; + memset(&dev_info, 0, sizeof(device_info_t)); + + float e53_value = 0; + char e53_str[16] = {0}; + + OLED_ShowString(0, 2, (uint8_t*)"connecting...", 16); + + /** + * Please Choose your AT Port first, default is HAL_UART_2(USART2) + */ + ret = esp8266_tencent_firmware_sal_init(HAL_UART_PORT_2); + if (ret < 0) { + printf("esp8266 tencent firmware sal init fail, ret is %d\r\n", ret); + } + + esp8266_tencent_firmware_join_ap(YOUR_WIFI_SSID, YOUR_WIFI_PWD); + + strncpy(dev_info.product_id, product_id, PRODUCT_ID_MAX_SIZE); + strncpy(dev_info.device_name, device_name, DEVICE_NAME_MAX_SIZE); + strncpy(dev_info.device_serc, key, DEVICE_SERC_MAX_SIZE); + tos_tf_module_info_set(&dev_info, TLS_MODE_PSK); + + mqtt_param_t init_params = DEFAULT_MQTT_PARAMS; + if (tos_tf_module_mqtt_conn(init_params) != 0) { + printf("module mqtt conn fail\n"); + } else { + printf("module mqtt conn success\n"); + } + + if (tos_tf_module_mqtt_state_get(&state) != -1) { + printf("MQTT: %s\n", state == MQTT_STATE_CONNECTED ? "CONNECTED" : "DISCONNECTED"); + } + + // 订阅数据模板 + size = snprintf(report_reply_topic_name, TOPIC_NAME_MAX_SIZE, "$thing/down/property/%s/%s", product_id, device_name); + if (size < 0 || size > sizeof(report_reply_topic_name) - 1) { + printf("sub topic content length not enough! content size:%d buf size:%d", size, (int)sizeof(report_reply_topic_name)); + } + if (tos_tf_module_mqtt_sub(report_reply_topic_name, QOS0, default_message_handler) != 0) { + printf("module mqtt sub fail\n"); + } else { + printf("module mqtt sub success\n"); + } + + memset(report_topic_name, sizeof(report_topic_name), 0); + size = snprintf(report_topic_name, TOPIC_NAME_MAX_SIZE, "$thing/up/property/%s/%s", product_id, device_name); + if (size < 0 || size > sizeof(report_topic_name) - 1) { + printf("pub topic content length not enough! content size:%d buf size:%d", size, (int)sizeof(report_topic_name)); + } + + if (e53_sc1_init() == -1) { + printf("e53 init fail\r\n"); + return; + } + + while (1) { + e53_value = e53_scl_read_data(); + printf("e53 value %.0f lx\r\n", e53_value); + + memset(e53_str, 0, sizeof(e53_str)); + sprintf(e53_str, "%.0f lx(lm/m2)", e53_value); + OLED_ShowString(0, 2, (uint8_t*)e53_str, 16); + + if (key_pressed_flag){ + key_pressed_flag = false; + memset(payload, 0, sizeof(payload)); + snprintf(payload, sizeof(payload), REPORT_POWER_SWITCH_DATA_TEMPLATE, LED_IS_OPEN); + + if (tos_tf_module_mqtt_pub(report_topic_name, QOS0, payload) != 0) { + printf("module mqtt pub fail\n"); + } else { + printf("module mqtt pub success\n"); + } + } + + // 请在此处添加光照强度数据上报物联网开发平台的代码 + + tos_sleep_ms(5000); + } +} + +static void iot_explorer_data_handle(void *arg) +{ + char buf[MAIL_SIZE]; + size_t mail_size = 0; + cJSON *root; + cJSON *params; + //cJSON *token; + cJSON *method; + cJSON *p; + + while(1){ + memset(buf, 0, MAIL_SIZE); + if (K_ERR_NONE == tos_mail_q_pend(&mail_q, buf, &mail_size, TOS_TIME_FOREVER)){ + //printf("mail content: %s\r\n", buf); + //字符串首尾的引号丢弃后才是标准的json数据格式 + buf[strlen(buf) - 1] = '\0'; + root = cJSON_Parse(buf + 1); + if (NULL == root){ + printf("Invalid json root\r\n"); + continue; + } + method = cJSON_GetObjectItem(root, "method"); + if (NULL == method){ + printf("Invalid json method\r\n"); + cJSON_Delete(root); + continue; + } + // 仅处理云端下发的 control 数据 + if (0 != strncmp(method->valuestring, "control", sizeof("control") - 1)){ + //printf("Invalid method\r\n"); + cJSON_Delete(root); + continue; + } + // 若需要回复报文,需要携带数据报文的 clitenToken 字段 + //token = cJSON_GetObjectItem(root, "clientToken"); + params = cJSON_GetObjectItem(root, "params"); + if (NULL == params){ + printf("Invalid json params\r\n"); + cJSON_Delete(root); + continue; + } + + // 请在此处添加物联网开发平台对智能灯的控制代码 + + + cJSON_Delete(root); + } + } +} + +#define TASK_HANDLE_MAIL_PRIORITY 3 +#define TASK_HANDLE_MAIL_STACK_SIZE 4096 +__STATIC__ k_stack_t stack_task_handle_mail[TASK_HANDLE_MAIL_STACK_SIZE]; +k_task_t task_handle_mail; + +void application_entry(void *arg) +{ + char *str = "TencentOS-tiny"; + + // 初始化tencent-os tiny定时器模块 + timer_init(); + // 初始化按键检测模块 + stm32g0xx_key_init(); + + // OLED 显示屏初始化 + OLED_Init(); + OLED_Clear(); + OLED_ShowString(0, 0, (uint8_t*)str, 16); + + // 创建tencent-os tiny邮箱,使用邮箱机制进行任务间通信 + tos_mail_q_create(&mail_q, mail_pool, MAIL_MAX, MAIL_SIZE); + // 创建tencent-os tiny任务,任务遍历邮箱,处理iot-explorer下发的数据 + (void)tos_task_create(&task_handle_mail, "iot-explorer", iot_explorer_data_handle, + (void *)NULL, TASK_HANDLE_MAIL_PRIORITY, + stack_task_handle_mail, TASK_HANDLE_MAIL_STACK_SIZE, 0); + + mqtt_demo_task(); + while (1) { + printf("This is a demo\r\n"); + tos_task_delay(10000); + } +} diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c new file mode 100644 index 00000000..36572a00 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c @@ -0,0 +1,212 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g0xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32g0xx_it.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "tos_k.h" +#include "tos_at.h" +#include "ch20_parser.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern UART_HandleTypeDef huart1; +extern UART_HandleTypeDef huart2; +extern UART_HandleTypeDef huart3; +extern UART_HandleTypeDef huart4; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M0+ Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVC_IRQn 0 */ + + /* USER CODE END SVC_IRQn 0 */ + /* USER CODE BEGIN SVC_IRQn 1 */ + + /* USER CODE END SVC_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +__weak void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); + if(tos_knl_is_running()) + { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32G0xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32g0xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25. + */ +void USART1_IRQHandler(void) +{ + /* USER CODE BEGIN USART1_IRQn 0 */ + + /* USER CODE END USART1_IRQn 0 */ + HAL_UART_IRQHandler(&huart1); + /* USER CODE BEGIN USART1_IRQn 1 */ + + /* USER CODE END USART1_IRQn 1 */ +} + +/** + * @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26. + */ +void USART2_IRQHandler(void) +{ + /* USER CODE BEGIN USART2_IRQn 0 */ + + /* USER CODE END USART2_IRQn 0 */ + HAL_UART_IRQHandler(&huart2); + /* USER CODE BEGIN USART2_IRQn 1 */ + + /* USER CODE END USART2_IRQn 1 */ +} + +/** + * @brief This function handles USART3 and USART4 interrupts. + */ +void USART3_4_IRQHandler(void) +{ + /* USER CODE BEGIN USART3_4_IRQn 0 */ + + /* USER CODE END USART3_4_IRQn 0 */ + HAL_UART_IRQHandler(&huart3); + HAL_UART_IRQHandler(&huart4); + /* USER CODE BEGIN USART3_4_IRQn 1 */ + + /* USER CODE END USART3_4_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) +{ + /* data is defined in usart.c */ + extern uint8_t data; + extern uint8_t ch20_msg; + + if (huart->Instance == USART2) { + HAL_UART_Receive_IT(&huart2, &data, 1); + tos_at_uart_input_byte(data); + } else if (huart->Instance == USART3) { + //HAL_UART_Receive_IT(&huart3, &ch20_msg, 1); + } +} +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_key.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_key.c new file mode 100644 index 00000000..f3361930 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_key.c @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ +#include "tos_k.h" +#include "stdbool.h" +#include "e53_sc1.h" + +extern void key1_handler_callback(void); + +static k_timer_t key_check_tmr; +static uint32_t key_press_count = 0; +static uint32_t key_release_count = 0; +static bool key_pressed = false; + +#define KEY_CHECK_SHAKING_COUNT 3 + +static void key_check_timer_cb(void *arg) +{ + if (GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_0)){ + key_press_count++; + key_release_count = 0; + } else { + key_press_count = 0; + key_release_count++; + } + + // 支持按键消抖 + if (key_press_count > KEY_CHECK_SHAKING_COUNT) { + // 按键按下时功能即生效,且只生效一次 + if (!key_pressed) { + //printf("key 1 pressed\r\n"); + key_pressed = true; + key1_handler_callback(); + } + } + if (key_release_count > KEY_CHECK_SHAKING_COUNT){ + if (key_pressed) { + key_pressed = false; + //printf("key 1 release\r\n"); + } + } +} + +void stm32g0xx_key_init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /*Configure GPIO pin : PtPin */ + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + // 使用tencent-os tiny的定时器实现按键检测功能 + tos_timer_create(&key_check_tmr, 1u, 10u, key_check_timer_cb, K_NULL, TOS_OPT_TIMER_PERIODIC); + tos_timer_start(&key_check_tmr); +} diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/startup_stm32g070xx.s b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/startup_stm32g070xx.s new file mode 100644 index 00000000..5d0cf138 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/startup_stm32g070xx.s @@ -0,0 +1,243 @@ +;****************************************************************************** +;* File Name : startup_stm32g070xx.s +;* Author : MCD Application Team +;* Description : STM32G070xx devices vector table for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM0 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;****************************************************************************** +;* @attention +;* +;* Copyright (c) 2018 STMicroelectronics. All rights reserved. +;* +;* This software component is licensed by ST under BSD 3-Clause license, +;* the "License"; You may not use this file except in compliance with the +;* License. You may obtain a copy of the License at: +;* opensource.org/licenses/BSD-3-Clause +;* +;****************************************************************************** + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD 0 ; Reserved + DCD RTC_TAMP_IRQHandler ; RTC through EXTI Line + DCD FLASH_IRQHandler ; FLASH + DCD RCC_IRQHandler ; RCC + DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1 + DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3 + DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15 + DCD 0 ; Reserved + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3 + DCD DMA1_Ch4_7_DMAMUX1_OVR_IRQHandler ; DMA1 Channel 4 to Channel 7, DMAMUX1 overrun + DCD ADC1_IRQHandler ; ADC1 + DCD TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD 0 ; Reserved + DCD TIM3_IRQHandler ; TIM3 + DCD TIM6_IRQHandler ; TIM6 + DCD TIM7_IRQHandler ; TIM7 + DCD TIM14_IRQHandler ; TIM14 + DCD TIM15_IRQHandler ; TIM15 + DCD TIM16_IRQHandler ; TIM16 + DCD TIM17_IRQHandler ; TIM17 + DCD I2C1_IRQHandler ; I2C1 + DCD I2C2_IRQHandler ; I2C2 + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_4_IRQHandler ; USART3, USART4 + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT RTC_TAMP_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_3_IRQHandler [WEAK] + EXPORT DMA1_Ch4_7_DMAMUX1_OVR_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT TIM1_BRK_UP_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT TIM14_IRQHandler [WEAK] + EXPORT TIM15_IRQHandler [WEAK] + EXPORT TIM16_IRQHandler [WEAK] + EXPORT TIM17_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_4_IRQHandler [WEAK] + + +WWDG_IRQHandler +RTC_TAMP_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_3_IRQHandler +DMA1_Ch4_7_DMAMUX1_OVR_IRQHandler +ADC1_IRQHandler +TIM1_BRK_UP_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM3_IRQHandler +TIM6_IRQHandler +TIM7_IRQHandler +TIM14_IRQHandler +TIM15_IRQHandler +TIM16_IRQHandler +TIM17_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_4_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***** diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/stm32g0xx_hal_conf.h b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/stm32g0xx_hal_conf.h new file mode 100644 index 00000000..d804c9ba --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/stm32g0xx_hal_conf.h @@ -0,0 +1,310 @@ +/** + ****************************************************************************** + * @file stm32g0xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2018 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32G0xx_HAL_CONF_H +#define STM32G0xx_HAL_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## Register Callbacks selection ############################## */ +/** + * @brief This is the list of modules where register callback can be used + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0u +#define USE_HAL_CEC_REGISTER_CALLBACKS 0u +#define USE_HAL_COMP_REGISTER_CALLBACKS 0u +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0u +#define USE_HAL_DAC_REGISTER_CALLBACKS 0u +#define USE_HAL_I2C_REGISTER_CALLBACKS 0u +#define USE_HAL_I2S_REGISTER_CALLBACKS 0u +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0u +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0u +#define USE_HAL_RNG_REGISTER_CALLBACKS 0u +#define USE_HAL_RTC_REGISTER_CALLBACKS 0u +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0u +#define USE_HAL_SPI_REGISTER_CALLBACKS 0u +#define USE_HAL_TIM_REGISTER_CALLBACKS 0u +#define USE_HAL_UART_REGISTER_CALLBACKS 0u +#define USE_HAL_USART_REGISTER_CALLBACKS 0u +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0u + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S1 peripheral + * This value is used by the RCC HAL module to compute the I2S1 clock source + * frequency. + */ +#if !defined (EXTERNAL_I2S1_CLOCK_VALUE) +#define EXTERNAL_I2S1_CLOCK_VALUE 48000U /*!< Value of the I2S1 External clock source in Hz*/ +#endif /* EXTERNAL_I2S1_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* ################## CRYP peripheral configuration ########################## */ + +#define USE_HAL_CRYP_SUSPEND_RESUME 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32g0xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32g0xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32g0xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32g0xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32g0xx_hal_adc.h" +#include "stm32g0xx_hal_adc_ex.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32g0xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED +#include "stm32g0xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32g0xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32g0xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32g0xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32g0xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32g0xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32g0xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32g0xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32g0xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32g0xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32g0xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32g0xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32g0xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32g0xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32g0xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32g0xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32g0xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32g0xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32g0xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32g0xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32g0xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for functions parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32G0xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/techo.json b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/techo.json new file mode 100644 index 00000000..041081e2 --- /dev/null +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/techo.json @@ -0,0 +1,40 @@ +{ + "version": "1.0", + "profile": { + "ProductId": "LRKSCAZLF1", + "CategoryId": "539" + }, + "properties": [ + { + "id": "power_switch", + "name": "电灯开关", + "desc": "控制电灯开灭", + "required": true, + "mode": "rw", + "define": { + "type": "bool", + "mapping": { + "0": "关", + "1": "开" + } + } + }, + { + "id": "lx", + "name": "光照强度", + "desc": "光照强度", + "mode": "r", + "define": { + "type": "int", + "min": "0", + "max": "20000", + "start": "0", + "step": "1", + "unit": "lx" + }, + "required": false + } + ], + "events": [], + "actions": [] +} \ No newline at end of file