diff --git a/README.md b/README.md index 87a926f..660ce89 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,27 @@ -# AWTK针对STM32f103ze的移植。 +# AWTK 针对腾讯 OS(STM32f103ze) 的移植。 * [AWTK](https://github.com/zlgopen/awtk) 全称 Toolkit AnyWhere,是 [ZLG](http://www.zlg.cn/) 开发的开源 GUI 引擎,旨在为嵌入式系统、WEB、各种小程序、手机和 PC 打造的通用 GUI 引擎,为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。 +* [腾讯 TOS](https://github.com/Tencent/TencentOS-tiny) 是腾讯面向物联网领域开发的实时操作系统,具有低功耗,低资源占用,模块化,安全可靠等特点,可有效提升物联网终端产品开发效率。TencentOS tiny 提供精简的 RTOS 内核,内核组件可裁剪可配置,可快速移植到多种主流 MCU (如 STM32 全系列)及模组芯片上。而且,基于 RTOS 内核提供了丰富的物联网组件,内部集成主流物联网协议栈(如 CoAP/MQTT/TLS/DTLS/LoRaWAN/NB-IoT 等),可助力物联网终端设备及业务快速接入腾讯云物联网平台。 -[awtk-stm32f103ze-raw](https://github.com/zlgopen/awtk-stm32f103ze-raw)是AWTK在STM32f103ze上的移植。 +* [awtk-stm32f103ze-tencentos](https://github.com/zlgopen/awtk-stm32f103ze-tencentos) 是 AWTK 在 [腾讯 TOS](https://github.com/Tencent/TencentOS-tiny) 上的移植。 -本项目以[普中科技STM32F103ZET6开发实验板](https://item.taobao.com/item.htm?spm=a230r.1.14.1.50a130e8TMKYMC&id=558855281660&ns=1&abbucket=5#detail) 为载体移植,其它开发板可能要做些修改,有问题请请创建issue。 +> 本项目以 [普中科技 STM32F103ZET6 开发实验板](https://item.taobao.com/item.htm?spm=a230r.1.14.1.50a130e8TMKYMC&id=558855281660&ns=1&abbucket=5#detail) 为载体移植,其它开发板可能要做些修改,有问题请请创建 issue。 ## 编译 1. 获取源码 ``` -git clone https://github.com/zlgopen/awtk-stm32f103ze-raw.git -cd awtk-stm32f103ze-raw +git clone https://github.com/zlgopen/awtk-stm32f103ze-tencentos.git +cd awtk-stm32f103ze-tencentos git clone https://github.com/zlgopen/awtk.git ``` -2. 用keil打开awtk.uvproj +2. 用 keil 打开 user/awtk.uvproj ## 文档 +* [AWTK 在腾讯 TOS 上的移植笔记](docs/tos-port.md) + * [AWTK 在 STM32F103 裸系统上的移植笔记](https://github.com/zlgopen/awtk/blob/master/docs/porting_to_stm32f103ze.md) diff --git a/awtk-port.1/SysTick.c b/awtk-port.1/SysTick.c deleted file mode 100644 index d9e7cc5..0000000 --- a/awtk-port.1/SysTick.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "SysTick.h" - -static u8 fac_us = 0; // usʱ -static u16 fac_ms = 0; // msʱ - -void systick_enable_int(void) { - SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; - SysTick->LOAD = fac_ms; - SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; -} - -//ʼӳٺ -// SYSTICKʱӹ̶ΪAHBʱӵ1/8 -// SYSCLK:ϵͳʱƵ -void SysTick_Init(void) { - SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); - fac_us = SystemCoreClock / 8000000; - - fac_ms = (u16)fac_us * 1000; - - systick_enable_int(); -} - -//ʱnus -// nusΪҪʱus. -void delay_us(u32 nus) { - u32 temp = 0; - SysTick->LOAD = nus * fac_us; //ʱ - SysTick->VAL = 0x00; //ռ - do { - temp = SysTick->CTRL; - } while ((temp & 0x01) && !(temp & (1 << 16))); //ȴʱ䵽 - - systick_enable_int(); -} - -//ʱnms -//עnmsķΧ -// SysTick->LOADΪ24λĴ,,ʱΪ: -// nms<=0xffffff*8*1000/SYSCLK -// SYSCLKλΪHz,nmsλΪms -//72M,nms<=1864 -void delay_ms(u16 nms) { - u32 temp = 0; - SysTick->LOAD = (u32)nms * fac_ms; //ʱ(SysTick->LOADΪ24bit) - SysTick->VAL = 0x00; //ռ - do { - temp = SysTick->CTRL; - } while ((temp & 0x01) && !(temp & (1 << 16))); //ȴʱ䵽 - - systick_enable_int(); -} diff --git a/awtk-port.1/SysTick.h b/awtk-port.1/SysTick.h deleted file mode 100644 index ae967e8..0000000 --- a/awtk-port.1/SysTick.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _SysTick_H -#define _SysTick_H - -#include "system.h" - -void SysTick_Init(void); -void delay_ms(u16 nms); -void delay_us(u32 nus); - - - -#endif diff --git a/awtk-port.1/assert.c b/awtk-port.1/assert.c deleted file mode 100644 index 72814f2..0000000 --- a/awtk-port.1/assert.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "tkc/types_def.h" - -__attribute__((weak, noreturn)) void __aeabi_assert(const char* expr, const char* file, int line) { - for (;;) { - } -} diff --git a/awtk-port.1/awtk_config.h b/awtk-port.1/awtk_config.h deleted file mode 100644 index 7a8a739..0000000 --- a/awtk-port.1/awtk_config.h +++ /dev/null @@ -1,180 +0,0 @@ - -/** - * File: awtk_config.h - * Author: AWTK Develop Team - * Brief: config - * - * Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * License file for more details. - * - */ - -/** - * History: - * ================================================================ - * 2018-09-12 Li XianJing created - * - */ - -#ifndef AWTK_CONFIG_H -#define AWTK_CONFIG_H - -/** - * 嵌入式系统有自己的main函数时,请定义本宏。 - * - */ - #define USE_GUI_MAIN 1 - -/** - * 如果需要支持预先解码的位图字体,请定义本宏。一般只在RAM极小时,才启用本宏。 - */ -#define WITH_BITMAP_FONT 1 - -/** - * 如果支持png/jpeg图片,请定义本宏 - * - * #define WITH_STB_IMAGE 1 - */ - -/** - * 如果用stb支持Truetype字体,请定义本宏 - * - * #define WITH_STB_FONT 1 - */ - -/** - * 如果用freetype支持Truetype字体,请定义本宏。 - * - * #define WITH_FT_FONT 1 - */ - -/** - * 如果支持从文件系统加载资源,请定义本宏 - * - * #define WITH_FS_RES 1 - */ - -/** - * 如果定义本宏,使用标准的UNICODE换行算法,除非资源极为有限,请定义本宏。 - * - */ -#define WITH_UNICODE_BREAK 1 - -/** - * 如果定义本宏,将图片解码成BGRA8888格式,否则解码成RGBA8888的格式。 - * 当硬件的2D加速需要BGRA格式时,请启用本宏。 - * - * #define WITH_BITMAP_BGRA 1 - */ - -/** - * 如果定义本宏,将不透明的PNG图片解码成BGR565格式,建议定义。 - * 另外和LCD的格式保存一致,可以大幅度提高性能。 - * - * #define WITH_BITMAP_BGR565 1 - */ - -/** - * 如果不需输入法,请定义本宏 - * - */ -#define WITH_NULL_IM 1 - -/** - * 如果有标准的malloc/free/calloc等函数,请定义本宏 - * - * #define HAS_STD_MALLOC 1 - */ - -/** - * 如果有标准的fopen/fclose等函数,请定义本宏 - * - * #define HAS_STDIO 1 - */ - -/** - * 如果有标准的pthread等函数,请定义本宏 - * - * #define HAS_PTHREAD 1 - */ - -/** - * 如果有优化版本的memcpy函数,请定义本宏 - * - * #define HAS_FAST_MEMCPY 1 - */ - -/** - * 如果出现wcsxxx之类的函数没有定义时,请定义该宏 - * - * #define WITH_WCSXXX 1 - */ -#define WITH_WCSXXX 1 - -/** - * 如果启用STM32 G2D硬件加速,请定义本宏 - * - * #define WITH_STM32_G2D 1 - */ - -/** - * 如果启用NXP PXP硬件加速,请定义本宏 - * - * #define WITH_PXP_G2D 1 - */ - -/** - * 在没有GPU时,如果启用agge作为nanovg的后端(较agg作为后端:小,快,图形质量稍差),请定义本宏。 - * - * #define WITH_NANOVG_AGGE 1 - */ - -/** - * 在没有GPU时,如果启用agg作为nanovg的后端(较agge作为后端:大,慢,图形质量好),请定义本宏。 - * 注意:agg是以GPL协议开源。 - * - * #define WITH_NANOVG_AGG 1 - */ - -/** - * 如果启用鼠标指针,请定义本宏 - * - * #define ENABLE_CURSOR 1 - */ - -/** - * 对于低端平台,如果不使用控件动画,请定义本宏。 - * - */ - #define WITHOUT_WIDGET_ANIMATORS 1 - -/** - * 对于低端平台,如果不使用窗口动画,请定义本宏。 - * - */ - #define WITHOUT_WINDOW_ANIMATORS 1 - -/** - * 对于低端平台,如果不使用对话框高亮策略,请定义本宏。 - * - */ - #define WITHOUT_DIALOG_HIGHLIGHTER 1 - -/** - * 对于低端平台,如果不使用扩展控件,请定义本宏。 - * - */ - #define WITHOUT_EXT_WIDGETS 1 - -/** - * 对于低端平台,如果内存不足以提供完整的FrameBuffer,请定义本宏启用局部FrameBuffer,可大幅度提高渲染性能。 - * - */ - #define FRAGMENT_FRAME_BUFFER_SIZE 8 * 1024 - -#endif /*AWTK_CONFIG_H*/ - diff --git a/awtk-port.1/gui_main.c b/awtk-port.1/gui_main.c deleted file mode 100644 index e69de29..0000000 diff --git a/awtk-port.1/lcd_stm32_raw.c b/awtk-port.1/lcd_stm32_raw.c deleted file mode 100644 index a14f97d..0000000 --- a/awtk-port.1/lcd_stm32_raw.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * File: lcd_stm32_raw.c - * Author: AWTK Develop Team - * Brief: stm32_raw implemented lcd interface - * - * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * License file for more details. - * - */ - -/** - * History: - * ================================================================ - * 2018-02-16 Li XianJing created - * - */ - -#include "tftlcd.h" - -#include "tkc/mem.h" -#include "lcd/lcd_reg.h" - -typedef uint16_t pixel_t; - -#define LCD_FORMAT BITMAP_FMT_BGR565 -#define pixel_from_rgb(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3)) -#define pixel_to_rgba(p) \ - { (0xff & ((p >> 11) << 3)), (0xff & ((p >> 5) << 2)), (0xff & (p << 3)) } - -#define set_window_func LCD_Set_Window -#define write_data_func LCD_WriteData_Color - -#include "base/pixel.h" -#include "blend/pixel_ops.inc" -#include "lcd/lcd_reg.inc" diff --git a/awtk-port.1/main_loop_stm32_raw.c b/awtk-port.1/main_loop_stm32_raw.c deleted file mode 100644 index 7e12133..0000000 --- a/awtk-port.1/main_loop_stm32_raw.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - * File: main_loop_stm32_raw.c - * Author: AWTK Develop Team - * Brief: main loop for stm32 - * - * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. - * - * this program is distributed in the hope that it will be useful, - * but without any warranty; without even the implied warranty of - * merchantability or fitness for a particular purpose. see the - * license file for more details. - * - */ - -/** - * history: - * ================================================================ - * 2018-02-17 li xianjing created - * - */ - -#include "key.h" -#include "led.h" -#include "rtc.h" -#include "touch.h" -#include "usart.h" -#include "stdlib.h" -#include "tftlcd.h" - -#include "base/idle.h" -#include "base/timer.h" -#include "lcd/lcd_reg.h" -#include "base/main_loop.h" -#include "tkc/platform.h" -#include "base/event_queue.h" -#include "base/font_manager.h" -#include "main_loop/main_loop_simple.h" - -ret_t platform_disaptch_input(main_loop_t* l) { - return RET_OK; -} - -static lcd_t* platform_create_lcd(wh_t w, wh_t h) { - return lcd_reg_create(w, h); -} - -void dispatch_input_events(void) { - int key = KEY_Scan(0); - - switch (key) { - case KEY_UP: { - key = TK_KEY_UP; - break; - } - case KEY_DOWN: { - key = TK_KEY_DOWN; - break; - } - case KEY_LEFT: { - key = TK_KEY_LEFT; - break; - } - case KEY_RIGHT: { - key = TK_KEY_RIGHT; - break; - } - default: { key = 0; } - } - - if (key) { - main_loop_post_key_event(main_loop(), TRUE, key); - } else { - main_loop_post_key_event(main_loop(), FALSE, key); - } - - if (TOUCH_Scan() == 0) { - main_loop_post_pointer_event(main_loop(), TRUE, TouchData.lcdx, TouchData.lcdy); - } else { - main_loop_post_pointer_event(main_loop(), FALSE, TouchData.lcdx, TouchData.lcdy); - } -} - -void TIM3_IRQHandler(void) { - if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) { - dispatch_input_events(); - TIM_ClearITPendingBit(TIM3, TIM_IT_Update); - } -} - -#include "main_loop/main_loop_raw.inc" diff --git a/awtk-port.1/platform.c b/awtk-port.1/platform.c deleted file mode 100644 index d757748..0000000 --- a/awtk-port.1/platform.c +++ /dev/null @@ -1,35 +0,0 @@ -/** - * File: platform.c - * Author: AWTK Develop Team - * Brief: platform dependent function of stm32 - * - * Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd. - * - * this program is distributed in the hope that it will be useful, - * but without any warranty; without even the implied warranty of - * merchantability or fitness for a particular purpose. see the - * license file for more details. - * - */ - -/** - * history: - * ================================================================ - * 2018-02-17 li xianjing created - * - */ - -#include "tkc/mem.h" -#include "base/timer.h" - -ret_t platform_prepare(void) { - static bool_t inited = FALSE; - static uint32_t s_heam_mem[7600]; - - if(!inited) { - inited = TRUE; - tk_mem_init(s_heam_mem, sizeof(s_heam_mem)); - } - - return RET_OK; -}