想在stm32 ucgui上移植UCOSII和UCGUI,需要多大的空间资源

STM32--CAN--ucgui-ucos II结合uc-gui的例程,展示了CAN通信的功能
238万源代码下载-
&文件名称: STM32--CAN--ucgui-ucos
& & & & &&]
&&所属分类:
&&开发工具: C-C++
&&文件大小: 3543 KB
&&上传时间:
&&下载次数: 100
&&提 供 者:
&详细说明:ucosII结合uc-gui的例程,展示了CAN通信的功能-ucosII combined with the routine of the uc-gui, showing the function of the CAN communication
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&STM32奋斗版 CAN通信 ucgui ucos\APP\app.c&&..............................\...\app_cfg.h&&..............................\...\config.h&&..............................\...\DEMO.h&&..............................\...\fsmc_sram.c&&..............................\...\fsmc_sram.h&&..............................\...\Fun.c&&..............................\...\includes.h&&..............................\...\JLinkLog.txt&&..............................\...\lcd_dis24.c&&..............................\...\os_cfg.h&&..............................\...\platform_config.h&&..............................\...\RAM.ini&&..............................\...\STM32-FD-ucgui_Opt.Bak&&..............................\...\STM32-FD-ucgui.Uv2&&..............................\...\STM32-FD-ucgui_Flash.dep&&..............................\...\STM32-FD-ucgui_STM32-FATFS.dep&&..............................\...\STM32-FD-ucgui_STM32-FD.dep&&..............................\...\STM32-FD-ucgui_Uv2.Bak&&..............................\...\stm32f10x_conf.h&&..............................\...\stm32f10x_it.c&&..............................\...\STM32_Reg.h&&..............................\...\STM32-FD-ucgui.Opt&&..............................\BSP\bsp.c&&..............................\...\bsp.h&&..............................\CM3\core_cm3.c&&..............................\...\core_cm3.h&&..............................\...\stm32f10x.h&&..............................\...\system_stm32f10x.c&&..............................\...\system_stm32f10x.h&&..............................\font\FangSong_GB2312_24.c&&..............................\....\hb24_32.c&&..............................\....\hwhb_32.c&&..............................\....\KaiTi_27.c&&..............................\....\SimSun16.c&&..............................\....\SimSun_13.c&&..............................\....\STCaiYun_35.c&&..............................\....\STXiHei_32.c&&..............................\FWlib\inc\misc.h&&..............................\.....\...\stm32f10x_adc.h&&..............................\.....\...\stm32f10x_bkp.h&&..............................\.....\...\stm32f10x_can.h&&..............................\.....\...\stm32f10x_cec.h&&..............................\.....\...\stm32f10x_conf.h&&..............................\.....\...\stm32f10x_crc.h&&..............................\.....\...\stm32f10x_dac.h&&..............................\.....\...\stm32f10x_dbgmcu.h&&..............................\.....\...\stm32f10x_dma.h&&..............................\.....\...\stm32f10x_exti.h&&..............................\.....\...\stm32f10x_flash.h&&..............................\.....\...\stm32f10x_fsmc.h&&..............................\.....\...\stm32f10x_gpio.h&&..............................\.....\...\stm32f10x_i2c.h&&..............................\.....\...\stm32f10x_iwdg.h&&..............................\.....\...\stm32f10x_pwr.h&&..............................\.....\...\stm32f10x_rcc.h&&..............................\.....\...\stm32f10x_rtc.h&&..............................\.....\...\stm32f10x_sdio.h&&..............................\.....\...\stm32f10x_spi.h&&..............................\.....\...\stm32f10x_tim.h&&..............................\.....\...\stm32f10x_usart.h&&..............................\.....\...\stm32f10x_wwdg.h&&..............................\.....\SRC\misc.c&&..............................\.....\...\stm32f10x_adc.c&&..............................\.....\...\stm32f10x_bkp.c&&..............................\.....\...\stm32f10x_can.c&&..............................\.....\...\stm32f10x_cec.c&&..............................\.....\...\stm32f10x_crc.c&&..............................\.....\...\stm32f10x_dac.c&&..............................\.....\...\stm32f10x_dbgmcu.c&&..............................\.....\...\stm32f10x_dma.c&&..............................\.....\...\stm32f10x_exti.c&&..............................\.....\...\stm32f10x_flash.c&&..............................\.....\...\stm32f10x_fsmc.c&&..............................\.....\...\stm32f10x_gpio.c&&..............................\.....\...\stm32f10x_i2c.c&&..............................\.....\...\stm32f10x_iwdg.c&&..............................\.....\...\stm32f10x_pwr.c&&..............................\.....\...\stm32f10x_rcc.c&&..............................\.....\...\stm32f10x_rtc.c&&..............................\.....\...\stm32f10x_sdio.c&&..............................\.....\...\stm32f10x_spi.c&&..............................\.....\...\stm32f10x_tim.c&&..............................\.....\...\stm32f10x_usart.c&&..............................\.....\...\stm32f10x_wwdg.c&&..............................\.....\...\system_stm32f10x.c&&..............................\GUIinc\BUTTON.h&&..............................\......\BUTTON_Private.h&&..............................\......\CHECKBOX.h&&..............................\......\CHECKBOX_Private.h&&..............................\......\DIALOG.h&&..............................\......\DIALOG_Intern.h&&..............................\......\DROPDOWN.h&&..............................\......\DROPDOWN_Private.h&&..............................\......\EDIT.h&&..............................\......\EDIT_Private.h&&..............................\......\FRAMEWIN.h&&..............................\......\FRAMEWIN_Private.h&&..............................\......\GUI.h&&..............................\......\GUIDebug.h
&[]:很好,推荐下载
&近期下载过的用户:
&相关搜索:
&&&&&&&&&&
&输入关键字,在本站238万海量源码库中尽情搜索:
&[] - uCOS-II官方公布的最新源代码V2.86及更新的相关关资料-uCOS-II latest source code
&[] - STM32207 display animation, ILI93225 driver
&[] - 中央空调控制器代码,STM32和ucgui
&[] - 基于uc/os的STM32F107的开发 CAN总线、串口发指令,电机速度闭环程序
&[] - 一款例程
(1) 提供一个基于u/COS-II操作系统的应用程序框架
(2) 演示如何创建多个任务
(3) 演示如何使用邮箱进行两个任务之间的通信
&[] - ucos-II融合uc-gui的程程序,结合重力传感器
&[] - 基于STM32的ucos,ucgui,fatfs,移植,并做好一个界面,有下拉菜单,有rtc,闹钟设置界面,利用BKP,掉电不丢失。
&[] - STM32关于UCCOS的GPS使用例程,融合了UC-gui,用户友好型界面
&[] - uCOS-III x86是uCOS-III基于x86平台的移植实例,总共两个内核版本:最新 Version : V3.03.00 和次新 Version : V3.02.00。
&[] - 51单片机上面基于SPI借口实现SD卡的Fat文件系统在写了uCOS-III移植后,一直想把GUI移植上去。经过不断的努力,有了不错的进展。下面对移植过程进行详解,以方便大家共同学习。
&&&&&&&& 我用的是uCGUI3.98版,在网上找了很久, 可是还不是完整版的。没办法,算是比较全的了,只好先用着。官方是4.03版的但是没有源码,是以库的形式。在搞开发的时候, 可以用官方提供的VC工程去开发,可以省去大量烧写芯片的时间。 我用vs2008测试过可以正常运行。
一、环境:
&&&&&&&& 软件:
STM32F10x 3.5固件库。
MDK4.23 编译器。
uCos-III v3.03。&&&&&&
uCGUI v3.98。
&&&&&&&& 硬件:
神舟三号开发板STM30F103ZE芯;
3.2寸屏320*240。
SPI接口的触摸板。
这是我搜集到的资料,都存现在网盘上了。现在115不好用了,只好换百度。
ucGUI中文手册.pdf
UCGUI3.98源码.rar
官方UCGUI4.04, 及说明书
下面上两个版本空的工程:
    FWLib3.5+uCOSIII3.03
&&&&&&&& FWLib2.0+uCOSIII3.03
&&&&&&&& 提示:
下文的移植都是在FWLib3.5+uCOSIII3.03这个工程上进行的。
这两个工程STM32F固件没有完整添加,在用到哪个功能就添加哪个(减少编译量)。
&&&&&&&& 在移植前最好看过一遍uCGUI中文手册,这样可以有个初步了解,和操作使用。
建立工程时用他推崇的结构:
&&&&&&&& 图1
内容介绍:
三、开始准备移植文件:
新建文件夹uCGUI
复制整个GUI和 Config文件夹到uCGUI。
复制 下GUI_X_Touch.c,GUI_X_uCOS.c两个文件到uCGUI中,因为有触摸功能和uCOS系统。
复制下整个GUIDemo文件夹到uCGUI。
在uCGUI文件夹下新建LCDDriver文件夹,把自己lcd的驱动程序写入其中。我新建的ili9320.c 和ili9320.h两个文件。需要写哪什么驱动函数,后面做详细的介绍。
到此文件的准备就完成了,开始向程序中添加。
四、添加到工程
我还是直接上图,添加哪些文件。
直接添加所有Dome中的文件。
添加所有GUI子文件。太多了,还是用CTRL+A吧,不然手都要点麻!
重要的一步,让添加的文件可直接索引到。
好了,所有文件都添加到工程中了。下面是最后重要的一步,对文件进行修改。
五、移植修改文件
LCD的驱动,这一步也关系到LCD显示的成功于否,主要要写三个函数:
void LCDxxx_Init(void);  //LCD硬件初始化
u16 LCDxxx _GetPoint(u16 x,u16 y);  //获取(x,y)坐标的像素点
void LCDxxx _SetPoint(u16 x,u16 y,u16 point);  //把像素点写入(x,y)坐标点
这三个函数以定要再在自己的开发板上测试好了,再复制过来。LCDxxx函数名可自定义。只要这三个函数没有问题,移植就成功一大半了
void ili9320_Initializtion(void);
u16 ili9320_GetPoint(u16 x,u16 y);
void ili9320_SetPoint(u16 x,u16 y,u16 point);
写好后,在uCGUI\GUI\LCDDriver下找到LCDTemplate.c文件。
找到LCD_L0_SetPixelIndex 添加ili9320_SetPoint函数;
找到 LCD_L0_GetPixelIndex添加ili9320_GetPoint函数。
如下代码:
1 /*********************************************************************
Exported functions
5 **********************************************************************
8 /*********************************************************************
LCD_L0_SetPixelIndex
12 * Purpose:
Sets the index of the given pixel. The upper layers
calling this routine make sure that the coordinates are in range, so
that no check on the parameters needs to be performed.
17 void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex) {
int xPhys = 0;
int yPhys = 0;
GUI_USE_PARA(x);
GUI_USE_PARA(y);
GUI_USE_PARA(PixelIndex);
/* Convert logical into physical coordinates (Dep. on LCDConf.h) */
#if LCD_SWAP_XY | LCD_MIRROR_X| LCD_MIRROR_Y
xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
/* Write into hardware ... Adapt to your system */
ili9320_SetPoint(xPhys, yPhys, PixelIndex);/* ... */
37 /*********************************************************************
LCD_L0_GetPixelIndex
41 * Purpose:
Returns the index of the given pixel. The upper layers
calling this routine make sure that the coordinates are in range, so
that no check on the parameters needs to be performed.
46 unsigned int LCD_L0_GetPixelIndex(int x, int y) {
int xPhys = 0;
int yPhys = 0;
LCD_PIXELINDEX PixelI
GUI_USE_PARA(x);
GUI_USE_PARA(y);
/* Convert logical into physical coordinates (Dep. on LCDConf.h) */
#if LCD_SWAP_XY | LCD_MIRROR_X| LCD_MIRROR_Y
xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
/* Read from hardware ... Adapt to your system */
PixelIndex = ili9320_GetPoint(xPhys, yPhys);/* ... */
return PixelI
在uCGUI\Config找到三个配置文件。
在pdf的第20章有详细介绍
先设定这几个必需的。
初始化宏定义
驱动如果是自己写的需要以下宏定义
#define LCD_CONTROLLER&&&&& -1
#define LCD_INIT_CONTROLLER() &ili9320_Initializtion();
可以用默认配置
GUITouchConf.h
先用默认值,等运行Dome后,有个校准,获得校准值,再进行修改。
GUI_X_Touch.c文件修改
主要添加读X轴和Y轴的AD值。如果和我用同样的开发板,可以用如下代码。
GUI_X_Touch.c
2 *********************************************************************************************************
uC/GUI V3.98
Universal graphic software for embedded applications
(c) Copyright 2002, Micrium Inc., Weston, FL
(c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
礐/GUI is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be redistributed
in any way. We appreciate your understanding and fairness.
14 ----------------------------------------------------------------------
: GUI_TOUCH_X.C
16 Purpose
: Config / System dependent externals for GUI
17 ---------------------------END-OF-HEADER------------------------------
21 #include "GUI.h"
22 #include "GUI_X.h"
23 #include "ili9320.h"
24 #include "bsp.h"
26 //#define NEW8989_LCD
// 如果触摸屏的触摸与指针的移动方向是反的请注释掉该宏定义
28 unsigned short int X,Y;
30 void GUI_TOUCH_X_ActivateX(void) {
33 void GUI_TOUCH_X_ActivateY(void) {
GUI_TOUCH_X_MeasureX(void)
unsigned char t=0,t1,count=0;
unsigned short int databuffer[10]={5,7,9,3,2,6,4,0,3,1};//数据组
unsigned short temp=0,X=0;
while(/*GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0)==0&&*/count&10)//循环读数10次
45 #ifndef NEW8989_LCD
databuffer[count]=TPReadX();
databuffer[count]=TPReadY();
if(count==10)//一定要读到10次数据,否则丢弃
do//将数据X升序排列
for(t=0;t&count-1;t++)
if(databuffer[t]&databuffer[t+1])//升序排列
temp=databuffer[t+1];
databuffer[t+1]=databuffer[t];
databuffer[t]=
}while(t1);
X=(databuffer[3]+databuffer[4]+databuffer[5]+databuffer[6])&&2;
70 #ifndef NEW8989_LCD
return(X);
return((X&100)?(X-100): 0);
GUI_TOUCH_X_MeasureY(void) {
unsigned char t=0,t1,count=0;
unsigned short int databuffer[10]={5,7,9,3,2,6,4,0,3,1};//数据组
unsigned short temp=0,Y=0;
while(/*GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0)==0&&*/count&10)
//循环读数10次
85 #ifndef NEW8989_LCD
databuffer[count]=TPReadY();
databuffer[count]=TPReadX();
if(count==10)//一定要读到10次数据,否则丢弃
do//将数据X升序排列
for(t=0;t&count-1;t++)
if(databuffer[t]&databuffer[t+1])//升序排列
temp=databuffer[t+1];
databuffer[t+1]=databuffer[t];
databuffer[t]=
}while(t1);
Y=(databuffer[3]+databuffer[4]+databuffer[5]+databuffer[6])&&2;
110 110 #ifndef NEW8989_LCD
return(Y);
112 112 #else
Y = 4095-Y;
return((Y&100)?(Y-100): 0);
115 115 #endif
GUI_X_uCOS.c文件如下替换
GUI_X_uCOS.c
2 *********************************************************************************************************
Universal graphic software for embedded applications
(c) Copyright 2002, Micrium Inc., Weston, FL
(c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
礐/GUI is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be redistributed
in any way. We appreciate your understanding and fairness.
14 ---Author-Explanation
16 * 1.00.00 020519 JJL
First release of uC/GUI to uC/OS-II interface
19 * Known problems or limitations with current version
24 * Open issues
27 *********************************************************************************************************
30 #include "os.h"
31 #include "os_Cfg_app.h"
32 #include "GUI_Private.H"
33 #include "stdio.H"
37 *********************************************************************************************************
GLOBAL VARIABLES
39 *********************************************************************************************************
50 *********************************************************************************************************
TIMING FUNCTIONS
53 * Notes: Some timing dependent routines of uC/GUI require a GetTime and delay funtion.
Default time unit (tick), normally is 1 ms.
55 *********************************************************************************************************
58 int GUI_X_GetTime(void)
return ((int)OSTimeGet( (OS_ERR *)&err));
65 void GUI_X_Delay(int period)
ticks = period * OS_CFG_TICK_RATE_HZ / 1000;
OSTimeDly(
)OS_OPT_TIME_DLY,
78 *********************************************************************************************************
GUI_X_ExecIdle()
80 *********************************************************************************************************
82 /*WM空闲时调用*/
83 void GUI_X_ExecIdle(void)
OSTimeDly(
)OS_OPT_TIME_DLY,
94 *********************************************************************************************************
MULTITASKING INTERFACE FUNCTIONS
97 * Note(1): 1) The following routines are required only if uC/GUI is used in a true multi task environment,
which means you have more than one thread using the uC/GUI API.
In this case the #define
needs to be in GUIConf.h
100 100 *********************************************************************************************************
101 101 */
103 103 void GUI_X_InitOS (void)
OSSemCreate(
*)&dispSem, //建立一个互斥型信号量
*)"dispSem",
(OS_SEM_CTR )1,
OSSemCreate(
*)&eventSem,
*)"eventSem",
(OS_SEM_CTR )1,
119 119 void GUI_X_Lock(void)
OSSemPend(
*)&dispSem,
)OS_OPT_PEND_BLOCKING,
132 132 void GUI_X_Unlock(void)
OSSemPost(
*)&dispSem,
)OS_OPT_POST_1,
142 142 U32 GUI_X_GetTaskId(void)
return ((U32)(OSTCBCurPtr-&Prio));
147 147 /*
148 148 *********************************************************************************************************
GUI_X_WaitEvent()
GUI_X_SignalEvent()
151 151 *********************************************************************************************************
152 152 */
155 155 void GUI_X_WaitEvent(void)
OSSemPend(
*)&eventSem,
)OS_OPT_PEND_BLOCKING,
168 168 void GUI_X_SignalEvent(void)
OSSemPost(
*)&eventSem,
)OS_OPT_POST_1,
177 177 /*
178 178 *********************************************************************************************************
KEYBOARD INTERFACE FUNCTIONS
181 181 * Purpose: The keyboard routines are required only by some widgets.
If widgets are not used, they may be eliminated.
184 184 * Note(s): If uC/OS-II is used, characters typed into the log window will be placed
in the keyboard buffer.
This is a neat feature which allows you to operate your target system without having to use or
even to have a keyboard connected to it. (useful for demos !)
187 187 *********************************************************************************************************
188 188 */
190 190 static void CheckInit(void)
if(KeyIsInited==DEF_FALSE)
KeyIsInited = DEF_TRUE;
GUI_X_Init();
200 200 /*被GUI_Init()调用,用来初始化一些GUI运行之前需要用的硬件,如键盘或者鼠标之类的.如果不需要的话,可以为空*/
201 201 void GUI_X_Init(void)
OSSemCreate(
*)&keySem,
*)"keySem",
(OS_SEM_CTR )0,
212 212 int GUI_X_GetKey(void)
CheckInit();
KeyPressed = 0;
return (r);
222 222 int GUI_X_WaitKey(void)
CheckInit();
if(KeyPressed==0)
OSSemPend(
*)&keySem,
//等待信号量
)OS_OPT_PEND_BLOCKING,
KeyPressed = 0;
return (r);
243 243 void GUI_X_StoreKey(int k)
KeyPressed =
OSSemPost(
*)&keySem,
//释放信号量
)OS_OPT_POST_1,
253 253 void GUI_X_Log(const char *s)
GUI_USE_PARA(s);
258 258 void GUI_X_Warn(const char *s)
GUI_USE_PARA(s);
263 263 void GUI_X_ErrorOut(const char *s)
GUI_USE_PARA(s);
在BSP.c文件中添加触摸板SPI接口程序。修改后如下:
2 ********************************************************************************
ARM Cortex-M3 Port
: Config.C
8 * Version
: Stm32f10x
13 * Toolchain
RealView Microcontroller Development Kit (MDK)
Keil uVision
16 * Description
: STM32F10x 内部 系统的配置
1,系统中断优先级模式设置
2,系统程序启动指定
3,系统时钟计时器配置
4,芯片引脚初始化
24 *******************************************************************************/
26 #include "misc.h"
27 #include "stm32f10x_gpio.h"
28 #include "stm32f10x_rcc.h"
29 #include "stm32f10x_iwdg.h"
30 #include "stm32f10x_spi.h"
31 #include "bsp.h"
34 GPIO_InitTypeDef GPIO_InitS
36 /*******************************************************************************
37 * Function Name
: GPIO_Configuration
38 * Description
: Configures the different GPIO ports.
39 * Input
40 * Output
41 * Return
42 *******************************************************************************/
43 void GPIO_Configuration(void)
45 #ifdef USE_STM3210B_EVAL
/* Enable the USART2 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_A
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOE, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, DISABLE);
69 /*******************************************************************************
70 * Function Name
71 * Description
: Inserts a delay time.
72 * Input
: nCount: specifies the delay time length.
73 * Output
74 * Return
75 *******************************************************************************/
76 //void Delay(volatile CPU_INT32U nCount)
for(; nCount != 0; nCount--);
81 /*******************************************************************************
82 函 数 名:void IWDG_Init(void)
83 功能描述:看门狗初始化
84 入口参数:
85 返回参数:
86 创建时间:
87 ********************************************************************************/
88 void IWDG_Init(void)
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
IWDG_SetPrescaler( IWDG_Prescaler_64);
IWDG_SetReload( 0x138);
//40KHz内部时钟 (1/40000 * 64 * 0x138 = 0.5s)
IWDG_WriteAccessCmd( IWDG_WriteAccess_Disable );
IWDG_Enable();
IWDG_ReloadCounter();
98 /*******************************************************************************
99 * Function Name :void SysTickInit(void)
100 100 * Description
:系统定时器时间配置
101 101 * Input
102 102 * Output
103 103 * Other
:时基为1ms
104 104 * Date
105 105 *******************************************************************************/
106 106 void SysTickInit(void)
SysTick_Config(SystemCoreClock / 1000);
//uCOS时基1ms
111 111 /*******************************************************************************
112 112 * Function Name :void InterruptOrder(void)
113 113 * Description
:中断向量,优先级
114 114 * Input
115 115 * Output
116 116 * Other
117 117 * Date
118 118 *******************************************************************************/
119 119 void NVIC_Configuration(void)
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4);//优先级设置
全为抢占式优先级
125 125 /*******************************************************************************
126 126 * Function Name :void SystemConfig(void)
127 127 * Description
:系统时间戳 初始化
128 128 * Input
129 129 * Output
130 130 * Other
131 131 * Date
132 132 *******************************************************************************/
133 133 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
134 134 void
CPU_TS_TmrInit (void)
137 137 #endif
140 140 /*******************************************************************************
141 141 * Function Name :void SystemConfig(void)
142 142 * Description
:读时间戳 计数值
143 143 * Input
:读到的计数值
144 144 * Output
145 145 * Other
146 146 * Date
147 147 *******************************************************************************/
148 148 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
149 149 CPU_TS_TMR
CPU_TS_TmrRd (void)
return (SysTick-&VAL);
153 153 #endif
155 155 /*******************************************************************************
156 156 * Function Name :void SystemConfig(void)
157 157 * Description
:系统初始化
158 158 * Input
159 159 * Output
160 160 * Other
161 161 * Date
162 162 *******************************************************************************/
163 163 void BspInit(void)
NVIC_Configuration();
//中断优先级设置
GPIO_Configuration();
//端口初始化,所有端口关
SPI_Config();
//触摸接口初始化
170 170 void led_init(void)
GPIO_InitTypeDef GPIO_InitS
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOF, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 |
GPIO_Pin_12 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOF, &GPIO_InitStructure);
187 187 void led_on(CPU_INT32U n)
switch (n)
case LED_0:
GPIO_SetBits(GPIOD, GPIO_Pin_2);
case LED_1:
GPIO_SetBits(GPIOD, GPIO_Pin_3);
case LED_2:
GPIO_SetBits(GPIOD, GPIO_Pin_4);
case LED_3:
GPIO_SetBits(GPIOF, GPIO_Pin_6);
case LED_4:
GPIO_SetBits(GPIOF, GPIO_Pin_7);
case LED_5:
GPIO_SetBits(GPIOF, GPIO_Pin_8);
215 215 void led_off(CPU_INT32U n)
switch (n)
case LED_0:
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
case LED_1:
GPIO_ResetBits(GPIOD, GPIO_Pin_3);
case LED_2:
GPIO_ResetBits(GPIOD, GPIO_Pin_4);
case LED_3:
GPIO_ResetBits(GPIOF, GPIO_Pin_6);
case LED_4:
GPIO_ResetBits(GPIOF, GPIO_Pin_7);
case LED_5:
GPIO_ResetBits(GPIOF, GPIO_Pin_8);
241 241 /*
SPI1_SCK PA5
SPI1_MISO PA6
245 245 SPI1_MOSI PA7
T_BUSY PA8
247 247 */
248 248 void SPI_Config(void)
GPIO_InitTypeDef
GPIO_InitS
SPI_InitTypeDef
//GPIOA Periph clock enable
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE);
//SPI1 Periph clock enable
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE);
//SPI2 Periph clock enable
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE ) ;
//Configure SPI2 pins: SCK, MISO and MOSI
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
//复用推挽输出
GPIO_Init(GPIOB,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//推挽输出
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
//上拉输入
GPIO_Init(GPIOA,&GPIO_InitStructure);
//Configure PF10 pin: TP_CS pin
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//推挽输出
GPIO_Init(GPIOB,&GPIO_InitStructure);
//Configure PA8 pin: TP_BUSY pin
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
//上拉输入
GPIO_Init(GPIOE,&GPIO_InitStructure);
/* Configure PE.06 as input floating For TP_IRQ*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOE,&GPIO_InitStructure);
// SPI1 Config
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullD
SPI_InitStructure.SPI_Mode = SPI_Mode_M
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_L
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1E
SPI_InitStructure.SPI_NSS = SPI_NSS_S
//SPI_NSS_Hard
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2,&SPI_InitStructure);
// SPI1 enable
SPI_Cmd(SPI2,ENABLE);
313 313 unsigned char SPI_WriteByte(unsigned char data)
unsigned char Data = 0;
//Wait until the transmit buffer is empty
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE)==RESET);
// Send the byte
SPI_I2S_SendData(SPI2,data);
//Wait until a data is received
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_RXNE)==RESET);
// Get the received data
Data = SPI_I2S_ReceiveData(SPI2);
// Return the shifted data
330 330 void SpiDelay(unsigned int DelayCnt)
unsigned int
for(i=0;i&DelayCi++);
336 336 u16 TPReadX(void)
SpiDelay(10);
SPI_WriteByte(0x90);
SpiDelay(10);
x=SPI_WriteByte(0x00);
x+=SPI_WriteByte(0x00);
SpiDelay(10);
return (x);
352 352 u16 TPReadY(void)
SpiDelay(10);
SPI_WriteByte(0xD0);
SpiDelay(10);
y=SPI_WriteByte(0x00);
y+=SPI_WriteByte(0x00);
SpiDelay(10);
return (y);
向工程中添加两个stm32f10x_fsmc.c,stm32f10x_spi.c这两个文件。
好了,大部分的准备工作都好了, 再在让新建一个任务来运行Dome中的MainTask();在任务3中调用GUI_TOUCH_Exec();
1 /*-------------------------------------------------------------------------
6 -------------------------------------------------------------------------*/
8 #include "bsp.h"
9 #include "App.h"
11 extern void MainTask(void);
12 extern void GUI_TOUCH_Exec(void);
taskStartTCB;
taskStartStk[STARTUP_TASK_STK_SIZE];
//启动任务的程序空间
task1Stk[TASK1_STK_SIZE];
task2Stk[TASK2_STK_SIZE];
task3Stk[TASK3_STK_SIZE];
dispStk[TASK4_STK_SIZE];
OS_SEM taskS
33 /*******************************************************************************
34 * Function Name :void TaskStart(void)
35 * Description
36 * Input
37 * Output
38 * Other
40 *******************************************************************************/
41 static void TaskStart(void)
led_init();
SysTickInit();
OSTaskCreate(
*)&task1TCB,
*)"Task1",
(OS_TASK_PTR)Task1,
)TASK1_PRIO,
*)&task1Stk[0],
(CPU_STK_SIZE)TASK1_STK_SIZE / 10,
(CPU_STK_SIZE)TASK1_STK_SIZE,
(OS_MSG_QTY )0,
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
OSTaskCreate(
*)&task2TCB,
*)"Task2",
(OS_TASK_PTR)Task2,
) TASK2_PRIO,
*)&task2Stk[0],
(CPU_STK_SIZE)TASK2_STK_SIZE / 10,
(CPU_STK_SIZE)TASK2_STK_SIZE,
(OS_MSG_QTY )0,
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
OSTaskCreate(
*)&task3TCB,
*)"Task3",
(OS_TASK_PTR)Task3,
)TASK3_PRIO,
*)&task3Stk[0],
(CPU_STK_SIZE)TASK3_STK_SIZE / 10,
(CPU_STK_SIZE)TASK3_STK_SIZE,
(OS_MSG_QTY )0,
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
OSTaskCreate(
*)&dispTCB,
*)"LCD display",
(OS_TASK_PTR)MainTask,
)Disp_PRIO,
*)&dispStk[0],
(CPU_STK_SIZE)TASK4_STK_SIZE / 10,
(CPU_STK_SIZE)TASK4_STK_SIZE,
(OS_MSG_QTY )0,
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
OSSemCreate(
*)&taskSem,
*)"taskSem",
(OS_SEM_CTR )0,
OSTaskDel(
*)&taskStartTCB,
115 115 static void Task1(void *p_arg)
led_on(LED_4);
OSTimeDly(
)OS_OPT_TIME_DLY,
led_off(LED_4);
OSTimeDly(
)OS_OPT_TIME_DLY,
OSSemPost(
*)&taskSem,
)OS_OPT_POST_ALL,
137 137 static void Task2(void *p_arg)
led_on(LED_5);
OSSemPend(
*)&taskSem,
)OS_OPT_PEND_BLOCKING,
led_off(LED_5);
OSSemPend(
*)&taskSem,
)OS_OPT_PEND_BLOCKING,
159 159 static void Task3(void *p_arg)
static int tasCon = 0;
GUI_TOUCH_Exec();
OSTimeDly(
)OS_OPT_TIME_DLY,
OSTimeDly(
)OS_OPT_TIME_DLY,
if ((tasCon++ % 50) & 25)
led_on(LED_3);
led_off(LED_3);
182 182 void KernelMain(void)
CPU_Init();
OSTaskCreate(
*)&taskStartTCB,
*)"Task Start",
(OS_TASK_PTR)TaskStart,
) STARTUP_TASK_PRIO,
*)&taskStartStk[0],
(CPU_STK_SIZE)STARTUP_TASK_STK_SIZE / 10,
(CPU_STK_SIZE)STARTUP_TASK_STK_SIZE,
(OS_MSG_QTY )0,
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
设定优先级 和分配空间。任务3分配350个字节,MainTask分配500个字节
优先级设定触摸版 比MainTask()高就可以了。
需要注意一个问题,GUI中用到了获取获取时基计数器的值。而时基计数器是在优先级为10的任务中进行刷新的。所以必需把&&&&&&&& MainTask()任务的优先级比10优先级低。
&&&&&&&& 还有一个解决办法:修改时基计数器任务的优先级,在uCOS-III\uCOS-III文件os_cfg_app.h
OS_CFG_TMR_TASK_PRIO
OS_CFG_TICK_TASK_PRIO&&&&&&
到此就可以进行编译了。
几分钟的等待,下载~~~
每次编译的时间实在是太长了。这样咱们把源代码生成库,再进行编译。如下图:
再编译生成
到Obj文件夹下到Project.lib 找到,改下名子GUI3_98.lib
把工程中的uCGUI/lib里的所有文件删除,用GUI3_98.lib替换。
再切换回来
再编译, 是不是非常快了。
注意:在对LCD配置变更时,需要重新制作.lib库。
以下两个连接是编译完成后的工程。
FWLib3.5+uCOSIII3.03+uCGUI3.98(源文件版).rar
FWLib3.5+uCOSIII3.03+uCGUI3.98(库形式版).rar
在移植的过程中主要讲述了三点
三个LCD的驱动函数。
GUI程序在uCOS-III优先级的选择。
GUI库的制作。
好了,就这些了,后期还会慢慢更新最新版。希望以上对新学习uCGUI的朋友有所帮助。
下面传几个Dome的照片。
阅读(...) 评论()

我要回帖

更多关于 stm32 ucgui视频教程 的文章

 

随机推荐