diff options
110 files changed, 5344 insertions, 3685 deletions
diff --git a/ChangeLog_CN.md b/ChangeLog_CN.md index 31ccb8ef9e..12435ced95 100644 --- a/ChangeLog_CN.md +++ b/ChangeLog_CN.md @@ -1,9 +1,58 @@ +# RT-Thread v2.1.0 beta版本更改说明 + +## BSP部分 + +* BeagleBone加入GPIO驱动; +* 京微雅格M7,更新驱动库并改进EMAC驱动程序; +* 新加入dm365移植(包括EMAC、GPIO、I2C、MMC/SD、SPI等驱动); +* LPC4088加入EMC、硬件定时器、CAN驱动; +* 新加入龙芯1C,智龙v2开发板移植(包括多串口驱动); +* 更改mini2440移植为applications/drivers等的目录方式; +* 更新simulator在MS VC++上的移植,处理好初始化代码工作,完善UART控制台驱动; +* 新加入stm32f7-disco移植; +* 在stm32f10x中新加入CAN驱动及应用代码示例; +* 在stm32f40x中加入硬件定时器驱动,RTC驱动; +* 调整stm32f107为新的串口驱动框架; + +## 组件 + +* DFS的struct stat定义中移除st_blksize成员(可以兼容于VC++中的stat定义); +* 修正DFS中select实现的问题; +* 修正DFS中文件操作出错、关闭时的fd处理问题; +* 修正DFS中mkdir和lseek出错时的fd处理问题; +* 修正lwIP中SYS_ARCH_PROTECT/SYS_ARCH_UNPROTECT保护的问题; +* 增加CAN驱动框架; +* 增加硬件定时器驱动框架; +* SD/MMC驱动框架中增加eMMC支持; +* 修正注册SDIO驱动时驱动关联的问题; +* 修正串口驱动框架DMA发送时激活标志的问题; +* SPI Flash驱动中加入对GD25Q spi flash芯片支持; +* 增加paho-mqtt组件移植; +* 增加msh的脚本执行能力,可以在msh下执行*.sh脚本; +* 增加msh下的mkfs命令; +* 修正在Linux Telnet下使用finsh shell回车符处理的问题; +* 增加应用模块在使用armcc、gnu gcc编译器时的libc符号导出; +* 在以太网网卡驱动框架中增加ETHIF_LINK_AUTOUP/PHYUP参数用于指定初始时的链路Up/Down状态; +* 在组件初始化中导出log_trace组件; + +## 内核 + +* 更改UNUSED/USED等更改成RT_UNUSED/RT_USED; +* 链接时增加.rodata.name section,当空间资源受限时可以把它放到性能低的内存区域; +* 完善IAR编译器下的组件自动初始化; +* 增加rt_assert_hook,在触发断言时可以执行这个钩子函数; +* 修正应用模块分散加载情况下的问题; + +## 工具 + +* scons中定义Group时加入了本Group内的编译参数定义; +* 修正了如果Group中即包含代码,也包含二进制库时,生成的Keil MDK工程文件有两个重名Group的问题; 版本: RT-Threadv2.0.1及v2.1.0 alpha RT-Thread v2.0.1是2.0这个系列的bug修正版,而v2.1.0 alpha则是当前开发主干的一个技术预览版本,它给出了v2.1.0这个版本系列的技术预览情况,不建议用于实际产品中,因为它可能存在大量的一些bug。 -RT-Thread v2.0.1修正的主要内容包括: +# RT-Thread v2.0.1更改说明 * IAR用的dlib,加入THREAD_SUPPORT 和 FILE_DESCRIPTOR的支持; * 修正finsh中echo回显模式的问题; @@ -15,28 +64,19 @@ RT-Thread v2.0.1修正的主要内容包括: * lwip更深度的集成:把它集成到RT-Thread的文件系统接口中,这样Linux/Unix下的一些socket网络应用能够更顺利的移植到RT-Thread上,也为以后可以应用到更多地方的select接口铺路。 -* 这部分是和RT-Thread发布本身无关,但也是这个版本系列设定的目标之一:开启一个云端集成开发环境的时代!云端会是什么样的,请用现代化的浏览器打开以下地址: -http://lab.rt-thread.org/cloudide/simulator/index.html - +* 这部分是和RT-Thread发布本身无关,但也是这个版本系列设定的目标之一:开启一个云端集成开发环境的时代!云端会是什么样的,请用现代化的浏览器打开[CloudIDE](http://lab.rt-thread.org/cloudide/simulator/index.html) - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 2.0.0正式版 +# RT-Thread 2.0.0正式版更改说明 经历了大约1年的时间,RT-Thread v2.0.0的最终版本终于发布出来了。自这个版本开发以来,引入了多项功能、修改、增强等。感谢参与的诸位开发人员! 以下是自v2.0.0 RC版本以来的详细更改记录。后续我还会给出v2.0.0版本自v1.2.x版本的主要不同、看点,以及给出下一个版本的roadmap规划。 - [内核] +## 内核 * console以RT_DEVICE_FLAG_STREAM参数打开字符设备; * 在rt_memheap_free中加入更多的断言检查; - [组件] +## 组件 * 更新RW009驱动以支持Wi-Fi SoftAP模式(aozima); * 修正sensor框架的一些问题,并加入C API接口(睿赛德服务公司提供); @@ -53,10 +93,9 @@ http://lab.rt-thread.org/cloudide/simulator/index.html * 增加lwIP/NAT组件,可以做多个网口间的地址转换(Hicard); * 增加lwIP/DHCP服务端,用于向客户端分配IP地址(睿赛德服务公司提供); - [BSP] +## BSP * 修正LPC4357串口驱动初始化时过早打开中断的问题(nongxiaoming); - * 重写LPC4357串口驱动,并让芯片上M4/M0核心分别都执行RT-Thread系统,两核心之间以VBUS组件进行系统间通信(睿赛德服务公司捐赠); * 新增RX移植(limxuzheng); * 新增NuMicro M051 Series移植,支持GCC、Keil MDK编译器(bright-pan); @@ -65,17 +104,11 @@ http://lab.rt-thread.org/cloudide/simulator/index.html * 在Linux Clang编译分析中,强制以32位模式进行编译(grissiom); * 修正STM32F103中串口驱动中断过早打开的问题(armink); - [工具] +## 工具 * 增加scons中的MD5支持(bright-pan); -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 2.0.0 RC +# RT-Thread 2.0.0 RC 更改说明 发布时间:2014/11/4 @@ -96,7 +129,7 @@ CSDN开源夏令营其他的成果,例如bluedroid移植也有了初步的成� 以下是这个版本的更改记录: - [内核] +## 内核 * 修正当采用高级别优化编译时,idle任务中查询是否有僵尸线程的潜在bug; @@ -104,93 +137,53 @@ CSDN开源夏令营其他的成果,例如bluedroid移植也有了初步的成� * 在console中打开设备时,加入流标志进行打开; - [组件] +## 组件 * 加入C++基础支撑组件。C++组件依赖于RT_USING_LIBC库,当使用GCC编译器时请注意查看其中的说明文档并更改ld script; - * 修正DFS中NFS打开目录的bug; - * 更改DFS ROMFS默认romfs_root为弱化符号; - * 添加DFS中dfs_file_lseek接口中关于fs的检查; - * 移除I2C core中无用的core lock锁; - * 添加sensor framework(采用C++的方式支持各种sensor); - * 修正serial框架中DMA发送的bug(heyuanjie87); - * 移除SPI框架中不必要的device初始化代码; - * 完善SPI Wi-Fi网卡RW009驱动并提供RSSI相关的命令; - * 修正MSH中未定义DFS_USING_WORKDIR时更改当前目录的bug; - * 修正MSH中未定义RT_LWIP_TCP时依然定义了netstat命令的bug; - * 修正MSH中未定义RT_USING_HEAP时依然定义了free命令的bug; - * 修正finsh中FINSH_USING_HISTORY相关的裁剪; - * 加入gdb stub组件,当前支持ARM Cortex-A8和Cortex-M3/4(wzyy2); - * 统一不同编译器下使用LIBC的宏为RT_USING_LIBC,原有的宏定义RT_USING_NEWLIB/RT_USING_ARM_LIBC需要从rtconfig.h中移除,并替换成RT_USING_LIBC; - * 加入最新的lwIP分支:lwip-head,以提供IPv4/v6双栈的功能(hduffddybz); - * YMode中打开串口设备时,添加open flag(armink); - [bsp] +## bsp * 加入北京京微雅格的M7(华山)低功耗FPGA的ARM Cortex-M3移植(aozima); - * 加入北京京微雅格的M7 EMAC以太网驱动(aozima); - * AT91SAM9260分支中更改RT_USING_NEWLIB为RT_USING_LIBC; - * BeagleBoneBlack分支中加入gdb stub支持(wzyy2); - * LPC176x分支中加入C++支持; - * LPC176x分支中修正SD卡驱动返回卡信息的bug; - * 修正LPC408x分支中GCC编译时的问题; - * LPC408x分支中加入C++支持; - * 龙芯1B分支中加入UART3驱动; - * 加入飞索半导体的MB9BF568 FM4分支移植(yangfasheng); - * mini2440分支中更改RT_USING_NEWLIB为 RT_USING_LIBC; - * stm32f0x分支中移除不同编译器下的LIBC定义,统一更改为RT_USING_LIBC; - * stm32f0x分支中加入串口接收溢出中断处理(armink); - * stm32f40x分支中加入gdb stub支持并添加UART6驱动(wzzy2); - * zynq7000分支中更改RT_USING_NEWLIB为RT_USING_LIBC; - * 加入ARM Cortex-M4芯片指令级的ffs实现; - * 修正MB0BF618S分支中缺少timer初始化的bug(mike mao); - [工具] +## 工具 * 移除Python 2.6中未支持的语法(xfguo); - * 移除Windows平台中的startupinfo信息(对Python版本兼容性更好); - * 修正CPPPATH被打乱的bug; -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 2.0.0 Beta +# RT-Thread 2.0.0 Beta更改说明 发布时间:2014/8/1 @@ -200,7 +193,7 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持� 更改记录 -[内核] +## 内核 * 移除rt_device_init_all()函数:在系统启动时不需要再调用这个函数来初始化驱动,而是由上层应用执行rt_device_open时自动进行设备初始化; * 修正设备对象引用计数在打开设备失败依然递增的问题; @@ -211,11 +204,11 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持� * 在执行soft timer超时函数时,打开调度器锁; * 新增块设备的自动刷新参数,RT_DEVICE_CTRL_BLK_AUTOREFRESH; -[工具] +## 工具 * 修正scons命令编译时,选择keil mdk (armcc)编译器时,命令行太长编译失败的问题; -[移植] +## 移植 * 移除rt_device_init_all()相关的调用; * 根据串口框架调整相关的驱动代码; @@ -233,7 +226,7 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持� * 新增MB9BF618S移植; * 新增tm4c129x移植,并加入相应的EMAC以太网驱动; -[组件] +## 组件 * DFS: 新增根据设备对象获得其上装载文件系统路径的函数:dfs_filesystem_get_mounted_path(struct rt_device* device); * DFS: 修正readdir在GNU GCC下的编译警告; @@ -260,18 +253,13 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持� * log trace: log trace中的session引用更改成常量形式; * ymodem: 增强数据接收的稳定性; -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- +# RT-Thread 2.0.0 Alpha更改说明 -版本: RT-Thread 2.0.0 Alpha 发布时间:2014/4/8 RT-Thread 2.0.0分支的第一个技术预览版本,仅用于展示2.0.0发展分支的演化动向(按照roadmap,2.0.0这个分支会有一部分RT-Thread和Linux互补性的技术,为Linux增加更好的实时性,为RT-Thread增加更多的功能性,这份技术预览版正是朝着这个目标而努力),欢迎反馈建议和问题。 -[组件变更] +## 组件 * msh: bugfix 和功能性增强。新的 msh 在调用外部模块方面更加方便。 * DFS: nfs 的 bugfix 和内置命令的增强。ELM FatFS加入对扇区不匹配情况下的信息输出,这样能够及时定位问题。 @@ -280,12 +268,12 @@ RT-Thread 2.0.0分支的第一个技术预览版本,仅用于展示2.0.0发展 * CMSIS:版本更新至 3.20 * drivers:USB 协议栈的重构。新的框架中编写驱动变得更加容易了。 -[BSP 变更] +## BSP * beaglebone:串口驱动更新 * realview-a8:添加了 VMM 组件 -[编译脚本] +## 工具 * 固件加入scons --target=ua -s,用于准备用户应用环境; @@ -301,28 +289,29 @@ insmod rtvmm.ko 来启动 RT-Thread。RT-Thread 启动之后控制台在第二个串口上(Atl + Ctrl + 4)。第一个串口Linux shell依然可以使用,第二个串口则是RT-Thread的shell。 - JavaScript解析器,这个是由牛头哥移植的,可以在一个非常小资料的MCU上以JavaScript脚本方式进行编程、开发。根据这种方式,也提供了RN001JS的以太网硬件模块:以JavaScript脚本语言作为二次开发,提供在线web(即WebIDE)进行编程并运行JavaScript程序。JavaScript作为一门轻量级、解释型的语言,更容易上手,配合WebIDE、及提供的一些example可以使得开发变得非常的轻松,也包括一些传感器的JavaScript例子,让做网页的人也可以玩硬件了! -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- +# RT-Thread 1.2.1更改说明 -版本: RT-Thread 1.2.1 发布时间: 2014/4/8 在原有的1.2.0版本的bug修正版本,也是1.2.0系列的第一个修正版本,原则上不添加任何的新功能,我们尽量会按照每个季度一个修订版本的方式推进。大家在使用的过程中有什么问题还请反馈给我们,这些问题很可能会在下个版本中修正! 以下是更改记录: -[内核] + +## 内核 + * 用户应用,增加用户应用命令行参数支持; * 在挂起一个任务时,把相应的定时器也关闭; -[BSP] +## BSP + * BeagleBone,加入更多串口驱动支持; * 移除BSP中rt_device_init_all函数调用,改成打开设备时自动进行初始化; * LPC176x,移除components初始化管理器; * LPC4088,修正LED驱动的问题; * STM32F107,移除components初始化管理器; -[组件] +## 组件 + * 文件系统,ELM FatFS加入对扇区不匹配情况下的信息输出,这样能够及时定位问题; * 文件系统,NFS网络文件系统修正相关的一些编译警告信息; * 文件系统,copy命令加入文件夹方式复制功能; @@ -336,18 +325,16 @@ insmod rtvmm.ko * POSIX thread,修正了同时使用lwIP组件时的编译警告; * 第三方组件,加入TJPGD的移植,加入libpng的移植; -[编译脚本] +## 工具 + * 固件加入scons --target=ua -s,用于准备用户应用环境; [发布后记] * RT-Thread携带了众多的BSP,不一定能够一一保证每个分支上把RT-Thread上相应的功能使用起来。所以针对这种情况,我们有一款评估用的硬件开发板:RealBoard 4088,在上面力求把一些相关例程都添加上,这样在一个基本的BSP基础上,可以对照着把其他的组件、功能添加进去; * RealBoard 4088使用的RT-Thread版本主要以RT-Thread 1.2.1版本为主。 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- +# RT-Thread 1.2.0正式版本更改说明 -版本: RT-Thread 1.2.0正式版本 发布时间: 2014/1/6 实现roadmap中提到的大部分内容 @@ -362,18 +349,22 @@ insmod rtvmm.ko - 默认使用lwIP 1.4.1 下面是自RT-Thread 1.2.0 RC版本发布以来具体的变更履历: -内核: + +## 内核 + * timer.c - 使用跳跃表(skip list)实现系统定时器链表,并在bsp中的startup.c中重新加入定时器初始化函数rt_system_timer_init() * rtdebug.h - 新增宏定义RT_DEBUG_IN_THREAD_CONTEXT * idle.c - 在函数rt_thread_idle_excute()中一次清除所有的死线程 * scheduler.c - 新增API rt_critical_level()返回调度器上锁次数 -移植: +## 移植 + * cortex-m0 - 修正 cortex-m0 GCC移植中hardfault的问题点 * cortex-r4 - 在startup后释放IRQ堆栈空间 * cortex-r4 - 按字节长度分配堆栈空间 -BSP分支: +## BSP分支 + * 新增lpc408x移植 * bsp/stm32f0x - 增加USART1,USART2驱动,支持finsh,支持组件初始化 * bsp/simulator - 当RTGUI配置无效时打印错误信息 @@ -385,7 +376,8 @@ BSP分支: * bsp/rm48x50 - 新增GCC的移植 * bsp/K60Fxxxx - 修正一个编译错误 -组件: +## 组件 + * dfs - 正确处理mkfs未实现的情况 * dfs - 使用指针代替index变量 * dfs - 在函数dfs_filesystem_lookup()将含义模糊的指针变量名称empty重命名为fs @@ -410,7 +402,8 @@ BSP分支: * drivers/pipe - 增加一个control命令来获得pipe剩余的空间 * drivers/serial - 如果读写长度为0,则立即返回 -例程: +## 例程 + * examples - 用rt_sem_control()中的RT_IPC_CMD_RESET命令rt_sem_trytake()来清除信号量 * examples - 始终打印输出测试结果 * examples - 在所有的测试结束后打印输出简报 @@ -429,11 +422,8 @@ BSP分支: 其他: * 更新README.md -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 1.2.0RC +# RT-Thread 1.2.0RC更改说明 + 发布时间: 2013/10/10/ 10:19 主要说明: 该版本新增ARM Cortex-A8的支持(BeagleBone),新增UNITY-2内核的支持(SEP6200),新增Ymodem协议。 @@ -1367,11 +1357,8 @@ RT-Thread实时操作系统编程指南与0.3.0正式版的相同,以后会逐 (*) 希望使用新特性的开发人员请关注后续0.4.0版本的发布情况,0.4.0版本添加了很多的新特性,例如:16位的瑞萨M16分支,大端模式的AVR32分支,以及MIPS分支等。 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- +# RT-Thread 0.4.0 beta2发布说明 -版本: RT-Thread 0.4.0 beta2 发布时间: 2011/7/4 这是RT-Thread 0.4.x系列的第二个测试版本。这个测试版本,依然更多的面向测试目的,不建议直接应用到实际的产品中。RT-Thread 0.4.0的非正式版本依然沿用GPL v2许可证进行发布,欢迎测试。 @@ -1439,11 +1426,8 @@ tools: ** 自动创建IAR工程 ** 自动创建MDK4工程 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- +# RT-Thread 0.4.0 beta1发布说明 -版本: RT-Thread 0.4.0 beta1 发布时间: 2010/11/30 自RT-Thread 0.3.0正式版发布以来,经过开发人员密集的整8个月开发,大众用户的积极反馈、测试,终于完成了RT-Thread 0.4.x系列的第一个测试版本。这个测试版本,依然更多的面向测试目的,不建议直接应用到实际的产品中。RT-Thread 0.4.0的非正式版本依然沿用GPL v2许可证进行发布,欢迎测试。 RT-Thread 0.4.0版本初始提出的几个功能亦基本达到,提供了相对完善的POSIX thread接口,动态库载入接口libdl以及应用模块支持。这些新功能的加入使得RT-Thread能够初步的兼容于POSIX标准。 @@ -1504,11 +1488,9 @@ RT-Thread 0.4.0 beta1下载 - FTK GUI。 对于Cortex-M3等平台,我们目前也在对 应用模块特性 进行评估,看看从技术上是否能够从另外的途径解决动态运行速度慢的问题。 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 0.3.1正式版 + +# RT-Thread 0.3.1正式版 发布说明 + 发布时间: 2010/9/29 是发布0.3.1正式版的时候了:在0.3.1的维护过程中,得到了大家很多的反馈,其中一些bug及修正也是由大家指出,这里感谢大家一直以来的支持,RT-Thread的发展进步离不开大家的帮助,谢谢! 相较RT-Thread 0.3.0版本,0.3.1版本是一个bug修正版,并无添加新的特性(*),使用上与0.3.0版本完全兼容。建议使用RT-Thread 0.3.0版本的用户,如果需要长时间不间断运行(大于1年),请切换到0.3.1正式版本来。 @@ -1539,7 +1521,7 @@ RT-Thread在Google SVN服务器上的开发分支亦做了相应调整: RT-Thread实时操作系统编程指南与0.3.0正式版的相同,以后会逐渐由API说明文档替代,朝着正规化的方向发展。 STM32分支 ---------- + 请注意STM32分支的工程文件组织方式和0.3.0版本中的不一样,原来的几个目录是不相独立的工程,而0.3.1中为了避免混淆,把它们变成了独立的工程(注:因为0.3.1与0.3.0是完全兼容的,所以不一定要更新BSP目录)。 project_107是针对STM32F107芯片的工程,project_valueline是针对STM32F100芯片 STM32 Discovery开发版的工程,其余的芯片默认是STM32F103ZE。如果要修改成自己所需要的芯片,请遵循一下步骤: @@ -1554,22 +1536,14 @@ keep { section VSymTab }; 具体请看stm32f10x_flash.icf文件。 -LM3S分支 --------- -LM3S分支默认采用LM3S8962芯片,针对的是TI这次发的48¥ 8962开发板。 +* LM3S分支 - LM3S分支默认采用LM3S8962芯片,针对的是TI这次发的48¥ 8962开发板。 -LPC176x分支 ------------ -工程默认包括finsh shell,文件系统,网络协议栈的支持。 +* LPC176x分支 - 工程默认包括finsh shell,文件系统,网络协议栈的支持。 (*) 希望使用新特性的开发人员请关注后续0.4.0版本的发布情况,0.4.0版本添加了很多的新特性,例如:16位的瑞萨M16分支,大端模式的AVR32分支,以及MIPS分支等。 +# RT-Thread 0.3.0正式版发布说明 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -版本: RT-Thread 0.3.0正式版 发布时间: 2010/3/30 相较以前的RT-Thread 0.3.0 RC版本,无大的修改(console调整为支持设备的模式),但依然建议所有使用0.2.x、0.3.0 beta/rc版的用户都开始使用0.3.0正式版。当前版本支持如下移植分支: @@ -1602,10 +1576,8 @@ LM3S的Keil MDK工程文件放在bsp\lm3s目录下;针对LM3S8962芯片(因为 把如上这个定义更改为SYSCTL_XTAL_8MHZ,否则得话会锁死JTAG。 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -版本: RT-Thread/LM3S 0.3.0 RC1版发布 +# RT-Thread/LM3S 0.3.0 RC1版发布说明 + 发布时间: 2010/1/4 实时线程操作系统是一款面向实时领域的操作系统,这个和通常的通用操作系统有着很大的不同。通用操作系统通常面对的是日常应用,例如打开浏览器上网,播放音乐,采用字处理软件编辑文档。 @@ -1613,7 +1585,8 @@ LM3S的Keil MDK工程文件放在bsp\lm3s目录下;针对LM3S8962芯片(因为 实时系统和这种通用系统有很大的差别。实时系统指的是,当外界有系统关注的相应事件发生时,系统能够在指定的时间内(deadline)进行正确的响应。用于实时系统的操作系统就叫做实时操作系统。从系统的定义也可以看得出,实时操作系统和通用操作系统在事务的处理上有明显的区别,实时操作系统有非常强的针对性,对相应的事件力求做到这固定的时间内进行响应;而通用操作系统则需要努力地做到各个事务的公平性(某些系统也会非常注意数据的吞吐量,例如网络服务器)。 实时线程操作系统(英文名RT-Thread)面向的正是这么一类的实时系统,因为其小型的特点也可以看成是一个嵌入式操作系统(嵌入式系统一般是针对一些专有目的而存在,比较吝啬于成本。而基于专有目的的特点,也注定了嵌入式系统或多或少的具有一些实时性的特点)。这种系统可以用于自动售票机,税控机,移动通信设备,mp3/mp4等便携式音乐设备,飞行器控制,车体导航控制,打印机,复印机,各类监控设备,路由器,ADSL,机顶盒等网络设备,医疗设备等等。 TI流明LM3S系列芯片是基于ARM Cortex M3 v7构架的32位芯片,其中LM3S S6000,S8000,S9000系列芯片携带网络功能。RT-Thread的标准内核可以运行在除LM3S S100系列外的所有系列芯片上。这次RT-Thread针对于LM3S进行移植验证并经过压力测试的是LM3S6918芯片,芯片携带64K片内静态内存,256K闪存,频率是50MHz。在这个平台上,RT-Thread支持的特性包括: -? 完善的实时核心 + +* 完善的实时核心 - 面向对象方式的实时核心(但依然保留了C语言的优雅、小巧风格); - 默认32线程优先级的全抢占式实时内核(亦可配置成256线程优先级);相同优先级线程时间片轮转调度; - 相同优先级线程实施时间片可配置的分时时间片轮转调度; @@ -1622,25 +1595,25 @@ TI流明LM3S系列芯片是基于ARM Cortex M3 v7构架的32位芯片,其中LM - 支持线程挂起和唤醒的固定内存块管理及线程安全的动态内存堆管理; - 向上层提供基于名字的统一接口设备驱动模型; -? FinSH shell命令行 +* FinSH shell命令行 - 命令即C代码的命令行方式; - 直接在命令行中调用系统内核函数; - 直接在命令行中访问系统全局变量; - 历史记录及命令自动补全; -? 面向小型设备的虚拟文件系统 +* 面向小型设备的虚拟文件系统 - 向上层应用提供POSIX风格的API接口; - 支持多种具体文件系统实现; - LM3S分支内置SD卡驱动程序; -? LwIP轻型TCP/IP协议栈 +* LwIP轻型TCP/IP协议栈 - 标准的BSD Socket接口; - IP、ICMP、UDP、TCP标准协议支持; - DNS,DHCP,PPP协议支持; - TFTP、HTTP、FTP应用协议支持(见netutil组件); - LM3S分支内置以太网驱动; -? 开发环境支持: +* 开发环境支持: - GNU GCC (scons做为构建工具) - Keil MDK @@ -1701,11 +1674,8 @@ Packet size 8k bytes: 870 KByte/s Tx, 3239 KByte/s Rx. 许可证 作为一套基础组件,就例如电脑中的中文输入法一样,它不应该收费,因此它能够免费的使用于商业产品中(0.3.x系统仅需要在我们这边进行产品信息备案,更换GPLv2许可证为商业许可证!0.4.x将更换产品许可证为BSD或Apache开源许可证)。 -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -版本: RT-Thread RTOS v0.2.3版本 +# RT-Thread RTOS v0.2.3版本更改说明 + 发布时间: 2008/10/6 更新记录 @@ -1719,11 +1689,10 @@ Packet size 8k bytes: 870 KByte/s Tx, 3239 KByte/s Rx. - 修正链表中初始化问题; - 修正Object中调用钩子函数的问题; -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -版本: RT-Thread v0.2.2 +# RT-Thread v0.2.2更改说明 + 发布时间: 2008/6/12 + RT-Thread v0.2.2单内核正式版发布,这个版本主要是增加更多的BSP移植: - s3c44b0的移植 [Xu Xinming] - AT91SAM7S64的移植 [Bernard Xiong,感谢icdev.com.cn提供开发板] @@ -1741,4 +1710,4 @@ AT91SAM7S64: (系统资源:16k RAM,64k ROM Flash) ia32: 支持i386-elf-gcc for windows的编译,linux下的还没试,应该也可以顺利编译。 编译完成后在bsp/qemu目录下生成rtthread-qemu.elf -把这个elf文件配置到grub的配置文件中,具体的grub配置请参看grub文档
\ No newline at end of file +把这个elf文件配置到grub的配置文件中,具体的grub配置请参看grub文档 @@ -3,17 +3,17 @@ [](https://travis-ci.org/RT-Thread/rt-thread) [](https://gitter.im/RT-Thread/rt-thread?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -RT-Thread is an open source real-time operating system for embedded devices from China. RT-Thread RTOS is a scalable real-time operating system: a tiny kernel for ARM Cortex-M0, Cortex-M3/4/7, or a rich feature system like ARM Cortex-A8, ARM Cortex-A9 DualCore etc. +RT-Thread is an open source real-time operating system for embedded devices from China, which has strong scalability: from a tiny kernel running on a tiny core, for example ARM Cortex-M0, or Cortex-M3/4/7, to a rich feature system running on ARM Cortex-A8, ARM Cortex-A9 DualCore etc. ## Overview ## -RT-Thread RTOS like a traditional real-time operating system. The kernel has real-time multi-task scheduling, semaphore, mutex, mail box, message queue etc. However, it has two different things: +RT-Thread RTOS like a traditional real-time operating system. The kernel has real-time multi-task scheduling, semaphore, mutex, mail box, message queue etc. However, it has three different things: * Device Driver; * Component; * Application Module -The device driver is more like a driver framework, UART, IIC, SPI, SDIO, USB device/host, EMAC, MTD NAND etc. The developer can easily add low level driver and board configuration, then he/she can use lots of features. +The device driver is more like a driver framework, UART, IIC, SPI, SDIO, USB device/host, EMAC, MTD NAND etc. The developer can easily add low level driver and board configuration, then combined with the upper framework, he/she can use lots of features. The Component is a software concept upon RT-Thread kernel, for example a shell (finsh/msh shell), virtual file system (FAT, YAFFS, UFFS, ROM/RAM file system etc), TCP/IP protocol stack (lwIP), POSIX (thread) interface etc. One component must be a directory under RT-Thread/Components and one component can be descripted by a SConscript file (then be compiled and linked into the system). @@ -41,7 +41,6 @@ As a special exception, including RT-Thread RTOS header files in a file, instant ## Usage ## RT-Thread RTOS uses [scons](http://www.scons.org) as building system. Therefore, please install scons and Python 2.7 firstly. - So far, the RT-Thread scons building system support the command line compile or generate some IDE's project. There are some option varaibles in the scons building script (rtconfig.py): * ```CROSS_TOOL``` the compiler which you want to use, gcc/keil/iar. @@ -58,7 +57,7 @@ When you set these variables correctly, you can use command: under BSP directory to simplely compile RT-Thread RTOS. If you want to generate the IDE's project file, you can use command: -s + scons --target=mdk/mdk4/mdk5/iar/cb -s to generate the project file. @@ -67,4 +66,4 @@ NOTE: RT-Thread scons building system will tailor the system according to your r ## Contribution ## -Thank all of RT-Thread Developers. +Please refer the contributors in the github. Thank all of RT-Thread Developers. diff --git a/bsp/efm32/copy_this_file_dfs_elm.c b/bsp/efm32/copy_this_file_dfs_elm.c index eea9ff7e6d..2f648750c9 100644 --- a/bsp/efm32/copy_this_file_dfs_elm.c +++ b/bsp/efm32/copy_this_file_dfs_elm.c @@ -641,7 +641,6 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) st->st_size = file_info.fsize; st->st_mtime = file_info.ftime; - st->st_blksize = 512; } #if _USE_LFN diff --git a/bsp/frdm-k64f/SConstruct b/bsp/frdm-k64f/SConstruct index d4132b593c..eb4f3d8eac 100644 --- a/bsp/frdm-k64f/SConstruct +++ b/bsp/frdm-k64f/SConstruct @@ -30,8 +30,5 @@ Export('rtconfig') # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) -# build program -env.Program(TARGET, objs) - -# end building -EndBuilding(TARGET) +# do building +DoBuilding(TARGET, objs) diff --git a/bsp/lpc408x/Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/system_LPC407x_8x_177x_8x.c b/bsp/lpc408x/Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/system_LPC407x_8x_177x_8x.c index d85871526e..b716d06f62 100644 --- a/bsp/lpc408x/Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/system_LPC407x_8x_177x_8x.c +++ b/bsp/lpc408x/Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/system_LPC407x_8x_177x_8x.c @@ -221,12 +221,12 @@ #define SCS_Val 0x00000020 #define CLKSRCSEL_Val 0x00000001 #define PLL0_SETUP 1 -#define PLL0CFG_Val 0x0000000a +#define PLL0CFG_Val 0x00000009 #define PLL1_SETUP 1 #define PLL1CFG_Val 0x00000023 #define CCLKSEL_Val 0x00000101 #define USBCLKSEL_Val 0x00000201 -#define EMCCLKSEL_Val 0x00000001 +#define EMCCLKSEL_Val 0x00000000 #define PCLKSEL_Val 0x00000002 #define SPIFICLKSEL_Val 0x00000002 #define PCONP_Val 0x042887DE diff --git a/bsp/lpc408x/Libraries/Device/SConscript b/bsp/lpc408x/Libraries/Device/SConscript index f61ac45490..6d7e911b8e 100644 --- a/bsp/lpc408x/Libraries/Device/SConscript +++ b/bsp/lpc408x/Libraries/Device/SConscript @@ -18,6 +18,6 @@ elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'iar': src += ['NXP/LPC407x_8x_177x_8x/Source/Templates/IAR/startup_LPC407x_8x_177x_8x.s'] -group = DefineGroup('CMSIS', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) +group = DefineGroup('Libraries', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') diff --git a/bsp/lpc408x/applications/board.c b/bsp/lpc408x/applications/board.c index ed1e8e769b..a2bb22bfe4 100644 --- a/bsp/lpc408x/applications/board.c +++ b/bsp/lpc408x/applications/board.c @@ -52,9 +52,10 @@ void rt_hw_board_init() #endif /* init systick */ - SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); + SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND - 1); /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); + /*init uart device*/ rt_hw_uart_init(); rt_console_set_device(RT_CONSOLE_DEVICE_NAME); @@ -64,5 +65,5 @@ void rt_hw_board_init() lpc_sdram_hw_init(); rt_kprintf("done!\n"); #endif - rt_components_board_init(); + // rt_components_board_init(); } diff --git a/bsp/lpc408x/applications/board.h b/bsp/lpc408x/applications/board.h index f34cb2acee..392dcf2031 100644 --- a/bsp/lpc408x/applications/board.h +++ b/bsp/lpc408x/applications/board.h @@ -11,6 +11,7 @@ * Date Author Notes * 2009-09-22 Bernard add board.h to this bsp * 2010-02-04 Magicoe add board.h to LPC176x bsp + * 2013-12-18 Bernard porting to LPC4088 bsp */ #ifndef __BOARD_H__ @@ -19,10 +20,21 @@ #include "LPC407x_8x_177x_8x.h" #include <rtthread.h> +/* SRAM allocation for Peripherals */ +#define USB_RAM_BASE 0x20000000 +#define MCI_RAM_BASE 0x20002000 +#define ETH_RAM_BASE 0x20004000 + +/* use SDRAM in default */ +#define LPC_EXT_SDRAM 1 + +/* disable SDRAM in default */ +#ifndef LPC_EXT_SDRAM +#define LPC_EXT_SDRAM 0 +#endif + // <RDTConfigurator URL="http://www.rt-thread.com/eclipse"> -// <integer name="LPC_EXT_SDRAM" description="Enable External SDRAM memory" default="0" /> -//#define LPC_EXT_SDRAM 0 // <integer name="LPC_EXT_SDRAM" description="Begin Address of External SDRAM" default="0xA0000000" /> #define LPC_EXT_SDRAM_BEGIN 0xA0000000 // <integer name="LPC_EXT_SDRAM_END" description="End Address of External SDRAM" default="0xA2000000" /> @@ -47,7 +59,7 @@ extern int Image$$RW_IRAM1$$ZI$$Limit; extern int __bss_end; #define HEAP_BEGIN ((void *)&__bss_end) #endif -#define HEAP_END (0x10000000 + 0x10000) +#define HEAP_END (void*)(0x10000000 + 0x10000) #define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME void rt_hw_board_init(void); diff --git a/bsp/lpc408x/drivers/drv_emac.c b/bsp/lpc408x/drivers/drv_emac.c new file mode 100644 index 0000000000..2b6293a953 --- /dev/null +++ b/bsp/lpc408x/drivers/drv_emac.c @@ -0,0 +1,512 @@ +/* + * File : drv_emac.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2013-05-19 Bernard porting from LPC17xx drivers. + */ + +#include <rtthread.h> +#include "lwipopts.h" +#include <netif/ethernetif.h> +#include <board.h> + +#include "lpc_pinsel.h" +#include "drv_emac.h" + +#define EMAC_PHY_AUTO 0 +#define EMAC_PHY_10MBIT 1 +#define EMAC_PHY_100MBIT 2 + +#define MAX_ADDR_LEN 6 + +/* EMAC_RAM_BASE is defined in board.h and the size is 16KB */ +#define RX_DESC_BASE ETH_RAM_BASE +#define RX_STAT_BASE (RX_DESC_BASE + NUM_RX_FRAG*8) +#define TX_DESC_BASE (RX_STAT_BASE + NUM_RX_FRAG*8) +#define TX_STAT_BASE (TX_DESC_BASE + NUM_TX_FRAG*8) +#define RX_BUF_BASE (TX_STAT_BASE + NUM_TX_FRAG*4) +#define TX_BUF_BASE (RX_BUF_BASE + NUM_RX_FRAG*ETH_FRAG_SIZE) + +/* RX and TX descriptor and status definitions. */ +#define RX_DESC_PACKET(i) (*(unsigned int *)(RX_DESC_BASE + 8*i)) +#define RX_DESC_CTRL(i) (*(unsigned int *)(RX_DESC_BASE+4 + 8*i)) +#define RX_STAT_INFO(i) (*(unsigned int *)(RX_STAT_BASE + 8*i)) +#define RX_STAT_HASHCRC(i) (*(unsigned int *)(RX_STAT_BASE+4 + 8*i)) +#define TX_DESC_PACKET(i) (*(unsigned int *)(TX_DESC_BASE + 8*i)) +#define TX_DESC_CTRL(i) (*(unsigned int *)(TX_DESC_BASE+4 + 8*i)) +#define TX_STAT_INFO(i) (*(unsigned int *)(TX_STAT_BASE + 4*i)) +#define RX_BUF(i) (RX_BUF_BASE + ETH_FRAG_SIZE*i) +#define TX_BUF(i) (TX_BUF_BASE + ETH_FRAG_SIZE*i) + +struct lpc_emac +{ + /* inherit from ethernet device */ + struct eth_device parent; + + rt_uint8_t phy_mode; + + /* interface address info. */ + rt_uint8_t dev_addr[MAX_ADDR_LEN]; /* hw address */ +}; +static struct lpc_emac lpc_emac_device; +static struct rt_semaphore sem_lock; +static struct rt_event tx_event; + +/* Local Function Prototypes */ +static void write_PHY(rt_uint32_t PhyReg, rt_uint32_t Value); +static rt_uint16_t read_PHY(rt_uint8_t PhyReg) ; + +void ENET_IRQHandler(void) +{ + rt_uint32_t status; + + /* enter interrupt */ + rt_interrupt_enter(); + + status = LPC_EMAC->IntStatus; + + if (status & INT_RX_DONE) + { + /* Disable EMAC RxDone interrupts. */ + LPC_EMAC->IntEnable = INT_TX_DONE; + + /* a frame has been received */ + eth_device_ready(&(lpc_emac_device.parent)); + } + else if (status & INT_TX_DONE) + { + /* set event */ + rt_event_send(&tx_event, 0x01); + } + + if (status & INT_RX_OVERRUN) + { + rt_kprintf("rx overrun\n"); + } + + if (status & INT_TX_UNDERRUN) + { + rt_kprintf("tx underrun\n"); + } + + /* Clear the interrupt. */ + LPC_EMAC->IntClear = status; + + /* leave interrupt */ + rt_interrupt_leave(); +} + +/* phy write */ +static void write_PHY(rt_uint32_t PhyReg, rt_uint32_t Value) +{ + unsigned int tout; + + LPC_EMAC->MADR = DP83848C_DEF_ADR | PhyReg; + LPC_EMAC->MWTD = Value; + + /* Wait utill operation completed */ + tout = 0; + for (tout = 0; tout < MII_WR_TOUT; tout++) + { + if ((LPC_EMAC->MIND & MIND_BUSY) == 0) + { + break; + } + } +} + +/* phy read */ +static rt_uint16_t read_PHY(rt_uint8_t PhyReg) +{ + rt_uint32_t tout; + + LPC_EMAC->MADR = DP83848C_DEF_ADR | PhyReg; + LPC_EMAC->MCMD = MCMD_READ; + + /* Wait until operation completed */ + tout = 0; + for (tout = 0; tout < MII_RD_TOUT; tout++) + { + if ((LPC_EMAC->MIND & MIND_BUSY) == 0) + { + break; + } + } + LPC_EMAC->MCMD = 0; + return (LPC_EMAC->MRDD); +} + +/* init rx descriptor */ +rt_inline void rx_descr_init(void) +{ + rt_uint32_t i; + + for (i = 0; i < NUM_RX_FRAG; i++) + { + RX_DESC_PACKET(i) = RX_BUF(i); + RX_DESC_CTRL(i) = RCTRL_INT | (ETH_FRAG_SIZE - 1); + RX_STAT_INFO(i) = 0; + RX_STAT_HASHCRC(i) = 0; + } + + /* Set EMAC Receive Descriptor Registers. */ + LPC_EMAC->RxDescriptor = RX_DESC_BASE; + LPC_EMAC->RxStatus = RX_STAT_BASE; + LPC_EMAC->RxDescriptorNumber = NUM_RX_FRAG - 1; + + /* Rx Descriptors Point to 0 */ + LPC_EMAC->RxConsumeIndex = 0; +} + +/* init tx descriptor */ +rt_inline void tx_descr_init(void) +{ + rt_uint32_t i; + + for (i = 0; i < NUM_TX_FRAG; i++) + { + TX_DESC_PACKET(i) = TX_BUF(i); + TX_DESC_CTRL(i) = (1ul << 31) | (1ul << 30) | (1ul << 29) | (1ul << 28) | (1ul << 26) | (ETH_FRAG_SIZE - 1); + TX_STAT_INFO(i) = 0; + } + + /* Set EMAC Transmit Descriptor Registers. */ + LPC_EMAC->TxDescriptor = TX_DESC_BASE; + LPC_EMAC->TxStatus = TX_STAT_BASE; + LPC_EMAC->TxDescriptorNumber = NUM_TX_FRAG - 1; + + /* Tx Descriptors Point to 0 */ + LPC_EMAC->TxProduceIndex = 0; +} + +/* +TX_EN P1_4 +TXD0 P1_0 +TXD1 P1_1 + +RXD0 P1_9 +RXD1 P1_10 +RX_ER P1_14 +CRS_DV P1_8 + +MDC P1_16 +MDIO P1_17 + +REF_CLK P1_15 +*/ +static rt_err_t lpc_emac_init(rt_device_t dev) +{ + /* Initialize the EMAC ethernet controller. */ + rt_uint32_t regv, tout; + + /* Power Up the EMAC controller. */ + LPC_SC->PCONP |= (1UL << 30); + + /* Enable P1 Ethernet Pins. */ + PINSEL_ConfigPin(1, 0, 1); /**< P1_0 ENET_TXD0 */ + PINSEL_ConfigPin(1, 1, 1); /**< P1_1 ENET_TXD1 */ + PINSEL_ConfigPin(1, 4, 1); /**< P1_4 ENET_TX_EN */ + PINSEL_ConfigPin(1, 8, 1); /**< P1_8 ENET_CRS_DV */ + PINSEL_ConfigPin(1, 9, 1); /**< P1_9 ENET_RXD0 */ + PINSEL_ConfigPin(1, 10, 1); /**< P1_10 ENET_RXD1 */ + PINSEL_ConfigPin(1, 14, 1); /**< P1_14 ENET_RX_ER */ + PINSEL_ConfigPin(1, 15, 1); /**< P1_15 ENET_REF_CLK */ + PINSEL_ConfigPin(1, 16, 1); /**< P1_16 ENET_MDC */ + PINSEL_ConfigPin(1, 17, 1); /**< P1_17 ENET_MDIO */ + + /* Reset all EMAC internal modules. */ + LPC_EMAC->MAC1 = MAC1_RES_TX | MAC1_RES_MCS_TX | MAC1_RES_RX | MAC1_RES_MCS_RX | + MAC1_SIM_RES | MAC1_SOFT_RES; + LPC_EMAC->Command = CR_REG_RES | CR_TX_RES | CR_RX_RES; + + /* A short delay after reset. */ + for (tout = 100; tout; tout--); + + /* Initialize MAC control registers. */ + LPC_EMAC->MAC1 = MAC1_PASS_ALL; + LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN; + LPC_EMAC->MAXF = ETH_MAX_FLEN; + LPC_EMAC->CLRT = CLRT_DEF; + LPC_EMAC->IPGR = IPGR_DEF; + + /* PCLK=18MHz, clock select=6, MDC=18/6=3MHz */ + /* Enable Reduced MII interface. */ + LPC_EMAC->MCFG = MCFG_CLK_DIV20 | MCFG_RES_MII; + for (tout = 100; tout; tout--); + LPC_EMAC->MCFG = MCFG_CLK_DIV20; + + /* Enable Reduced MII interface. */ + LPC_EMAC->Command = CR_RMII | CR_PASS_RUNT_FRM | CR_PASS_RX_FILT; + + /* Reset Reduced MII Logic. */ + LPC_EMAC->SUPP = SUPP_RES_RMII | SUPP_SPEED; + for (tout = 100; tout; tout--); + LPC_EMAC->SUPP = SUPP_SPEED; + + /* Put the PHY in reset mode */ + write_PHY(PHY_REG_BMCR, 0x8000); + for (tout = 1000; tout; tout--); + + /* Configure the PHY device */ + /* Configure the PHY device */ + switch (lpc_emac_device.phy_mode) + { + case EMAC_PHY_AUTO: + /* Use autonegotiation about the link speed. */ + write_PHY(PHY_REG_BMCR, PHY_AUTO_NEG); + break; + case EMAC_PHY_10MBIT: + /* Connect at 10MBit */ + write_PHY(PHY_REG_BMCR, PHY_FULLD_10M); + break; + case EMAC_PHY_100MBIT: + /* Connect at 100MBit */ + write_PHY(PHY_REG_BMCR, PHY_FULLD_100M); + break; + } + if (tout >= 0x100000) return -RT_ERROR; // auto_neg failed + + regv = 0x0004; + /* Configure Full/Half Duplex mode. */ + if (regv & 0x0004) + { + /* Full duplex is enabled. */ + LPC_EMAC->MAC2 |= MAC2_FULL_DUP; + LPC_EMAC->Command |= CR_FULL_DUP; + LPC_EMAC->IPGT = IPGT_FULL_DUP; + } + else + { + /* Half duplex mode. */ + LPC_EMAC->IPGT = IPGT_HALF_DUP; + } + + /* Configure 100MBit/10MBit mode. */ + if (regv & 0x0002) + { + /* 10MBit mode. */ + LPC_EMAC->SUPP = 0; + } + else + { + /* 100MBit mode. */ + LPC_EMAC->SUPP = SUPP_SPEED; + } + + /* Set the Ethernet MAC Address registers */ + LPC_EMAC->SA0 = (lpc_emac_device.dev_addr[1] << 8) | lpc_emac_device.dev_addr[0]; + LPC_EMAC->SA1 = (lpc_emac_device.dev_addr[3] << 8) | lpc_emac_device.dev_addr[2]; + LPC_EMAC->SA2 = (lpc_emac_device.dev_addr[5] << 8) | lpc_emac_device.dev_addr[4]; + + /* Initialize Tx and Rx DMA Descriptors */ + rx_descr_init(); + tx_descr_init(); + + /* Receive Broadcast and Perfect Match Packets */ + LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; + + /* Reset all interrupts */ + LPC_EMAC->IntClear = 0xFFFF; + + /* Enable EMAC interrupts. */ + LPC_EMAC->IntEnable = INT_RX_DONE | INT_TX_DONE; + + /* Enable receive and transmit mode of MAC Ethernet core */ + LPC_EMAC->Command |= (CR_RX_EN | CR_TX_EN); + LPC_EMAC->MAC1 |= MAC1_REC_EN; + + /* Enable the ENET Interrupt */ + NVIC_EnableIRQ(ENET_IRQn); + + return RT_EOK; +} + +static rt_err_t lpc_emac_open(rt_device_t dev, rt_uint16_t oflag) +{ + return RT_EOK; +} + +static rt_err_t lpc_emac_close(rt_device_t dev) +{ + return RT_EOK; +} + +static rt_size_t lpc_emac_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) +{ + rt_set_errno(-RT_ENOSYS); + return 0; +} + +static rt_size_t lpc_emac_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size) +{ + rt_set_errno(-RT_ENOSYS); + return 0; +} + +static rt_err_t lpc_emac_control(rt_device_t dev, rt_uint8_t cmd, void *args) +{ + switch (cmd) + { + case NIOCTL_GADDR: + /* get mac address */ + if (args) rt_memcpy(args, lpc_emac_device.dev_addr, 6); + else return -RT_ERROR; + break; + + default : + break; + } + + return RT_EOK; +} + +/* EtherNet Device Interface */ +/* transmit packet. */ +rt_err_t lpc_emac_tx(rt_device_t dev, struct pbuf *p) +{ + rt_uint32_t Index, IndexNext; + rt_uint8_t *ptr; + + /* calculate next index */ + IndexNext = LPC_EMAC->TxProduceIndex + 1; + if (IndexNext > LPC_EMAC->TxDescriptorNumber) IndexNext = 0; + + /* check whether block is full */ + while (IndexNext == LPC_EMAC->TxConsumeIndex) + { + rt_err_t result; + rt_uint32_t recved; + + /* there is no block yet, wait a flag */ + result = rt_event_recv(&tx_event, 0x01, + RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &recved); + + RT_ASSERT(result == RT_EOK); + } + + /* lock EMAC device */ + rt_sem_take(&sem_lock, RT_WAITING_FOREVER); + + /* get produce index */ + Index = LPC_EMAC->TxProduceIndex; + + /* calculate next index */ + IndexNext = LPC_EMAC->TxProduceIndex + 1; + if (IndexNext > LPC_EMAC->TxDescriptorNumber) + IndexNext = 0; + + /* copy data to tx buffer */ + ptr = (rt_uint8_t *)TX_BUF(Index); + pbuf_copy_partial(p, ptr, p->tot_len, 0); + + TX_DESC_CTRL(Index) &= ~0x7ff; + TX_DESC_CTRL(Index) |= (p->tot_len - 1) & 0x7ff; + + /* change index to the next */ + LPC_EMAC->TxProduceIndex = IndexNext; + + /* unlock EMAC device */ + rt_sem_release(&sem_lock); + + return RT_EOK; +} + +/* reception packet. */ +struct pbuf *lpc_emac_rx(rt_device_t dev) +{ + struct pbuf *p; + rt_uint32_t size; + rt_uint32_t Index; + + /* init p pointer */ + p = RT_NULL; + + /* lock EMAC device */ + rt_sem_take(&sem_lock, RT_WAITING_FOREVER); + + Index = LPC_EMAC->RxConsumeIndex; + if (Index != LPC_EMAC->RxProduceIndex) + { + size = (RX_STAT_INFO(Index) & 0x7ff) + 1; + if (size > ETH_FRAG_SIZE) size = ETH_FRAG_SIZE; + + /* allocate buffer */ + p = pbuf_alloc(PBUF_LINK, size, PBUF_RAM); + if (p != RT_NULL) + { + pbuf_take(p, (rt_uint8_t *)RX_BUF(Index), size); + } + + /* move Index to the next */ + if (++Index > LPC_EMAC->RxDescriptorNumber) + Index = 0; + + /* set consume index */ + LPC_EMAC->RxConsumeIndex = Index; + } + else + { + /* Enable RxDone interrupt */ + LPC_EMAC->IntEnable = INT_RX_DONE | INT_TX_DONE; + } + + /* unlock EMAC device */ + rt_sem_release(&sem_lock); + + return p; +} + +int lpc_emac_hw_init(void) +{ + rt_event_init(&tx_event, "tx_event", RT_IPC_FLAG_FIFO); + rt_sem_init(&sem_lock, "eth_lock", 1, RT_IPC_FLAG_FIFO); + + /* set autonegotiation mode */ + lpc_emac_device.phy_mode = EMAC_PHY_AUTO; + + // OUI 00-60-37 NXP Semiconductors + lpc_emac_device.dev_addr[0] = 0x00; + lpc_emac_device.dev_addr[1] = 0x60; + lpc_emac_device.dev_addr[2] = 0x37; + /* set mac address: (only for test) */ + lpc_emac_device.dev_addr[3] = 0x12; + lpc_emac_device.dev_addr[4] = 0x34; + lpc_emac_device.dev_addr[5] = 0x56; + + lpc_emac_device.parent.parent.init = lpc_emac_init; + lpc_emac_device.parent.parent.open = lpc_emac_open; + lpc_emac_device.parent.parent.close = lpc_emac_close; + lpc_emac_device.parent.parent.read = lpc_emac_read; + lpc_emac_device.parent.parent.write = lpc_emac_write; + lpc_emac_device.parent.parent.control = lpc_emac_control; + lpc_emac_device.parent.parent.user_data = RT_NULL; + + lpc_emac_device.parent.eth_rx = lpc_emac_rx; + lpc_emac_device.parent.eth_tx = lpc_emac_tx; + + eth_device_init(&(lpc_emac_device.parent), "e0"); + return 0; +} +INIT_DEVICE_EXPORT(lpc_emac_hw_init); + +#ifdef RT_USING_FINSH +#include <finsh.h> +void emac_dump() +{ + rt_kprintf("Command : %08x\n", LPC_EMAC->Command); + rt_kprintf("Status : %08x\n", LPC_EMAC->Status); + rt_kprintf("RxStatus : %08x\n", LPC_EMAC->RxStatus); + rt_kprintf("TxStatus : %08x\n", LPC_EMAC->TxStatus); + rt_kprintf("IntEnable: %08x\n", LPC_EMAC->IntEnable); + rt_kprintf("IntStatus: %08x\n", LPC_EMAC->IntStatus); +} +FINSH_FUNCTION_EXPORT(emac_dump, dump emac register); +#endif + diff --git a/bsp/lpc408x/drivers/drv_emac.h b/bsp/lpc408x/drivers/drv_emac.h new file mode 100644 index 0000000000..abadc18520 --- /dev/null +++ b/bsp/lpc408x/drivers/drv_emac.h @@ -0,0 +1,291 @@ +/* + * File : drv_emac.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2013-05-19 Bernard porting from LPC17xx drivers. + */ + +#ifndef __DRV_EMAC_H__ +#define __DRV_EMAC_H__ + +#include "board.h" + +/* EMAC Memory Buffer configuration for 16K Ethernet RAM. */ +#define NUM_RX_FRAG 4 /* Num.of RX Fragments 4*1536= 6.0kB */ +#define NUM_TX_FRAG 3 /* Num.of TX Fragments 3*1536= 4.6kB */ +#define ETH_FRAG_SIZE 1536 /* Packet Fragment size 1536 Bytes */ + +#define ETH_MAX_FLEN 1536 /* Max. Ethernet Frame Size */ + + +/* MAC Configuration Register 1 */ +#define MAC1_REC_EN 0x00000001 /* Receive Enable */ +#define MAC1_PASS_ALL 0x00000002 /* Pass All Receive Frames */ +#define MAC1_RX_FLOWC 0x00000004 /* RX Flow Control */ +#define MAC1_TX_FLOWC 0x00000008 /* TX Flow Control */ +#define MAC1_LOOPB 0x00000010 /* Loop Back Mode */ +#define MAC1_RES_TX 0x00000100 /* Reset TX Logic */ +#define MAC1_RES_MCS_TX 0x00000200 /* Reset MAC TX Control Sublayer */ +#define MAC1_RES_RX 0x00000400 /* Reset RX Logic */ +#define MAC1_RES_MCS_RX 0x00000800 /* Reset MAC RX Control Sublayer */ +#define MAC1_SIM_RES 0x00004000 /* Simulation Reset */ +#define MAC1_SOFT_RES 0x00008000 /* Soft Reset MAC */ + +/* MAC Configuration Register 2 */ +#define MAC2_FULL_DUP 0x00000001 /* Full Duplex Mode */ +#define MAC2_FRM_LEN_CHK 0x00000002 /* Frame Length Checking */ +#define MAC2_HUGE_FRM_EN 0x00000004 /* Huge Frame Enable */ +#define MAC2_DLY_CRC 0x00000008 /* Delayed CRC Mode */ +#define MAC2_CRC_EN 0x00000010 /* Append CRC to every Frame */ +#define MAC2_PAD_EN 0x00000020 /* Pad all Short Frames */ +#define MAC2_VLAN_PAD_EN 0x00000040 /* VLAN Pad Enable */ +#define MAC2_ADET_PAD_EN 0x00000080 /* Auto Detect Pad Enable */ +#define MAC2_PPREAM_ENF 0x00000100 /* Pure Preamble Enforcement */ +#define MAC2_LPREAM_ENF 0x00000200 /* Long Preamble Enforcement */ +#define MAC2_NO_BACKOFF 0x00001000 /* No Backoff Algorithm */ +#define MAC2_BACK_PRESSURE 0x00002000 /* Backoff Presurre / No Backoff */ +#define MAC2_EXCESS_DEF 0x00004000 /* Excess Defer */ + +/* Back-to-Back Inter-Packet-Gap Register */ +#define IPGT_FULL_DUP 0x00000015 /* Recommended value for Full Duplex */ +#define IPGT_HALF_DUP 0x00000012 /* Recommended value for Half Duplex */ + +/* Non Back-to-Back Inter-Packet-Gap Register */ +#define IPGR_DEF 0x00000012 /* Recommended value */ + +/* Collision Window/Retry Register */ +#define CLRT_DEF 0x0000370F /* Default value */ + +/* PHY Support Register */ +#define SUPP_SPEED 0x00000100 /* Reduced MII Logic Current Speed */ +#define SUPP_RES_RMII 0x00000800 /* Reset Reduced MII Logic */ + +/* Test Register */ +#define TEST_SHCUT_PQUANTA 0x00000001 /* Shortcut Pause Quanta */ +#define TEST_TST_PAUSE 0x00000002 /* Test Pause */ +#define TEST_TST_BACKP 0x00000004 /* Test Back Pressure */ + +/* MII Management Configuration Register */ +#define MCFG_SCAN_INC 0x00000001 /* Scan Increment PHY Address */ +#define MCFG_SUPP_PREAM 0x00000002 /* Suppress Preamble */ +#define MCFG_CLK_SEL 0x0000001C /* Clock Select Mask */ +#define MCFG_RES_MII 0x00008000 /* Reset MII Management Hardware */ + +#define MCFG_CLK_DIV4 0x00000000 /* MDC = hclk / 4 */ +#define MCFG_CLK_DIV6 0x00000008 /* MDC = hclk / 6 */ +#define MCFG_CLK_DIV8 0x0000000C /* MDC = hclk / 8 */ +#define MCFG_CLK_DIV10 0x00000010 /* MDC = hclk / 10 */ +#define MCFG_CLK_DIV14 0x00000014 /* MDC = hclk / 14 */ +#define MCFG_CLK_DIV20 0x00000018 /* MDC = hclk / 20 */ +#define MCFG_CLK_DIV28 0x0000001C /* MDC = hclk / 28 */ + + +/* MII Management Command Register */ +#define MCMD_READ 0x00000001 /* MII Read */ +#define MCMD_SCAN 0x00000002 /* MII Scan continuously */ + +#define MII_WR_TOUT 0x00050000 /* MII Write timeout count */ +#define MII_RD_TOUT 0x00050000 /* MII Read timeout count */ + +/* MII Management Address Register */ +#define MADR_REG_ADR 0x0000001F /* MII Register Address Mask */ +#define MADR_PHY_ADR 0x00001F00 /* PHY Address Mask */ + +/* MII Management Indicators Register */ +#define MIND_BUSY 0x00000001 /* MII is Busy */ +#define MIND_SCAN 0x00000002 /* MII Scanning in Progress */ +#define MIND_NOT_VAL 0x00000004 /* MII Read Data not valid */ +#define MIND_MII_LINK_FAIL 0x00000008 /* MII Link Failed */ + +/* Command Register */ +#define CR_RX_EN 0x00000001 /* Enable Receive */ +#define CR_TX_EN 0x00000002 /* Enable Transmit */ +#define CR_REG_RES 0x00000008 /* Reset Host Registers */ +#define CR_TX_RES 0x00000010 /* Reset Transmit Datapath */ +#define CR_RX_RES 0x00000020 /* Reset Receive Datapath */ +#define CR_PASS_RUNT_FRM 0x00000040 /* Pass Runt Frames */ +#define CR_PASS_RX_FILT 0x00000080 /* Pass RX Filter */ +#define CR_TX_FLOW_CTRL 0x00000100 /* TX Flow Control */ +#define CR_RMII 0x00000200 /* Reduced MII Interface */ +#define CR_FULL_DUP 0x00000400 /* Full Duplex */ + +/* Status Register */ +#define SR_RX_EN 0x00000001 /* Enable Receive */ +#define SR_TX_EN 0x00000002 /* Enable Transmit */ + +/* Transmit Status Vector 0 Register */ +#define TSV0_CRC_ERR 0x00000001 /* CRC error */ +#define TSV0_LEN_CHKERR 0x00000002 /* Length Check Error */ +#define TSV0_LEN_OUTRNG 0x00000004 /* Length Out of Range */ +#define TSV0_DONE 0x00000008 /* Tramsmission Completed */ +#define TSV0_MCAST 0x00000010 /* Multicast Destination */ +#define TSV0_BCAST 0x00000020 /* Broadcast Destination */ +#define TSV0_PKT_DEFER 0x00000040 /* Packet Deferred */ +#define TSV0_EXC_DEFER 0x00000080 /* Excessive Packet Deferral */ +#define TSV0_EXC_COLL 0x00000100 /* Excessive Collision */ +#define TSV0_LATE_COLL 0x00000200 /* Late Collision Occured */ +#define TSV0_GIANT 0x00000400 /* Giant Frame */ +#define TSV0_UNDERRUN 0x00000800 /* Buffer Underrun */ +#define TSV0_BYTES 0x0FFFF000 /* Total Bytes Transferred */ +#define TSV0_CTRL_FRAME 0x10000000 /* Control Frame */ +#define TSV0_PAUSE 0x20000000 /* Pause Frame */ +#define TSV0_BACK_PRESS 0x40000000 /* Backpressure Method Applied */ +#define TSV0_VLAN 0x80000000 /* VLAN Frame */ + +/* Transmit Status Vector 1 Register */ +#define TSV1_BYTE_CNT 0x0000FFFF /* Transmit Byte Count */ +#define TSV1_COLL_CNT 0x000F0000 /* Transmit Collision Count */ + +/* Receive Status Vector Register */ +#define RSV_BYTE_CNT 0x0000FFFF /* Receive Byte Count */ +#define RSV_PKT_IGNORED 0x00010000 /* Packet Previously Ignored */ +#define RSV_RXDV_SEEN 0x00020000 /* RXDV Event Previously Seen */ +#define RSV_CARR_SEEN 0x00040000 /* Carrier Event Previously Seen */ +#define RSV_REC_CODEV 0x00080000 /* Receive Code Violation */ +#define RSV_CRC_ERR 0x00100000 /* CRC Error */ +#define RSV_LEN_CHKERR 0x00200000 /* Length Check Error */ +#define RSV_LEN_OUTRNG 0x00400000 /* Length Out of Range */ +#define RSV_REC_OK 0x00800000 /* Frame Received OK */ +#define RSV_MCAST 0x01000000 /* Multicast Frame */ +#define RSV_BCAST 0x02000000 /* Broadcast Frame */ +#define RSV_DRIB_NIBB 0x04000000 /* Dribble Nibble */ +#define RSV_CTRL_FRAME 0x08000000 /* Control Frame */ +#define RSV_PAUSE 0x10000000 /* Pause Frame */ +#define RSV_UNSUPP_OPC 0x20000000 /* Unsupported Opcode */ +#define RSV_VLAN 0x40000000 /* VLAN Frame */ + +/* Flow Control Counter Register */ +#define FCC_MIRR_CNT 0x0000FFFF /* Mirror Counter */ +#define FCC_PAUSE_TIM 0xFFFF0000 /* Pause Timer */ + +/* Flow Control Status Register */ +#define FCS_MIRR_CNT 0x0000FFFF /* Mirror Counter Current */ + +/* Receive Filter Control Register */ +#define RFC_UCAST_EN 0x00000001 /* Accept Unicast Frames Enable */ +#define RFC_BCAST_EN 0x00000002 /* Accept Broadcast Frames Enable */ +#define RFC_MCAST_EN 0x00000004 /* Accept Multicast Frames Enable */ +#define RFC_UCAST_HASH_EN 0x00000008 /* Accept Unicast Hash Filter Frames */ +#define RFC_MCAST_HASH_EN 0x00000010 /* Accept Multicast Hash Filter Fram.*/ +#define RFC_PERFECT_EN 0x00000020 /* Accept Perfect Match Enable */ +#define RFC_MAGP_WOL_EN 0x00001000 /* Magic Packet Filter WoL Enable */ +#define RFC_PFILT_WOL_EN 0x00002000 /* Perfect Filter WoL Enable */ + +/* Receive Filter WoL Status/Clear Registers */ +#define WOL_UCAST 0x00000001 /* Unicast Frame caused WoL */ +#define WOL_BCAST 0x00000002 /* Broadcast Frame caused WoL */ +#define WOL_MCAST 0x00000004 /* Multicast Frame caused WoL */ +#define WOL_UCAST_HASH 0x00000008 /* Unicast Hash Filter Frame WoL */ +#define WOL_MCAST_HASH 0x00000010 /* Multicast Hash Filter Frame WoL */ +#define WOL_PERFECT 0x00000020 /* Perfect Filter WoL */ +#define WOL_RX_FILTER 0x00000080 /* RX Filter caused WoL */ +#define WOL_MAG_PACKET 0x00000100 /* Magic Packet Filter caused WoL */ + +/* Interrupt Status/Enable/Clear/Set Registers */ +#define INT_RX_OVERRUN 0x00000001 /* Overrun Error in RX Queue */ +#define INT_RX_ERR 0x00000002 /* Receive Error */ +#define INT_RX_FIN 0x00000004 /* RX Finished Process Descriptors */ +#define INT_RX_DONE 0x00000008 /* Receive Done */ +#define INT_TX_UNDERRUN 0x00000010 /* Transmit Underrun */ +#define INT_TX_ERR 0x00000020 /* Transmit Error */ +#define INT_TX_FIN 0x00000040 /* TX Finished Process Descriptors */ +#define INT_TX_DONE 0x00000080 /* Transmit Done */ +#define INT_SOFT_INT 0x00001000 /* Software Triggered Interrupt */ +#define INT_WAKEUP 0x00002000 /* Wakeup Event Interrupt */ + +/* Power Down Register */ +#define PD_POWER_DOWN 0x80000000 /* Power Down MAC */ + +/* RX Descriptor Control Word */ +#define RCTRL_SIZE 0x000007FF /* Buffer size mask */ +#define RCTRL_INT 0x80000000 /* Generate RxDone Interrupt */ + +/* RX Status Hash CRC Word */ +#define RHASH_SA 0x000001FF /* Hash CRC for Source Address */ +#define RHASH_DA 0x001FF000 /* Hash CRC for Destination Address */ + +/* RX Status Information Word */ +#define RINFO_SIZE 0x000007FF /* Data size in bytes */ +#define RINFO_CTRL_FRAME 0x00040000 /* Control Frame */ +#define RINFO_VLAN 0x00080000 /* VLAN Frame */ +#define RINFO_FAIL_FILT 0x00100000 /* RX Filter Failed */ +#define RINFO_MCAST 0x00200000 /* Multicast Frame */ +#define RINFO_BCAST 0x00400000 /* Broadcast Frame */ +#define RINFO_CRC_ERR 0x00800000 /* CRC Error in Frame */ +#define RINFO_SYM_ERR 0x01000000 /* Symbol Error from PHY */ +#define RINFO_LEN_ERR 0x02000000 /* Length Error */ +#define RINFO_RANGE_ERR 0x04000000 /* Range Error (exceeded max. size) */ +#define RINFO_ALIGN_ERR 0x08000000 /* Alignment Error */ +#define RINFO_OVERRUN 0x10000000 /* Receive overrun */ +#define RINFO_NO_DESCR 0x20000000 /* No new Descriptor available */ +#define RINFO_LAST_FLAG 0x40000000 /* Last Fragment in Frame */ +#define RINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ + +#define RINFO_ERR_MASK (RINFO_FAIL_FILT | RINFO_CRC_ERR | RINFO_SYM_ERR | \ + RINFO_LEN_ERR | RINFO_ALIGN_ERR | RINFO_OVERRUN) + +/* TX Descriptor Control Word */ +#define TCTRL_SIZE 0x000007FF /* Size of data buffer in bytes */ +#define TCTRL_OVERRIDE 0x04000000 /* Override Default MAC Registers */ +#define TCTRL_HUGE 0x08000000 /* Enable Huge Frame */ +#define TCTRL_PAD 0x10000000 /* Pad short Frames to 64 bytes */ +#define TCTRL_CRC 0x20000000 /* Append a hardware CRC to Frame */ +#define TCTRL_LAST 0x40000000 /* Last Descriptor for TX Frame */ +#define TCTRL_INT 0x80000000 /* Generate TxDone Interrupt */ + +/* TX Status Information Word */ +#define TINFO_COL_CNT 0x01E00000 /* Collision Count */ +#define TINFO_DEFER 0x02000000 /* Packet Deferred (not an error) */ +#define TINFO_EXCESS_DEF 0x04000000 /* Excessive Deferral */ +#define TINFO_EXCESS_COL 0x08000000 /* Excessive Collision */ +#define TINFO_LATE_COL 0x10000000 /* Late Collision Occured */ +#define TINFO_UNDERRUN 0x20000000 /* Transmit Underrun */ +#define TINFO_NO_DESCR 0x40000000 /* No new Descriptor available */ +#define TINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ + +/* ENET Device Revision ID */ +#define OLD_EMAC_MODULE_ID 0x39022000 /* Rev. ID for first rev '-' */ + +/* DP83848C PHY Registers */ +#define PHY_REG_BMCR 0x00 /* Basic Mode Control Register */ +#define PHY_REG_BMSR 0x01 /* Basic Mode Status Register */ +#define PHY_REG_IDR1 0x02 /* PHY Identifier 1 */ +#define PHY_REG_IDR2 0x03 /* PHY Identifier 2 */ +#define PHY_REG_ANAR 0x04 /* Auto-Negotiation Advertisement */ +#define PHY_REG_ANLPAR 0x05 /* Auto-Neg. Link Partner Abitily */ +#define PHY_REG_ANER 0x06 /* Auto-Neg. Expansion Register */ +#define PHY_REG_ANNPTR 0x07 /* Auto-Neg. Next Page TX */ + +/* PHY Extended Registers */ +#define PHY_REG_STS 0x10 /* Status Register */ +#define PHY_REG_MICR 0x11 /* MII Interrupt Control Register */ +#define PHY_REG_MISR 0x12 /* MII Interrupt Status Register */ +#define PHY_REG_FCSCR 0x14 /* False Carrier Sense Counter */ +#define PHY_REG_RECR 0x15 /* Receive Error Counter */ +#define PHY_REG_PCSR 0x16 /* PCS Sublayer Config. and Status */ +#define PHY_REG_RBR 0x17 /* RMII and Bypass Register */ +#define PHY_REG_LEDCR 0x18 /* LED Direct Control Register */ +#define PHY_REG_PHYCR 0x19 /* PHY Control Register */ +#define PHY_REG_10BTSCR 0x1A /* 10Base-T Status/Control Register */ +#define PHY_REG_CDCTRL1 0x1B /* CD Test Control and BIST Extens. */ +#define PHY_REG_EDCR 0x1D /* Energy Detect Control Register */ + +#define PHY_FULLD_100M 0x2100 /* Full Duplex 100Mbit */ +#define PHY_HALFD_100M 0x2000 /* Half Duplex 100Mbit */ +#define PHY_FULLD_10M 0x0100 /* Full Duplex 10Mbit */ +#define PHY_HALFD_10M 0x0000 /* Half Duplex 10MBit */ +#define PHY_AUTO_NEG 0x3000 /* Select Auto Negotiation */ + +#define DP83848C_DEF_ADR 0x0F00 /* Default PHY device address */ +#define DP83848C_ID 0x20005C90 /* PHY Identifier */ + +int lpc_emac_hw_init(void); + +#endif diff --git a/bsp/lpc408x/drivers/drv_led.c b/bsp/lpc408x/drivers/drv_led.c index f9cc5e602f..e00f3a2fb1 100644 --- a/bsp/lpc408x/drivers/drv_led.c +++ b/bsp/lpc408x/drivers/drv_led.c @@ -1,7 +1,7 @@ #include <rtthread.h> #include "board.h" -#define RT_DEVICE_CTRL_RTC_GET_COUNT 0x81 /**< get count */ +#define LED_DEVICE_CTRL 0x81 /*LED control command*/ #define LED_NUM 4 struct led_ctrl @@ -22,24 +22,24 @@ static struct lpc_led led; static rt_err_t rt_led_init(rt_device_t dev) { - /* led0 : P4.14,led1:P4.15 ,led2:P4.16 ,led3:P4.17*/ + /* led0 : P4.27,led1:P4.15 ,led2:P4.16 ,led3:P4.17*/ /* set P4.14,P4.15,P4.16,P4.17 as GPIO. */ - LPC_IOCON->P4_14 = 0x00; + LPC_IOCON->P4_27 = 0x00; LPC_IOCON->P4_15 = 0x00; LPC_IOCON->P4_16 = 0x00; LPC_IOCON->P4_17 = 0x00; - /* set P4.14,P4.15,P4.16,P4.17 output. */ - LPC_GPIO4->DIR |= (0x0f << 14); + /* set P4.27,P4.15,P4.16,P4.17 output. */ + LPC_GPIO4->DIR |= (0x07 << 15) | (0x01 << 27); /* turn off all the led */ - LPC_GPIO4->SET = (0x0f << 14); - led.ctrl[0].num = 14; - led.ctrl[0].port = LPC_GPIO4; - led.ctrl[1].num = 15; - led.ctrl[1].port = LPC_GPIO4; - led.ctrl[2].num = 16; - led.ctrl[2].port = LPC_GPIO4; - led.ctrl[3].num = 17; + LPC_GPIO4->SET = (0x07 << 15) | (0x01 << 27); + led.ctrl[3].num = 27; led.ctrl[3].port = LPC_GPIO4; + led.ctrl[2].num = 15; + led.ctrl[2].port = LPC_GPIO4; + led.ctrl[1].num = 16; + led.ctrl[1].port = LPC_GPIO4; + led.ctrl[0].num = 17; + led.ctrl[0].port = LPC_GPIO4; return RT_EOK; } @@ -106,7 +106,7 @@ static rt_err_t rt_led_control(rt_device_t dev, rt_uint8_t cmd, void *args) { RT_ASSERT(dev == &led.parent); - if (cmd == RT_DEVICE_CTRL_RTC_GET_COUNT) + if (cmd == LED_DEVICE_CTRL) { rt_uint32_t *led_num = args; *led_num = LED_NUM; @@ -114,7 +114,7 @@ static rt_err_t rt_led_control(rt_device_t dev, rt_uint8_t cmd, void *args) return RT_EOK; } -void rt_led_hw_init(void) +int rt_led_hw_init(void) { led.parent.type = RT_Device_Class_Char; led.parent.rx_indicate = RT_NULL; @@ -131,8 +131,9 @@ void rt_led_hw_init(void) rt_device_register(&led.parent, "led", RT_DEVICE_FLAG_RDWR); /* init led device */ rt_led_init(&led.parent); + return 0; } - +INIT_DEVICE_EXPORT(rt_led_hw_init); #ifdef RT_USING_FINSH #include <finsh.h> void led_test(rt_uint32_t led_num, rt_uint32_t value) diff --git a/bsp/lpc408x/drivers/drv_sdram.c b/bsp/lpc408x/drivers/drv_sdram.c new file mode 100644 index 0000000000..b648ed079c --- /dev/null +++ b/bsp/lpc408x/drivers/drv_sdram.c @@ -0,0 +1,153 @@ +/* + * File : drv_sdram.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2013-05-19 Bernard The first version for LPC40xx + */ + +#include "drv_sdram.h" + +#include <lpc_emc.h> +#include <lpc_timer.h> + +#define SDRAM_BASE_ADDR 0xA0000000 +#define SDRAM_SIZE 0x2000000 + +/******************************************************************************************* +* @��������sdram_gpio_config() +* @���� ��void +* @����ֵ��void +* @���� ��SDRAM�ܽ����ú������ڲ����� +*********************************************************************************************/ +static void sdram_gpio_config(void) +{ + LPC_IOCON->P3_0 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D0 @ P3.0 */ + LPC_IOCON->P3_1 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D1 @ P3.1 */ + LPC_IOCON->P3_2 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D2 @ P3.2 */ + LPC_IOCON->P3_3 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D3 @ P3.3 */ + + LPC_IOCON->P3_4 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D4 @ P3.4 */ + LPC_IOCON->P3_5 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D5 @ P3.5 */ + LPC_IOCON->P3_6 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D6 @ P3.6 */ + LPC_IOCON->P3_7 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D7 @ P3.7 */ + + LPC_IOCON->P3_8 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D8 @ P3.8 */ + LPC_IOCON->P3_9 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D9 @ P3.9 */ + LPC_IOCON->P3_10 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D10 @ P3.10 */ + LPC_IOCON->P3_11 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D11 @ P3.11 */ + + LPC_IOCON->P3_12 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D12 @ P3.12 */ + LPC_IOCON->P3_13 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D13 @ P3.13 */ + LPC_IOCON->P3_14 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D14 @ P3.14 */ + LPC_IOCON->P3_15 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D15 @ P3.15 */ + + + LPC_IOCON->P4_0 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A0 @ P4.0 */ + LPC_IOCON->P4_1 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A1 @ P4.1 */ + LPC_IOCON->P4_2 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A2 @ P4.2 */ + LPC_IOCON->P4_3 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A3 @ P4.3 */ + + LPC_IOCON->P4_4 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A4 @ P4.4 */ + LPC_IOCON->P4_5 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A5 @ P4.5 */ + LPC_IOCON->P4_6 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A6 @ P4.6 */ + LPC_IOCON->P4_7 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A7 @ P4.7 */ + + LPC_IOCON->P4_8 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A8 @ P4.8 */ + LPC_IOCON->P4_9 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A9 @ P4.9 */ + LPC_IOCON->P4_10 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A10 @ P4.10 */ + LPC_IOCON->P4_11 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A11 @ P4.11 */ + + LPC_IOCON->P4_12 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A12 @ P4.12 */ + LPC_IOCON->P4_13 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A13 @ P4.13 */ + LPC_IOCON->P4_14 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* A14 @ P4.14 */ + + LPC_IOCON->P4_25 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* WEN @ P4.25 */ + + LPC_IOCON->P2_16 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* CASN @ P2.16 */ + LPC_IOCON->P2_17 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* RASN @ P2.17 */ + LPC_IOCON->P2_18 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* CLK[0] @ P2.18 */ + LPC_IOCON->P2_19 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* CLK[1] @ P2.19 */ + + LPC_IOCON->P2_20 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* DYCSN[0] @ P2.20 */ + LPC_IOCON->P2_24 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* CKE[0] @ P2.24 */ + + LPC_IOCON->P2_28 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* DQM[0] @ P2.28 */ + LPC_IOCON->P2_29 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* DQM[1] @ P2.29 */ +} + +void lpc_sdram_hw_init(void) +{ + volatile uint32_t i; + volatile uint32_t dwtemp; + uint16_t wtemp = wtemp; + TIM_TIMERCFG_Type TIM_ConfigStruct; + + TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; + TIM_ConfigStruct.PrescaleValue = 1; + + // Set configuration for Tim_config and Tim_MatchConfig + TIM_Init(LPC_TIM0, TIM_TIMER_MODE, &TIM_ConfigStruct); + + LPC_SC->PCONP |= 0x00000800; + LPC_SC->EMCDLYCTL = 0x00001010; + LPC_EMC->Control = 0x00000001; + LPC_EMC->Config = 0x00000000; + + sdram_gpio_config(); + //LPC_SC->EMCCLKSEL = 1; //����Ƶ��һ��Ƶ�ʣ�60Mhz + LPC_EMC->DynamicRP = EMC_NS2CLK(20); /* 20ns, */ + LPC_EMC->DynamicRAS = /*EMC_NS2CLK(42, nsPerClk);*/ 15; /* 42ns to 100K ns, */ + LPC_EMC->DynamicSREX = 1 - 1; /* tSRE, 1clk, */ + LPC_EMC->DynamicAPR = 2 - 1; /* Not found!!! Estimated as 2clk, */ + LPC_EMC->DynamicDAL = EMC_NS2CLK(20) + 2; /* tDAL = tRP + tDPL = 20ns + 2clk */ + LPC_EMC->DynamicWR = 2 - 1; /* 2CLK, */ + LPC_EMC->DynamicRC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRC=63ns(min)*/ + LPC_EMC->DynamicRFC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRFC=tRC */ + LPC_EMC->DynamicXSR = 0x0000000F; /* exit self-refresh to active, ��֪������Ϊ��� */ + LPC_EMC->DynamicRRD = EMC_NS2CLK(63); /* 3clk, tRRD=15ns(min) */ + LPC_EMC->DynamicMRD = 2 - 1; /* 2clk, tMRD=2clk(min) */ + + LPC_EMC->DynamicReadConfig = 0x00000001; /* Command delayed strategy, using EMCCLKDELAY */ + /* H57V2562GTR-75C: tCL=3CLK, tRCD=20ns(min), 3 CLK=24ns */ + LPC_EMC->DynamicRasCas0 = 0x303; + + /* For Manley lpc1778 SDRAM: H57V2562GTR-75C, 256Mb, 16Mx16, 4 banks, row=13, column=9 */ +#ifdef SDRAM_CONFIG_16BIT + LPC_EMC->DynamicConfig0 = 0x680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ +#elif defined SDRAM_CONFIG_32BIT + LPC_EMC->DynamicConfig0 = 0x4680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ +#endif + TIM_Waitms(100); + + LPC_EMC->DynamicControl = 0x00000183; /* Issue NOP command */ + TIM_Waitms(200); /* wait 200ms */ + + LPC_EMC->DynamicControl = 0x00000103; /* Issue PALL command */ + + LPC_EMC->DynamicRefresh = 0x00000002; /* ( n * 16 ) -> 32 clock cycles */ + for (i = 0; i < 0x80; i++); /* wait 128 AHB clock cycles */ + + LPC_EMC->DynamicRefresh = EMC_SDRAM_REFRESH(64); + + LPC_EMC->DynamicControl = 0x00000083; /* Issue MODE command */ + +#ifdef SDRAM_CONFIG_16BIT + wtemp = *((volatile uint16_t *)(SDRAM_BASE | (0x33 << 12))); /* 8 burst, 3 CAS latency */ +#elif defined SDRAM_CONFIG_32BIT + dwtemp = *((volatile uint32_t *)(SDRAM_BASE | (0x32 << 13))); /* 4 burst, 3 CAS latency */ +#endif + + LPC_EMC->DynamicControl = 0x00000000; /* Issue NORMAL command */ + + LPC_EMC->DynamicConfig0 |= 0x80000; /* enable buffer */ + TIM_Waitms(1); + + TIM_DeInit(LPC_TIM0); +} diff --git a/bsp/lpc408x/drivers/drv_sdram.h b/bsp/lpc408x/drivers/drv_sdram.h new file mode 100644 index 0000000000..a689f1ed98 --- /dev/null +++ b/bsp/lpc408x/drivers/drv_sdram.h @@ -0,0 +1,35 @@ +/* + * File : drv_sdram.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2013-05-19 Bernard The first version for LPC40xx + */ + +#ifndef __DRV_SDRAM_H__ +#define __DRV_SDRAM_H__ + +#include <board.h> + +#define SDRAM_CONFIG_16BIT //use the 16 bitSDRAM +//#define SDRAM_CONFIG_32BIT //use the 32 bitSDRAM + +#ifdef SDRAM_CONFIG_16BIT +#define SDRAM_SIZE 0x2000000 // 256Mbit +#elif defined SDRAM_CONFIG_32BIT // +#define SDRAM_SIZE 0x4000000 // 512Mbit +#else +error Wrong SDRAM config, check ex_sdram.h +#endif + +#define SDRAM_BASE 0xA0000000 /* CS0 */ + +void lpc_sdram_hw_init(void); + +#endif diff --git a/bsp/lpc408x/drivers/drv_uart.c b/bsp/lpc408x/drivers/drv_uart.c index 0b3756a5b9..ef50f3a4d8 100644 --- a/bsp/lpc408x/drivers/drv_uart.c +++ b/bsp/lpc408x/drivers/drv_uart.c @@ -17,20 +17,17 @@ #include <rtdevice.h> #include "board.h" -#include "lpc_uart.h" -#include "lpc_pinsel.h" struct lpc_uart { - UART_ID_Type UART; + LPC_UART_TypeDef *UART; IRQn_Type UART_IRQn; }; static rt_err_t lpc_configure(struct rt_serial_device *serial, struct serial_configure *cfg) { struct lpc_uart *uart; - UART_CFG_Type UARTConfigStruct; - UART_FIFO_CFG_Type UARTFIFOConfigStruct; + uint32_t Fdiv = 0; RT_ASSERT(serial != RT_NULL); uart = (struct lpc_uart *)serial->parent.user_data; @@ -41,25 +38,20 @@ static rt_err_t lpc_configure(struct rt_serial_device *serial, struct serial_con * 1 Stop bit * None parity */ - UART_ConfigStructInit(&UARTConfigStruct); - UARTConfigStruct.Baud_rate = 115200; + /* set DLAB=1 */ + uart->UART->LCR |= 0x80; + /* config uart baudrate */ + Fdiv = (PeripheralClock / 16) / cfg->baud_rate; + uart->UART->DLM = Fdiv / 256; + uart->UART->DLL = Fdiv % 256; + /* set DLAB=0 */ + uart->UART->LCR &= ~0x80; + /* config to 8 data bit,1 Stop bit,None parity */ + uart->UART->LCR |= 0x03; - // Initialize UART0 peripheral with given to corresponding parameter - UART_Init(uart->UART, &UARTConfigStruct); + /*enable and reset FIFO*/ + uart->UART->FCR = 0x07; - /* Initialize FIFOConfigStruct to default state: - * - FIFO_DMAMode = DISABLE - * - FIFO_Level = UART_FIFO_TRGLEV0 - * - FIFO_ResetRxBuf = ENABLE - * - FIFO_ResetTxBuf = ENABLE - * - FIFO_State = ENABLE - */ - UART_FIFOConfigStructInit(&UARTFIFOConfigStruct); - - // Initialize FIFO for UART0 peripheral - UART_FIFOConfig(uart->UART, &UARTFIFOConfigStruct); - - UART_TxCmd(uart->UART, ENABLE); return RT_EOK; } @@ -75,11 +67,11 @@ static rt_err_t lpc_control(struct rt_serial_device *serial, int cmd, void *arg) { case RT_DEVICE_CTRL_CLR_INT: /* disable rx irq */ - UART_IntConfig(uart->UART, UART_INTCFG_RBR, DISABLE); + uart->UART->IER &= ~0x01; break; case RT_DEVICE_CTRL_SET_INT: /* enable rx irq */ - UART_IntConfig(uart->UART, UART_INTCFG_RBR, ENABLE); + uart->UART->IER |= 0x01; break; } @@ -91,21 +83,21 @@ static int lpc_putc(struct rt_serial_device *serial, char c) struct lpc_uart *uart; uart = (struct lpc_uart *)serial->parent.user_data; - UART_Send(uart->UART, (uint8_t *)&c, 1, BLOCKING); + while (!(uart->UART->LSR & 0x20)); + uart->UART->THR = c; return 1; } static int lpc_getc(struct rt_serial_device *serial) { - uint8_t ch; struct lpc_uart *uart; uart = (struct lpc_uart *)serial->parent.user_data; - if (UART_Receive(uart->UART, &ch, 1, NONE_BLOCKING) == 1) - return (int) ch; - - return -1; + if (uart->UART->LSR & 0x01) + return (uart->UART->RBR); + else + return -1; } static const struct rt_uart_ops lpc_uart_ops = @@ -116,127 +108,167 @@ static const struct rt_uart_ops lpc_uart_ops = lpc_getc, }; -#if defined(RT_USING_UART0) +#ifdef RT_USING_UART0 /* UART0 device driver structure */ +#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ +struct serial_ringbuffer uart0_int_rx; +#endif + struct lpc_uart uart0 = { - UART_0, + LPC_UART0, UART0_IRQn, }; struct rt_serial_device serial0; void UART0_IRQHandler(void) { - struct lpc_uart *uart; - uint32_t intsrc, tmp, tmp1; - - uart = &uart0; + volatile uint32_t IIR, tmp; /* enter interrupt */ rt_interrupt_enter(); - /* Determine the interrupt source */ - intsrc = UART_GetIntId(uart->UART); - tmp = intsrc & UART_IIR_INTID_MASK; - - // Receive Line Status - if (tmp == UART_IIR_INTID_RLS) + IIR = LPC_UART0->IIR; + IIR &= 0x0e; + switch (IIR) { - // Check line status - tmp1 = UART_GetLineStatus(uart->UART); - // Mask out the Receive Ready and Transmit Holding empty status - tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \ - | UART_LSR_BI | UART_LSR_RXFE); - // If any error exist - if (tmp1) - { - // - } - } - // Receive Data Available or Character time-out - if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) - { + case 0x04: + case 0x0C: + #if RTTHREAD_VERSION < 20000 + rt_hw_serial_isr(&serial0); + #else rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND); + #endif + break; + case 0x06: + tmp = LPC_UART0->LSR; + break; + default : + tmp = LPC_UART0->LSR; + break; } - /* leave interrupt */ rt_interrupt_leave(); } #endif -#if defined(RT_USING_UART2) +#ifdef RT_USING_UART2 /* UART2 device driver structure */ +#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ +struct serial_ringbuffer uart2_int_rx; +#endif + struct lpc_uart uart2 = { - UART_2, + LPC_UART2, UART2_IRQn, }; struct rt_serial_device serial2; void UART2_IRQHandler(void) { - struct lpc_uart *uart; - uint32_t intsrc, tmp, tmp1; - - uart = &uart2; + volatile uint32_t IIR, tmp; /* enter interrupt */ rt_interrupt_enter(); - /* Determine the interrupt source */ - intsrc = UART_GetIntId(uart->UART); - tmp = intsrc & UART_IIR_INTID_MASK; - - // Receive Line Status - if (tmp == UART_IIR_INTID_RLS) + IIR = LPC_UART2->IIR; + IIR &= 0x0e; + switch (IIR) { - // Check line status - tmp1 = UART_GetLineStatus(uart->UART); - // Mask out the Receive Ready and Transmit Holding empty status - tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \ - | UART_LSR_BI | UART_LSR_RXFE); - // If any error exist - if (tmp1) - { - // - } + case 0x04: + case 0x0C: + #if RTTHREAD_VERSION < 20000 + rt_hw_serial_isr(&serial2); + #else + rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND); + #endif + break; + case 0x06: + tmp = LPC_UART2->LSR; + break; + default : + tmp = LPC_UART2->LSR; + break; } - // Receive Data Available or Character time-out - if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif + +#ifdef RT_USING_UART4 +/* UART4 device driver structure */ +#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ +struct serial_ringbuffer uart4_int_rx; +#endif + +struct lpc_uart uart4 = +{ + LPC_UART4, + UART4_IRQn, +}; +struct rt_serial_device serial4; + +void UART4_IRQHandler(void) +{ + volatile uint32_t IIR, tmp; + + /* enter interrupt */ + rt_interrupt_enter(); + + IIR = LPC_UART4->IIR; + IIR &= 0x0e; + switch (IIR) { - rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND); + case 0x04: + case 0x0C: + #if RTTHREAD_VERSION < 20000 + rt_hw_serial_isr(&serial4); + #else + rt_hw_serial_isr(&serial4, RT_SERIAL_EVENT_RX_IND); + #endif + break; + case 0x06: + tmp = LPC_UART4->LSR; + break; + default : + tmp = LPC_UART4->LSR; + break; } /* leave interrupt */ rt_interrupt_leave(); } #endif + void rt_hw_uart_init(void) { struct lpc_uart *uart; - struct serial_configure config; + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; #ifdef RT_USING_UART0 uart = &uart0; - config.baud_rate = BAUD_RATE_115200; - config.bit_order = BIT_ORDER_LSB; - config.data_bits = DATA_BITS_8; - config.parity = PARITY_NONE; - config.stop_bits = STOP_BITS_1; - config.invert = NRZ_NORMAL; - config.bufsz = RT_SERIAL_RB_BUFSZ; serial0.ops = &lpc_uart_ops; serial0.config = config; - + #if RTTHREAD_VERSION < 20000 + serial0.int_rx = &uart0_int_rx; + #endif + serial0.parent.user_data = uart; + /* * Initialize UART0 pin connect * P0.2: U0_TXD * P0.3: U0_RXD */ - PINSEL_ConfigPin(0, 2, 1); - PINSEL_ConfigPin(0, 3, 1); + LPC_IOCON->P0_2 &= ~0x07; + LPC_IOCON->P0_2 |= 0x01; + LPC_IOCON->P0_3 &= ~0x07; + LPC_IOCON->P0_3 |= 0x01; + + /* enable the uart0 power and clock */ + LPC_SC->PCONP |= 0x01 << 3; /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(uart->UART_IRQn, ((0x01 << 3) | 0x01)); @@ -244,41 +276,77 @@ void rt_hw_uart_init(void) /* Enable Interrupt for UART channel */ NVIC_EnableIRQ(uart->UART_IRQn); - /* register UART1 device */ + /* register UART0 device */ rt_hw_serial_register(&serial0, "uart0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, uart); #endif + #ifdef RT_USING_UART2 uart = &uart2; - config.baud_rate = BAUD_RATE_115200; - config.bit_order = BIT_ORDER_LSB; - config.data_bits = DATA_BITS_8; - config.parity = PARITY_NONE; - config.stop_bits = STOP_BITS_1; - config.invert = NRZ_NORMAL; - config.bufsz = RT_SERIAL_RB_BUFSZ; serial2.ops = &lpc_uart_ops; serial2.config = config; + #if RTTHREAD_VERSION < 20000 + serial2.int_rx = &uart2_int_rx; + #endif + serial2.parent.user_data = uart; /* * Initialize UART2 pin connect * P2.8: U2_TXD * P0.11: U2_RXD */ - PINSEL_ConfigPin(2, 8, 2); - PINSEL_ConfigPin(0, 11, 1); + LPC_IOCON->P2_8 &= ~0x07; + LPC_IOCON->P0_11 &= ~0x07; + LPC_IOCON->P2_8 |= 0x02; + LPC_IOCON->P0_11 |= 0x01; + /* enable the uart2 power and clock */ + LPC_SC->PCONP |= 0x01 << 24; /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(uart->UART_IRQn, ((0x01 << 3) | 0x01)); /* Enable Interrupt for UART channel */ NVIC_EnableIRQ(uart->UART_IRQn); - /* register UART1 device */ + /* register UART2 device */ rt_hw_serial_register(&serial2, "uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, uart); #endif + +#ifdef RT_USING_UART4 + uart = &uart4; + + serial4.ops = &lpc_uart_ops; + serial4.config = config; + #if RTTHREAD_VERSION < 20000 + serial4.int_rx = &uart4_int_rx; + #endif + serial4.parent.user_data = uart; + + /* + * Initialize UART2 pin connect + * P5.4: U2_TXD + * P5.3: U2_RXD + */ + LPC_IOCON->P5_4 &= ~0x07; + LPC_IOCON->P5_3 &= ~0x07; + LPC_IOCON->P5_4 |= 0x04; + LPC_IOCON->P5_3 |= 0x04; + + /* enable the uart4 power and clock */ + LPC_SC->PCONP |= 0x01 << 8; + /* preemption = 1, sub-priority = 1 */ + NVIC_SetPriority(uart->UART_IRQn, ((0x01 << 3) | 0x01)); + + /* Enable Interrupt for UART channel */ + NVIC_EnableIRQ(uart->UART_IRQn); + + /* register UART2 device */ + rt_hw_serial_register(&serial4, "uart4", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, + uart); +#endif } diff --git a/bsp/lpc408x/drivers/drv_uart.h b/bsp/lpc408x/drivers/drv_uart.h index c5ca6c70c4..d93995b96e 100644 --- a/bsp/lpc408x/drivers/drv_uart.h +++ b/bsp/lpc408x/drivers/drv_uart.h @@ -1,3 +1,17 @@ +/* + * File : drv_uart.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009-2014 RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2014-01-05 NongXiaoming The first version for LPC40xx + */ + #ifndef __UART_H__ #define __UART_H__ diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index 2ef8f1523e..9b04e63aab 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -165,7 +165,7 @@ // <bool name="RT_LWIP_SNMP" description="Enable SNMP protocol" default="false" /> // #define RT_LWIP_SNMP // <bool name="RT_LWIP_DHCP" description="Enable DHCP client to get IP address" default="false" /> -// #define RT_LWIP_DHCP +#define RT_LWIP_DHCP // <integer name="RT_LWIP_TCPTHREAD_PRIORITY" description="the thread priority of TCP thread" default="128" /> #define RT_LWIP_TCPTHREAD_PRIORITY 12 // <integer name="RT_LWIP_TCPTHREAD_MBOX_SIZE" description="the mail box size of TCP thread to wait for" default="32" /> diff --git a/bsp/lpc408x/template.uvopt b/bsp/lpc408x/template.uvopt new file mode 100644 index 0000000000..bfe099d207 --- /dev/null +++ b/bsp/lpc408x/template.uvopt @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no" ?> +<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_opt.xsd"> + + <SchemaVersion>1.0</SchemaVersion> + + <Header>### uVision Project, (C) Keil Software</Header> + + <Extensions> + <cExt>*.c</cExt> + <aExt>*.s*; *.src; *.a*</aExt> + <oExt>*.obj</oExt> + <lExt>*.lib</lExt> + <tExt>*.txt; *.h; *.inc</tExt> + <pExt>*.plm</pExt> + <CppX>*.cpp</CppX> + </Extensions> + + <DaveTm> + <dwLowDateTime>0</dwLowDateTime> + <dwHighDateTime>0</dwHighDateTime> + </DaveTm> + + <Target> + <TargetName>RT-Thread LPC408x</TargetName> + <ToolsetNumber>0x4</ToolsetNumber> + <ToolsetName>ARM-ADS</ToolsetName> + <TargetOption> + <CLKADS>12000000</CLKADS> + <OPTTT> + <gFlags>1</gFlags> + <BeepAtEnd>1</BeepAtEnd> + <RunSim>1</RunSim> + <RunTarget>0</RunTarget> + </OPTTT> + <OPTHX> + <HexSelection>1</HexSelection> + <FlashByte>65535</FlashByte> + <HexRangeLowAddress>0</HexRangeLowAddress> + <HexRangeHighAddress>0</HexRangeHighAddress> + <HexOffset>0</HexOffset> + </OPTHX> + <OPTLEX> + <PageWidth>79</PageWidth> + <PageLength>66</PageLength> + <TabStop>8</TabStop> + <ListingPath>.\build\</ListingPath> + </OPTLEX> + <ListingPage> + <CreateCListing>1</CreateCListing> + <CreateAListing>1</CreateAListing> + <CreateLListing>1</CreateLListing> + <CreateIListing>0</CreateIListing> + <AsmCond>1</AsmCond> + <AsmSymb>1</AsmSymb> + <AsmXref>0</AsmXref> + <CCond>1</CCond> + <CCode>0</CCode> + <CListInc>0</CListInc> + <CSymb>0</CSymb> + <LinkerCodeListing>0</LinkerCodeListing> + </ListingPage> + <OPTXL> + <LMap>1</LMap> + <LComments>1</LComments> + <LGenerateSymbols>1</LGenerateSymbols> + <LLibSym>1</LLibSym> + <LLines>1</LLines> + <LLocSym>1</LLocSym> + <LPubSym>1</LPubSym> + <LXref>0</LXref> + <LExpSel>0</LExpSel> + </OPTXL> + <OPTFL> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <IsCurrentTarget>1</IsCurrentTarget> + </OPTFL> + <CpuCode>0</CpuCode> + <DllOpt> + <SimDllName>SARMCM3.DLL</SimDllName> + <SimDllArguments>-MPU</SimDllArguments> + <SimDlgDllName>DCM.DLL</SimDlgDllName> + <SimDlgDllArguments>-pCM4</SimDlgDllArguments> + <TargetDllName>SARMCM3.DLL</TargetDllName> + <TargetDllArguments>-MPU</TargetDllArguments> + <TargetDlgDllName>TCM.DLL</TargetDlgDllName> + <TargetDlgDllArguments>-pCM4</TargetDlgDllArguments> + </DllOpt> + <DebugOpt> + <uSim>0</uSim> + <uTrg>1</uTrg> + <sLdApp>1</sLdApp> + <sGomain>1</sGomain> + <sRbreak>1</sRbreak> + <sRwatch>1</sRwatch> + <sRmem>1</sRmem> + <sRfunc>1</sRfunc> + <sRbox>1</sRbox> + <tLdApp>1</tLdApp> + <tGomain>0</tGomain> + <tRbreak>1</tRbreak> + <tRwatch>1</tRwatch> + <tRmem>1</tRmem> + <tRfunc>0</tRfunc> + <tRbox>1</tRbox> + <tRtrace>0</tRtrace> + <sRunDeb>0</sRunDeb> + <sLrtime>0</sLrtime> + <nTsel>7</nTsel> + <sDll></sDll> + <sDllPa></sDllPa> + <sDlgDll></sDlgDll> + <sDlgPa></sDlgPa> + <sIfile></sIfile> + <tDll></tDll> + <tDllPa></tDllPa> + <tDlgDll></tDlgDll> + <tDlgPa></tDlgPa> + <tIfile></tIfile> + <pMon>Segger\JL2CM3.dll</pMon> + </DebugOpt> + <TargetDriverDllRegistry> + <SetRegEntry> + <Number>0</Number> + <Key>JL2CM3</Key> + <Name>-U4294967295 -O78 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO11 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000</Name> + </SetRegEntry> + </TargetDriverDllRegistry> + <Breakpoint/> + <Tracepoint> + <THDelay>0</THDelay> + </Tracepoint> + <DebugFlag> + <trace>0</trace> + <periodic>0</periodic> + <aLwin>0</aLwin> + <aCover>0</aCover> + <aSer1>0</aSer1> + <aSer2>0</aSer2> + <aPa>0</aPa> + <viewmode>0</viewmode> + <vrSel>0</vrSel> + <aSym>0</aSym> + <aTbox>0</aTbox> + <AscS1>0</AscS1> + <AscS2>0</AscS2> + <AscS3>0</AscS3> + <aSer3>0</aSer3> + <eProf>0</eProf> + <aLa>0</aLa> + <aPa1>0</aPa1> + <AscS4>0</AscS4> + <aSer4>0</aSer4> + <StkLoc>0</StkLoc> + <TrcWin>0</TrcWin> + <newCpu>0</newCpu> + <uProt>0</uProt> + </DebugFlag> + <LintExecutable></LintExecutable> + <LintConfigFile></LintConfigFile> + </TargetOption> + </Target> + +</ProjectOpt> diff --git a/bsp/ls1cdev/applications/application.c b/bsp/ls1cdev/applications/application.c index f907c9f347..6690da528a 100644 --- a/bsp/ls1cdev/applications/application.c +++ b/bsp/ls1cdev/applications/application.c @@ -9,44 +9,18 @@ * * Change Logs: * Date Author Notes - * 2010-06-25 Bernard first version - * 2011-08-08 lgnq modified for Loongson LS1B - * 2015-07-06 chinesebear modified for Loongson LS1C + * 2010-06-25 Bernard first version + * 2011-08-08 lgnq modified for Loongson LS1B + * 2015-07-06 chinesebear modified for Loongson LS1C */ #include <rtthread.h> -#include <ls1c.h> - -#ifdef RT_USING_COMPONENTS_INIT #include <components.h> -#endif - -#ifdef RT_USING_RTGUI -#include <rtgui/rtgui.h> -extern void rt_hw_dc_init(void); -#endif void rt_init_thread_entry(void *parameter) { -#ifdef RT_USING_RTGUI - { - rt_device_t dc; - - /* init Display Controller */ - rt_hw_dc_init(); - - /* find Display Controller device */ - dc = rt_device_find("dc"); - - /* set Display Controller device as rtgui graphic driver */ - rtgui_graphic_set_device(dc); - } -#endif - -#ifdef RT_USING_COMPONENTS_INIT /* initialization RT-Thread Components */ rt_components_init(); -#endif } int rt_application_init(void) @@ -56,11 +30,9 @@ int rt_application_init(void) /* create initialization thread */ tid = rt_thread_create("init", rt_init_thread_entry, RT_NULL, - 4096, 8, 20); + 4096, RT_THREAD_PRIORITY_MAX/3, 20); if (tid != RT_NULL) rt_thread_startup(tid); return 0; } - - diff --git a/bsp/ls1cdev/applications/startup.c b/bsp/ls1cdev/applications/startup.c index 36171b72c1..5c78776f84 100644 --- a/bsp/ls1cdev/applications/startup.c +++ b/bsp/ls1cdev/applications/startup.c @@ -77,12 +77,6 @@ void rtthread_startup(void) /* init application */ rt_application_init(); - /* init finsh*/ - #ifdef RT_USING_FINSH - finsh_system_init(); - finsh_set_device("uart2"); - #endif - /* start scheduler */ rt_system_scheduler_start(); diff --git a/bsp/ls1cdev/drivers/SConscript b/bsp/ls1cdev/drivers/SConscript index 5e1060d78e..6c6d2c7adb 100644 --- a/bsp/ls1cdev/drivers/SConscript +++ b/bsp/ls1cdev/drivers/SConscript @@ -3,10 +3,6 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') -# remove no need file. -if GetDepend('RT_USING_RTGUI') == False: - SrcRemove(src, 'display_controller.c') - CPPPATH = [cwd] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) diff --git a/bsp/ls1cdev/drivers/board.c b/bsp/ls1cdev/drivers/board.c index c1267b8f7d..f9c7454a16 100644 --- a/bsp/ls1cdev/drivers/board.c +++ b/bsp/ls1cdev/drivers/board.c @@ -110,5 +110,3 @@ void rt_hw_console_output(const char *ptr) } /*@}*/ - - diff --git a/bsp/ls1cdev/drivers/display_controller.c b/bsp/ls1cdev/drivers/display_controller.c deleted file mode 100644 index 1c91ebf8d8..0000000000 --- a/bsp/ls1cdev/drivers/display_controller.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * File : display_controller.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006-2012, RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2011-08-09 lgnq first version for LS1B DC - */ - -#include <rtthread.h> -#include "display_controller.h" - -struct vga_struct vga_mode[] = -{ - {/*"640x480_70.00"*/ 28560, 640, 664, 728, 816, 480, 481, 484, 500, }, - {/*"640x640_60.00"*/ 33100, 640, 672, 736, 832, 640, 641, 644, 663, }, - {/*"640x768_60.00"*/ 39690, 640, 672, 736, 832, 768, 769, 772, 795, }, - {/*"640x800_60.00"*/ 42130, 640, 680, 744, 848, 800, 801, 804, 828, }, - {/*"800x480_70.00"*/ 35840, 800, 832, 912, 1024, 480, 481, 484, 500, }, - {/*"800x600_60.00"*/ 38220, 800, 832, 912, 1024, 600, 601, 604, 622, }, - {/*"800x640_60.00"*/ 40730, 800, 832, 912, 1024, 640, 641, 644, 663, }, - {/*"832x600_60.00"*/ 40010, 832, 864, 952, 1072, 600, 601, 604, 622, }, - {/*"832x608_60.00"*/ 40520, 832, 864, 952, 1072, 608, 609, 612, 630, }, - {/*"1024x480_60.00"*/ 38170, 1024, 1048, 1152, 1280, 480, 481, 484, 497, }, - {/*"1024x600_60.00"*/ 48960, 1024, 1064, 1168, 1312, 600, 601, 604, 622, }, - {/*"1024x640_60.00"*/ 52830, 1024, 1072, 1176, 1328, 640, 641, 644, 663, }, - {/*"1024x768_60.00"*/ 64110, 1024, 1080, 1184, 1344, 768, 769, 772, 795, }, - {/*"1152x764_60.00"*/ 71380, 1152, 1208, 1328, 1504, 764, 765, 768, 791, }, - {/*"1280x800_60.00"*/ 83460, 1280, 1344, 1480, 1680, 800, 801, 804, 828, }, - {/*"1280x1024_55.00"*/ 98600, 1280, 1352, 1488, 1696, 1024, 1025, 1028, 1057, }, - {/*"1440x800_60.00"*/ 93800, 1440, 1512, 1664, 1888, 800, 801, 804, 828, }, - {/*"1440x900_67.00"*/ 120280, 1440, 1528, 1680, 1920, 900, 901, 904, 935, }, -}; - -ALIGN(16) -volatile rt_uint16_t _rt_framebuffer[FB_YSIZE][FB_XSIZE]; -static struct rt_device_graphic_info _dc_info; - -#define abs(x) ((x<0)?(-x):x) -#define min(a,b) ((a<b)?a:b) - -int caclulate_freq(long long XIN, long long PCLK) -{ - int i; - long long clk, clk1; - int start, end; - int mi; - int pll,ctrl,div,div1,frac; - - pll = PLL_FREQ; - ctrl = PLL_DIV_PARAM; - rt_kprintf("pll=0x%x, ctrl=0x%x\n", pll, ctrl); -// rt_kprintf("cpu freq is %d\n", tgt_pipefreq()); - start = -1; - end = 1; - - for (i=start; i<=end; i++) - { - clk = (12+i+(pll&0x3f))*33333333/2; - div = clk/(long)PCLK/1000; - clk1 = (12+i+1+(pll&0x3f))*33333333/2; - div1 = clk1/(long)PCLK/1000; - if (div!=div1) - break; - } - - if (div!=div1) - { - frac = ((PCLK*1000*div1)*2*1024/33333333 - (12+i+(pll&0x3f))*1024)&0x3ff; - pll = (pll & ~0x3ff3f)|(frac<<8)|((pll&0x3f)+i); - ctrl = ctrl&~(0x1f<<26)|(div1<<26)|(1<<31); - } - else - { - clk = (12+start+(pll&0x3f))*33333333/2; - clk1 = (12+end+(pll&0x3f))*33333333/2; - if (abs((long)clk/div/1000-PCLK)<abs((long)clk1/(div+1)/1000-PCLK)) - { - pll = (pll & ~0x3ff3f)|((pll&0x3f)+start); - ctrl = ctrl&~(0x1f<<26)|(div<<26)|(1<<31); - } - else - { - pll = (pll & ~0x3ff3f)|((pll&0x3f)+end); - ctrl = ctrl&~(0x1f<<26)|((div+1)<<26)|(1<<31); - } - } - - rt_kprintf("new pll=0x%x, ctrl=0x%x\n", pll, ctrl); - ctrl |= 0x2a00; - PLL_DIV_PARAM = ctrl; - PLL_FREQ = pll; - rt_thread_delay(10); -// initserial(0); -// _probe_frequencies(); -// rt_kprintf("cpu freq is %d\n",tgt_pipefreq()); - return 0; -} - -static rt_err_t rt_dc_init(rt_device_t dev) -{ - int i, out, mode=-1; - int val; - - for (i=0; i<sizeof(vga_mode)/sizeof(struct vga_struct); i++) - { - if (vga_mode[i].hr == FB_XSIZE && vga_mode[i].vr == FB_YSIZE) - { - mode=i; -#ifdef LS1FSOC -// out = caclulatefreq(APB_CLK/1000,vga_mode[i].pclk); -// rt_kprintf("out=%x\n",out); - /*inner gpu dc logic fifo pll ctrl,must large then outclk*/ -// *(volatile int *)0xbfd00414 = out+1; - /*output pix1 clock pll ctrl*/ -// *(volatile int *)0xbfd00410 = out; - /*output pix2 clock pll ctrl */ -// *(volatile int *)0xbfd00424 = out; -#else - caclulate_freq(APB_CLK/1000, vga_mode[i].pclk); -#endif - break; - } - } - - if (mode<0) - { - rt_kprintf("\n\n\nunsupported framebuffer resolution\n\n\n"); - return; - } - - DC_FB_CONFIG = 0x0; - DC_FB_CONFIG = 0x3; // // framebuffer configuration RGB565 - DC_FB_BUFFER_ADDR0 = (rt_uint32_t)_rt_framebuffer - 0x80000000; - DC_FB_BUFFER_ADDR1 = (rt_uint32_t)_rt_framebuffer - 0x80000000; - DC_DITHER_CONFIG = 0x0; - DC_DITHER_TABLE_LOW = 0x0; - DC_DITHER_TABLE_HIGH = 0x0; - DC_PANEL_CONFIG = 0x80001311; - DC_PANEL_TIMING = 0x0; - - DC_HDISPLAY = (vga_mode[mode].hfl<<16) | vga_mode[mode].hr; - DC_HSYNC = 0x40000000 | (vga_mode[mode].hse<<16) | vga_mode[mode].hss; - DC_VDISPLAY = (vga_mode[mode].vfl<<16) | vga_mode[mode].vr; - DC_VSYNC = 0x40000000 | (vga_mode[mode].vse<<16) | vga_mode[mode].vss; - -#if defined(CONFIG_VIDEO_32BPP) - DC_FB_CONFIG = 0x00100104; - DC_FB_BUFFER_STRIDE = FB_XSIZE*4; -#elif defined(CONFIG_VIDEO_16BPP) - DC_FB_CONFIG = 0x00100103; - DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255); -#elif defined(CONFIG_VIDEO_15BPP) - DC_FB_CONFIG = 0x00100102; - DC_FB_BUFFER_STRIDE = FB_XSIZE*2; -#elif defined(CONFIG_VIDEO_12BPP) - DC_FB_CONFIG = 0x00100101; - DC_FB_BUFFER_STRIDE = FB_XSIZE*2; -#else //640x480-32Bits - DC_FB_CONFIG = 0x00100104; - DC_FB_BUFFER_STRIDE = FB_XSIZE*4; -#endif //32Bits - -#ifdef LS1GSOC - /*fix ls1g dc - *first switch to tile mode - *change origin register to 0 - *goback nomal mode - */ - { - val = DC_FB_CONFIG; - DC_FB_CONFIG = val | 0x10; - DC_FB_BUFFER_ORIGIN = 0; - DC_FB_BUFFER_ORIGIN; - rt_thread_delay(10); - DC_FB_CONFIG; - DC_FB_CONFIG = val; - } -#endif - - return RT_EOK; -} - -static rt_err_t rt_dc_control(rt_device_t dev, rt_uint8_t cmd, void *args) -{ - switch (cmd) - { - case RTGRAPHIC_CTRL_RECT_UPDATE: - break; - case RTGRAPHIC_CTRL_POWERON: - break; - case RTGRAPHIC_CTRL_POWEROFF: - break; - case RTGRAPHIC_CTRL_GET_INFO: - rt_memcpy(args, &_dc_info, sizeof(_dc_info)); - break; - case RTGRAPHIC_CTRL_SET_MODE: - break; - } - - return RT_EOK; -} - -void rt_hw_dc_init(void) -{ - rt_device_t dc = rt_malloc(sizeof(struct rt_device)); - if (dc == RT_NULL) - { - rt_kprintf("dc == RT_NULL\n"); - return; /* no memory yet */ - } - - _dc_info.bits_per_pixel = 16; - _dc_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565P; - _dc_info.framebuffer = (rt_uint8_t*)HW_FB_ADDR; - _dc_info.width = FB_XSIZE; - _dc_info.height = FB_YSIZE; - - /* init device structure */ - dc->type = RT_Device_Class_Graphic; - dc->init = rt_dc_init; - dc->open = RT_NULL; - dc->close = RT_NULL; - dc->control = rt_dc_control; - dc->user_data = (void*)&_dc_info; - - /* register Display Controller device to RT-Thread */ - rt_device_register(dc, "dc", RT_DEVICE_FLAG_RDWR); -} diff --git a/bsp/ls1cdev/drivers/display_controller.h b/bsp/ls1cdev/drivers/display_controller.h deleted file mode 100644 index 6ea1657037..0000000000 --- a/bsp/ls1cdev/drivers/display_controller.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * File : display_controller.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006-2012, RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2011-08-08 lgnq first version for LS1B - * 2015-07-06 chinesebear modified for loongson 1c - */ - -#ifndef __DISPLAY_CONTROLLER_H__ -#define __DISPLAY_CONTROLLER_H__ - -#include <rtthread.h> -#include "ls1c.h" - -#define DC_BASE 0xBC301240 //Display Controller - -/* Frame Buffer registers */ -#define DC_FB_CONFIG __REG32(DC_BASE + 0x000) -#define DC_FB_BUFFER_ADDR0 __REG32(DC_BASE + 0x020) -#define DC_FB_BUFFER_STRIDE __REG32(DC_BASE + 0x040) -#define DC_FB_BUFFER_ORIGIN __REG32(DC_BASE + 0x060) -#define DC_DITHER_CONFIG __REG32(DC_BASE + 0x120) -#define DC_DITHER_TABLE_LOW __REG32(DC_BASE + 0x140) -#define DC_DITHER_TABLE_HIGH __REG32(DC_BASE + 0x160) -#define DC_PANEL_CONFIG __REG32(DC_BASE + 0x180) -#define DC_PANEL_TIMING __REG32(DC_BASE + 0x1A0) -#define DC_HDISPLAY __REG32(DC_BASE + 0x1C0) -#define DC_HSYNC __REG32(DC_BASE + 0x1E0) -#define DC_VDISPLAY __REG32(DC_BASE + 0x240) -#define DC_VSYNC __REG32(DC_BASE + 0x260) -#define DC_FB_BUFFER_ADDR1 __REG32(DC_BASE + 0x340) - -/* Display Controller driver for 1024x768 16bit */ -#define FB_XSIZE 1024 -#define FB_YSIZE 768 -#define CONFIG_VIDEO_16BPP - -#define APB_CLK 33333333 - -#define K1BASE 0xA0000000 -#define KSEG1(addr) ((void *)(K1BASE | (rt_uint32_t)(addr))) -#define HW_FB_ADDR KSEG1(_rt_framebuffer) -#define HW_FB_PIXEL(x, y) *(volatile rt_uint16_t*)((rt_uint8_t*)HW_FB_ADDR + (y * FB_XSIZE * 2) + x * 2) - -struct vga_struct -{ - long pclk; - int hr,hss,hse,hfl; - int vr,vss,vse,vfl; -}; - -#endif diff --git a/bsp/ls1cdev/rtconfig.h b/bsp/ls1cdev/rtconfig.h index 6c021a44dc..d6fed266e6 100644 --- a/bsp/ls1cdev/rtconfig.h +++ b/bsp/ls1cdev/rtconfig.h @@ -23,6 +23,8 @@ #define RT_USING_OVERFLOW_CHECK // <bool name="RT_USING_INTERRUPT_INFO" description="Show more interrupt description" default="true" /> #define RT_USING_INTERRUPT_INFO +// <integer name="IDLE_THREAD_STACK_SIZE" description="The stack size of idle thread" default="1024" /> +#define IDLE_THREAD_STACK_SIZE 1024 // </section> // <bool name="RT_USING_HOOK" description="Using hook functions" default="true" /> @@ -91,15 +93,16 @@ #define FINSH_USING_DESCRIPTION // <integer name="FINSH_THREAD_STACK_SIZE" description="The stack size for finsh thread" default="4096" /> #define FINSH_THREAD_STACK_SIZE 4096 +// <bool name="FINSH_USING_MSH" description="Using module shell" default="true" /> +#define FINSH_USING_MSH +// <bool name="FINSH_USING_MSH_DEFAULT" description="Using module shell as the default shell" default="true" /> +#define FINSH_USING_MSH_DEFAULT // </section> - // <section name="LIBC" description="C Runtime library setting" default="always" > #define RT_USING_LIBC -// <bool name="RT_USING_NEWLIB" description="Using newlib library, only available under GNU GCC" default="true" /> -// #define RT_USING_NEWLIB // <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" /> -// #define RT_USING_PTHREADS +#define RT_USING_PTHREADS // </section> // <section name="RT_USING_DFS" description="Device file system" default="true" > diff --git a/bsp/simulator/.gitignore b/bsp/simulator/.gitignore new file mode 100644 index 0000000000..fef6f4cbc8 --- /dev/null +++ b/bsp/simulator/.gitignore @@ -0,0 +1,47 @@ +# Object files +*.o +*.ko +*.mo +*.d +*.crf +*.lst + +# Libraries +*.lib +*.a + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib +*.pyc + +# Executables +*.exe +*.out +*.app +*.elf +*.axf +*.bin +*.hex + +# Intermediate file +*.bak +*.swp +*.map +*.dblite +*.dep +*.lnp +*.uvgui.* +*.build_log.* +build + +Debug +_UpgradeReport_Files +*.ncb +*.suo +*.exp +*.XML +*.user +*.def diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct index 760002d80d..4283082d04 100755 --- a/bsp/simulator/SConstruct +++ b/bsp/simulator/SConstruct @@ -88,7 +88,7 @@ def ObjRemove(objs, remove): # build program -shared if GetDepend('RT_USING_MODULE'): # Remove module.c in $RTT_ROOT/src - ObjRemove(objs, ['module.obj', 'module.o']) + ObjRemove(objs, ['module.obj', 'module.o', 'module.c']) AddOption('--def', dest='def', @@ -99,7 +99,7 @@ if GetDepend('RT_USING_MODULE'): if rtconfig.PLATFORM == 'mingw': env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS else: - rtconfig.POST_ACTION = 'createdef.py $TARGET rtthread.def' + rtconfig.POST_ACTION = 'python createdef.py $TARGET rtthread.def' program = env.Program(TARGET, objs) else: diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c index a01e8d91b7..df34aa87c9 100755 --- a/bsp/simulator/applications/application.c +++ b/bsp/simulator/applications/application.c @@ -1,11 +1,21 @@ /* * File : application.c * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes @@ -16,154 +26,15 @@ #include <stdio.h> #include <board.h> -#ifdef RT_USING_FINSH -#include <finsh.h> -#include <shell.h> -#endif - -#ifdef RT_USING_LWIP -#include <lwip/sys.h> -#include <netif/ethernetif.h> -extern void lwip_system_init(void); -#endif - #ifdef RT_USING_DFS -#include <dfs_init.h> #include <dfs_fs.h> -#ifdef RT_USING_DFS_ELMFAT -#include <dfs_elm.h> -#endif -#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) -#include <dfs_nfs.h> -#endif -#ifdef RT_USING_DFS_ROMFS -#include <dfs_romfs.h> -#endif -#ifdef RT_USING_DFS_DEVFS -#include <devfs.h> -#endif -#ifdef RT_USING_DFS_UFFS -#include <dfs_uffs.h> -#endif -#ifdef RT_USING_DFS_JFFS2 -#include <dfs_jffs2.h> -#endif -#ifdef RT_USING_DFS_YAFFS2 -#include <dfs_yaffs2.h> -#endif -#ifdef RT_USING_DFS_ROMFS -#include <dfs_romfs.h> -#endif #endif -#ifdef RT_USING_NEWLIB -#include <libc.h> -#endif -#ifdef RT_USING_PTHREADS -#include <pthread.h> -#endif - -#ifdef RT_USING_MODULE -#include <rtm.h> -#endif - -#ifdef RT_USING_RTGUI -#include <rtgui/rtgui_system.h> -#endif +#include "init.h" void rt_init_thread_entry(void *parameter) { -#ifdef RT_USING_LWIP -#ifdef RT_USING_TAPNETIF - tap_netif_hw_init(); -#else - pcap_netif_hw_init(); -#endif -#endif - - rt_platform_init(); - -#ifdef RT_USING_MODULE - rt_system_module_init(); -#endif - -#ifdef RT_USING_FINSH - /* initialize finsh */ - finsh_system_init(); - finsh_set_device(RT_CONSOLE_DEVICE_NAME); -#endif - -#ifdef RT_USING_LWIP - /* initialize lwip stack */ - /* register ethernetif device */ - eth_system_device_init(); - - /* initialize lwip system */ - lwip_system_init(); - rt_kprintf("TCP/IP initialized!\n"); -#endif - -#ifdef RT_USING_DFS - /* initialize the device file system */ - dfs_init(); - -#ifdef RT_USING_DFS_ELMFAT - /* initialize the elm chan FatFS file system*/ - elm_init(); -#endif - -#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) - /* initialize NFSv3 client file system */ - nfs_init(); -#endif - -#ifdef RT_USING_DFS_YAFFS2 - dfs_yaffs2_init(); -#endif - -#ifdef RT_USING_DFS_UFFS - dfs_uffs_init(); -#endif - -#ifdef RT_USING_DFS_JFFS2 - dfs_jffs2_init(); -#endif - -#ifdef RT_USING_DFS_ROMFS - dfs_romfs_init(); -#endif - -#ifdef RT_USING_DFS_RAMFS - dfs_ramfs_init(); -#endif - -#ifdef RT_USING_DFS_DEVFS - devfs_init(); -#endif -#endif /* end of RT_USING_DFS */ - -#ifdef RT_USING_NEWLIB - libc_system_init(RT_CONSOLE_DEVICE_NAME); -#else - /* the pthread system initialization will be initiallized in libc */ -#ifdef RT_USING_PTHREADS - pthread_system_init(); -#endif -#endif - -#ifdef RT_USING_RTGUI - rtgui_system_server_init(); -#endif - -#ifdef RT_USING_USB_HOST - rt_usb_host_init(); -#endif - -#ifdef RT_USING_RTGUI - /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be - * called after rt_components_init. */ - rt_hw_sdl_start(); -#endif /* RT_USING_RTGUI */ + components_init(); /* File system Initialization */ #ifdef RT_USING_DFS @@ -228,5 +99,3 @@ int rt_application_init() return 0; } - -/*@}*/
\ No newline at end of file diff --git a/bsp/simulator/applications/init.c b/bsp/simulator/applications/init.c new file mode 100644 index 0000000000..b78deefe71 --- /dev/null +++ b/bsp/simulator/applications/init.c @@ -0,0 +1,170 @@ +/* + * File : init.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2015-09-30 Bernard the first version + */ + +#include <rtthread.h> + +#include "init.h" + +#ifdef RT_USING_FINSH +#include <finsh.h> +#include <shell.h> +#endif + +#ifdef RT_USING_LWIP +#include <lwip/sys.h> +#include <netif/ethernetif.h> +extern void lwip_system_init(void); +#endif + +#ifdef RT_USING_DFS +#include <dfs_init.h> +#include <dfs_fs.h> +#ifdef RT_USING_DFS_ELMFAT +#include <dfs_elm.h> +#endif +#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) +#include <dfs_nfs.h> +#endif +#ifdef RT_USING_DFS_ROMFS +#include <dfs_romfs.h> +#endif +#ifdef RT_USING_DFS_DEVFS +#include <devfs.h> +#endif +#ifdef RT_USING_DFS_UFFS +#include <dfs_uffs.h> +#endif +#ifdef RT_USING_DFS_JFFS2 +#include <dfs_jffs2.h> +#endif +#ifdef RT_USING_DFS_YAFFS2 +#include <dfs_yaffs2.h> +#endif +#ifdef RT_USING_DFS_ROMFS +#include <dfs_romfs.h> +#endif +#endif + +#ifdef RT_USING_NEWLIB +#include <libc.h> +#endif +#ifdef RT_USING_PTHREADS +#include <pthread.h> +#endif + +#ifdef RT_USING_MODULE +#include <rtm.h> +#endif + +#ifdef RT_USING_RTGUI +#include <rtgui/rtgui_system.h> +#endif + +/* components initialization for simulator */ +void components_init(void) +{ + platform_init(); + +#ifdef RT_USING_MODULE + rt_system_module_init(); +#endif + +#ifdef RT_USING_FINSH + /* initialize finsh */ + finsh_system_init(); + finsh_set_device(RT_CONSOLE_DEVICE_NAME); +#endif + +#ifdef RT_USING_LWIP + /* initialize lwip stack */ + /* register ethernetif device */ + eth_system_device_init(); + + /* initialize lwip system */ + lwip_system_init(); + rt_kprintf("TCP/IP initialized!\n"); +#endif + +#ifdef RT_USING_DFS + /* initialize the device file system */ + dfs_init(); + +#ifdef RT_USING_DFS_ELMFAT + /* initialize the elm chan FatFS file system*/ + elm_init(); +#endif + +#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) + /* initialize NFSv3 client file system */ + nfs_init(); +#endif + +#ifdef RT_USING_DFS_YAFFS2 + dfs_yaffs2_init(); +#endif + +#ifdef RT_USING_DFS_UFFS + dfs_uffs_init(); +#endif + +#ifdef RT_USING_DFS_JFFS2 + dfs_jffs2_init(); +#endif + +#ifdef RT_USING_DFS_ROMFS + dfs_romfs_init(); +#endif + +#ifdef RT_USING_DFS_RAMFS + dfs_ramfs_init(); +#endif + +#ifdef RT_USING_DFS_DEVFS + devfs_init(); +#endif +#endif /* end of RT_USING_DFS */ + +#ifdef RT_USING_NEWLIB + libc_system_init(RT_CONSOLE_DEVICE_NAME); +#else + /* the pthread system initialization will be initiallized in libc */ +#ifdef RT_USING_PTHREADS + pthread_system_init(); +#endif +#endif + +#ifdef RT_USING_RTGUI + rtgui_system_server_init(); +#endif + +#ifdef RT_USING_USB_HOST + rt_usb_host_init(); +#endif + +#ifdef RT_USING_RTGUI + /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be + * called after rt_components_init. */ + rt_hw_sdl_start(); +#endif /* RT_USING_RTGUI */ +} diff --git a/bsp/simulator/applications/init.h b/bsp/simulator/applications/init.h new file mode 100644 index 0000000000..ae8c838e1e --- /dev/null +++ b/bsp/simulator/applications/init.h @@ -0,0 +1,31 @@ +/* + * File : init.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2015-09-30 Bernard the first version + */ + +#ifndef INIT_H__ +#define INIT_H__ + +void platform_init(void); +void components_init(void); + +#endif diff --git a/bsp/simulator/applications/platform.c b/bsp/simulator/applications/platform.c index fbc1003d2a..229c507c9a 100644 --- a/bsp/simulator/applications/platform.c +++ b/bsp/simulator/applications/platform.c @@ -1,8 +1,16 @@ #include <rtthread.h> #include "board.h" -void rt_platform_init(void) +void platform_init(void) { +#ifdef RT_USING_LWIP +#ifdef RT_USING_TAPNETIF + tap_netif_hw_init(); +#else + pcap_netif_hw_init(); +#endif +#endif + #ifdef RT_USING_DFS /* initialize sd card */ rt_hw_sdcard_init(); @@ -16,9 +24,5 @@ void rt_platform_init(void) #endif #endif /* RT_USING_DFS */ - -#ifdef _WIN32 - rt_thread_idle_sethook(rt_hw_win32_low_cpu); -#endif } diff --git a/bsp/simulator/drivers/board.c b/bsp/simulator/drivers/board.c index dcb8d9a049..4e498395c9 100755 --- a/bsp/simulator/drivers/board.c +++ b/bsp/simulator/drivers/board.c @@ -14,9 +14,12 @@ #include <rthw.h> #include <rtthread.h> -#include "board.h" + #include <stdlib.h> +#include "board.h" +#include "uart_console.h" + /** * @addtogroup simulator on win32 */ @@ -93,9 +96,11 @@ void rt_hw_board_init() /* init system memory */ heap = rt_hw_sram_init(); -//#if defined(RT_USING_USART) - rt_hw_usart_init(); -//#endif + uart_console_init(); + +#ifdef _WIN32 + rt_thread_idle_sethook(rt_hw_win32_low_cpu); +#endif #if defined(RT_USING_CONSOLE) rt_console_set_device(RT_CONSOLE_DEVICE_NAME); diff --git a/bsp/simulator/drivers/dfs_win32.c b/bsp/simulator/drivers/dfs_win32.c index 8d6e7b0305..a0ebcf5e6e 100644 --- a/bsp/simulator/drivers/dfs_win32.c +++ b/bsp/simulator/drivers/dfs_win32.c @@ -505,8 +505,6 @@ static int dfs_win32_stat(struct dfs_filesystem *fs, const char *path, struct st st->st_mtime = time_tmp.QuadPart; } - st->st_blksize = 0; - FindClose(hFind); return 0; diff --git a/bsp/simulator/drivers/module_win32.c b/bsp/simulator/drivers/module_win32.c index 3f0a273746..0c998eed2c 100644 --- a/bsp/simulator/drivers/module_win32.c +++ b/bsp/simulator/drivers/module_win32.c @@ -17,7 +17,7 @@ #include <rtm.h> #ifdef RT_USING_MODULE -static void rt_module_init_object_container(struct rt_module *module) +void rt_module_init_object_container(struct rt_module *module) { RT_ASSERT(module != RT_NULL); @@ -130,6 +130,7 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module)) */ int rt_system_module_init(void) { + return 0; } /** @@ -148,6 +149,7 @@ rt_module_t rt_module_self(void) /* return current module */ return (rt_module_t)tid->module_id; } +RTM_EXPORT(rt_module_self); /** * This function will find the specified module. @@ -191,6 +193,7 @@ rt_module_t rt_module_find(const char *name) /* not found */ return RT_NULL; } +RTM_EXPORT(rt_module_find); #ifdef RT_USING_DFS #include <windows.h> @@ -237,10 +240,10 @@ rt_module_t rt_module_open(const char *path) struct dfs_filesystem *fs; appentry_t fptr; HINSTANCE hinstlib; - int len; - char * winpath; - rt_module_t module; - char * name; + rt_module_t module; + + char * winpath = RT_NULL; + char * name = RT_NULL; RT_DEBUG_NOT_IN_INTERRUPT; @@ -256,10 +259,10 @@ rt_module_t rt_module_open(const char *path) } /* change path */ - len = strlen(path+1); + // len = strlen(path+1); if ((winpath = dfs_win32_dirdup((char *)path)) == RT_NULL) { - rt_kprintf("out of memory, exit", path); + rt_kprintf("out of memory, exit"); return RT_NULL; } @@ -282,10 +285,8 @@ rt_module_t rt_module_open(const char *path) name = _module_name(path); /* allocate module */ - module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, - name); - if (!module) - return RT_NULL; + module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name); + if (!module) return RT_NULL; module->nref = 0; module->module_entry = fptr; @@ -298,31 +299,21 @@ rt_module_t rt_module_open(const char *path) if (module->module_entry != 0) { - rt_uint32_t *stack_size; - rt_uint8_t *priority; - #ifdef RT_USING_SLAB /* init module memory allocator */ module->mem_list = RT_NULL; /* create page array */ - module->page_array = + module->page_array = (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info)); module->page_cnt = 0; #endif - /* get the main thread stack size */ - module->stack_size = 2048; - module->thread_priority = RT_THREAD_PRIORITY_MAX - 2; - /* create module thread */ module->module_thread = rt_thread_create(name, - (void(*)(void *))module->module_entry, - RT_NULL, - module->stack_size, - module->thread_priority, - 10); + (void(*)(void *))module->module_entry, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX - 2, 10); RT_DEBUG_LOG(RT_DEBUG_MODULE, ("thread entry 0x%x\n", module->module_entry)); @@ -354,14 +345,220 @@ rt_module_t rt_module_open(const char *path) #if defined(RT_USING_FINSH) #include <finsh.h> - FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from a file); #endif #endif +#define RT_MODULE_ARG_MAX 8 +static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[]) +{ + int argc = 0; + char *ptr = cmd; + + while ((ptr - cmd) < length) + { + /* strip bank and tab */ + while ((*ptr == ' ' || *ptr == '\t') && (ptr -cmd)< length) + *ptr++ = '\0'; + /* check whether it's the end of line */ + if ((ptr - cmd)>= length) break; + + /* handle string with quote */ + if (*ptr == '"') + { + argv[argc++] = ++ptr; + + /* skip this string */ + while (*ptr != '"' && (ptr-cmd) < length) + if (*ptr ++ == '\\') ptr ++; + if ((ptr - cmd) >= length) break; + + /* skip '"' */ + *ptr ++ = '\0'; + } + else + { + argv[argc++] = ptr; + while ((*ptr != ' ' && *ptr != '\t') && (ptr - cmd) < length) + ptr ++; + } + + if (argc >= RT_MODULE_ARG_MAX) break; + } + + return argc; +} + +/* module main thread entry */ +static void module_main_entry(void* parameter) +{ + int argc; + char *argv[RT_MODULE_ARG_MAX]; + typedef int (*main_func_t)(int argc, char** argv); + + rt_module_t module = (rt_module_t) parameter; + if (module == RT_NULL || module->module_cmd_line == RT_NULL) return; + + rt_memset(argv, 0x00, sizeof(argv)); + argc = _rt_module_split_arg((char*)module->module_cmd_line, module->module_cmd_size, argv); + if (argc == 0) return ; + + /* do the main function */ + ((main_func_t)module->module_entry)(argc, argv); + return; +} + +/** + * This function will do a executable program with main function and parameters. + * + * @param path the full path of application module + * @param cmd_line the command line of program + * @param size the size of command line of program + * + * @return the module object + */ +rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_size) +{ + struct dfs_filesystem *fs; + appentry_t fptr; + HINSTANCE hinstlib; + rt_module_t module; + + char * winpath = RT_NULL; + char * name = RT_NULL; + char *full_path = RT_NULL; + + RT_DEBUG_NOT_IN_INTERRUPT; + + /* check parameters */ + RT_ASSERT(path != RT_NULL); + + if (*path != '/') + { + full_path = dfs_normalize_path(RT_NULL, path); + } + else + { + full_path = (const char*)path; + } + + /* app module should only in DFS_WIN32 */ + fs = dfs_filesystem_lookup(full_path); + if ((fs == RT_NULL) || (strcmp(fs->ops->name,"wdir") != 0)) + { + rt_kprintf("invalid path: %s\n", path); + goto __exit; + } + + /* change path */ + // len = strlen(full_path + 1); + if ((winpath = dfs_win32_dirdup((char *)full_path)) == RT_NULL) + { + rt_kprintf("out of memory, exit", path); + goto __exit; + } + + hinstlib = LoadLibrary(winpath); + if (hinstlib == NULL) + { + rt_kprintf("error: unable to open %s\n", winpath); + goto __exit; + } + + fptr = (appentry_t)GetProcAddress(hinstlib, "main"); + if (fptr == NULL) + { + rt_kprintf("error: unable to find function in %s\n", winpath); + FreeLibrary(hinstlib); + goto __exit; + } + + /* release winpath */ + rt_free(winpath); + + /* get the name of the module */ + name = _module_name(path); + + /* allocate module */ + module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name); + if (!module) + { + goto __exit; + } + + module->nref = 0; + module->module_entry = fptr; + + /* init module object container */ + rt_module_init_object_container(module); + + /* increase module reference count */ + module->nref ++; + + if (module->module_entry != 0) + { + /* set module argument */ + module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1); + rt_memcpy(module->module_cmd_line, cmd_line, line_size); + module->module_cmd_line[line_size] = '\0'; + module->module_cmd_size = line_size; + +#ifdef RT_USING_SLAB + /* init module memory allocator */ + module->mem_list = RT_NULL; + + /* create page array */ + module->page_array = + (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info)); + module->page_cnt = 0; +#endif + + /* create module thread */ + module->module_thread = rt_thread_create(name, + module_main_entry, module, + 2048, RT_THREAD_PRIORITY_MAX - 2, 10); + + /* set module id */ + module->module_thread->module_id = (void *)module; + module->parent.flag = RT_MODULE_FLAG_WITHENTRY; + + /* startup module thread */ + rt_thread_startup(module->module_thread); + } + else + { + /* without entry point */ + module->parent.flag |= RT_MODULE_FLAG_WITHOUTENTRY; + } + +#ifdef RT_USING_HOOK + if (rt_module_load_hook != RT_NULL) + { + rt_module_load_hook(module); + } +#endif + + rt_free(name); + return module; + +__exit: + if (full_path != path) rt_free(full_path); + if (name != RT_NULL) rt_free(full_path); + if (winpath != RT_NULL)rt_free(winpath); + + return RT_NULL; + /* FreeLibrary(hinstlib); */ +} + rt_err_t rt_module_destroy(rt_module_t module) { return 0; } + +rt_err_t rt_module_unload(rt_module_t module) +{ + return 0; +} + #endif diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index b3b265273d..de0dd7cf30 100755 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -9,7 +9,6 @@ // #define SD_TRACE rt_kprintf #define SD_TRACE(...) -//#define SDCARD_SIM "F:\\Project\\tools\\SDCARD" #define SDCARD_SIM "sd.bin" #define SDCARD_SIZE (16*1024*1024) //16M diff --git a/bsp/simulator/drivers/serial.c b/bsp/simulator/drivers/serial.c deleted file mode 100755 index 72cbad3baf..0000000000 --- a/bsp/simulator/drivers/serial.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * File : serial.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2013 RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2009-02-05 Bernard first version - * 2009-10-25 Bernard fix rt_serial_read bug when there is no data - * in the buffer. - * 2010-03-29 Bernard cleanup code. - * 2013-02-7 prife rewrite for simulator - */ - -#include <rthw.h> - -#include "serial.h" -#include <stdio.h> - -#if 0 -static FILE *fp = RT_NULL; -#endif - -/*@{*/ -int seial_save_byte(unsigned char ch, struct serial_device * serial) -{ - /* save on rx buffer */ - rt_base_t level; - struct rt_device * dev = RT_DEVICE(serial); - /* disable interrupt */ - //��ʱ�ر��жϣ���ΪҪ����uart���ݽṹ - level = rt_hw_interrupt_disable(); - - /* save character */ - serial->serial_rx.rx_buffer[serial->serial_rx.save_index] = ch; - serial->serial_rx.save_index ++; - //����Ĵ�����save_index�Ƿ��Ѿ�����������β������������ת��ͷ������Ϊһ�����λ����� - if (serial->serial_rx.save_index >= SERIAL_RX_BUFFER_SIZE) - serial->serial_rx.save_index = 0; - - //���������ʾ��ת���save_index����read_index��������read_index������һ���ɵ����� - /* if the next position is read index, discard this 'read char' */ - if (serial->serial_rx.save_index == serial->serial_rx.read_index) - { - serial->serial_rx.read_index ++; - if (serial->serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE) - serial->serial_rx.read_index = 0; - } - - /* enable interrupt */ - //uart���ݽṹ�Ѿ�������ɣ�����ʹ���ж� - rt_hw_interrupt_enable(level); - - /* invoke callback */ - if (dev->rx_indicate != RT_NULL) - { - rt_size_t rx_length; - - /* get rx length */ - rx_length = serial->serial_rx.read_index > serial->serial_rx.save_index ? - SERIAL_RX_BUFFER_SIZE - serial->serial_rx.read_index + serial->serial_rx.save_index : - serial->serial_rx.save_index - serial->serial_rx.read_index; - - dev->rx_indicate(dev, rx_length); - } - return 0; -} - -/* RT-Thread Device Interface */ -/** - * This function initializes serial - */ -static rt_err_t rt_serial_init(rt_device_t dev) -{ - struct serial_device * serial = SERIAL_DEVICE(dev); - if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED)) - { - if (dev->flag & RT_DEVICE_FLAG_INT_RX) - { - rt_memset(serial->serial_rx.rx_buffer, 0, - sizeof(serial->serial_rx.rx_buffer)); - serial->serial_rx.read_index = 0; - serial->serial_rx.save_index = 0; - } - - dev->flag |= RT_DEVICE_FLAG_ACTIVATED; - } - return RT_EOK; -} - -static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag) -{ - return RT_EOK; -} - -static rt_err_t rt_serial_close(rt_device_t dev) -{ - return RT_EOK; -} -static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) -{ - rt_uint8_t *ptr; - rt_err_t err_code; - struct serial_device * serial = SERIAL_DEVICE(dev); - - ptr = buffer; - err_code = RT_EOK; - - if (dev->flag & RT_DEVICE_FLAG_INT_RX) - { - /* interrupt mode Rx */ - while (size) - { - rt_base_t level; - - /* disable interrupt */ - level = rt_hw_interrupt_disable(); - - if (serial->serial_rx.read_index != serial->serial_rx.save_index) - { - /* read a character */ - *ptr++ = serial->serial_rx.rx_buffer[serial->serial_rx.read_index]; - size--; - - /* move to next position */ - serial->serial_rx.read_index ++; - if (serial->serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE) - serial->serial_rx.read_index = 0; - } - else - { - /* set error code */ - err_code = -RT_EEMPTY; - - /* enable interrupt */ - rt_hw_interrupt_enable(level); - break; - } - - /* enable interrupt */ - rt_hw_interrupt_enable(level); - } - } - - - /* set error code */ - rt_set_errno(err_code); - return (rt_uint32_t)ptr - (rt_uint32_t)buffer; -} - -static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size) -{ - int level; -#if 0 - if (fp == NULL) - fp = fopen("log.txt", "wb+"); - - if (fp != NULL) - fwrite(buffer, size, 1, fp); -#endif - - level = rt_hw_interrupt_disable(); - fwrite(buffer, size, 1, stdout); - fflush(stdout); - rt_hw_interrupt_enable(level); - return size; -} - -static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args) -{ - RT_ASSERT(dev != RT_NULL); - - switch (cmd) - { - case RT_DEVICE_CTRL_SUSPEND: - /* suspend device */ - dev->flag |= RT_DEVICE_FLAG_SUSPENDED; - break; - - case RT_DEVICE_CTRL_RESUME: - /* resume device */ - dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED; - break; - } - - return RT_EOK; -} - -/* - * serial register - */ -rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_uint32_t flag) -{ - RT_ASSERT(device != RT_NULL); - device->type = RT_Device_Class_Char; - device->rx_indicate = RT_NULL; - device->tx_complete = RT_NULL; - device->init = rt_serial_init; - device->open = rt_serial_open; - device->close = rt_serial_close; - device->read = rt_serial_read; - device->write = rt_serial_write; - device->control = rt_serial_control; - device->user_data = RT_NULL; - - /* register a character device */ - return rt_device_register(device, name, (rt_uint16_t)(RT_DEVICE_FLAG_RDWR | flag)); -} - -rt_err_t rt_hw_serial_init(struct serial_device * serial, char * name) -{ - return rt_hw_serial_register(RT_DEVICE(serial), name, - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM); -} diff --git a/bsp/simulator/drivers/serial.h b/bsp/simulator/drivers/serial.h deleted file mode 100644 index 7c554c3f45..0000000000 --- a/bsp/simulator/drivers/serial.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -********************************************************************************************************* -* MC9S12DP256/DG128 Specific code -* BANKED MEMORY MODEL -* -* File : rthw.c -* By : parai -* email:[email protected] -*******************************************************************************************************/ - -#ifndef __RT_HW_SERIAL_H__ -#define __RT_HW_SERIAL_H__ - -#include <rtdevice.h> -#define SERIAL_RX_BUFFER_SIZE 80 -struct serial_int_rx -{ - rt_uint8_t rx_buffer[SERIAL_RX_BUFFER_SIZE]; - rt_uint32_t read_index, save_index; -}; - -struct serial_device -{ - struct rt_device dev; - struct serial_int_rx serial_rx; -}; - -#define SERIAL_DEVICE(dev) ((struct serial_device *)(dev)) - -int seial_save_byte(unsigned char ch, struct serial_device * serial); -rt_err_t rt_hw_serial_init(struct serial_device * serial, char * name); -#endif diff --git a/bsp/simulator/drivers/usart_sim.c b/bsp/simulator/drivers/uart_console.c index 6c8209dcc0..913daf2311 100755..100644 --- a/bsp/simulator/drivers/usart_sim.c +++ b/bsp/simulator/drivers/uart_console.c @@ -1,34 +1,27 @@ -/* - * File : serial.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2013 RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2012-09-25 prife first implementation - * 2013-01-15 prife support linux - * 2013-02-6 prife rewrite to fit the new serial.c - */ -#include <rthw.h> -#include <rtthread.h> +#include <stdio.h> + +#include <rthw.h> +#include <rtdevice.h> +#include <rtthread.h> +#include <rtdevice.h> + +/* uart driver */ +struct console_uart +{ + int rx_ready; + + struct rt_ringbuffer rb; + rt_uint8_t rx_buffer[256]; +} _console_uart; +static struct rt_serial_device _serial; + +#define SAVEKEY(key) do { char ch = key; rt_ringbuffer_put_force(&(_console_uart.rb), &ch, 1); } while (0) #ifdef _WIN32 #include <windows.h> #include <mmsystem.h> #include <conio.h> -#endif -#include <stdio.h> -#include "serial.h" - -struct serial_device serial1; - -#define SAVEKEY(key) seial_save_byte(key, &serial1) -#ifdef _WIN32 /* * Handler for OSKey Thread */ @@ -36,9 +29,8 @@ static HANDLE OSKey_Thread; static DWORD OSKey_ThreadID; static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam); -void rt_hw_usart_init(void) +void console_lowlevel_init(void) { - rt_hw_serial_init(&serial1, RT_CONSOLE_DEVICE_NAME); /* * create serial thread that receive key input from keyboard */ @@ -52,9 +44,9 @@ void rt_hw_usart_init(void) if (OSKey_Thread == NULL) { //Display Error Message - return; } + SetThreadPriority(OSKey_Thread, THREAD_PRIORITY_NORMAL); SetThreadPriorityBoost(OSKey_Thread, @@ -67,6 +59,7 @@ void rt_hw_usart_init(void) ResumeThread(OSKey_Thread); } +static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam) #else /* POSIX version */ #include <pthread.h> @@ -78,11 +71,11 @@ void rt_hw_usart_init(void) static void * ThreadforKeyGet(void * lpParam); static pthread_t OSKey_Thread; -void rt_hw_usart_init(void) + +void console_lowlevel_init(void) { int res; - rt_hw_serial_init(&serial1, RT_CONSOLE_DEVICE_NAME); res = pthread_create(&OSKey_Thread, NULL, &ThreadforKeyGet, NULL); if (res) { @@ -90,15 +83,10 @@ void rt_hw_usart_init(void) exit(EXIT_FAILURE); } } -#endif - -#ifdef _WIN32 -static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam) -#else static struct termios oldt, newt; /*simulate windows' getch(), it works!!*/ -void set_stty(void) +static void set_stty(void) { /* get terminal input's attribute */ tcgetattr(STDIN_FILENO, &oldt); @@ -116,15 +104,14 @@ void restore_stty(void) } #define getch getchar - static void * ThreadforKeyGet(void * lpParam) #endif /* not _WIN32*/ { /* - * �����(��)�� 0xe04b - * �����(��)�� 0xe048 - * �����(��)�� 0xe04d - * �����(��)�� 0xe050 + * left key(��)�� 0xe04b + * up key(��)�� 0xe048 + * right key(��)�� 0xe04d + * down key(��)�� 0xe050 */ unsigned char key; @@ -135,7 +122,9 @@ static void * ThreadforKeyGet(void * lpParam) pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask); set_stty(); #endif + (void)lpParam; //prevent compiler warnings + for (;;) { key = getch(); @@ -173,5 +162,109 @@ static void * ThreadforKeyGet(void * lpParam) } #endif SAVEKEY(key); + + /* Notfiy serial ISR */ + rt_hw_serial_isr(&_serial, RT_SERIAL_EVENT_RX_IND); } } /*** ThreadforKeyGet ***/ + +static rt_err_t console_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +{ + /* no baudrate, nothing */ + + return RT_EOK; +} + +static rt_err_t console_control(struct rt_serial_device *serial, int cmd, void *arg) +{ + struct console_uart* uart; + + RT_ASSERT(serial != RT_NULL); + uart = (struct console_uart *)serial->parent.user_data; + + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + uart->rx_ready = 0; + break; + case RT_DEVICE_CTRL_SET_INT: + uart->rx_ready = 1; + break; + } + + return RT_EOK; +} + +static int console_putc(struct rt_serial_device *serial, char c) +{ + int level; + struct console_uart* uart; + + RT_ASSERT(serial != RT_NULL); + uart = (struct console_uart *)serial->parent.user_data; + +#if 0 /* Enable it if you want to save the console log */ + { + static FILE* fp = NULL; + + if (fp == NULL) + fp = fopen("log.txt", "wb+"); + + if (fp != NULL) + fwrite(buffer, size, 1, fp); + } +#endif + + level = rt_hw_interrupt_disable(); + fwrite(&c, 1, 1, stdout); + fflush(stdout); + rt_hw_interrupt_enable(level); + return 1; +} + +static int console_getc(struct rt_serial_device *serial) +{ + char ch; + struct console_uart* uart; + + RT_ASSERT(serial != RT_NULL); + uart = (struct console_uart *)serial->parent.user_data; + + if (rt_ringbuffer_getchar(&(uart->rb), &ch)) return ch; + + return -1; +} + +static const struct rt_uart_ops console_uart_ops = +{ + console_configure, + console_control, + console_putc, + console_getc, +}; + +int uart_console_init(void) +{ + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; + struct console_uart* uart; + struct rt_serial_device* serial; + + uart = &_console_uart; + serial = &_serial; + + uart->rx_ready = 0; + + serial->ops = &console_uart_ops; + serial->config = config; + /* initialize ring buffer */ + rt_ringbuffer_init(&uart->rb, uart->rx_buffer, sizeof(uart->rx_buffer)); + + /* register UART device */ + rt_hw_serial_register(serial, "console", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); + + console_lowlevel_init(); + + return 0; +} diff --git a/bsp/simulator/drivers/uart_console.h b/bsp/simulator/drivers/uart_console.h new file mode 100644 index 0000000000..149a7a21f8 --- /dev/null +++ b/bsp/simulator/drivers/uart_console.h @@ -0,0 +1,6 @@ +#ifndef UART_CONSOLE_H__ +#define UART_CONSOLE_H__ + +int uart_console_init(void); + +#endif diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h index a1f877de2e..aa839f5621 100755 --- a/bsp/simulator/rtconfig.h +++ b/bsp/simulator/rtconfig.h @@ -1,237 +1,245 @@ /* RT-Thread config file */ + #ifndef __RTTHREAD_CFG_H__ #define __RTTHREAD_CFG_H__ -#define RT_HEAP_SIZE (1024*1024*2) - -#if defined(_MSC_VER) -/* SECTION: port for visual studio */ -#undef RT_USING_NEWLIB -#undef RT_USING_MINILIBC -#define NORESOURCE //RT_VESRION in winuser.h -#define _CRT_ERRNO_DEFINED //errno macro redefinition -#define _INC_WTIME_INL//dfs_elm.c time.h conflicts with wtime.inl -#define _INC_TIME_INL //dfs_elm.c time.h conflicts with wtime.inl - -/* disable some warning in MSC */ -#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ -#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */ -#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */ -#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */ -#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */ -#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */ - -#elif defined(__GNUC__) -#define RT_USING_NOLIBC - -#if defined(__MINGW32__) -#define _NO_OLDNAMES /* to ignore: mode_t in sys/type.h */ -#endif -#endif - -/* SECTION: basic kernel options */ -/* RT_NAME_MAX*/ -#define RT_NAME_MAX 8 +// <RDTConfigurator URL="http://www.rt-thread.com/eclipse"> -/* RT_ALIGN_SIZE*/ +// <integer name="RT_NAME_MAX" description="Maximal size of kernel object name length" default="6" /> +#define RT_NAME_MAX 6 +// <integer name="RT_ALIGN_SIZE" description="Alignment size for CPU architecture data access" default="4" /> #define RT_ALIGN_SIZE 4 - -/* PRIORITY_MAX */ -#define RT_THREAD_PRIORITY_MAX 32 - -/* Tick per Second */ +// <integer name="RT_THREAD_PRIORITY_MAX" description="Maximal level of thread priority" default="32"> +// <item description="8">8</item> +// <item description="32">32</item> +// <item description="256">256</item> +// </integer> +#define RT_THREAD_PRIORITY_MAX 32 +// <integer name="RT_TICK_PER_SECOND" description="OS tick per second" default="100" /> #define RT_TICK_PER_SECOND 100 - -/* SECTION: RT_DEBUG */ -/* Thread Debug */ +// <section name="RT_DEBUG" description="Kernel Debug Configuration" default="true" > #define RT_DEBUG -//#define RT_DEBUG_SCHEDULER 1 -#define RT_THREAD_DEBUG - +// <bool name="RT_THREAD_DEBUG" description="Thread debug enable" default="false" /> +// #define RT_THREAD_DEBUG +// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" /> #define RT_USING_OVERFLOW_CHECK +// </section> -/* Using Hook */ +// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" /> #define RT_USING_HOOK - -/* Using Software Timer */ -/* #define RT_USING_TIMER_SOFT */ -#define RT_TIMER_THREAD_PRIO 4 +// <section name="RT_USING_TIMER_SOFT" description="Using software timer which will start a thread to handle soft-timer" default="true" > +// #define RT_USING_TIMER_SOFT +// <integer name="RT_TIMER_THREAD_PRIO" description="The priority level of timer thread" default="4" /> +#define RT_TIMER_THREAD_PRIO 4 +// <integer name="RT_TIMER_THREAD_STACK_SIZE" description="The stack size of timer thread" default="512" /> #define RT_TIMER_THREAD_STACK_SIZE 512 -#define RT_TIMER_TICK_PER_SECOND 10 +// </section> -/* SECTION: IPC */ -/* Using Semaphore*/ +// <section name="IPC" description="Inter-Thread communication" default="always" > +// <bool name="RT_USING_SEMAPHORE" description="Using semaphore in the system" default="true" /> #define RT_USING_SEMAPHORE - -/* Using Mutex */ +// <bool name="RT_USING_MUTEX" description="Using mutex in the system" default="true" /> #define RT_USING_MUTEX - -/* Using Event */ +// <bool name="RT_USING_EVENT" description="Using event group in the system" default="true" /> #define RT_USING_EVENT - -/* Using MailBox */ +// <bool name="RT_USING_MAILBOX" description="Using mailbox in the system" default="true" /> #define RT_USING_MAILBOX - -/* Using Message Queue */ +// <bool name="RT_USING_MESSAGEQUEUE" description="Using message queue in the system" default="true" /> #define RT_USING_MESSAGEQUEUE +// </section> -/* SECTION: Memory Management */ -/* Using Memory Pool Management*/ -/* #define RT_USING_MEMPOOL */ - -/* Using Dynamic Heap Management */ +// <section name="MM" description="Memory Management" default="always" > +// <bool name="RT_USING_MEMPOOL" description="Using Memory Pool Management in the system" default="true" /> +#define RT_USING_MEMPOOL +// <bool name="RT_USING_MEMHEAP" description="Using Memory Heap Object in the system" default="true" /> +#define RT_USING_MEMHEAP +// <bool name="RT_USING_HEAP" description="Using Dynamic Heap Management in the system" default="true" /> #define RT_USING_HEAP - -/* Using Small MM */ +// <bool name="RT_USING_SMALL_MEM" description="Optimizing for small memory" default="false" /> #define RT_USING_SMALL_MEM -/* #define RT_TINY_SIZE */ +// <bool name="RT_USING_SLAB" description="Using SLAB memory management for large memory" default="false" /> +// #define RT_USING_SLAB +// </section> -/* SECTION: Device System */ -/* Using Device System */ +// <section name="RT_USING_DEVICE" description="Using Device Driver Framework" default="true" > #define RT_USING_DEVICE +// <bool name="RT_USING_DEVICE_IPC" description="Using Inter-Thread communication for Device" default="true" > #define RT_USING_DEVICE_IPC -/* #define RT_USING_UART1 */ +// <bool name="RT_USING_SERIAL" description="Using serial device framework" default="true"> +#define RT_USING_SERIAL +// <bool name="RT_USING_UART0" description="Using UART0" default="true" /> +#define RT_USING_UART0 +// </section> -/* SECTION: Console options */ +// <section name="RT_USING_CONSOLE" description="Using console" default="true" > #define RT_USING_CONSOLE -/* the buffer size of console*/ +// <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" /> #define RT_CONSOLEBUF_SIZE 128 -#define RT_CONSOLE_DEVICE_NAME "sci0" - -/* SECTION: APP MODULE */ -/* #define RT_USING_MODULE */ - -/* SECTION: MTD interface options */ -/* using mtd nand flash */ -#define RT_USING_MTD_NAND -/* using mtd nor flash */ -/* #define RT_USING_MTD_NOR */ +// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" /> +#define RT_CONSOLE_DEVICE_NAME "console" +// </section> -/* SECTION: finsh, a C-Express shell */ +// <section name="RT_USING_FINSH" description="Using finsh as shell, which is a C-Express shell" default="true" > #define RT_USING_FINSH -/* Using symbol table */ +// <bool name="FINSH_USING_SYMTAB" description="Using symbol table in finsh shell" default="true" /> #define FINSH_USING_SYMTAB +// <bool name="FINSH_USING_DESCRIPTION" description="Keeping description in symbol table" default="true" /> #define FINSH_USING_DESCRIPTION +// <integer name="FINSH_THREAD_STACK_SIZE" description="The stack size for finsh thread" default="4096" /> +#define FINSH_THREAD_STACK_SIZE 4096 +// <bool name="FINSH_USING_MSH" description="Enable module shell feature" /> +#define FINSH_USING_MSH +// <bool name="FINSH_USING_MSH_DEFAULT" description="Use module shell as the default shell" /> +#define FINSH_USING_MSH_DEFAULT +// </section> -/* SECTION: device file system */ -#define RT_USING_DFS -#define DFS_FILESYSTEM_TYPES_MAX 8 +// <section name="LIBC" description="C Runtime library setting" default="always" > +// <bool name="RT_USING_LIBC" description="Using C library" default="true" /> +// #define RT_USING_LIBC +// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" /> +// #define RT_USING_PTHREADS +// <bool name="RT_USING_MODULE" description="Enable Moudle Application" default="true" /> +// #define RT_USING_MODULE +// </section> -/* DFS: ELM FATFS options */ +// <section name="RT_USING_DFS" description="Device file system" default="true" > +#define RT_USING_DFS +// <bool name="DFS_USING_WORKDIR" description="Using working directory" default="true" /> +#define DFS_USING_WORKDIR +// <integer name="DFS_FILESYSTEMS_MAX" description="The maximal number of mounted file system" default="4" /> +#define DFS_FILESYSTEMS_MAX 2 +// <integer name="DFS_FD_MAX" description="The maximal number of opened files" default="4" /> +#define DFS_FD_MAX 4 +// <bool name="RT_USING_DFS_ELMFAT" description="Using ELM FatFs" default="true" /> #define RT_USING_DFS_ELMFAT -#define RT_DFS_ELM_WORD_ACCESS -/* Reentrancy (thread safe) of the FatFs module. */ -#define RT_DFS_ELM_REENTRANT -/* Number of volumes (logical drives) to be used. */ -#define RT_DFS_ELM_DRIVES 2 -/* #define RT_DFS_ELM_USE_LFN 1 */ -#define RT_DFS_ELM_MAX_LFN 255 -/* Maximum sector size to be handled. */ -#define RT_DFS_ELM_MAX_SECTOR_SIZE 512 - -/* DFS: network file system options */ -/* #define RT_USING_DFS_NFS */ - -/* DFS: UFFS nand file system options */ -#define RT_USING_DFS_UFFS -/* configuration for uffs, more to see dfs_uffs.h and uffs_config.h */ -#define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO -/* enable this ,you need provide a mark_badblock/check_block function */ -/* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */ - -/* DFS: JFFS2 nor flash file system options */ -//#define RT_USING_DFS_JFFS2 +// <integer name="RT_DFS_ELM_USE_LFN" description="Support long file name" default="0"> +// <item description="LFN with static LFN working buffer">1</item> +// <item description="LFN with dynamic LFN working buffer on the stack">2</item> +// <item description="LFN with dynamic LFN working buffer on the heap">3</item> +// </integer> +#define RT_DFS_ELM_USE_LFN 3 +// <integer name="RT_DFS_ELM_CODE_PAGE" description="OEM code page" default="437"> +#define RT_DFS_ELM_CODE_PAGE 437 +// <integer name="RT_DFS_ELM_MAX_LFN" description="Maximal size of file name length" default="256" /> +#define RT_DFS_ELM_MAX_LFN 128 +// <bool name="RT_USING_DFS_YAFFS2" description="Using YAFFS2" default="false" /> +// #define RT_USING_DFS_YAFFS2 +// <bool name="RT_USING_DFS_UFFS" description="Using UFFS" default="false" /> +// #define RT_USING_DFS_UFFS +// <bool name="RT_USING_DFS_DEVFS" description="Using devfs for device objects" default="true" /> +// #define RT_USING_DFS_DEVFS +// <bool name="RT_USING_DFS_NFS" description="Using NFS v3 client file system" default="false" /> +// #define RT_USING_DFS_NFS +// <string name="RT_NFS_HOST_EXPORT" description="NFSv3 host export" default="192.168.1.5:/" /> +#define RT_NFS_HOST_EXPORT "192.168.1.5:/" +// </section> -/* DFS: windows share directory mounted to rt-thread/dfs */ -/* only used in bsp/simulator */ -#ifdef _WIN32 -#define RT_USING_DFS_WINSHAREDIR -#endif - -/* the max number of mounted file system */ -#define DFS_FILESYSTEMS_MAX 4 -/* the max number of opened files */ -#define DFS_FD_MAX 4 - -/* SECTION: lwip, a lightweight TCP/IP protocol stack */ -/* #define RT_USING_LWIP */ -/* LwIP uses RT-Thread Memory Management */ -#define RT_LWIP_USING_RT_MEM -/* Enable ICMP protocol*/ +// <section name="RT_USING_LWIP" description="lwip, a lightweight TCP/IP protocol stack" default="true" > +// #define RT_USING_LWIP +// <bool name="RT_LWIP_ICMP" description="Enable ICMP protocol" default="true" /> #define RT_LWIP_ICMP -/* Enable UDP protocol*/ +// <bool name="RT_LWIP_IGMP" description="Enable IGMP protocol" default="false" /> +// #define RT_LWIP_IGMP +// <bool name="RT_LWIP_UDP" description="Enable UDP protocol" default="true" /> #define RT_LWIP_UDP -/* Enable TCP protocol*/ +// <bool name="RT_LWIP_TCP" description="Enable TCP protocol" default="true" /> #define RT_LWIP_TCP -/* Enable DNS */ +// <bool name="RT_LWIP_DNS" description="Enable DNS protocol" default="true" /> #define RT_LWIP_DNS +// <bool name="RT_LWIP_SNMP" description="Enable SNMP protocol" default="false" /> +// #define RT_LWIP_SNMP +// <bool name="RT_LWIP_DHCP" description="Enable DHCP client to get IP address" default="false" /> +// #define RT_LWIP_DHCP +// <integer name="RT_LWIP_TCPTHREAD_PRIORITY" description="the thread priority of TCP thread" default="128" /> +#define RT_LWIP_TCPTHREAD_PRIORITY 12 +// <integer name="RT_LWIP_TCPTHREAD_MBOX_SIZE" description="the mail box size of TCP thread to wait for" default="32" /> +#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8 +// <integer name="RT_LWIP_TCPTHREAD_STACKSIZE" description="the thread stack size of TCP thread" default="4096" /> +#define RT_LWIP_TCPTHREAD_STACKSIZE 4096 +// <integer name="RT_LWIP_ETHTHREAD_PRIORITY" description="the thread priority of ethnetif thread" default="144" /> +#define RT_LWIP_ETHTHREAD_PRIORITY 14 +// <integer name="RT_LWIP_ETHTHREAD_MBOX_SIZE" description="the mail box size of ethnetif thread to wait for" default="8" /> +#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8 +// <integer name="RT_LWIP_ETHTHREAD_STACKSIZE" description="the stack size of ethnetif thread" default="512" /> +#define RT_LWIP_ETHTHREAD_STACKSIZE 512 +// <ipaddr name="RT_LWIP_IPADDR" description="IP address of device" default="192.168.1.30" /> +#define RT_LWIP_IPADDR0 192 +#define RT_LWIP_IPADDR1 168 +#define RT_LWIP_IPADDR2 1 +#define RT_LWIP_IPADDR3 30 +// <ipaddr name="RT_LWIP_GWADDR" description="Gateway address of device" default="192.168.1.1" /> +#define RT_LWIP_GWADDR0 192 +#define RT_LWIP_GWADDR1 168 +#define RT_LWIP_GWADDR2 1 +#define RT_LWIP_GWADDR3 1 +// <ipaddr name="RT_LWIP_MSKADDR" description="Mask address of device" default="255.255.255.0" /> +#define RT_LWIP_MSKADDR0 255 +#define RT_LWIP_MSKADDR1 255 +#define RT_LWIP_MSKADDR2 255 +#define RT_LWIP_MSKADDR3 0 +// </section> -/* the number of simultaneously active TCP connections*/ -#define RT_LWIP_TCP_PCB_NUM 5 - -/* Using DHCP */ -/* #define RT_LWIP_DHCP */ - -/* ip address of target*/ -#define RT_LWIP_IPADDR0 192 -#define RT_LWIP_IPADDR1 168 -#define RT_LWIP_IPADDR2 126 -#define RT_LWIP_IPADDR3 30 +// <section name="RT_USING_RTGUI" description="RT-Thread/GUI" default="true" > +// #define RT_USING_RTGUI +// <integer name="RTGUI_NAME_MAX" description="the name size of RT-Thread/GUI widget/objects" default="12" /> +#define RTGUI_NAME_MAX 12 +// <bool name="RTGUI_USING_SMALL_SIZE" description="use small size in RT-Thread/GUI" default="true" /> +#define RTGUI_USING_SMALL_SIZE +// <bool name="RTGUI_USING_FONT16" description="support 16 weight font" default="true" /> +#define RTGUI_USING_FONT16 +// <bool name="RTGUI_USING_FONT12" description="support 12 weight font" default="true" /> +// #define RTGUI_USING_FONT12 +// <bool name="RTGUI_USING_FONTHZ" description="support Chinese font" default="true" /> +#define RTGUI_USING_FONTHZ +// <integer name="RTGUI_DEFAULT_FONT_SIZE" description="default font size in RT-Thread/GUI" default="16" /> +#define RTGUI_DEFAULT_FONT_SIZE 16 +// <bool name="RTGUI_USING_DFS_FILERW" description="use RT-Thread/DFS as file interface" default="true" /> +#define RTGUI_USING_DFS_FILERW +// <bool name="RTGUI_USING_HZ_BMP" description="use Chinese font bitmap engine" default="true" /> +#define RTGUI_USING_HZ_BMP +// <bool name="RTGUI_IMAGE_XPM" description="Using xpm image in RTGUI" default="true" /> +#define RTGUI_IMAGE_XPM +// <bool name="RTGUI_IMAGE_JPEG" description="Using jpeg image in RTGUI" default="true" /> +// #define RTGUI_IMAGE_JPEG +// <bool name="RTGUI_IMAGE_PNG" description="Using PNG image in RTGUI" default="true" /> +// #define RTGUI_IMAGE_PNG +// <bool name="RTGUI_IMAGE_PNG" description="Using PNG image in RTGUI" default="true" /> +#define RTGUI_IMAGE_BMP +// <bool name="RTGUI_USING_HZ_FILE" description="use font file as Chinese font" default="false" /> + #define RTGUI_USING_HZ_FILE +// <bool name="RTGUI_USING_MOUSE_CURSOR" description="use mouse cursor" default="false" /> +#define RTGUI_USING_MOUSE_CURSOR +// </section> -/* gateway address of target*/ -#define RT_LWIP_GWADDR0 192 -#define RT_LWIP_GWADDR1 168 -#define RT_LWIP_GWADDR2 126 -#define RT_LWIP_GWADDR3 1 +// </RDTConfigurator> -/* mask address of target*/ -#define RT_LWIP_MSKADDR0 255 -#define RT_LWIP_MSKADDR1 255 -#define RT_LWIP_MSKADDR2 255 -#define RT_LWIP_MSKADDR3 0 +#define RT_HEAP_SIZE (1024*1024*2) -/* tcp thread options */ -#define RT_LWIP_TCPTHREAD_PRIORITY 12 -#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10 -#define RT_LWIP_TCPTHREAD_STACKSIZE 1024 +#if defined(_MSC_VER) +#define NORESOURCE //RT_VESRION in winuser.h +#define _CRT_ERRNO_DEFINED //errno macro redefinition +#define _INC_WTIME_INL//dfs_elm.c time.h conflicts with wtime.inl +#define _INC_TIME_INL //dfs_elm.c time.h conflicts with wtime.inl -/* Ethernet if thread options */ -#define RT_LWIP_ETHTHREAD_PRIORITY 15 -#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10 -#define RT_LWIP_ETHTHREAD_STACKSIZE 512 +/* disable some warning in MSC */ +#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ +#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */ +#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */ +#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */ +#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */ +#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */ -/* TCP sender buffer space */ -#define RT_LWIP_TCP_SND_BUF 8192 -/* TCP receive window. */ -#define RT_LWIP_TCP_WND 8192 +#elif defined(__GNUC__) +#define RT_USING_NOLIBC -/* SECTION: RT-Thread/GUI */ -/* #define RT_USING_RTGUI */ +#if defined(__MINGW32__) +#define _NO_OLDNAMES /* to ignore: mode_t in sys/type.h */ +#endif /* end of __MINGW32__ */ -/* name length of RTGUI object */ -#define RTGUI_NAME_MAX 12 -/* support 16 weight font */ -#define RTGUI_USING_FONT16 -/* support Chinese font */ -#define RTGUI_USING_FONTHZ -/* use DFS as file interface */ -#define RTGUI_USING_DFS_FILERW -/* use font file as Chinese font */ -/* #define RTGUI_USING_HZ_FILE */ -/* use Chinese bitmap font */ -#define RTGUI_USING_HZ_BMP -/* use small size in RTGUI */ -#define RTGUI_USING_SMALL_SIZE -/* use mouse cursor */ -/* #define RTGUI_USING_MOUSE_CURSOR */ -/* default font size in RTGUI */ -#define RTGUI_DEFAULT_FONT_SIZE 16 +#endif /* end of _MSC_VER */ -/* image support */ -#define RTGUI_IMAGE_XPM -#define RTGUI_IMAGE_BMP -/* #define RTGUI_IMAGE_JPEG */ -/* #define RTGUI_IMAGE_PNG */ -#define RTGUI_USING_NOTEBOOK_IMAGE +#ifdef _WIN32 +#define RT_USING_DFS_WINSHAREDIR +#endif #endif diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py index d3ed2599d5..8ccacadfd6 100755 --- a/bsp/simulator/rtconfig.py +++ b/bsp/simulator/rtconfig.py @@ -114,8 +114,8 @@ elif PLATFORM == 'cl': CFLAGS += ' /MT' LFLAGS += '' - CFLAGS += ' /ZI /Od /W 3 /WL ' - LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 ' + CFLAGS += ' /Zi /Od /W 3 /WL ' + LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 /INCREMENTAL:NO' CPATH = '' LPATH = '' diff --git a/bsp/simulator/rtgui_demo/SConscript b/bsp/simulator/rtgui_demo/SConscript deleted file mode 100644 index 0992612410..0000000000 --- a/bsp/simulator/rtgui_demo/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -objs = [] -list = os.listdir(cwd) - -for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') diff --git a/bsp/simulator/rtgui_demo/snake/SConscript b/bsp/simulator/rtgui_demo/snake/SConscript deleted file mode 100644 index a5734dc40c..0000000000 --- a/bsp/simulator/rtgui_demo/snake/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -import rtconfig -from building import * - -src = Glob('*.c') + Glob('*.cpp') -cwd = GetCurrentDir() - -CPPPATH = [cwd] -group = DefineGroup('snake', src, depend = ['RT_USING_RTGUI'], CPPPATH=CPPPATH) - -Return('group') diff --git a/bsp/simulator/rtgui_demo/snake/snake.c b/bsp/simulator/rtgui_demo/snake/snake.c deleted file mode 100644 index 87e1c8b36f..0000000000 --- a/bsp/simulator/rtgui_demo/snake/snake.c +++ /dev/null @@ -1,271 +0,0 @@ -#include <string.h> -#include <stdlib.h> -#include <rtthread.h> -#include "snake.h" - -#define ASSERT_RET(x, ret) \ - do{ \ - if (x) \ - return ret; \ - }while(0) - -rt_list_t snake_head; -SNAKE_DIR prevdir, newdir; - -static SNAKE_DIR dir_adjust(SNAKE_DIR dir) -{ - if ((SNAKE_DIR_UP == prevdir && SNAKE_DIR_DOWN != dir) - || (SNAKE_DIR_DOWN == prevdir && SNAKE_DIR_UP != dir) - || (SNAKE_DIR_LEFT == prevdir && SNAKE_DIR_RIGHT != dir) - || (SNAKE_DIR_RIGHT == prevdir && SNAKE_DIR_LEFT != dir) - ) - { - newdir = dir; - } - else - { - rt_kprintf("dirction change error\n\r"); - } - - return newdir; -} - -static void across_XY(point_t *node, const map_t *map) -{ - RT_ASSERT(node != RT_NULL && map != RT_NULL); - - // ������ȳ�����ǰ�߿�����Դ�Խǽ������ - node->x = (node->x + map->width) % map->width; - node->y = (node->y + map->height) % map->height; -} - -static SYS_STE node_update(snake_t *tail, const point_t *node, map_t *map) -{ - SYS_STE ret; - point_t *pos; - - RT_ASSERT(tail != RT_NULL && node != RT_NULL && map != RT_NULL); - - pos = map->snake_flush; - pos[0].x = pos[0].y = -1; - pos[1].x = pos[1].y = -1; - - ret = (SYS_STE)map->range[node->y * map->width + node->x]; - - if (FOOD == map->range[node->y * map->width + node->x]) - { - // ��һ��ʳ������һ���ڵ� - snake_t *new = (snake_t *)rt_malloc(sizeof(snake_t)); - if (!new) - return NORMAL; - - pos[0] = *node; - new->body = *node; - rt_list_insert_after(&snake_head, &new->list); - } - else if (NORMAL == map->range[node->y * map->width + node->x]) - { - // ��β���ĺ��õ�ͷ������������ - rt_list_remove(&tail->list); - map->range[tail->body.y * map->width + tail->body.x] = NORMAL; - - pos[0] = *node; - pos[1] = tail->body; - - tail->body = *node; - rt_list_insert_after(&snake_head, &tail->list); - } - - map->range[node->y * map->width + node->x] = OVER; - - if (ret != OVER) - prevdir = newdir; - - return ret; -} - - -map_t *map_init(rt_uint32_t width, rt_uint32_t heigth) -{ - map_t *map = rt_malloc(sizeof(map_t)); - - if (map != RT_NULL) - { - map->range = rt_malloc(heigth * width); - - if (!map->range) - { - rt_free(map); - map = RT_NULL; - } - else - { - map->width = width; - map->height = heigth; - memset(map->range, NORMAL, heigth * width); - } - } - - return map; -} - -// ����һ��ָ�����ȵ�����ָ���� -rt_bool_t snake_init(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map) -{ - rt_int32_t i; - rt_int32_t inc_x, inc_y; - point_t old = *start; - - ASSERT_RET(!map || !start, RT_FALSE); - - rt_list_init(&snake_head); - - if (dir == SNAKE_DIR_UP || dir == SNAKE_DIR_DOWN) - { - if (map->height <= length) - return RT_FALSE; - - inc_x = 0; - inc_y = dir == SNAKE_DIR_DOWN ? 1 : -1; // �����ӳ����ӣ�ͷ����ָ��λ�� - old.y -= inc_y; - } - else - { - if (map->width <= length) - return RT_FALSE; - - inc_y = 0; - inc_x = dir == SNAKE_DIR_RIGHT ? -1 : 1; - old.x -= inc_x; - } - - for (i = 0; i < length; i++) - { - snake_t *new = (snake_t *)rt_malloc(sizeof(snake_t)); - if (!new) - return RT_FALSE; - - new->body.y = inc_y + old.y; - new->body.x = inc_x + old.x; - - // ������ȳ�����ǰ�߿�����Դ�Խǽ������ - across_XY(&new->body, map); - - map->range[new->body.y * map->width + new->body.x] = OVER; - - old = new->body; - rt_list_insert_before(&snake_head, &new->list); - } - - prevdir = dir; - - return RT_TRUE; -} - -// �����ʳ�� -rt_bool_t food_init(map_t *map, rt_uint32_t max_num) -{ - point_t food; - -#ifndef FOOD_TIMEOUT -#define FOOD_TIMEOUT 10 -#endif - - rt_uint32_t timeout, num; - - ASSERT_RET(!map, RT_FALSE); - - num = 0; - timeout = rt_tick_get(); - srand(rand()); - - map->food_flush[0].x = map->food_flush[0].y = -1; - - do - { - food.x = rand() % map->width; - food.y = rand() % map->height; - - if (map->range[food.y * map->width + food.x] == NORMAL) - { - map->food_flush[0] = food; - map->range[food.y * map->width + food.x] = FOOD; - num++; - } - } - while (num < max_num && rt_tick_get() - timeout < FOOD_TIMEOUT); - - return num; -} - -void map_deinit(map_t *map) -{ - if (map) - { - if (map->range) - { - rt_free(map->range); - map->range = RT_NULL; - } - rt_free(map); - } -} - -void snake_deinit(void) -{ - snake_t *node; - - while (!rt_list_isempty(&snake_head)) - { - node = rt_list_entry(snake_head.prev, snake_t, list); - rt_list_remove(&node->list); - rt_free(node); - } -} - -void food_deinit(void) -{ - -} - -SYS_STE snake_step(SNAKE_DIR dir, map_t *map) -{ - snake_t *tail, *head; - point_t node; - - ASSERT_RET(!map, RT_FALSE); - - dir = dir_adjust(dir); - - // ȡ��ͷβ�����ڵ㣬�����ڵ㲻��Ҫ�ı� - tail = rt_list_entry(snake_head.prev, snake_t, list); - head = rt_list_entry(snake_head.next, snake_t, list); - - node = head->body; - - // ����һ���µ���ͷ���� - switch (dir) - { - case SNAKE_DIR_UP: - case SNAKE_DIR_DOWN: - node.y = head->body.y + (dir == SNAKE_DIR_DOWN ? -1 : 1); - break; - case SNAKE_DIR_LEFT: - case SNAKE_DIR_RIGHT: - node.x = head->body.x + (dir == SNAKE_DIR_RIGHT ? 1 : -1); - break; - } - across_XY(&node, map); - - return node_update(tail, &node, map); -} - -rt_bool_t snake_restart(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map) -{ - ASSERT_RET(!map || !start, RT_FALSE); - - snake_deinit(); - memset(map->range, NORMAL, map->width * map->height); - - return snake_init(start, length, dir, map); -} diff --git a/bsp/simulator/rtgui_demo/snake/snake.h b/bsp/simulator/rtgui_demo/snake/snake.h deleted file mode 100644 index 557d4d9241..0000000000 --- a/bsp/simulator/rtgui_demo/snake/snake.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _SNAKE_H_ -#define _SNAKE_H_ - -#include <rtthread.h> - -#define snake_length_max 20 //����߳� -#define snake_length_init 3 //��ʼ���߳� -#define snake_room_size_hight 8 //���Ӹ� 0-255 ����>8 -#define snake_room_size_widht 8 //���ӿ� 0-255 ����>8 - -#define snake_init_pointx 1 -#define snake_init_pointy 2 - -typedef struct -{ - rt_int32_t x, y; -} point_t; - -typedef struct -{ - rt_int32_t width; // max x - rt_int32_t height; // max y - rt_uint8_t *range; // map, map->range[y * map->width + x] - point_t snake_flush[2]; - point_t food_flush[1]; -} map_t; - -typedef enum -{ - SNAKE_DIR_UP, - SNAKE_DIR_DOWN, - SNAKE_DIR_LEFT, - SNAKE_DIR_RIGHT -} SNAKE_DIR; - -typedef enum -{ - FOOD, // �Ե�ˮ�� - OVER, // ҧ������ - NORMAL // �����ж� -} SYS_STE; - -typedef struct -{ - point_t body; - rt_list_t list; -} snake_t; - -// ����һ����ͼ -map_t *map_init(rt_uint32_t width, rt_uint32_t heigth); - -// ����һ��ָ�����ȵ�����ָ���� -rt_bool_t snake_init(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map); - -// �����ʳ�� -rt_bool_t food_init(map_t *map, rt_uint32_t max_num); - -void map_deinit(map_t *map); - -void snake_deinit(void); - -void food_deinit(void); - -SYS_STE snake_step(SNAKE_DIR dir, map_t *map); - -rt_bool_t snake_restart(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map); - -#endif diff --git a/bsp/simulator/rtgui_demo/snake/snake_gui.c b/bsp/simulator/rtgui_demo/snake/snake_gui.c deleted file mode 100644 index 0df1ba7a87..0000000000 --- a/bsp/simulator/rtgui_demo/snake/snake_gui.c +++ /dev/null @@ -1,400 +0,0 @@ -#include <string.h> -#include <rtthread.h> - -#include <rtgui/rtgui.h> -#include <rtgui/rtgui_app.h> -#include <rtgui/widgets/container.h> -#include <rtgui/widgets/window.h> -#include <rtgui/widgets/button.h> - -#include "snake.h" - -#define LATTICE_SIZE (20) -#define FOOD_MAX (8) - -#define WALL_COLOR RTGUI_RGB(255, 0, 0) -#define SNAKE_COLOR RTGUI_RGB(0, 100, 200) -#define SNAKE_HEAD_COLOR RTGUI_RGB(180, 70, 130) -#define BACKGROUND_COLOR RTGUI_RGB(153, 153, 0) -#define FOOD_COLOR RTGUI_RGB(128, 0, 0) - -static rtgui_timer_t *timer; -static rt_size_t room_size_x, room_size_y; -static rt_size_t lattice_size_x, lattice_size_y; -static struct rtgui_rect room_rect, lattice_rect; - -map_t *map; -SNAKE_DIR run_state; -rt_int32_t snake_len; -rt_int32_t food_num; -point_t second_node; - -static void snake_fill_lattice(struct rtgui_dc *dc, - rt_uint32_t x, - rt_uint32_t y, - rtgui_color_t color) -{ - struct rtgui_rect rect; - - // coordinate conversion - y = (lattice_size_y - 1) - y; - - RTGUI_DC_BC(dc) = color; - - rect.x1 = lattice_rect.x1 + (LATTICE_SIZE * x); - rect.x2 = rect.x1 + LATTICE_SIZE; - rect.x1 += 2; - - rect.y1 = lattice_rect.y1 + (LATTICE_SIZE * y); - rect.y2 = rect.y1 + LATTICE_SIZE; - rect.y1 += 2; - - rtgui_dc_fill_rect(dc, &rect); -} - -static void snake_draw(struct rtgui_widget *widget) -{ - struct rtgui_dc *dc; - struct rtgui_rect rect; - rt_uint32_t i; - - dc = rtgui_dc_begin_drawing(widget); - if (dc == RT_NULL) - { - rt_kprintf("dc == RT_NULL\r\n"); - return; - } - - /* get room size, run once frist. */ - if ((room_size_x == 0) || (room_size_y == 0)) - { - rt_size_t tmp; - - rtgui_widget_get_rect(widget, &rect); - rt_kprintf("rect => x1:%d x2:%d, y1:%d y2:%d\r\n", rect.x1, rect.x2, rect.y1, rect.y2); - - room_size_x = rect.x2 - rect.x1; - room_size_y = rect.y2 - rect.y1; - memcpy(&room_rect, &rect, sizeof(struct rtgui_rect)); - rt_kprintf("room_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", - room_rect.x1, room_rect.x2, - room_rect.y1, room_rect.y2); - - lattice_size_x = (room_rect.x2 - room_rect.x1) / LATTICE_SIZE; - lattice_size_y = (room_rect.y2 - room_rect.y1) / LATTICE_SIZE; - lattice_size_x -= 2; - lattice_size_y -= 2; - rt_kprintf("lattice_size_x:%d lattice_size_y:%d\r\n", - lattice_size_x, - lattice_size_y); - - tmp = (room_rect.x2 - room_rect.x1) - (LATTICE_SIZE * lattice_size_x); - lattice_rect.x1 = room_rect.x1 + (tmp / 2); - lattice_rect.x2 = lattice_rect.x1 + (LATTICE_SIZE * lattice_size_x); - - tmp = (room_rect.y2 - room_rect.y1) - (LATTICE_SIZE * lattice_size_y); - lattice_rect.y1 = room_rect.y1 + (tmp / 2); - lattice_rect.y2 = lattice_rect.y1 + (LATTICE_SIZE * lattice_size_y); - rt_kprintf("lattice_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", - lattice_rect.x1, lattice_rect.x2, - lattice_rect.y1, lattice_rect.y2); - - /* create snake. */ - { - point_t start; - map = map_init(lattice_size_x, lattice_size_y); - if (map != RT_NULL) - { - start.x = snake_init_pointx; - start.y = snake_init_pointy; - run_state = SNAKE_DIR_DOWN; - - if (snake_init(&start, snake_length_init, run_state, map)) - { - food_num = 1; - food_init(map, food_num); - } - else - { - map_deinit(map); - map = RT_NULL; - } - } - } - } - - RTGUI_DC_BC(dc) = BACKGROUND_COLOR; - rtgui_dc_fill_rect(dc, &room_rect); - - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.x2 += 1; - rect.y2 += 1; - RTGUI_DC_FC(dc) = WALL_COLOR; - rtgui_dc_draw_rect(dc, &rect); - - for (i = 1; i < lattice_size_y; i++) - { - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.x1 += 1; - rect.x2 -= 1; - rtgui_dc_draw_horizontal_line(dc, rect.x1, rect.x2, - rect.y1 + (LATTICE_SIZE * i)); - } - - for (i = 1; i < lattice_size_x; i++) - { - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.y1 += 1; - rect.y2 -= 1; - rtgui_dc_draw_vertical_line(dc, rect.x1 + (LATTICE_SIZE * i), - rect.y1, rect.y2); - } - - /* draw snake. */ - { - rt_int32_t x, y; - rt_bool_t first_node = RT_TRUE; - - for (y = 0; y < map->height; y++) - { - for (x = 0; x < map->width; x++) - { - switch (map->range[y * map->width + x]) - { - case NORMAL: - break; - case FOOD: - snake_fill_lattice(dc, x, y, FOOD_COLOR); - break; - case OVER: - if (first_node) - { - first_node = RT_FALSE; - second_node.x = x; - second_node.y = y; - snake_fill_lattice(dc, x, y, SNAKE_HEAD_COLOR); - } - else - { - snake_fill_lattice(dc, x, y, SNAKE_COLOR); - } - break; - } - } - - } - } - - rtgui_dc_end_drawing(dc); - - return; -} - -static void snake_update(struct rtgui_widget *widget) -{ - struct rtgui_dc *dc; - rt_int32_t x, y; - rt_uint32_t i; - - dc = rtgui_dc_begin_drawing(widget); - if (dc == RT_NULL) - { - rt_kprintf("dc == RT_NULL\r\n"); - return; - } - - snake_fill_lattice(dc, second_node.x, second_node.y, SNAKE_COLOR); - second_node = map->snake_flush[0]; - - for (i = 0; i < 3; i++) - { - if (i < 2) - { - x = map->snake_flush[i].x; - y = map->snake_flush[i].y; - } - else - { - x = map->food_flush[0].x; - y = map->food_flush[0].y; - } - - if ((x >= 0) && (y >= 0)) - { - switch (map->range[(map->width * y) + x]) - { - case NORMAL: - snake_fill_lattice(dc, x, y, BACKGROUND_COLOR); - break; - case FOOD: - snake_fill_lattice(dc, x, y, FOOD_COLOR); - break; - case OVER: - if (0 == i) - snake_fill_lattice(dc, x, y, SNAKE_HEAD_COLOR); - else - snake_fill_lattice(dc, x, y, SNAKE_COLOR); - break; - } - } - } - - rtgui_dc_end_drawing(dc); - return; -} - -static void snake_handler(struct rtgui_widget *widget, rtgui_event_t *event) -{ - struct rtgui_event_kbd *ekbd; - - ekbd = (struct rtgui_event_kbd *) event; - if (ekbd->type == RTGUI_KEYDOWN) - { - switch (ekbd->key) - { - case RTGUIK_UP: - rt_kprintf("RTGUIK_UP\r\n"); - run_state = SNAKE_DIR_UP; - break; - case RTGUIK_DOWN: - rt_kprintf("RTGUIK_DOWN\r\n"); - run_state = SNAKE_DIR_DOWN; - break; - case RTGUIK_LEFT: - rt_kprintf("RTGUIK_LEFT\r\n"); - run_state = SNAKE_DIR_LEFT; - break; - case RTGUIK_RIGHT: - rt_kprintf("RTGUIK_RIGHT\r\n"); - run_state = SNAKE_DIR_RIGHT; - break; - default: - break; - } - } -} - -static rt_bool_t event_handler(struct rtgui_object *object, rtgui_event_t *event) -{ - struct rtgui_widget *widget = RTGUI_WIDGET(object); - - rt_kprintf("event_handler\r\n"); - - if (event->type == RTGUI_EVENT_PAINT) - { - rt_kprintf("RTGUI_EVENT_PAINT\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_draw(widget); - rtgui_timer_start(timer); - } - else if (event->type == RTGUI_EVENT_SHOW) - { - rt_kprintf("RTGUI_EVENT_SHOW\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_draw(widget); - rtgui_timer_start(timer); - } - else if (event->type == RTGUI_EVENT_HIDE) - { - rt_kprintf("RTGUI_EVENT_HIDE\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - rtgui_timer_stop(timer); - } - else if (event->type == RTGUI_EVENT_WIN_DEACTIVATE) - { - rt_kprintf("RTGUI_EVENT_WIN_DEACTIVATE\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - rtgui_timer_stop(timer); - } - else if (event->type == RTGUI_EVENT_KBD) - { - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_handler(widget, event); - } - else - { - rt_kprintf("event->type:%d\r\n", event->type); - return rtgui_win_event_handler((struct rtgui_object *)object, event); - } - - return RT_FALSE; -} - -static void timeout(struct rtgui_timer *timer, void *parameter) -{ - struct rtgui_widget *widget; - SYS_STE ret; - - if (!map) - return; - - ret = snake_step(run_state, map); - if (OVER == ret) - return; - - if (FOOD == ret) - { - snake_len++; - if (snake_len >= (map->width * map->height) / 3) - { - point_t start; - - start.x = snake_init_pointx; - start.y = snake_init_pointy; - run_state = SNAKE_DIR_DOWN; - snake_len = snake_length_init; - - if (!snake_restart(&start, snake_len, run_state, map)) - { - map_deinit(map); - snake_deinit(); - map = RT_NULL; - } - } - - food_init(map, 1); - } - - widget = RTGUI_WIDGET(parameter); - snake_update(widget); -} - -void snake_main(void) -{ - struct rtgui_app *application; - struct rtgui_win *win; - rtgui_rect_t rect; - - application = rtgui_app_create("sanke_app"); - if (application != RT_NULL) - { - rtgui_get_screen_rect(&rect); - rtgui_set_mainwin_rect(&rect); - win = rtgui_mainwin_create(RT_NULL, - "sanke_win", - RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE); - if (win == RT_NULL) - { - rt_kprintf("sanke_win create fail!\r\n"); - return; - } - - rtgui_object_set_event_handler(RTGUI_OBJECT(win), event_handler); - - timer = rtgui_timer_create(RT_TICK_PER_SECOND / 2, - RT_TIMER_FLAG_PERIODIC, - timeout, - (void *)win); - - rtgui_win_show(win, RT_TRUE); - - //�˳���ŷ��� - map_deinit(map); - snake_deinit(); - food_deinit(); - rtgui_app_destroy(application); - } -} - -#include <finsh.h> -FINSH_FUNCTION_EXPORT(snake_main, snake run) diff --git a/bsp/simulator/testdll/SConstruct b/bsp/simulator/testdll/SConstruct deleted file mode 100644 index 690df89ce8..0000000000 --- a/bsp/simulator/testdll/SConstruct +++ /dev/null @@ -1,85 +0,0 @@ -import os -import sys -import SCons.cpp -import rtconfig - -if os.getenv('RTT_ROOT'): - RTT_ROOT = os.getenv('RTT_ROOT') -else: - RTT_ROOT = os.path.normpath(os.getcwd() + '/../..') - -if os.getenv('RTT_RTGUI'): - RTT_RTGUI = os.getenv('RTT_RTGUI') -else: - # set the rtgui root directory by hand - # empty string means use the RTGUI in svn - RTT_RTGUI = os.path.normpath(r'F:\Project\git\rt-gui\components\rtgui') - # RTT_RTGUI ='' - -sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] -from building import * - -Export('RTT_ROOT') - -# add target option -AddOption('--app', - dest='app', - nargs=1, type='string', - action='store', - metavar='DIR', - help='installation prefix') - -# add target option -AddOption('--type', - dest='type', - nargs=1, type='string', - action='store', - metavar='DIR', - help='installation prefix') - -app = GetOption('app') -env = Environment(TARGET_ARCH='x86') -CPPPATH = [ - RTT_ROOT + '/include', - RTT_ROOT + '/bsp/' + rtconfig.BSP, - RTT_ROOT + '/components/finsh', - RTT_ROOT + '/components/libdl', - RTT_ROOT + '/components/external/ftk/ftk/src/os/rt-thread', - RTT_ROOT + '/components/external/ftk/ftk/src/demos', - RTT_ROOT + '/components/external/ftk/ftk/apps/common', - RTT_ROOT + '/components/external/ftk/ftk/src', - RTT_ROOT + '/components/dfs', - RTT_ROOT + '/components/dfs/include', - RTT_ROOT + '/components/libc/newlib', - RTT_ROOT + '/components/external/cairo/cairo-1.10.2/src', - RTT_ROOT + '/components/external/cairo/' -] -if RTT_RTGUI: - RTGUI_ROOT = RTT_RTGUI -else: - RTGUI_ROOT = RTT_ROOT + '/components/rtgui' -RTGUI_PATH = [ - RTGUI_ROOT + '/include', - RTGUI_ROOT + '/common', - RTGUI_ROOT + '/server', - RTGUI_ROOT + '/widgets', -] -CPPPATH += RTGUI_PATH - -env.Append(CCFLAGS=rtconfig.CFLAGS) -env.Append(LINKFLAGS=rtconfig.LFLAGS) -env.Append(CPPPATH=CPPPATH) -env.Append(LIBS='rtthread', LIBPATH='../') -env.Append(CPPDEFINES=['RTT_IN_MODULE']) -env.PrependENVPath('PATH', rtconfig.EXEC_PATH) - -PrepareModuleBuilding(env, RTT_ROOT) - -#dir = app + '/build/' + rtconfig.BSP -dir = app + '/build/' -objs = SConscript(app + '/Sconscript', variant_dir=dir, duplicate=0) -TARGET = dir + '/' + app + '.' + rtconfig.TARGET_EXT - -# build program -#env.Program(TARGET, objs) -env.SharedLibrary(TARGET, objs) diff --git a/bsp/simulator/testdll/basicapp/Sconscript b/bsp/simulator/testdll/basicapp/Sconscript deleted file mode 100644 index d8dd99964e..0000000000 --- a/bsp/simulator/testdll/basicapp/Sconscript +++ /dev/null @@ -1,7 +0,0 @@ -import rtconfig -Import('RTT_ROOT') -from building import * - -src = Glob('*.c') -group = DefineGroup('', src, depend = ['']) -Return('group')
\ No newline at end of file diff --git a/bsp/simulator/testdll/basicapp/basicapp.c b/bsp/simulator/testdll/basicapp/basicapp.c deleted file mode 100644 index 3a1927277e..0000000000 --- a/bsp/simulator/testdll/basicapp/basicapp.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <rtthread.h> - -static int a = 0; -static int b = 1000000; -int c = 100; - -static void function(int count1, int count2, int count3) -{ - rt_kprintf("Hello RT-Thread %d %d\n", count1, count2, count3); -} - -int main(void) -{ - int i; - - rt_kprintf("application entry\n"); - rt_kprintf("[addr]a-0x%x,b-0x%x,c-0x%x\n", &a, &b, &c); - rt_kprintf("[value]a-%d,b-%d,c-%d\n", a, b, c); - - for(i=0; i<100; i++) - { - a++; - b--; - c++; - function(a, c, b ); - } - - return 0; -} - diff --git a/bsp/simulator/testdll/label/Sconscript b/bsp/simulator/testdll/label/Sconscript deleted file mode 100644 index d8dd99964e..0000000000 --- a/bsp/simulator/testdll/label/Sconscript +++ /dev/null @@ -1,7 +0,0 @@ -import rtconfig -Import('RTT_ROOT') -from building import * - -src = Glob('*.c') -group = DefineGroup('', src, depend = ['']) -Return('group')
\ No newline at end of file diff --git a/bsp/simulator/testdll/label/label_demo1.c b/bsp/simulator/testdll/label/label_demo1.c deleted file mode 100644 index 9a72c31fd2..0000000000 --- a/bsp/simulator/testdll/label/label_demo1.c +++ /dev/null @@ -1,74 +0,0 @@ -#include <rtthread.h> - -#include <rtgui/rtgui.h> -#include <rtgui/rtgui_app.h> -#include <rtgui/widgets/window.h> -#include <rtgui/widgets/label.h> -#include <rtgui/driver.h> - -/* ��LCD�ϴ���һ�������ڣ����ǵ�һ������ */ -static void win_thread_entry(void *parameter) -{ - struct rtgui_app *app; - struct rtgui_win *win; - struct rtgui_label *label; - struct rtgui_rect rect; - - app = rtgui_app_create(rt_thread_self(), "MyApp"); - RT_ASSERT(app != RT_NULL); - - /* create a full screen window */ - rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect); - - win = rtgui_win_create(RT_NULL, "MainWin", &rect, - RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE); - if (win == RT_NULL) - { - rtgui_app_destroy(app); - return; - } - - /* ����һ��label������Ϊhelloworld */ - label = rtgui_label_create("Hello World!"); - - /* ����label��λ�ã������Ǿ������� */ - rect.x1 = 0; - rect.y1 = 100; - rect.x2 = 240; - rect.y2 = 140; - rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); - - rt_kprintf("bc: %x\n", RTGUI_WIDGET_BACKGROUND(label)); - rt_kprintf("fc: %x\n", RTGUI_WIDGET_FOREGROUND(label)); -#if 0 - RTGUI_WIDGET_BACKGROUND(label) = 0; - RTGUI_WIDGET_FOREGROUND(label) = RTGUI_RGB(0xFF, 0xFF, 0); -#endif - - /*����label��������*/ - rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label)); - - /* ��ʾ������ */ - rtgui_win_show(win, RT_FALSE); - - /* ѭ�� */ - rtgui_app_run(app); - - rtgui_win_destroy(win); - rtgui_app_destroy(app); - rt_kprintf("MyApp Quit.\n"); -} - -int main() -{ - rt_thread_t tid; - - tid = rt_thread_create("win", win_thread_entry, RT_NULL, - 2048, 20, 20); - if (tid != RT_NULL) - { - rt_thread_startup(tid); - } - - return 0; -} diff --git a/bsp/simulator/testdll/rtconfig.py b/bsp/simulator/testdll/rtconfig.py deleted file mode 100644 index a2ea824d75..0000000000 --- a/bsp/simulator/testdll/rtconfig.py +++ /dev/null @@ -1,51 +0,0 @@ -# bsp name -BSP = 'simulator' - -# toolchains -EXEC_PATH = '' -PREFIX = '' -TARGET_EXT = 'dll' -AS = PREFIX + 'cl' -CC = PREFIX + 'cl' -AR = PREFIX + 'cl' -LINK = PREFIX + 'cl' -AFLAGS = '' -CFLAGS = '' -LFLAGS = '' -BUILD = 'debug' - -if BUILD == 'debug': - CFLAGS += ' /MTd' - LFLAGS += ' /DEBUG' -else: - CFLAGS += ' /MT' - LFLAGS += '' - -CFLAGS += ' /ZI /Od /W 3 /WL' -LFLAGS += ' /DEF:rttapp.def /SUBSYSTEM:CONSOLE /MACHINE:X86' -#LFLAGS += ' /DEF:rttapp.def /SUBSYSTEM:WINDOWS /MACHINE:X86' #/ENTRY:mainCRTStartup - -CPATH = '' -LPATH = '' - -''' -EXEC_PATH = 'C:/Program Files/CodeSourcery/Sourcery G++ Lite/bin' -PREFIX = 'arm-none-eabi-' -CC = PREFIX + 'gcc' -CXX = PREFIX + 'g++' -AS = PREFIX + 'gcc' -AR = PREFIX + 'ar' -LINK = PREFIX + 'gcc' -TARGET_EXT = 'so' -SIZE = PREFIX + 'size' -OBJDUMP = PREFIX + 'objdump' -OBJCPY = PREFIX + 'objcopy' - -DEVICE = ' -mcpu=arm920t' -CFLAGS = DEVICE + ' -O0 -fPIC -DFTK_AS_PLUGIN -DRT_THREAD ' -AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' -LFLAGS = DEVICE + ' -Wl,-z,max-page-size=0x4 -shared -fPIC -nostdlib -s' - -CPATH = '' -LPATH = '' -''' diff --git a/bsp/simulator/testdll/rttapp.def b/bsp/simulator/testdll/rttapp.def deleted file mode 100644 index a3a3ca51a8..0000000000 --- a/bsp/simulator/testdll/rttapp.def +++ /dev/null @@ -1,3 +0,0 @@ -LIBRARY app -EXPORTS -main diff --git a/bsp/simulator/testdll/snake/SConscript b/bsp/simulator/testdll/snake/SConscript deleted file mode 100644 index f9808e4fe7..0000000000 --- a/bsp/simulator/testdll/snake/SConscript +++ /dev/null @@ -1,7 +0,0 @@ -import rtconfig -Import('RTT_ROOT') -from building import * - -src = Glob('*.c') -group = DefineGroup('', src, depend = ['']) -Return('group') diff --git a/bsp/simulator/testdll/snake/snake.c b/bsp/simulator/testdll/snake/snake.c deleted file mode 100644 index 87e1c8b36f..0000000000 --- a/bsp/simulator/testdll/snake/snake.c +++ /dev/null @@ -1,271 +0,0 @@ -#include <string.h> -#include <stdlib.h> -#include <rtthread.h> -#include "snake.h" - -#define ASSERT_RET(x, ret) \ - do{ \ - if (x) \ - return ret; \ - }while(0) - -rt_list_t snake_head; -SNAKE_DIR prevdir, newdir; - -static SNAKE_DIR dir_adjust(SNAKE_DIR dir) -{ - if ((SNAKE_DIR_UP == prevdir && SNAKE_DIR_DOWN != dir) - || (SNAKE_DIR_DOWN == prevdir && SNAKE_DIR_UP != dir) - || (SNAKE_DIR_LEFT == prevdir && SNAKE_DIR_RIGHT != dir) - || (SNAKE_DIR_RIGHT == prevdir && SNAKE_DIR_LEFT != dir) - ) - { - newdir = dir; - } - else - { - rt_kprintf("dirction change error\n\r"); - } - - return newdir; -} - -static void across_XY(point_t *node, const map_t *map) -{ - RT_ASSERT(node != RT_NULL && map != RT_NULL); - - // ������ȳ�����ǰ�߿�����Դ�Խǽ������ - node->x = (node->x + map->width) % map->width; - node->y = (node->y + map->height) % map->height; -} - -static SYS_STE node_update(snake_t *tail, const point_t *node, map_t *map) -{ - SYS_STE ret; - point_t *pos; - - RT_ASSERT(tail != RT_NULL && node != RT_NULL && map != RT_NULL); - - pos = map->snake_flush; - pos[0].x = pos[0].y = -1; - pos[1].x = pos[1].y = -1; - - ret = (SYS_STE)map->range[node->y * map->width + node->x]; - - if (FOOD == map->range[node->y * map->width + node->x]) - { - // ��һ��ʳ������һ���ڵ� - snake_t *new = (snake_t *)rt_malloc(sizeof(snake_t)); - if (!new) - return NORMAL; - - pos[0] = *node; - new->body = *node; - rt_list_insert_after(&snake_head, &new->list); - } - else if (NORMAL == map->range[node->y * map->width + node->x]) - { - // ��β���ĺ��õ�ͷ������������ - rt_list_remove(&tail->list); - map->range[tail->body.y * map->width + tail->body.x] = NORMAL; - - pos[0] = *node; - pos[1] = tail->body; - - tail->body = *node; - rt_list_insert_after(&snake_head, &tail->list); - } - - map->range[node->y * map->width + node->x] = OVER; - - if (ret != OVER) - prevdir = newdir; - - return ret; -} - - -map_t *map_init(rt_uint32_t width, rt_uint32_t heigth) -{ - map_t *map = rt_malloc(sizeof(map_t)); - - if (map != RT_NULL) - { - map->range = rt_malloc(heigth * width); - - if (!map->range) - { - rt_free(map); - map = RT_NULL; - } - else - { - map->width = width; - map->height = heigth; - memset(map->range, NORMAL, heigth * width); - } - } - - return map; -} - -// ����һ��ָ�����ȵ�����ָ���� -rt_bool_t snake_init(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map) -{ - rt_int32_t i; - rt_int32_t inc_x, inc_y; - point_t old = *start; - - ASSERT_RET(!map || !start, RT_FALSE); - - rt_list_init(&snake_head); - - if (dir == SNAKE_DIR_UP || dir == SNAKE_DIR_DOWN) - { - if (map->height <= length) - return RT_FALSE; - - inc_x = 0; - inc_y = dir == SNAKE_DIR_DOWN ? 1 : -1; // �����ӳ����ӣ�ͷ����ָ��λ�� - old.y -= inc_y; - } - else - { - if (map->width <= length) - return RT_FALSE; - - inc_y = 0; - inc_x = dir == SNAKE_DIR_RIGHT ? -1 : 1; - old.x -= inc_x; - } - - for (i = 0; i < length; i++) - { - snake_t *new = (snake_t *)rt_malloc(sizeof(snake_t)); - if (!new) - return RT_FALSE; - - new->body.y = inc_y + old.y; - new->body.x = inc_x + old.x; - - // ������ȳ�����ǰ�߿�����Դ�Խǽ������ - across_XY(&new->body, map); - - map->range[new->body.y * map->width + new->body.x] = OVER; - - old = new->body; - rt_list_insert_before(&snake_head, &new->list); - } - - prevdir = dir; - - return RT_TRUE; -} - -// �����ʳ�� -rt_bool_t food_init(map_t *map, rt_uint32_t max_num) -{ - point_t food; - -#ifndef FOOD_TIMEOUT -#define FOOD_TIMEOUT 10 -#endif - - rt_uint32_t timeout, num; - - ASSERT_RET(!map, RT_FALSE); - - num = 0; - timeout = rt_tick_get(); - srand(rand()); - - map->food_flush[0].x = map->food_flush[0].y = -1; - - do - { - food.x = rand() % map->width; - food.y = rand() % map->height; - - if (map->range[food.y * map->width + food.x] == NORMAL) - { - map->food_flush[0] = food; - map->range[food.y * map->width + food.x] = FOOD; - num++; - } - } - while (num < max_num && rt_tick_get() - timeout < FOOD_TIMEOUT); - - return num; -} - -void map_deinit(map_t *map) -{ - if (map) - { - if (map->range) - { - rt_free(map->range); - map->range = RT_NULL; - } - rt_free(map); - } -} - -void snake_deinit(void) -{ - snake_t *node; - - while (!rt_list_isempty(&snake_head)) - { - node = rt_list_entry(snake_head.prev, snake_t, list); - rt_list_remove(&node->list); - rt_free(node); - } -} - -void food_deinit(void) -{ - -} - -SYS_STE snake_step(SNAKE_DIR dir, map_t *map) -{ - snake_t *tail, *head; - point_t node; - - ASSERT_RET(!map, RT_FALSE); - - dir = dir_adjust(dir); - - // ȡ��ͷβ�����ڵ㣬�����ڵ㲻��Ҫ�ı� - tail = rt_list_entry(snake_head.prev, snake_t, list); - head = rt_list_entry(snake_head.next, snake_t, list); - - node = head->body; - - // ����һ���µ���ͷ���� - switch (dir) - { - case SNAKE_DIR_UP: - case SNAKE_DIR_DOWN: - node.y = head->body.y + (dir == SNAKE_DIR_DOWN ? -1 : 1); - break; - case SNAKE_DIR_LEFT: - case SNAKE_DIR_RIGHT: - node.x = head->body.x + (dir == SNAKE_DIR_RIGHT ? 1 : -1); - break; - } - across_XY(&node, map); - - return node_update(tail, &node, map); -} - -rt_bool_t snake_restart(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map) -{ - ASSERT_RET(!map || !start, RT_FALSE); - - snake_deinit(); - memset(map->range, NORMAL, map->width * map->height); - - return snake_init(start, length, dir, map); -} diff --git a/bsp/simulator/testdll/snake/snake.h b/bsp/simulator/testdll/snake/snake.h deleted file mode 100644 index 557d4d9241..0000000000 --- a/bsp/simulator/testdll/snake/snake.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _SNAKE_H_ -#define _SNAKE_H_ - -#include <rtthread.h> - -#define snake_length_max 20 //����߳� -#define snake_length_init 3 //��ʼ���߳� -#define snake_room_size_hight 8 //���Ӹ� 0-255 ����>8 -#define snake_room_size_widht 8 //���ӿ� 0-255 ����>8 - -#define snake_init_pointx 1 -#define snake_init_pointy 2 - -typedef struct -{ - rt_int32_t x, y; -} point_t; - -typedef struct -{ - rt_int32_t width; // max x - rt_int32_t height; // max y - rt_uint8_t *range; // map, map->range[y * map->width + x] - point_t snake_flush[2]; - point_t food_flush[1]; -} map_t; - -typedef enum -{ - SNAKE_DIR_UP, - SNAKE_DIR_DOWN, - SNAKE_DIR_LEFT, - SNAKE_DIR_RIGHT -} SNAKE_DIR; - -typedef enum -{ - FOOD, // �Ե�ˮ�� - OVER, // ҧ������ - NORMAL // �����ж� -} SYS_STE; - -typedef struct -{ - point_t body; - rt_list_t list; -} snake_t; - -// ����һ����ͼ -map_t *map_init(rt_uint32_t width, rt_uint32_t heigth); - -// ����һ��ָ�����ȵ�����ָ���� -rt_bool_t snake_init(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map); - -// �����ʳ�� -rt_bool_t food_init(map_t *map, rt_uint32_t max_num); - -void map_deinit(map_t *map); - -void snake_deinit(void); - -void food_deinit(void); - -SYS_STE snake_step(SNAKE_DIR dir, map_t *map); - -rt_bool_t snake_restart(const point_t *start, const int length, const SNAKE_DIR dir, map_t *map); - -#endif diff --git a/bsp/simulator/testdll/snake/snake_gui.c b/bsp/simulator/testdll/snake/snake_gui.c deleted file mode 100644 index 5ad2c8d7c5..0000000000 --- a/bsp/simulator/testdll/snake/snake_gui.c +++ /dev/null @@ -1,397 +0,0 @@ -#include <string.h> -#include <rtthread.h> - -#include <rtgui/rtgui.h> -#include <rtgui/rtgui_app.h> -#include <rtgui/widgets/container.h> -#include <rtgui/widgets/window.h> -#include <rtgui/widgets/button.h> - -#include "snake.h" - -#define LATTICE_SIZE (20) -#define FOOD_MAX (8) - -#define WALL_COLOR RTGUI_RGB(255, 0, 0) -#define SNAKE_COLOR RTGUI_RGB(0, 100, 200) -#define SNAKE_HEAD_COLOR RTGUI_RGB(180, 70, 130) -#define BACKGROUND_COLOR RTGUI_RGB(153, 153, 0) -#define FOOD_COLOR RTGUI_RGB(128, 0, 0) - -static rtgui_timer_t *timer; -static rt_size_t room_size_x, room_size_y; -static rt_size_t lattice_size_x, lattice_size_y; -static struct rtgui_rect room_rect, lattice_rect; - -map_t *map; -SNAKE_DIR run_state; -rt_int32_t snake_len; -rt_int32_t food_num; -point_t second_node; - -static void snake_fill_lattice(struct rtgui_dc *dc, - rt_uint32_t x, - rt_uint32_t y, - rtgui_color_t color) -{ - struct rtgui_rect rect; - - // coordinate conversion - y = (lattice_size_y - 1) - y; - - RTGUI_DC_BC(dc) = color; - - rect.x1 = lattice_rect.x1 + (LATTICE_SIZE * x); - rect.x2 = rect.x1 + LATTICE_SIZE; - rect.x1 += 2; - - rect.y1 = lattice_rect.y1 + (LATTICE_SIZE * y); - rect.y2 = rect.y1 + LATTICE_SIZE; - rect.y1 += 2; - - rtgui_dc_fill_rect(dc, &rect); -} - -static void snake_draw(struct rtgui_widget *widget) -{ - struct rtgui_dc *dc; - struct rtgui_rect rect; - rt_uint32_t i; - - dc = rtgui_dc_begin_drawing(widget); - if (dc == RT_NULL) - { - rt_kprintf("dc == RT_NULL\r\n"); - return; - } - - /* get room size, run once frist. */ - if ((room_size_x == 0) || (room_size_y == 0)) - { - rt_size_t tmp; - - rtgui_widget_get_rect(widget, &rect); - rt_kprintf("rect => x1:%d x2:%d, y1:%d y2:%d\r\n", rect.x1, rect.x2, rect.y1, rect.y2); - - room_size_x = rect.x2 - rect.x1; - room_size_y = rect.y2 - rect.y1; - memcpy(&room_rect, &rect, sizeof(struct rtgui_rect)); - rt_kprintf("room_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", - room_rect.x1, room_rect.x2, - room_rect.y1, room_rect.y2); - - lattice_size_x = (room_rect.x2 - room_rect.x1) / LATTICE_SIZE; - lattice_size_y = (room_rect.y2 - room_rect.y1) / LATTICE_SIZE; - lattice_size_x -= 2; - lattice_size_y -= 2; - rt_kprintf("lattice_size_x:%d lattice_size_y:%d\r\n", - lattice_size_x, - lattice_size_y); - - tmp = (room_rect.x2 - room_rect.x1) - (LATTICE_SIZE * lattice_size_x); - lattice_rect.x1 = room_rect.x1 + (tmp / 2); - lattice_rect.x2 = lattice_rect.x1 + (LATTICE_SIZE * lattice_size_x); - - tmp = (room_rect.y2 - room_rect.y1) - (LATTICE_SIZE * lattice_size_y); - lattice_rect.y1 = room_rect.y1 + (tmp / 2); - lattice_rect.y2 = lattice_rect.y1 + (LATTICE_SIZE * lattice_size_y); - rt_kprintf("lattice_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", - lattice_rect.x1, lattice_rect.x2, - lattice_rect.y1, lattice_rect.y2); - - /* create snake. */ - { - point_t start; - map = map_init(lattice_size_x, lattice_size_y); - if (map != RT_NULL) - { - start.x = snake_init_pointx; - start.y = snake_init_pointy; - run_state = SNAKE_DIR_DOWN; - - if (snake_init(&start, snake_length_init, run_state, map)) - { - food_num = 1; - food_init(map, food_num); - } - else - { - map_deinit(map); - map = RT_NULL; - } - } - } - } - - RTGUI_DC_BC(dc) = BACKGROUND_COLOR; - rtgui_dc_fill_rect(dc, &room_rect); - - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.x2 += 1; - rect.y2 += 1; - RTGUI_DC_FC(dc) = WALL_COLOR; - rtgui_dc_draw_rect(dc, &rect); - - for (i = 1; i < lattice_size_y; i++) - { - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.x1 += 1; - rect.x2 -= 1; - rtgui_dc_draw_horizontal_line(dc, rect.x1, rect.x2, - rect.y1 + (LATTICE_SIZE * i)); - } - - for (i = 1; i < lattice_size_x; i++) - { - memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); - rect.y1 += 1; - rect.y2 -= 1; - rtgui_dc_draw_vertical_line(dc, rect.x1 + (LATTICE_SIZE * i), - rect.y1, rect.y2); - } - - /* draw snake. */ - { - rt_int32_t x, y; - rt_bool_t first_node = RT_TRUE; - - for (y = 0; y < map->height; y++) - { - for (x = 0; x < map->width; x++) - { - switch (map->range[y * map->width + x]) - { - case NORMAL: - break; - case FOOD: - snake_fill_lattice(dc, x, y, FOOD_COLOR); - break; - case OVER: - if (first_node) - { - first_node = RT_FALSE; - second_node.x = x; - second_node.y = y; - snake_fill_lattice(dc, x, y, SNAKE_HEAD_COLOR); - } - else - { - snake_fill_lattice(dc, x, y, SNAKE_COLOR); - } - break; - } - } - - } - } - - rtgui_dc_end_drawing(dc); - - return; -} - -static void snake_update(struct rtgui_widget *widget) -{ - struct rtgui_dc *dc; - rt_int32_t x, y; - rt_uint32_t i; - - dc = rtgui_dc_begin_drawing(widget); - if (dc == RT_NULL) - { - rt_kprintf("dc == RT_NULL\r\n"); - return; - } - - snake_fill_lattice(dc, second_node.x, second_node.y, SNAKE_COLOR); - second_node = map->snake_flush[0]; - - for (i = 0; i < 3; i++) - { - if (i < 2) - { - x = map->snake_flush[i].x; - y = map->snake_flush[i].y; - } - else - { - x = map->food_flush[0].x; - y = map->food_flush[0].y; - } - - if ((x >= 0) && (y >= 0)) - { - switch (map->range[(map->width * y) + x]) - { - case NORMAL: - snake_fill_lattice(dc, x, y, BACKGROUND_COLOR); - break; - case FOOD: - snake_fill_lattice(dc, x, y, FOOD_COLOR); - break; - case OVER: - if (0 == i) - snake_fill_lattice(dc, x, y, SNAKE_HEAD_COLOR); - else - snake_fill_lattice(dc, x, y, SNAKE_COLOR); - break; - } - } - } - - rtgui_dc_end_drawing(dc); - return; -} - -static void snake_handler(struct rtgui_widget *widget, rtgui_event_t *event) -{ - struct rtgui_event_kbd *ekbd; - - ekbd = (struct rtgui_event_kbd *) event; - if (ekbd->type == RTGUI_KEYDOWN) - { - switch (ekbd->key) - { - case RTGUIK_UP: - rt_kprintf("RTGUIK_UP\r\n"); - run_state = SNAKE_DIR_UP; - break; - case RTGUIK_DOWN: - rt_kprintf("RTGUIK_DOWN\r\n"); - run_state = SNAKE_DIR_DOWN; - break; - case RTGUIK_LEFT: - rt_kprintf("RTGUIK_LEFT\r\n"); - run_state = SNAKE_DIR_LEFT; - break; - case RTGUIK_RIGHT: - rt_kprintf("RTGUIK_RIGHT\r\n"); - run_state = SNAKE_DIR_RIGHT; - break; - default: - break; - } - } -} - -static rt_bool_t event_handler(struct rtgui_object *object, rtgui_event_t *event) -{ - struct rtgui_widget *widget = RTGUI_WIDGET(object); - - rt_kprintf("event_handler\r\n"); - - if (event->type == RTGUI_EVENT_PAINT) - { - rt_kprintf("RTGUI_EVENT_PAINT\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_draw(widget); - rtgui_timer_start(timer); - } - else if (event->type == RTGUI_EVENT_SHOW) - { - rt_kprintf("RTGUI_EVENT_SHOW\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_draw(widget); - rtgui_timer_start(timer); - } - else if (event->type == RTGUI_EVENT_HIDE) - { - rt_kprintf("RTGUI_EVENT_HIDE\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - rtgui_timer_stop(timer); - } - else if (event->type == RTGUI_EVENT_WIN_DEACTIVATE) - { - rt_kprintf("RTGUI_EVENT_WIN_DEACTIVATE\r\n"); - rtgui_win_event_handler((struct rtgui_object *)object, event); - rtgui_timer_stop(timer); - } - else if (event->type == RTGUI_EVENT_KBD) - { - rtgui_win_event_handler((struct rtgui_object *)object, event); - snake_handler(widget, event); - } - else - { - rt_kprintf("event->type:%d\r\n", event->type); - return rtgui_win_event_handler((struct rtgui_object *)object, event); - } - - return RT_FALSE; -} - -static void timeout(struct rtgui_timer *timer, void *parameter) -{ - struct rtgui_widget *widget; - SYS_STE ret; - - if (!map) - return; - - ret = snake_step(run_state, map); - if (OVER == ret) - return; - - if (FOOD == ret) - { - snake_len++; - if (snake_len >= (map->width * map->height) / 3) - { - point_t start; - - start.x = snake_init_pointx; - start.y = snake_init_pointy; - run_state = SNAKE_DIR_DOWN; - snake_len = snake_length_init; - - if (!snake_restart(&start, snake_len, run_state, map)) - { - map_deinit(map); - snake_deinit(); - map = RT_NULL; - } - } - - food_init(map, 1); - } - - widget = RTGUI_WIDGET(parameter); - snake_update(widget); -} - -void main(void) -{ - struct rtgui_app *application; - struct rtgui_win *win; - rtgui_rect_t rect; - - application = rtgui_app_create("sanke_app"); - if (application != RT_NULL) - { - rtgui_get_screen_rect(&rect); - rtgui_set_mainwin_rect(&rect); - win = rtgui_mainwin_create(RT_NULL, - "sanke_win", - RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE); - if (win == RT_NULL) - { - rt_kprintf("sanke_win create fail!\r\n"); - return; - } - - rtgui_object_set_event_handler(RTGUI_OBJECT(win), event_handler); - - timer = rtgui_timer_create(RT_TICK_PER_SECOND / 2, - RT_TIMER_FLAG_PERIODIC, - timeout, - (void *)win); - - rtgui_win_show(win, RT_TRUE); - - //�˳���ŷ��� - map_deinit(map); - snake_deinit(); - food_deinit(); - rtgui_app_destroy(application); - } -} diff --git a/bsp/simulator/testdll/var/Sconscript b/bsp/simulator/testdll/var/Sconscript deleted file mode 100644 index d8dd99964e..0000000000 --- a/bsp/simulator/testdll/var/Sconscript +++ /dev/null @@ -1,7 +0,0 @@ -import rtconfig -Import('RTT_ROOT') -from building import * - -src = Glob('*.c') -group = DefineGroup('', src, depend = ['']) -Return('group')
\ No newline at end of file diff --git a/bsp/simulator/testdll/var/var.c b/bsp/simulator/testdll/var/var.c deleted file mode 100644 index 41eba40f38..0000000000 --- a/bsp/simulator/testdll/var/var.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <rtthread.h> - -/* rtgui\common\rtgui_object.c */ -_declspec(dllimport) void * _rtgui_object; - -/* rtgui\common\color.c */ -_declspec(dllimport) rt_uint32_t blue; -//extern rt_uint32_t * green; - -int main(void) -{ - int i; - - //rt_kprintf("green = %x, *green", green, *(rt_uint32_t *)green); - rt_kprintf("blue = %x\n", blue); - rt_kprintf("_rtgui_object = %x\n", _rtgui_object); - - return 0; -} - diff --git a/bsp/stm32f40x/Libraries/SConscript b/bsp/stm32f40x/Libraries/SConscript index d23856456a..c83c06b439 100644 --- a/bsp/stm32f40x/Libraries/SConscript +++ b/bsp/stm32f40x/Libraries/SConscript @@ -18,8 +18,8 @@ if rtconfig.CROSS_TOOL == 'gcc': src = src + ['CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s'] elif rtconfig.CROSS_TOOL == 'keil': src = src + ['CMSIS/ST/STM32F4xx/Source/Templates/arm/startup_stm32f4xx.s'] -# elif rtconfig.CROSS_TOOL == 'iar': - # src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/iar/' + startup_scripts[rtconfig.STM32_TYPE]] +elif rtconfig.CROSS_TOOL == 'iar': + src = src + ['CMSIS/ST/STM32F4xx/Source/Templates/iar/startup_stm32f4xx.s'] path = [cwd + '/STM32F4xx_StdPeriph_Driver/inc', cwd + '/CMSIS/ST/STM32F4xx/Include', diff --git a/bsp/stm32f40x/drivers/board.h b/bsp/stm32f40x/drivers/board.h index 97b506c146..7f362503b0 100644 --- a/bsp/stm32f40x/drivers/board.h +++ b/bsp/stm32f40x/drivers/board.h @@ -37,8 +37,14 @@ // <o> Internal SRAM memory size[Kbytes] <8-64> // <i>Default: 64 +#ifdef __ICCARM__ +// Use *.icf ram symbal, to avoid hardcode. +extern char __ICFEDIT_region_RAM_end__; +#define STM32_SRAM_END &__ICFEDIT_region_RAM_end__ +#else #define STM32_SRAM_SIZE 128 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) +#endif // <o> Console on USART: <0=> no console <1=>USART 1 <2=>USART 2 <3=> USART 3 // <i>Default: 1 diff --git a/bsp/stm32f40x/drivers/stm32f4_rtc.c b/bsp/stm32f40x/drivers/stm32f4_rtc.c new file mode 100644 index 0000000000..b949f4510b --- /dev/null +++ b/bsp/stm32f40x/drivers/stm32f4_rtc.c @@ -0,0 +1,247 @@ +/* + * File : stm32f4_rtc.c + * This file is stm32f4 rtc driver part of RT-Thread RTOS + * COPYRIGHT (C) 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2015-09-29 FlyM the first version. + */ +#include <time.h> +#include <rtthread.h> +#include <stm32f4xx.h> +#include "stm32f4_rtc.h" + +static int get_week(int year, int month, int day) +{ + if (month==1||month==2) + { + year -=1; + month +=12; + } + return (day+1+2*month+3*(month+1)/5+year+(year/4)-year/100+year/400)%7; +} + +static struct rt_device rtc; +static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag) +{ + if (dev->rx_indicate != RT_NULL) + { + /* Open Interrupt */ + } + + return RT_EOK; +} + +static rt_size_t rt_rtc_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size) +{ + return 0; +} + +static rt_err_t rt_rtc_control(rt_device_t dev, rt_uint8_t cmd, void *args) +{ + rt_time_t *time; + RT_ASSERT(dev != RT_NULL); + + switch (cmd) + { + case RT_DEVICE_CTRL_RTC_GET_TIME: + { + struct tm ct; + RTC_TimeTypeDef t; + RTC_DateTypeDef d; + + rt_memset(&ct,0,sizeof(struct tm)); + time = (rt_time_t *)args; + /* read device */ + RTC_GetDate(RTC_Format_BIN,&d); + RTC_GetTime(RTC_Format_BIN,&t); + + ct.tm_year = d.RTC_Year + 100; + ct.tm_mon = d.RTC_Month - 1; + ct.tm_mday = d.RTC_Date; + ct.tm_wday = d.RTC_WeekDay; + + ct.tm_hour = t.RTC_Hours; + ct.tm_min = t.RTC_Minutes; + ct.tm_sec = t.RTC_Seconds; + + *time = mktime(&ct); + } + break; + + case RT_DEVICE_CTRL_RTC_SET_TIME: + { + struct tm *ct; + struct tm tm_new; + time_t *time; + RTC_TimeTypeDef RTC_TimeStructure; + RTC_InitTypeDef RTC_InitStructure; + RTC_DateTypeDef RTC_DateStructure; + + time = (time_t *)args; + /* lock scheduler. */ + rt_enter_critical(); + /* converts calendar time time into local time. */ + ct = localtime(time); + /* copy the statically located variable */ + rt_memcpy(&tm_new, ct, sizeof(struct tm)); + /* unlock scheduler. */ + rt_exit_critical(); + /* Enable the PWR clock */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); + /* Allow access to RTC */ + PWR_BackupAccessCmd(ENABLE); + /* ck_spre(1Hz) = RTCCLK(LSI) /(uwAsynchPrediv + 1)*(uwSynchPrediv + 1)*/ + //uwSynchPrediv = 0xFF; + //uwAsynchPrediv = 0x7F; + /* Configure the RTC data register and RTC prescaler */ + RTC_InitStructure.RTC_AsynchPrediv = 0x7F; + RTC_InitStructure.RTC_SynchPrediv = 0xFF; + RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; + RTC_Init(&RTC_InitStructure); + /* Set the date */ + RTC_DateStructure.RTC_Year = tm_new.tm_year - 100; + RTC_DateStructure.RTC_Month = tm_new.tm_mon + 1; + RTC_DateStructure.RTC_Date = tm_new.tm_mday; + RTC_DateStructure.RTC_WeekDay = get_week(tm_new.tm_year+1900,tm_new.tm_mon+1,tm_new.tm_mday); + RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure); + /* Set the time*/ + if (tm_new.tm_hour > 11) + { + RTC_TimeStructure.RTC_H12 = RTC_H12_PM; + } + else + { + RTC_TimeStructure.RTC_H12 = RTC_H12_AM; + } + RTC_TimeStructure.RTC_Hours = tm_new.tm_hour; + RTC_TimeStructure.RTC_Minutes = tm_new.tm_min; + RTC_TimeStructure.RTC_Seconds = tm_new.tm_sec; + + RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure); + + /* Indicator for the RTC configuration */ + RTC_WriteBackupRegister(RTC_BKP_DR0, 0x32F2); + } + break; + } + + return RT_EOK; +} + +/******************************************************************************* +* Function Name : RTC_Configuration +* Description : Configures the RTC. +* Input : None +* Output : None +* Return : 0 reday,-1 error. +*******************************************************************************/ +int RTC_Configuration(void) +{ + /* Enable the PWR clock */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); + + /* Allow access to RTC */ + PWR_BackupAccessCmd(ENABLE); + +#if defined (RTC_CLOCK_SOURCE_LSI) /* LSI used as RTC source clock*/ + /* The RTC Clock may varies due to LSI frequency dispersion */ + /* Enable the LSI OSC */ + RCC_LSICmd(ENABLE); + + /* Wait till LSI is ready */ + while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) + { + } + + /* Select the RTC Clock Source */ + RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); + + /* ck_spre(1Hz) = RTCCLK(LSI) /(uwAsynchPrediv + 1)*(uwSynchPrediv + 1)*/ + //uwSynchPrediv = 0xFF; + //uwAsynchPrediv = 0x7F; + +#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock */ + /* Enable the LSE OSC */ + RCC_LSEConfig(RCC_LSE_ON); + + /* Wait till LSE is ready */ + while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) + { + } + /* Select the RTC Clock Source */ + RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); + +#else +#error Please select the RTC Clock source inside the main.c file +#endif /* RTC_CLOCK_SOURCE_LSI */ + + /* Enable the RTC Clock */ + RCC_RTCCLKCmd(ENABLE); + + /* Wait for RTC APB registers synchronisation */ + RTC_WaitForSynchro(); + + return 0; +} + +void rt_hw_rtc_init(void) +{ + rtc.type = RT_Device_Class_RTC; + + if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2) + { + rt_kprintf("rtc is not configured\n"); + rt_kprintf("please configure with set_date and set_time\n"); + if ( RTC_Configuration() != 0) + { + rt_kprintf("rtc configure fail...\r\n"); + return ; + } + } + else + { + /* Wait for RTC registers synchronization */ + RTC_WaitForSynchro(); + } + + /* register rtc device */ + rtc.init = RT_NULL; + rtc.open = rt_rtc_open; + rtc.close = RT_NULL; + rtc.read = rt_rtc_read; + rtc.write = RT_NULL; + rtc.control = rt_rtc_control; + + /* no private */ + rtc.user_data = RT_NULL; + + rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR); + + return; +} + +#ifdef RT_USING_FINSH +#include "finsh.h" +void show_time(void) +{ + RTC_TimeTypeDef t; + RTC_DateTypeDef d; + /* Get the current Date */ + RTC_GetDate(RTC_Format_BIN,&d); + /* Get the current Time */ + RTC_GetTime(RTC_Format_BIN, &t); + /* Display time Format : hh:mm:ss */ + rt_kprintf("Now Time = 20%02d %02d %02d[%02d]-%0.2d:%0.2d:%0.2d \r\n", \ + d.RTC_Year,d.RTC_Month,d.RTC_Date,d.RTC_WeekDay,t.RTC_Hours, t.RTC_Minutes, t.RTC_Seconds); +} + +FINSH_FUNCTION_EXPORT(show_time, show current time.) +#endif + + diff --git a/bsp/stm32f40x/drivers/stm32f4_rtc.h b/bsp/stm32f40x/drivers/stm32f4_rtc.h new file mode 100644 index 0000000000..42fa4ebed7 --- /dev/null +++ b/bsp/stm32f40x/drivers/stm32f4_rtc.h @@ -0,0 +1,23 @@ +/* + * File : stm32f4_rtc.h + * This file is stm32f4 rtc driver part of RT-Thread RTOS + * COPYRIGHT (C) 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2015-09-29 FlyM the first version + */ + +#ifndef __STM32F4_RTC_H__ +#define __STM32F4_RTC_H__ + +#define RTC_CLOCK_SOURCE_LSE + +void rt_hw_rtc_init(void); + +#endif + diff --git a/bsp/stm32f40x/readme.md b/bsp/stm32f40x/readme.md new file mode 100644 index 0000000000..e1d0e56820 --- /dev/null +++ b/bsp/stm32f40x/readme.md @@ -0,0 +1,25 @@ +board info: +STM32F4 discovery +http://www.st.com/internet/evalboard/product/252419.jsp + +note: +in drivers/stm32f4xx_conf.h + /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ + #define HSE_VALUE ((uint32_t)8000000) + + + + **================= IAR WARNING =================** + + after use `scons --target=iar -s` cmd to product IAR project, you have to add iar link file by hand + + IAR steps: + 1. Project-->Options-->Linker + 2. Config-->Linker Configuration file + 3. select `Override Default`, then select `bsp/stm32f40x/stm32f40x_flash.icf` + 4. rebuild project + + + **TODO** + auto add *.icf by scons script + diff --git a/bsp/stm32f40x/readme.txt b/bsp/stm32f40x/readme.txt deleted file mode 100644 index 7bebe251c6..0000000000 --- a/bsp/stm32f40x/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -board info: -STM32F4 discovery -http://www.st.com/internet/evalboard/product/252419.jsp - -note: -in drivers/stm32f4xx_conf.h - /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ - #define HSE_VALUE ((uint32_t)8000000) - diff --git a/bsp/stm32f40x/stm32f40x_flash.icf b/bsp/stm32f40x/stm32f40x_flash.icf new file mode 100644 index 0000000000..204f459388 --- /dev/null +++ b/bsp/stm32f40x/stm32f40x_flash.icf @@ -0,0 +1,36 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x08000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x08000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF; /*STM32 F446RE*/ + +/*Export the end address of ram, to avoid hard-code heap size in application*/ +export symbol __ICFEDIT_region_RAM_end__; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x200; +define symbol __ICFEDIT_size_heap__ = 0x000; +/**** End of ICF editor section. ###ICF###*/ + + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +keep { section FSymTab }; +keep { section VSymTab }; +keep { section .rti_fn* }; +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, block CSTACK, last block HEAP}; diff --git a/bsp/stm32f7-disco/applications/application.c b/bsp/stm32f7-disco/applications/main.c index e1dafdf5b2..a0b14aee41 100644 --- a/bsp/stm32f7-disco/applications/application.c +++ b/bsp/stm32f7-disco/applications/main.c @@ -1,5 +1,5 @@ /* - * File : application.c + * File : main.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2015, RT-Thread Development Team * @@ -24,21 +24,10 @@ */ #include <rtthread.h> -#include <components.h> -void rt_init_thread_entry(void *parameter) +int main(void) { - rt_components_init(); -} - -int rt_application_init() -{ - rt_thread_t tid; - - tid = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 2048, RT_THREAD_PRIORITY_MAX / 3, 20); - if (tid != RT_NULL) rt_thread_startup(tid); - + /* put user application code here */ return 0; } + diff --git a/bsp/stm32f7-disco/applications/startup.c b/bsp/stm32f7-disco/applications/startup.c deleted file mode 100644 index 628a805042..0000000000 --- a/bsp/stm32f7-disco/applications/startup.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * File : startup.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Change Logs: - * Date Author Notes - * 2006-08-31 Bernard first implementation - * 2015-08-01 xiaonong modify for STM32F7 version - */ - -#include <rthw.h> -#include <rtthread.h> -#include "board.h" - -#ifdef RT_USING_EXT_SDRAM -#include "drv_sdram.h" -#include "sram.h" -#endif - -/** - * @addtogroup STM32 - */ - -/*@{*/ - -extern int rt_application_init(void); - -#ifdef USE_FULL_ASSERT -/** -* @brief assert_failed -* Reports the name of the source file and the source line number -* where the assert_param error has occurred. -* @param File: pointer to the source file name -* @param Line: assert_param error line source number -* @retval None -*/ -void assert_failed(uint8_t* file, uint32_t line) -{ - /* User can add his own implementation to report the file name and line - number,ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - rt_kprintf("\n\r Wrong parameter value detected on\r\n"); - rt_kprintf(" file %s\r\n", file); - rt_kprintf(" line %d\r\n", line); - - /* Infinite loop */ - while (1) - {} -} -#endif - -/** - * This function will startup RT-Thread RTOS. - */ -void rtthread_startup(void) -{ - /* init board */ - rt_hw_board_init(); - - /* show version */ - rt_show_version(); - - /* init tick */ - rt_system_tick_init(); - - /* init kernel object */ - rt_system_object_init(); - - /* init timer system */ - rt_system_timer_init(); - -#ifdef RT_USING_EXT_SDRAM - sdram_hw_init(); - rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END); - sram_init(); -#else - rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END); -#endif - - /* init scheduler system */ - rt_system_scheduler_init(); - - /* init application */ - rt_application_init(); - - /* init timer thread */ - rt_system_timer_thread_init(); - - /* init idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); - - /* never reach here */ - return ; -} - -int main(void) -{ - /* disable interrupt first */ - rt_hw_interrupt_disable(); - - /* startup RT-Thread RTOS */ - rtthread_startup(); - - return 0; -} - -/*@}*/ diff --git a/bsp/stm32f7-disco/drivers/board.c b/bsp/stm32f7-disco/drivers/board.c index 734ecf2094..02f0acf2e6 100644 --- a/bsp/stm32f7-disco/drivers/board.c +++ b/bsp/stm32f7-disco/drivers/board.c @@ -22,12 +22,9 @@ * 2009-01-05 Bernard first implementation */ -#include <rthw.h> #include <rtthread.h> -#include <components.h> - #include "board.h" -#include "drv_usart.h" +#include "sram.h" #include "drv_mpu.h" /** @@ -70,11 +67,11 @@ static void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLN = 400; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 8; - + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); if(ret != HAL_OK) { - while(1) { ; } + while (1) { ; } } ret = HAL_PWREx_EnableOverDrive(); @@ -85,7 +82,8 @@ static void SystemClock_Config(void) /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ - RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |\ + RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; @@ -186,7 +184,16 @@ void rt_hw_board_init() /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); +#ifdef RT_USING_COMPONENTS_INIT rt_components_board_init(); +#endif + +#ifdef RT_USING_EXT_SDRAM + rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END); + sram_init(); +#else + rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END); +#endif #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME); diff --git a/bsp/stm32f7-disco/drivers/board.h b/bsp/stm32f7-disco/drivers/board.h index d4aebe06d6..8d1e9f3739 100644 --- a/bsp/stm32f7-disco/drivers/board.h +++ b/bsp/stm32f7-disco/drivers/board.h @@ -31,8 +31,8 @@ // <e>Use external SDRAM memory on the board // <o>Begin Address of External SDRAM #define EXT_SDRAM_BEGIN 0xC0000000 +// <o>Size of External SDRAM #define EXT_SDRAM_SIZE (0x800000) -// <o>End Address of External SDRAM #define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE) // </e> diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.c b/bsp/stm32f7-disco/drivers/drv_mpu.c index 4cab4d2281..ecf556203b 100644 --- a/bsp/stm32f7-disco/drivers/drv_mpu.c +++ b/bsp/stm32f7-disco/drivers/drv_mpu.c @@ -23,9 +23,9 @@ */ #include "drv_mpu.h" - - -void mpu_init(void) +#include <rtthread.h> +#include "stm32f7xx.h" +int mpu_init(void) { MPU_Region_InitTypeDef MPU_InitStruct; @@ -79,5 +79,6 @@ void mpu_init(void) /* Enable the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + return 0; } - +//INIT_BOARD_EXPORT(mpu_init); diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.h b/bsp/stm32f7-disco/drivers/drv_mpu.h index 707adfc2ef..9baf74b0d7 100644 --- a/bsp/stm32f7-disco/drivers/drv_mpu.h +++ b/bsp/stm32f7-disco/drivers/drv_mpu.h @@ -1,9 +1,9 @@ #ifndef __DRV_MPU_H #define __DRV_MPU_H -#include "stm32f7xx.h" + /* Initialize Cortex M MPU */ -void mpu_init(void); +int mpu_init(void); #endif diff --git a/bsp/stm32f7-disco/drivers/drv_sdram.c b/bsp/stm32f7-disco/drivers/drv_sdram.c index 4b58e21d01..303bd3b928 100644 --- a/bsp/stm32f7-disco/drivers/drv_sdram.c +++ b/bsp/stm32f7-disco/drivers/drv_sdram.c @@ -362,3 +362,9 @@ void SDRAM_DMA_IRQHandler(void) { HAL_DMA_IRQHandler(sdramHandle.hdma); } + +static int rt_sdram_hw_init(void) +{ + return (int)sdram_hw_init(); +} +INIT_BOARD_EXPORT(rt_sdram_hw_init); diff --git a/bsp/stm32f7-disco/rtconfig.h b/bsp/stm32f7-disco/rtconfig.h index bd0aaed397..f599858171 100644 --- a/bsp/stm32f7-disco/rtconfig.h +++ b/bsp/stm32f7-disco/rtconfig.h @@ -227,4 +227,7 @@ /* enable SDRAM */ #define RT_USING_EXT_SDRAM +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN + #endif diff --git a/bsp/stm32f7-disco/rtconfig.py b/bsp/stm32f7-disco/rtconfig.py index 91ef8db8b3..0741e1931c 100644 --- a/bsp/stm32f7-disco/rtconfig.py +++ b/bsp/stm32f7-disco/rtconfig.py @@ -19,10 +19,8 @@ elif CROSS_TOOL == 'keil': PLATFORM = 'armcc' EXEC_PATH = r'C:/Keil_v5' elif CROSS_TOOL == 'iar': - print '================ERROR============================' - print 'Not support iar yet!' - print '=================================================' - exit(0) + PLATFORM = 'iar' + IAR_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.2' if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') @@ -45,7 +43,7 @@ if PLATFORM == 'gcc': STRIP = PREFIX + 'strip' DEVICE = ' -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED' + CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED -eentry' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread_stm32f7xx.map,-cref,-u,Reset_Handler -T rtthread-stm32f7xx.ld' @@ -99,6 +97,7 @@ elif PLATFORM == 'armcc': elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -123,18 +122,23 @@ elif PLATFORM == 'iar': CFLAGS += ' --dlib_config "' + IAR_PATH + '/arm/INC/c/DLib_Config_Normal.h"' CFLAGS += ' -Ol' CFLAGS += ' --use_c++_inline' - + CFLAGS += ' --silent' + AFLAGS = '' AFLAGS += ' -s+' AFLAGS += ' -w+' AFLAGS += ' -r' AFLAGS += ' --cpu Cortex-M7' AFLAGS += ' --fpu None' - + AFLAGS += ' -S' + LFLAGS = ' --config rtthread-stm32f7xx.icf' LFLAGS += ' --redirect _Printf=_PrintfTiny' LFLAGS += ' --redirect _Scanf=_ScanfSmall' LFLAGS += ' --entry __iar_program_start' + LFLAGS += ' --silent' + + CXXFLAGS = CFLAGS EXEC_PATH = IAR_PATH + '/arm/bin/' POST_ACTION = '' diff --git a/bsp/stm32f7-disco/rtthread-stm32f7xx.icf b/bsp/stm32f7-disco/rtthread-stm32f7xx.icf new file mode 100644 index 0000000000..73cbc1c601 --- /dev/null +++ b/bsp/stm32f7-disco/rtthread-stm32f7xx.icf @@ -0,0 +1,33 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/
+/*-Editor annotation file-*/
+/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
+/*-Specials-*/
+define symbol __ICFEDIT_intvec_start__ = 0x00200000;
+/*-Memory Regions-*/
+define symbol __ICFEDIT_region_ROM_start__ = 0x00200000;
+define symbol __ICFEDIT_region_ROM_end__ = 0x002FFFFF;
+define symbol __ICFEDIT_region_RAM_start__ = 0x20010000;
+define symbol __ICFEDIT_region_RAM_end__ = 0x2003FFFF;
+/*-Sizes-*/
+define symbol __ICFEDIT_size_cstack__ = 0x400;
+define symbol __ICFEDIT_size_heap__ = 0x200;
+/**** End of ICF editor section. ###ICF###*/
+
+
+define memory mem with size = 4G;
+define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
+define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
+
+define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
+define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
+
+initialize by copy { readwrite };
+do not initialize { section .noinit };
+
+place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
+
+place in ROM_region { readonly };
+place in RAM_region { readwrite, block CSTACK, block HEAP };
+keep { section FSymTab };
+keep { section VSymTab };
+keep { section .rti_fn* };
diff --git a/bsp/stm32f7-disco/rtthread-stm32f7xx.ld b/bsp/stm32f7-disco/rtthread-stm32f7xx.ld index a841a10714..16f747b83a 100644 --- a/bsp/stm32f7-disco/rtthread-stm32f7xx.ld +++ b/bsp/stm32f7-disco/rtthread-stm32f7xx.ld @@ -6,7 +6,7 @@ /* Program Entry, set to mark it as "used" and avoid gc */ MEMORY { - CODE (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */ + CODE (rx) : ORIGIN = 0x00200000, LENGTH = 1024k /* 1024KB flash */ DATA (rw) : ORIGIN = 0x20010000, LENGTH = 256k /* 256K sram */ } ENTRY(Reset_Handler) diff --git a/bsp/stm32f7-disco/rtthread-stm32f7xx.sct b/bsp/stm32f7-disco/rtthread-stm32f7xx.sct index a084b410ca..f9e5ff5279 100644 --- a/bsp/stm32f7-disco/rtthread-stm32f7xx.sct +++ b/bsp/stm32f7-disco/rtthread-stm32f7xx.sct @@ -2,8 +2,8 @@ ; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
-LR_IROM1 0x08000000 0x00100000 { ; load region size_region
- ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
+LR_IROM1 0x00200000 0x00100000 { ; load region size_region
+ ER_IROM1 0x00200000 0x00100000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
diff --git a/bsp/stm32f7-disco/template.ewp b/bsp/stm32f7-disco/template.ewp new file mode 100644 index 0000000000..5f300148cc --- /dev/null +++ b/bsp/stm32f7-disco/template.ewp @@ -0,0 +1,1919 @@ +<?xml version="1.0" encoding="iso-8859-1"?>
+
+<project>
+ <fileVersion>2</fileVersion>
+ <configuration>
+ <name>Debug</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>1</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>24</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>ExePath</name>
+ <state>build\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>build\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>build\List</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input variant</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state>Automatic choice of formatter.</state>
+ </option>
+ <option>
+ <name>Output variant</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state>Automatic choice of formatter.</state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state>Use the normal configuration of the C/C++ runtime library. No locale interface, C locale, no file descriptor support, no multibytes in printf and scanf, and no hex floats in strtod.</state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.20.1.7306</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state>7.40.3.8937</state>
+ </option>
+ <option>
+ <name>GeneralEnableMisra</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraVerbose</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state>STM32F746NG ST STM32F746NG</state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>GeneralMisraVer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state>$TOOLKIT_DIR$\INC\c\DLib_Config_Normal.h</state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>22</version>
+ <state>41</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CoreVariant</name>
+ <version>22</version>
+ <state>41</state>
+ </option>
+ <option>
+ <name>GFPUDeviceSlave</name>
+ <state>STM32F746NG ST STM32F746NG</state>
+ </option>
+ <option>
+ <name>FPU2</name>
+ <version>0</version>
+ <state>6</state>
+ </option>
+ <option>
+ <name>NrRegs</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>NEON</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave2</name>
+ <version>22</version>
+ <state>41</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>31</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>ewarm</state>
+ <state>STM32F411xE</state>
+ <state>USE_STDPERIPH_DRIVER</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state>Pa050</state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>00000000</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CompilerMisraOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IInterwork2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCppDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccExceptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccRTTI</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>AMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>3</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state>rtthread.bin</state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>0</hasPrio>
+ </data>
+ </settings>
+ <settings>
+ <name>BICOMP</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>XLinkMisraHandler</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>rtthread.out</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>$PROJ_DIR$\rtthread-stm32f7xx.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state>__iar_program_start</state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>BILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ </configuration>
+ <configuration>
+ <name>Release</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>0</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>24</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>ExePath</name>
+ <state>Release\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>Release\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>Release\List</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input variant</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>Output variant</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.20.1.7306</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state>7.40.3.8937</state>
+ </option>
+ <option>
+ <name>GeneralEnableMisra</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraVerbose</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state>Default None</state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>GeneralMisraVer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>22</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CoreVariant</name>
+ <version>22</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUDeviceSlave</name>
+ <state>Default None</state>
+ </option>
+ <option>
+ <name>FPU2</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>NrRegs</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>NEON</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave2</name>
+ <version>22</version>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>31</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>NDEBUG</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>11111110</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CompilerMisraOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IInterwork2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>3</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCppDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccExceptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccRTTI</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>0</hasPrio>
+ </data>
+ </settings>
+ <settings>
+ <name>BICOMP</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>XLinkMisraHandler</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>###Unitialized###</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>lnk0t.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>BILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ </configuration>
+</project>
+
+
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 1f4569558f..fcbb738572 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -213,8 +213,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat st->st_size = 0; st->st_mtime = 0; - st->st_blksize = 512; - + return DFS_STATUS_OK; } else @@ -238,8 +237,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat st->st_size = 0; st->st_mtime = 0; - st->st_blksize = 512; - + return DFS_STATUS_OK; } } diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index 3658a5dc80..ca2c082972 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -738,7 +738,6 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) st->st_mode &= ~(DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH); st->st_size = file_info.fsize; - st->st_blksize = 512; /* get st_mtime. */ { diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c index 6516797544..78c7730136 100644 --- a/components/dfs/filesystems/jffs2/dfs_jffs2.c +++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c @@ -331,7 +331,7 @@ static int dfs_jffs2_open(struct dfs_fd* file) return jffs2_result_to_dfs(result); } - /* save this pointer, it will be used when calling read()��write(), + /* save this pointer, it will be used when calling read()��write(), flush(), lessk(), and will be rt_free when calling close()*/ file->data = jffs2_file; file->pos = jffs2_file->f_offset; @@ -686,7 +686,6 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st st->st_dev = 0; st->st_size = s.st_size; st->st_mtime = s.st_mtime; - st->st_blksize = 1;//fixme: what's this field? return 0; } diff --git a/components/dfs/filesystems/lwip/lwip_netdb.c b/components/dfs/filesystems/lwip/lwip_netdb.c index 6871474251..1e14dfb093 100644 --- a/components/dfs/filesystems/lwip/lwip_netdb.c +++ b/components/dfs/filesystems/lwip/lwip_netdb.c @@ -29,6 +29,7 @@ struct hostent *gethostbyname(const char *name) { return lwip_gethostbyname(name); } +RTM_EXPORT(gethostbyname); int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) @@ -40,6 +41,7 @@ void freeaddrinfo(struct addrinfo *ai) { lwip_freeaddrinfo(ai); } +RTM_EXPORT(freeaddrinfo); int getaddrinfo(const char *nodename, const char *servname, @@ -48,3 +50,4 @@ int getaddrinfo(const char *nodename, { return lwip_getaddrinfo(nodename, servname, hints, res); } +RTM_EXPORT(getaddrinfo); diff --git a/components/dfs/filesystems/lwip/lwip_select.c b/components/dfs/filesystems/lwip/lwip_select.c index 3477b6f1d6..31d9190cfc 100644 --- a/components/dfs/filesystems/lwip/lwip_select.c +++ b/components/dfs/filesystems/lwip/lwip_select.c @@ -118,5 +118,6 @@ select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, return result; } +RTM_EXPORT(select); #endif diff --git a/components/dfs/filesystems/lwip/lwip_sockets.c b/components/dfs/filesystems/lwip/lwip_sockets.c index 346ef7b266..6b68378f7d 100644 --- a/components/dfs/filesystems/lwip/lwip_sockets.c +++ b/components/dfs/filesystems/lwip/lwip_sockets.c @@ -32,154 +32,167 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - int new_client = -1; + int new_client = -1; int sock = dfs_lwip_getsocket(s); new_client = lwip_accept(sock, addr, addrlen); - if (new_client != -1) - { - /* this is a new socket, create it in file system fd */ - int fd; - struct dfs_fd *d; - - /* allocate a fd */ - fd = fd_new(); - if (fd < 0) - { - rt_set_errno(-DFS_STATUS_ENOMEM); - lwip_close(sock); + if (new_client != -1) + { + /* this is a new socket, create it in file system fd */ + int fd; + struct dfs_fd *d; - printf("no fd yet!\n"); - return -1; - } - d = fd_get(fd); + /* allocate a fd */ + fd = fd_new(); + if (fd < 0) + { + rt_set_errno(-DFS_STATUS_ENOMEM); + lwip_close(sock); - /* this is a socket fd */ - d->type = FT_SOCKET; - d->path = RT_NULL; - - d->fs = dfs_lwip_get_fs(); - - d->flags = DFS_O_RDWR; /* set flags as read and write */ - d->size = 0; - d->pos = 0; + rt_kprintf("no fd yet!\n"); + return -1; + } + d = fd_get(fd); - /* set socket to the data of dfs_fd */ - d->data = (void*) new_client; + /* this is a socket fd */ + d->type = FT_SOCKET; + d->path = RT_NULL; + + d->fs = dfs_lwip_get_fs(); + + d->flags = DFS_O_RDWR; /* set flags as read and write */ + d->size = 0; + d->pos = 0; + + /* set socket to the data of dfs_fd */ + d->data = (void *) new_client; + + /* release the ref-count of fd */ + fd_put(d); - /* release the ref-count of fd */ - fd_put(d); - return fd; - } + } - return new_client; + return new_client; } +RTM_EXPORT(accept); int bind(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_bind(sock, name, namelen); } +RTM_EXPORT(bind); int shutdown(int s, int how) { int sock; - struct dfs_fd *d; + struct dfs_fd *d; - d = fd_get(s); - if (d == RT_NULL) - { - rt_set_errno(-DFS_STATUS_EBADF); - - return -1; - } + d = fd_get(s); + if (d == RT_NULL) + { + rt_set_errno(-DFS_STATUS_EBADF); - sock = dfs_lwip_getsocket(s); + return -1; + } + + sock = dfs_lwip_getsocket(s); if (lwip_shutdown(sock, how) == 0) { - /* socket has been closed, delete it from file system fd */ - fd_put(d); - fd_put(d); - - return 0; + /* socket has been closed, delete it from file system fd */ + fd_put(d); + fd_put(d); + + return 0; } - return -1; + return -1; } +RTM_EXPORT(shutdown); -int getpeername (int s, struct sockaddr *name, socklen_t *namelen) +int getpeername(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); return lwip_getpeername(sock, name, namelen); } +RTM_EXPORT(getpeername); -int getsockname (int s, struct sockaddr *name, socklen_t *namelen) +int getsockname(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_getsockname(sock, name, namelen); } +RTM_EXPORT(getsockname); -int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) +int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_getsockopt(sock, level, optname, optval, optlen); } +RTM_EXPORT(getsockopt); -int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen) +int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_setsockopt(sock, level, optname, optval, optlen); } +RTM_EXPORT(setsockopt); int connect(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_connect(sock, name, namelen); } +RTM_EXPORT(connect); int listen(int s, int backlog) { int sock = dfs_lwip_getsocket(s); - + return lwip_listen(sock, backlog); } +RTM_EXPORT(listen); int recv(int s, void *mem, size_t len, int flags) { int sock = dfs_lwip_getsocket(s); - + return lwip_recv(sock, mem, len, flags); } +RTM_EXPORT(recv); int recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen) + struct sockaddr *from, socklen_t *fromlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_recvfrom(sock, mem, len, flags, from, fromlen); } +RTM_EXPORT(recvfrom); int send(int s, const void *dataptr, size_t size, int flags) { int sock = dfs_lwip_getsocket(s); - + return lwip_send(sock, dataptr, size, flags); } +RTM_EXPORT(send); int sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen) + const struct sockaddr *to, socklen_t tolen) { int sock = dfs_lwip_getsocket(s); - + return lwip_sendto(sock, dataptr, size, flags, to, tolen); } +RTM_EXPORT(sendto); int socket(int domain, int type, int protocol) { @@ -207,13 +220,13 @@ int socket(int domain, int type, int protocol) d->path = RT_NULL; d->fs = dfs_lwip_get_fs(); - + d->flags = DFS_O_RDWR; /* set flags as read and write */ d->size = 0; d->pos = 0; - + /* set socket to the data of dfs_fd */ - d->data = (void*) sock; + d->data = (void *) sock; } /* release the ref-count of fd */ @@ -221,4 +234,4 @@ int socket(int domain, int type, int protocol) return fd; } - +RTM_EXPORT(socket); diff --git a/components/dfs/filesystems/lwip/sys/socket.h b/components/dfs/filesystems/lwip/sys/socket.h index 5317e05e4c..b9608d97ed 100644 --- a/components/dfs/filesystems/lwip/sys/socket.h +++ b/components/dfs/filesystems/lwip/sys/socket.h @@ -29,9 +29,11 @@ extern "C" { #endif +#include <inttypes.h> #include <lwip/sockets.h> typedef uint16_t sa_family_t; +typedef uint16_t in_port_t; struct sockaddr_storage { diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c index 7ff5fef5f7..4bf96c2aeb 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/filesystems/nfs/dfs_nfs.c @@ -850,7 +850,6 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) st->st_size = info->size; st->st_mtime = info->mtime.seconds; - st->st_blksize = 512; xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res); xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle); diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c index fecebe4688..7533b6f192 100644 --- a/components/dfs/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c @@ -292,7 +292,6 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs, st->st_size = dirent->size; st->st_mtime = 0; - st->st_blksize = 512; return DFS_STATUS_OK; } diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 65fc331466..6110d61227 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -96,7 +96,8 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch { if (check_dirent(&dirent[index]) != 0) return RT_NULL; - if (rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0) + if (rt_strlen(dirent[index].name) == (subpath_end - subpath) && + rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0) { dirent_size = dirent[index].size; @@ -245,7 +246,6 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) st->st_size = dirent->size; st->st_mtime = 0; - st->st_blksize = 512; return DFS_STATUS_OK; } diff --git a/components/dfs/filesystems/uffs/dfs_uffs.c b/components/dfs/filesystems/uffs/dfs_uffs.c index faaee0990e..87517aaaf5 100644 --- a/components/dfs/filesystems/uffs/dfs_uffs.c +++ b/components/dfs/filesystems/uffs/dfs_uffs.c @@ -347,7 +347,7 @@ static int dfs_uffs_open(struct dfs_fd* file) return uffs_result_to_dfs(uffs_get_error()); } - /* save this pointer, it will be used when calling read()��write(), + /* save this pointer, it will be used when calling read()��write(), * flush(), seek(), and will be free when calling close()*/ file->data = (void *)fd; @@ -619,7 +619,6 @@ static int dfs_uffs_stat(struct dfs_filesystem* fs, const char *path, struct sta st->st_mtime = s.st_mtime; mtd = RT_MTD_NAND_DEVICE(fs->dev_id); - st->st_blksize = mtd->page_size; return 0; } diff --git a/components/dfs/include/dfs_def.h b/components/dfs/include/dfs_def.h index a73ff4ec8b..0f75a5162b 100644 --- a/components/dfs/include/dfs_def.h +++ b/components/dfs/include/dfs_def.h @@ -255,14 +255,17 @@ #define DFS_S_IWOTH 00002 #define DFS_S_IXOTH 00001 +#ifdef _MSC_VER +#include <wchar.h> +#else struct stat { rt_device_t st_dev; rt_uint16_t st_mode; rt_uint32_t st_size; rt_time_t st_mtime; - rt_uint32_t st_blksize; }; +#endif struct statfs { diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index aebe2996c6..752933b66f 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -392,7 +392,6 @@ int dfs_file_stat(const char *path, struct stat *buf) buf->st_size = 0; buf->st_mtime = 0; - buf->st_blksize = 512; /* release full path */ rt_free(fullpath); diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index c379d5c969..52a9139d80 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -368,7 +368,6 @@ int fstat(int fildes, struct stat *buf) buf->st_size = d->size; buf->st_mtime = 0; - buf->st_blksize = 512; fd_put(d); diff --git a/components/external/SQLite-3.8.1/src/os_rtthread.c b/components/external/SQLite-3.8.1/src/os_rtthread.c index fb51b53685..6d57ed7098 100644 --- a/components/external/SQLite-3.8.1/src/os_rtthread.c +++ b/components/external/SQLite-3.8.1/src/os_rtthread.c @@ -1728,7 +1728,7 @@ static int fcntlSizeHint(rtthreadFile *pFile, i64 nByte){ ** is the same technique used by glibc to implement posix_fallocate() ** on systems that do not have a real fallocate() system call. */ - int nBlk = buf.st_blksize; /* File-system block size */ + int nBlk = 4096; // no blksize in RT-Thread, use 4096. /* File-system block size */ i64 iWrite; /* Next offset to write to */ if( robust_ftruncate(pFile->h, nSize) ){ diff --git a/components/finsh/SConscript b/components/finsh/SConscript index 8d6729e4a7..639cbebd4a 100644 --- a/components/finsh/SConscript +++ b/components/finsh/SConscript @@ -22,8 +22,9 @@ finsh_token.c ''') msh_src = Split(''' -msh_cmd.c msh.c +msh_cmd.c +msh_file.c ''') CPPPATH = [cwd] diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index c42b412f23..29b22c05c2 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -99,17 +99,17 @@ static long _list_thread(struct rt_list_node *list) else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init "); else if (thread->stat == RT_THREAD_CLOSE) rt_kprintf(" close "); - ptr = (rt_uint8_t*)thread->stack_addr; + ptr = (rt_uint8_t *)thread->stack_addr; while (*ptr == '#')ptr ++; rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n", - thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp), - thread->stack_size, - thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr), - thread->remaining_tick, - thread->error); + thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp), + thread->stack_size, + thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr), + thread->remaining_tick, + thread->error); } - + return 0; } @@ -148,7 +148,7 @@ static long _list_sem(struct rt_list_node *list) sem = (struct rt_semaphore *)(rt_list_entry(node, struct rt_object, list)); if (!rt_list_isempty(&sem->parent.suspend_thread)) { - rt_kprintf("%-8.*s %03d %d:", + rt_kprintf("%-8.*s %03d %d:", RT_NAME_MAX, sem->parent.parent.name, sem->value, @@ -448,7 +448,7 @@ static long _list_device(struct rt_list_node *list) { struct rt_device *device; struct rt_list_node *node; - char * const device_type_str[] = + char *const device_type_str[] = { "Character Device", "Block Device", @@ -464,11 +464,11 @@ static long _list_device(struct rt_list_node *list) "SPI Bus", "SPI Device", "SDIO Bus", - "PM Pseudo Device", + "PM Pseudo Device", "Pipe", "Portal Device", - "Timer Device", - "Miscellaneous Device", + "Timer Device", + "Miscellaneous Device", "Unknown" }; @@ -507,13 +507,13 @@ int list_module(void) list = &rt_object_container[RT_Object_Class_Module].object_list; - rt_kprintf("module name ref\n"); - rt_kprintf("------------ --------\n"); + rt_kprintf("module name ref address \n"); + rt_kprintf("------------ -------- ------------\n"); for (node = list->next; node != list; node = node->next) { module = (struct rt_module *)(rt_list_entry(node, struct rt_object, list)); - rt_kprintf("%-16.*s %-04d\n", - RT_NAME_MAX, module->parent.name, module->nref); + rt_kprintf("%-16.*s %-04d 0x%08x\n", + RT_NAME_MAX, module->parent.name, module->nref, module->module_space); } return 0; @@ -525,13 +525,13 @@ int list_mod_detail(const char *name) { int i; struct rt_module *module; - + /* find module */ if ((module = rt_module_find(name)) != RT_NULL) { /* module has entry point */ if (!(module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY)) - { + { struct rt_thread *thread; struct rt_list_node *tlist; rt_uint8_t *ptr; @@ -548,15 +548,15 @@ int list_mod_detail(const char *name) else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend"); else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init "); - ptr = (rt_uint8_t*)thread->stack_addr; + ptr = (rt_uint8_t *)thread->stack_addr; while (*ptr == '#')ptr ++; rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n", - thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp), - thread->stack_size, - thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr), - thread->remaining_tick, - thread->error); + thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp), + thread->stack_size, + thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr), + thread->remaining_tick, + thread->error); } /* list sub thread in module */ @@ -607,18 +607,18 @@ int list_mod_detail(const char *name) if (!rt_list_isempty(tlist)) _list_timer(tlist); } - if (module->nsym > 0) - { - rt_kprintf("symbol address \n"); - rt_kprintf("-------- ----------\n"); - - /* list module export symbols */ - for (i=0; i<module->nsym; i++) - { - rt_kprintf("%s 0x%x\n", - module->symtab[i].name, module->symtab[i].addr); - } - } + if (module->nsym > 0) + { + rt_kprintf("symbol address \n"); + rt_kprintf("-------- ----------\n"); + + /* list module export symbols */ + for (i = 0; i < module->nsym; i++) + { + rt_kprintf("%s 0x%x\n", + module->symtab[i].name, module->symtab[i].addr); + } + } } return 0; @@ -632,16 +632,16 @@ long list(void) struct finsh_syscall_item *syscall_item; struct finsh_sysvar_item *sysvar_item; #endif - + rt_kprintf("--Function List:\n"); { struct finsh_syscall *index; for (index = _syscall_table_begin; - index < _syscall_table_end; - FINSH_NEXT_SYSCALL(index)) + index < _syscall_table_end; + FINSH_NEXT_SYSCALL(index)) { - /* skip the internal command */ - if (strncmp((char*)index->name, "__", 2) == 0) continue; + /* skip the internal command */ + if (strncmp((char *)index->name, "__", 2) == 0) continue; #ifdef FINSH_USING_DESCRIPTION rt_kprintf("%-16s -- %s\n", index->name, index->desc); @@ -664,8 +664,8 @@ long list(void) { struct finsh_sysvar *index; for (index = _sysvar_table_begin; - index < _sysvar_table_end; - FINSH_NEXT_SYSVAR(index)) + index < _sysvar_table_end; + FINSH_NEXT_SYSVAR(index)) { #ifdef FINSH_USING_DESCRIPTION rt_kprintf("%-16s -- %s\n", index->name, index->desc); @@ -682,7 +682,7 @@ long list(void) sysvar_item = sysvar_item->next; } #endif - + return 0; } FINSH_FUNCTION_EXPORT(list, list all symbol in system) @@ -732,12 +732,12 @@ void list_prefix(char *prefix) { struct finsh_syscall *index; for (index = _syscall_table_begin; - index < _syscall_table_end; - FINSH_NEXT_SYSCALL(index)) + index < _syscall_table_end; + FINSH_NEXT_SYSCALL(index)) { - /* skip internal command */ - if (str_is_prefix("__", index->name) == 0) continue; - + /* skip internal command */ + if (str_is_prefix("__", index->name) == 0) continue; + if (str_is_prefix(prefix, index->name) == 0) { if (func_cnt == 0) @@ -807,10 +807,10 @@ void list_prefix(char *prefix) /* checks in system variable */ { - struct finsh_sysvar* index; + struct finsh_sysvar *index; for (index = _sysvar_table_begin; - index < _sysvar_table_end; - FINSH_NEXT_SYSVAR(index)) + index < _sysvar_table_end; + FINSH_NEXT_SYSVAR(index)) { if (str_is_prefix(prefix, index->name) == 0) { diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 6d747b40db..bd4b12d9d5 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -37,7 +37,7 @@ #endif #define RT_FINSH_ARG_MAX 10 -typedef int (*cmd_function_t)(int argc, char** argv); +typedef int (*cmd_function_t)(int argc, char **argv); #ifdef FINSH_USING_MSH #ifdef FINSH_USING_MSH_ONLY @@ -56,7 +56,7 @@ rt_bool_t msh_is_used(void) return __msh_state; } -static int msh_exit(int argc, char** argv) +static int msh_exit(int argc, char **argv) { /* return to finsh shell mode */ __msh_state = RT_FALSE; @@ -74,15 +74,15 @@ static int msh_enter(void) FINSH_FUNCTION_EXPORT_ALIAS(msh_enter, msh, use module shell); #endif -int msh_help(int argc, char** argv) +int msh_help(int argc, char **argv) { rt_kprintf("RT-Thread shell commands:\n"); { struct finsh_syscall *index; for (index = _syscall_table_begin; - index < _syscall_table_end; - FINSH_NEXT_SYSCALL(index)) + index < _syscall_table_end; + FINSH_NEXT_SYSCALL(index)) { if (strncmp(index->name, "__cmd_", 6) != 0) continue; #if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB) @@ -98,7 +98,7 @@ int msh_help(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(msh_help, __cmd_help, RT-Thread shell help.); -static int msh_split(char* cmd, rt_size_t length, char* argv[RT_FINSH_ARG_MAX]) +static int msh_split(char *cmd, rt_size_t length, char *argv[RT_FINSH_ARG_MAX]) { char *ptr; rt_size_t position; @@ -161,13 +161,13 @@ static cmd_function_t msh_get_cmd(char *cmd, int size) cmd_function_t cmd_func = RT_NULL; for (index = _syscall_table_begin; - index < _syscall_table_end; - FINSH_NEXT_SYSCALL(index)) + index < _syscall_table_end; + FINSH_NEXT_SYSCALL(index)) { if (strncmp(index->name, "__cmd_", 6) != 0) continue; - + if (strncmp(&index->name[6], cmd, size) == 0 && - index->name[6 + size] == '\0') + index->name[6 + size] == '\0') { cmd_func = (cmd_function_t)index->func; break; @@ -180,7 +180,7 @@ static cmd_function_t msh_get_cmd(char *cmd, int size) #if defined(RT_USING_MODULE) && defined(RT_USING_DFS) /* Return 0 on module executed. Other value indicate error. */ -int msh_exec_module(const char* cmd_line, int size) +int msh_exec_module(const char *cmd_line, int size) { int ret; int fd = -1; @@ -197,7 +197,7 @@ int msh_exec_module(const char* cmd_line, int size) length = cmd_length + 32; /* allocate program name memory */ - pg_name = (char*) rt_malloc(length); + pg_name = (char *) rt_malloc(length); if (pg_name == RT_NULL) return -RT_ENOMEM; @@ -251,12 +251,21 @@ int msh_exec_module(const char* cmd_line, int size) int system(const char *command) { - return msh_exec_module(command, rt_strlen(command)); + int ret = -RT_ENOMEM; + char *cmd = rt_strdup(command); + + if (cmd) + { + ret = msh_exec(cmd, rt_strlen(cmd)); + rt_free(cmd); + } + + return ret; } RTM_EXPORT(system); #endif -static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp) +static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) { int argc; int cmd0_size = 0; @@ -287,12 +296,12 @@ static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp) return 0; } -int msh_exec(char* cmd, rt_size_t length) +int msh_exec(char *cmd, rt_size_t length) { int cmd_ret; - /* strim the beginning of command */ - while(*cmd == ' ' || *cmd == '\t') + /* strim the beginning of command */ + while (*cmd == ' ' || *cmd == '\t') { cmd++; length--; @@ -318,7 +327,12 @@ int msh_exec(char* cmd, rt_size_t length) #endif #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) - /* change to this directory */ + if (msh_exec_script(cmd, length) == 0) + { + return 0; + } + + /* change to this directory */ if (chdir(cmd) == 0) { return 0; @@ -329,7 +343,7 @@ int msh_exec(char* cmd, rt_size_t length) { char *tcmd; tcmd = cmd; - while(*tcmd != ' ' && *tcmd != '\0') + while (*tcmd != ' ' && *tcmd != '\0') { tcmd++; } @@ -355,14 +369,14 @@ static int str_common(const char *str1, const char *str2) #ifdef RT_USING_DFS void msh_auto_complete_path(char *path) { - DIR* dir = RT_NULL; + DIR *dir = RT_NULL; struct dirent *dirent = RT_NULL; char *full_path, *ptr, *index; if (!path) return; - full_path = (char*)rt_malloc(256); + full_path = (char *)rt_malloc(256); if (full_path == RT_NULL) return; /* out of memory */ if (*path != '/') @@ -434,9 +448,9 @@ void msh_auto_complete_path(char *path) /* save dirent name */ strcpy(full_path, dirent->d_name); } - + length = str_common(dirent->d_name, full_path); - + if (length < min_length) { min_length = length; @@ -460,7 +474,7 @@ void msh_auto_complete_path(char *path) rt_kprintf("%s\n", dirent->d_name); } } - + length = index - path; memcpy(index, full_path, min_length); path[length + min_length] = '\0'; @@ -481,7 +495,7 @@ void msh_auto_complete(char *prefix) min_length = 0; name_ptr = RT_NULL; - if (*prefix == '\0') + if (*prefix == '\0') { msh_help(0, RT_NULL); return; @@ -522,7 +536,7 @@ void msh_auto_complete(char *prefix) /* skip finsh shell function */ if (strncmp(index->name, "__cmd_", 6) != 0) continue; - cmd_name = (const char*) &index->name[6]; + cmd_name = (const char *) &index->name[6]; if (strncmp(prefix, cmd_name, strlen(prefix)) == 0) { if (min_length == 0) diff --git a/components/finsh/msh.h b/components/finsh/msh.h index 959170da3d..df49732956 100644 --- a/components/finsh/msh.h +++ b/components/finsh/msh.h @@ -33,7 +33,10 @@ #include <rtthread.h> rt_bool_t msh_is_used(void); -int msh_exec(char* cmd, rt_size_t length); +int msh_exec(char *cmd, rt_size_t length); void msh_auto_complete(char *prefix); +int msh_exec_module(const char *cmd_line, int size); +int msh_exec_script(const char *cmd_line, int size); + #endif diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c index fc6b56cdd1..a4b865b028 100644 --- a/components/finsh/msh_cmd.c +++ b/components/finsh/msh_cmd.c @@ -41,7 +41,7 @@ extern char working_directory[]; #endif -int cmd_ls(int argc, char** argv) +int cmd_ls(int argc, char **argv) { extern void ls(const char *pathname); @@ -53,7 +53,7 @@ int cmd_ls(int argc, char** argv) ls("/"); #endif } - else + else { ls(argv[1]); } @@ -62,7 +62,7 @@ int cmd_ls(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_ls, __cmd_ls, List information about the FILEs.); -int cmd_cp(int argc, char** argv) +int cmd_cp(int argc, char **argv) { void copy(const char *src, const char *dst); @@ -80,7 +80,7 @@ int cmd_cp(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_cp, __cmd_cp, Copy SOURCE to DEST.); -int cmd_mv(int argc, char** argv) +int cmd_mv(int argc, char **argv) { if (argc != 3) { @@ -89,66 +89,66 @@ int cmd_mv(int argc, char** argv) } else { - int fd; - char *dest = RT_NULL; + int fd; + char *dest = RT_NULL; rt_kprintf("%s => %s\n", argv[1], argv[2]); - fd = open(argv[2], O_DIRECTORY, 0); - if (fd >= 0) - { - char *src; - - close(fd); + fd = open(argv[2], O_DIRECTORY, 0); + if (fd >= 0) + { + char *src; + + close(fd); - /* it's a directory */ - dest = (char*)rt_malloc(DFS_PATH_MAX); - if (dest == RT_NULL) - { - rt_kprintf("out of memory\n"); - return -RT_ENOMEM; - } + /* it's a directory */ + dest = (char *)rt_malloc(DFS_PATH_MAX); + if (dest == RT_NULL) + { + rt_kprintf("out of memory\n"); + return -RT_ENOMEM; + } - src = argv[1] + rt_strlen(argv[1]); - while (src != argv[1]) - { - if (*src == '/') break; - src --; - } + src = argv[1] + rt_strlen(argv[1]); + while (src != argv[1]) + { + if (*src == '/') break; + src --; + } - rt_snprintf(dest, DFS_PATH_MAX - 1, "%s/%s", argv[2], src); - } - else - { - fd = open(argv[2], O_RDONLY, 0); - if (fd >= 0) - { - close(fd); - - unlink(argv[2]); - } + rt_snprintf(dest, DFS_PATH_MAX - 1, "%s/%s", argv[2], src); + } + else + { + fd = open(argv[2], O_RDONLY, 0); + if (fd >= 0) + { + close(fd); - dest = argv[2]; - } + unlink(argv[2]); + } - rename(argv[1], dest); - if (dest != RT_NULL && dest != argv[2]) rt_free(dest); + dest = argv[2]; + } + + rename(argv[1], dest); + if (dest != RT_NULL && dest != argv[2]) rt_free(dest); } return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_mv, __cmd_mv, Rename SOURCE to DEST.); -int cmd_cat(int argc, char** argv) +int cmd_cat(int argc, char **argv) { int index; - extern void cat(const char* filename); + extern void cat(const char *filename); if (argc == 1) { rt_kprintf("Usage: cat [FILE]...\n"); rt_kprintf("Concatenate FILE(s)\n"); - return 0; + return 0; } for (index = 1; index < argc; index ++) @@ -160,7 +160,7 @@ int cmd_cat(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_cat, __cmd_cat, Concatenate FILE(s)); -int cmd_rm(int argc, char** argv) +int cmd_rm(int argc, char **argv) { int index; @@ -168,7 +168,7 @@ int cmd_rm(int argc, char** argv) { rt_kprintf("Usage: rm FILE...\n"); rt_kprintf("Remove (unlink) the FILE(s).\n"); - return 0; + return 0; } for (index = 1; index < argc; index ++) @@ -178,10 +178,10 @@ int cmd_rm(int argc, char** argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_rm, __cmd_rm, Remove (unlink) the FILE(s).); +FINSH_FUNCTION_EXPORT_ALIAS(cmd_rm, __cmd_rm, Remove(unlink) the FILE(s).); #ifdef DFS_USING_WORKDIR -int cmd_cd(int argc, char** argv) +int cmd_cd(int argc, char **argv) { if (argc == 1) { @@ -196,34 +196,34 @@ int cmd_cd(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_cd, __cmd_cd, Change the shell working directory.); -int cmd_pwd(int argc, char** argv) +int cmd_pwd(int argc, char **argv) { - rt_kprintf("%s\n", working_directory); - return 0; + rt_kprintf("%s\n", working_directory); + return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_pwd, __cmd_pwd, Print the name of the current working directory.); #endif -int cmd_mkdir(int argc, char** argv) +int cmd_mkdir(int argc, char **argv) { - if (argc == 1) - { - rt_kprintf("Usage: mkdir [OPTION] DIRECTORY\n"); - rt_kprintf("Create the DIRECTORY, if they do not already exist.\n"); - } - else - { - mkdir(argv[1], 0); - } + if (argc == 1) + { + rt_kprintf("Usage: mkdir [OPTION] DIRECTORY\n"); + rt_kprintf("Create the DIRECTORY, if they do not already exist.\n"); + } + else + { + mkdir(argv[1], 0); + } - return 0; + return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_mkdir, __cmd_mkdir, Create the DIRECTORY.); -int cmd_mkfs(int argc, char** argv) +int cmd_mkfs(int argc, char **argv) { int result = 0; - char* type="elm"; /* use the default file system type as 'fatfs' */ + char *type = "elm"; /* use the default file system type as 'fatfs' */ if (argc == 2) { @@ -234,7 +234,7 @@ int cmd_mkfs(int argc, char** argv) if (strcmp(argv[1], "-t") == 0) { type = argv[2]; - result = dfs_mkfs(type, argv[1]); + result = dfs_mkfs(type, argv[3]); } } else @@ -242,7 +242,7 @@ int cmd_mkfs(int argc, char** argv) rt_kprintf("Usage: mkfs [-t type] device\n"); return 0; } - + if (result != RT_EOK) { rt_kprintf("mkfs failed, result=%d\n", result); @@ -255,17 +255,17 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_mkfs, __cmd_mkfs, format disk with file system); #endif #ifdef RT_USING_LWIP -int cmd_ifconfig(int argc, char** argv) +int cmd_ifconfig(int argc, char **argv) { extern void list_if(void); - extern void set_if(char* netif_name, char* ip_addr, char* gw_addr, char* nm_addr); + extern void set_if(char *netif_name, char *ip_addr, char *gw_addr, char *nm_addr); - if(argc == 1) + if (argc == 1) { list_if(); } - else if(argc == 5) + else if (argc == 5) { rt_kprintf("config : %s\n", argv[1]); rt_kprintf("IP addr: %s\n", argv[2]); @@ -283,22 +283,22 @@ int cmd_ifconfig(int argc, char** argv) FINSH_FUNCTION_EXPORT_ALIAS(cmd_ifconfig, __cmd_ifconfig, list the information of network interfaces); #ifdef RT_LWIP_TCP -int cmd_netstat(int argc, char** argv) +int cmd_netstat(int argc, char **argv) { - extern void list_tcps(void); + extern void list_tcps(void); - list_tcps(); - return 0; + list_tcps(); + return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_netstat, __cmd_netstat, list the information of TCP/IP); +FINSH_FUNCTION_EXPORT_ALIAS(cmd_netstat, __cmd_netstat, list the information of TCP / IP); #endif #endif /* RT_USING_LWIP */ -int cmd_ps(int argc, char** argv) +int cmd_ps(int argc, char **argv) { extern long list_thread(void); extern int list_module(void); - + #ifdef RT_USING_MODULE if ((argc == 2) && (strcmp(argv[1], "-m") == 0)) list_module(); @@ -309,14 +309,14 @@ int cmd_ps(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_ps, __cmd_ps, List threads in the system.); -int cmd_time(int argc, char** argv) +int cmd_time(int argc, char **argv) { return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_time, __cmd_time, Execute command with time.); #ifdef RT_USING_HEAP -int cmd_free(int argc, char** argv) +int cmd_free(int argc, char **argv) { extern void list_mem(void); extern void list_memheap(void); diff --git a/components/finsh/msh_file.c b/components/finsh/msh_file.c new file mode 100644 index 0000000000..80012e9bb8 --- /dev/null +++ b/components/finsh/msh_file.c @@ -0,0 +1,159 @@ +/* + * script for RT-Thread module shell + * + * COPYRIGHT (C) 2013-2015, Shanghai Real-Thread Technology Co., Ltd + * + * This file is part of RT-Thread (http://www.rt-thread.org) + * Maintainer: bernard.xiong <bernard.xiong at gmail.com> + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2015-09-25 Bernard the first verion for FinSH + */ + +#include <rtthread.h> +#include <finsh.h> + +#include "msh.h" + +#if defined(FINSH_USING_MSH) && defined(RT_USING_DFS) +#include <dfs_posix.h> + +static int msh_readline(int fd, char *line_buf, int size) +{ + char ch; + int index = 0; + + do + { + if (read(fd, &ch, 1) != 1) + { + /* nothing in this file */ + return 0; + } + } + while (ch == '\n' || ch == '\r'); + + /* set the first character */ + line_buf[index ++] = ch; + + while (index < size) + { + if (read(fd, &ch, 1) == 1) + { + if (ch == '\n' || ch == '\r') + { + line_buf[index] = '\0'; + break; + } + + line_buf[index++] = ch; + } + else + { + line_buf[index] = '\0'; + break; + } + } + + return index; +} + +int msh_exec_script(const char *cmd_line, int size) +{ + int ret; + int fd = -1; + char *pg_name; + int length, cmd_length = 0; + + if (size == 0) return -RT_ERROR; + + /* get the length of command0 */ + while ((cmd_line[cmd_length] != ' ' && cmd_line[cmd_length] != '\t') && cmd_length < size) + cmd_length ++; + + /* get name length */ + length = cmd_length + 32; + + /* allocate program name memory */ + pg_name = (char *) rt_malloc(length); + if (pg_name == RT_NULL) return -RT_ENOMEM; + + /* copy command0 */ + memcpy(pg_name, cmd_line, cmd_length); + pg_name[cmd_length] = '\0'; + + if (strstr(pg_name, ".sh") != RT_NULL || strstr(pg_name, ".SH") != RT_NULL) + { + /* try to open program */ + fd = open(pg_name, O_RDONLY, 0); + + /* search in /bin path */ + if (fd < 0) + { + rt_snprintf(pg_name, length - 1, "/bin/%.*s", cmd_length, cmd_line); + fd = open(pg_name, O_RDONLY, 0); + } + } + + rt_free(pg_name); + if (fd >= 0) + { + /* found script */ + char *line_buf; + int length; + + line_buf = (char *) rt_malloc(RT_CONSOLEBUF_SIZE); + + /* read line by line and then exec it */ + do + { + length = msh_readline(fd, line_buf, RT_CONSOLEBUF_SIZE); + if (length > 0) + { + char ch = '\0'; + int index; + + for (index = 0; index < length; index ++) + { + ch = line_buf[index]; + if (ch == ' ' || ch == '\t') continue; + else break; + } + + if (ch != '#') /* not a comment */ + msh_exec(line_buf, length); + } + } + while (length > 0); + + close(fd); + rt_free(line_buf); + + ret = 0; + } + else + { + ret = -1; + } + + return ret; +} + +#endif diff --git a/components/finsh/shell.c b/components/finsh/shell.c index ce80e4dec2..8962a7333f 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -425,7 +425,7 @@ void finsh_thread_entry(void *parameter) if (rt_device_read(shell->device, 0, &next, 1) == 1) { - if (next == '\0') ch = 'r'; /* linux telnet will issue '\0' */ + if (next == '\0') ch = '\r'; /* linux telnet will issue '\0' */ else ch = next; } else ch = '\r'; diff --git a/components/libc/armlibc/libc_syms.c b/components/libc/armlibc/libc_syms.c new file mode 100644 index 0000000000..847c48544a --- /dev/null +++ b/components/libc/armlibc/libc_syms.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <time.h> + +#include <rtm.h> + +/* some export routines for module */ + +RTM_EXPORT(strstr); +RTM_EXPORT(strlen); +RTM_EXPORT(strchr); +RTM_EXPORT(strcpy); +RTM_EXPORT(strncpy); +RTM_EXPORT(strcmp); +RTM_EXPORT(strncmp); +RTM_EXPORT(strcat); +RTM_EXPORT(strtol); + +RTM_EXPORT(memcpy); +RTM_EXPORT(memcmp); +RTM_EXPORT(memmove); +RTM_EXPORT(memset); +RTM_EXPORT(memchr); + +RTM_EXPORT(toupper); +RTM_EXPORT(atoi); + +RTM_EXPORT(localtime); +RTM_EXPORT(time); + +/* import the full stdio for printf */ +#ifdef __MICROLIB +#error "[RT_USING_LIBC] Please use standard libc but not microlib." +#endif + +RTM_EXPORT(puts); +RTM_EXPORT(printf); diff --git a/components/libc/armlibc/mem_std.c b/components/libc/armlibc/mem_std.c index 6faf86555f..56aa525df2 100644 --- a/components/libc/armlibc/mem_std.c +++ b/components/libc/armlibc/mem_std.c @@ -22,18 +22,22 @@ void *malloc(int n) { return rt_malloc(n); } +RTM_EXPORT(malloc); void *realloc(void *rmem, rt_size_t newsize) { return rt_realloc(rmem, newsize); } +RTM_EXPORT(realloc); void *calloc(rt_size_t nelem, rt_size_t elsize) { return rt_calloc(nelem, elsize); } +RTM_EXPORT(calloc); void free(void *rmem) { rt_free(rmem); } +RTM_EXPORT(free); diff --git a/components/libc/dlib/sys/types.h b/components/libc/dlib/sys/types.h index b01d8283d4..3074bd69d0 100644 --- a/components/libc/dlib/sys/types.h +++ b/components/libc/dlib/sys/types.h @@ -9,4 +9,6 @@ typedef rt_int32_t key_t; /* Used for interprocess communication. */ typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */ typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ +typedef int mode_t; + #endif diff --git a/components/libc/newlib/libc_sym.c b/components/libc/newlib/libc_sym.c new file mode 100644 index 0000000000..48e488f5d8 --- /dev/null +++ b/components/libc/newlib/libc_sym.c @@ -0,0 +1,47 @@ +#include <rtthread.h> +#include <rtm.h> + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +RTM_EXPORT(strcpy); +RTM_EXPORT(strncpy); +RTM_EXPORT(strlen); +RTM_EXPORT(strcat); +RTM_EXPORT(strstr); +RTM_EXPORT(strchr); +RTM_EXPORT(strcmp); +RTM_EXPORT(strtol); +RTM_EXPORT(strtoul); +RTM_EXPORT(strncmp); + +RTM_EXPORT(memcpy); +RTM_EXPORT(memcmp); +RTM_EXPORT(memmove); +RTM_EXPORT(memset); +RTM_EXPORT(memchr); + +RTM_EXPORT(putchar); +RTM_EXPORT(puts); +RTM_EXPORT(printf); +RTM_EXPORT(sprintf); +RTM_EXPORT(snprintf); + +RTM_EXPORT(fwrite); + +#include <time.h> +RTM_EXPORT(localtime); +RTM_EXPORT(time); + +#include <setjmp.h> +RTM_EXPORT(longjmp); +RTM_EXPORT(setjmp); + +RTM_EXPORT(exit); +RTM_EXPORT(abort); + +RTM_EXPORT(rand); + +#include <assert.h> +RTM_EXPORT(__assert_func); diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index d3a69f9ac3..c0aed9d4f0 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -115,9 +115,10 @@ static void tcpip_init_done_callback(void *arg) netif_set_up(ethif->netif); } -#if LWIP_NETIF_LINK_CALLBACK - netif_set_link_up(ethif->netif); -#endif + if (!(ethif->flags & ETHIF_LINK_PHYUP)) + { + netif_set_link_up(ethif->netif); + } /* enter critical */ rt_enter_critical(); diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h index 2019df7017..bdad32ec20 100644 --- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h +++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h @@ -11,6 +11,10 @@ #define ETHERNET_MTU RT_LWIP_ETH_MTU #endif +/* eth flag with auto_linkup or phy_linkup */ +#define ETHIF_LINK_AUTOUP 0x0000 +#define ETHIF_LINK_PHYUP 0x0100 + struct eth_device { /* inherit from rt_device */ @@ -20,9 +24,9 @@ struct eth_device struct netif *netif; struct rt_semaphore tx_ack; - rt_uint8_t flags; + rt_uint16_t flags; rt_uint8_t link_changed; - rt_uint16_t link_status; + rt_uint8_t link_status; /* eth device interface */ struct pbuf* (*eth_rx)(rt_device_t dev); @@ -31,7 +35,7 @@ struct eth_device rt_err_t eth_device_ready(struct eth_device* dev); rt_err_t eth_device_init(struct eth_device * dev, char *name); -rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flag); +rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag); rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up); int eth_system_device_init(void); diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 2e0ef2f8bd..f0b2f814dc 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -154,7 +154,7 @@ static err_t eth_netif_device_init(struct netif *netif) } /* copy device flags to netif flags */ - netif->flags = ethif->flags; + netif->flags = (ethif->flags & 0xff); /* set default netif */ if (netif_default == RT_NULL) @@ -173,9 +173,11 @@ static err_t eth_netif_device_init(struct netif *netif) netif_set_up(ethif->netif); } -#ifdef LWIP_NETIF_LINK_CALLBACK - netif_set_link_up(ethif->netif); -#endif + if (!(ethif->flags & ETHIF_LINK_PHYUP)) + { + /* set link_up for this netif */ + netif_set_link_up(ethif->netif); + } return ERR_OK; } @@ -184,7 +186,7 @@ static err_t eth_netif_device_init(struct netif *netif) } /* Keep old drivers compatible in RT-Thread */ -rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flags) +rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags) { struct netif* netif; @@ -246,7 +248,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_ rt_err_t eth_device_init(struct eth_device * dev, char *name) { - rt_uint8_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; + rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; #if LWIP_DHCP /* DHCP support */ diff --git a/src/thread.c b/src/thread.c index 6c0490a6a3..f94ad21a74 100644 --- a/src/thread.c +++ b/src/thread.c @@ -331,7 +331,7 @@ RTM_EXPORT(rt_thread_create); /** * This function will delete a thread. The thread object will be removed from - * thread queue and detached/deleted from system object management. + * thread queue and deleted from system object management in the idle thread. * * @param thread the thread to be deleted * diff --git a/tools/building.py b/tools/building.py index 5ad6d4e9d2..07f5e91fc9 100644 --- a/tools/building.py +++ b/tools/building.py @@ -267,6 +267,12 @@ def PrepareModuleBuilding(env, root_directory, bsp_directory): global Env global Rtt_Root + # patch for win32 spawn + if env['PLATFORM'] == 'win32': + win32_spawn = Win32Spawn() + win32_spawn.env = env + env['SPAWN'] = win32_spawn.spawn + Env = env Rtt_Root = root_directory @@ -491,37 +497,35 @@ def DoBuilding(target, objects): lst.append(item) return lst - objects = one_list(objects) - - # remove source files with local flags setting - for group in Projects: - if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'): - for source in group['src']: - for obj in objects: - if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath): - objects.remove(obj) - - # re-add the source files to the objects - for group in Projects: + # handle local group + def local_group(group, objects): if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'): CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '') CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', ['']) CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', ['']) for source in group['src']: - objects += Env.Object(source, CCFLAGS = CCFLAGS, - CPPPATH = CPPPATH, - CPPDEFINES = CPPDEFINES) + objects.append(Env.Object(source, CCFLAGS = CCFLAGS, + CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)) + + return True + + return False + + objects = one_list(objects) program = None # check whether special buildlib option lib_name = GetOption('buildlib') if lib_name: + objects = [] # remove all of objects # build library with special component for Group in Projects: if Group['name'] == lib_name: lib_name = GroupLibName(Group['name'], Env) - objects = Env.Object(Group['src']) + if not local_group(Group, objects): + objects = Env.Object(Group['src']) + program = Env.Library(lib_name, objects) # add library copy action @@ -529,6 +533,18 @@ def DoBuilding(target, objects): break else: + # remove source files with local flags setting + for group in Projects: + if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'): + for source in group['src']: + for obj in objects: + if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath): + objects.remove(obj) + + # re-add the source files to the objects + for group in Projects: + local_group(group, objects) + program = Env.Program(target, objects) EndBuilding(target, program) diff --git a/tools/keil.py b/tools/keil.py index d1aa5562d7..599658d983 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -34,9 +34,12 @@ from utils import xml_indent fs_encoding = sys.getfilesystemencoding() def _get_filetype(fn): - if fn.rfind('.c') != -1 or fn.rfind('.C') != -1 or fn.rfind('.cpp') != -1: + if fn.rfind('.c') != -1 or fn.rfind('.C') != -1: return 1 + if fn.rfind('.cpp') != -1 or fn.rfined('.cxx') != -1: + return 8 + # assemble file type if fn.rfind('.s') != -1 or fn.rfind('.S') != -1: return 2 @@ -88,131 +91,7 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path): file_path.text = path.decode(fs_encoding) -def MDK4AddGroup(ProjectFiles, parent, name, files, project_path): - # don't add an empty group - if len(files) == 0: - return - - group = SubElement(parent, 'Group') - group_name = SubElement(group, 'GroupName') - group_name.text = name - - for f in files: - fn = f.rfile() - name = fn.name - path = os.path.dirname(fn.abspath) - - basename = os.path.basename(path) - path = _make_path_relative(project_path, path) - path = os.path.join(path, name) - - files = SubElement(group, 'Files') - file = SubElement(files, 'File') - file_name = SubElement(file, 'FileName') - name = os.path.basename(path) - - if name.find('.cpp') != -1: - obj_name = name.replace('.cpp', '.o') - elif name.find('.c') != -1: - obj_name = name.replace('.c', '.o') - elif name.find('.s') != -1: - obj_name = name.replace('.s', '.o') - elif name.find('.S') != -1: - obj_name = name.replace('.s', '.o') - - if ProjectFiles.count(obj_name): - name = basename + '_' + name - ProjectFiles.append(obj_name) - file_name.text = name.decode(fs_encoding) - file_type = SubElement(file, 'FileType') - file_type.text = '%d' % _get_filetype(name) - file_path = SubElement(file, 'FilePath') - - file_path.text = path.decode(fs_encoding) - -def MDK4Project(target, script): - project_path = os.path.dirname(os.path.abspath(target)) - - project_uvopt = os.path.abspath(target).replace('uvproj', 'uvopt') - if os.path.isfile(project_uvopt): - os.unlink(project_uvopt) - - tree = etree.parse('template.uvproj') - root = tree.getroot() - - out = file(target, 'wb') - out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') - - CPPPATH = [] - CPPDEFINES = [] - LINKFLAGS = '' - CCFLAGS = '' - ProjectFiles = [] - - # add group - groups = tree.find('Targets/Target/Groups') - if groups is None: - groups = SubElement(tree.find('Targets/Target'), 'Groups') - groups.clear() # clean old groups - for group in script: - group_xml = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path) - - # get each include path - if group.has_key('CPPPATH') and group['CPPPATH']: - if CPPPATH: - CPPPATH += group['CPPPATH'] - else: - CPPPATH += group['CPPPATH'] - - # get each group's definitions - if group.has_key('CPPDEFINES') and group['CPPDEFINES']: - if CPPDEFINES: - CPPDEFINES += group['CPPDEFINES'] - else: - CPPDEFINES += group['CPPDEFINES'] - - # get each group's link flags - if group.has_key('LINKFLAGS') and group['LINKFLAGS']: - if LINKFLAGS: - LINKFLAGS += ' ' + group['LINKFLAGS'] - else: - LINKFLAGS += group['LINKFLAGS'] - - if group.has_key('LIBS') and group['LIBS']: - for item in group['LIBS']: - lib_path = '' - for path_item in group['LIBPATH']: - full_path = os.path.join(path_item, item + '.lib') - if os.path.isfile(full_path): # has this library - lib_path = full_path - - if lib_path != '': - MDK4AddGroupForFN(ProjectFiles, groups, group['name'], lib_path, project_path) - - # write include path, definitions and link flags - IncludePath = tree.find('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/IncludePath') - IncludePath.text = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in CPPPATH]) - - Define = tree.find('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/Define') - Define.text = ', '.join(set(CPPDEFINES)) - - Misc = tree.find('Targets/Target/TargetOption/TargetArmAds/LDads/Misc') - Misc.text = LINKFLAGS - - xml_indent(root) - out.write(etree.tostring(root, encoding='utf-8')) - out.close() - - # copy uvopt file - if os.path.exists('template.uvopt'): - import shutil - shutil.copy2('template.uvopt', 'project.uvopt') - -def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path): - group = SubElement(parent, 'Group') - group_name = SubElement(group, 'GroupName') - group_name.text = name - +def MDK4AddLibToGroup(ProjectFiles, group, name, filename, project_path): name = os.path.basename(filename) path = os.path.dirname (filename) @@ -232,6 +111,8 @@ def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path): obj_name = name.replace('.s', '.o') elif name.find('.S') != -1: obj_name = name.replace('.s', '.o') + else: + obj_name = name if ProjectFiles.count(obj_name): name = basename + '_' + name @@ -243,7 +124,7 @@ def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path): file_path.text = path.decode(fs_encoding) -def MDK5AddGroup(ProjectFiles, parent, name, files, project_path): +def MDK4AddGroup(ProjectFiles, parent, name, files, project_path): # don't add an empty group if len(files) == 0: return @@ -274,8 +155,6 @@ def MDK5AddGroup(ProjectFiles, parent, name, files, project_path): obj_name = name.replace('.s', '.o') elif name.find('.S') != -1: obj_name = name.replace('.s', '.o') - else: - obj_name = name if ProjectFiles.count(obj_name): name = basename + '_' + name @@ -287,16 +166,13 @@ def MDK5AddGroup(ProjectFiles, parent, name, files, project_path): file_path.text = path.decode(fs_encoding) -def MDK5Project(target, script): - project_path = os.path.dirname(os.path.abspath(target)) + return group - project_uvopt = os.path.abspath(target).replace('uvprojx', 'uvoptx') - if os.path.isfile(project_uvopt): - os.unlink(project_uvopt) +# The common part of making MDK4/5 project +def MDK45Project(tree, target, script): + project_path = os.path.dirname(os.path.abspath(target)) - tree = etree.parse('template.uvprojx') root = tree.getroot() - out = file(target, 'wb') out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') @@ -312,7 +188,31 @@ def MDK5Project(target, script): groups = SubElement(tree.find('Targets/Target'), 'Groups') groups.clear() # clean old groups for group in script: - group_xml = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path) + group_tree = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path) + + # for local CPPPATH/CPPDEFINES + if (group_tree != None) and (group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CCFLAGS')): + GroupOption = SubElement(group_tree, 'GroupOption') + GroupArmAds = SubElement(GroupOption, 'GroupArmAds') + Cads = SubElement(GroupArmAds, 'Cads') + VariousControls = SubElement(Cads, 'VariousControls') + MiscControls = SubElement(VariousControls, 'MiscControls') + if group.has_key('LOCAL_CCFLAGS'): + MiscControls.text = group['LOCAL_CCFLAGS'] + else: + MiscControls.text = ' ' + Define = SubElement(VariousControls, 'Define') + if group.has_key('LOCAL_CPPDEFINES'): + Define.text = ', '.join(set(group['LOCAL_CPPDEFINES'])) + else: + Define.text = ' ' + Undefine = SubElement(VariousControls, 'Undefine') + Undefine.text = ' ' + IncludePath = SubElement(VariousControls, 'IncludePath') + if group.has_key('LOCAL_CPPPATH'): + IncludePath.text = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in group['LOCAL_CPPPATH']]) + else: + IncludePath.text = ' ' # get each include path if group.has_key('CPPPATH') and group['CPPPATH']: @@ -344,27 +244,17 @@ def MDK5Project(target, script): lib_path = full_path if lib_path != '': - MDK4AddGroupForFN(ProjectFiles, groups, group['name'], lib_path, project_path) - - # remove repeat path - paths = set() - for path in CPPPATH: - inc = _make_path_relative(project_path, os.path.normpath(path)) - paths.add(inc) #.replace('\\', '/') - - paths = [i for i in paths] - paths.sort() - CPPPATH = string.join(paths, ';') - - definitions = [i for i in set(CPPDEFINES)] - CPPDEFINES = string.join(definitions, ', ') + if (group_tree != None): + MDK4AddLibToGroup(ProjectFiles, group_tree, group['name'], lib_path, project_path) + else: + MDK4AddGroupForFN(ProjectFiles, groups, group['name'], lib_path, project_path) # write include path, definitions and link flags IncludePath = tree.find('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/IncludePath') - IncludePath.text = CPPPATH + IncludePath.text = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in CPPPATH]) Define = tree.find('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/Define') - Define.text = CPPDEFINES + Define.text = ', '.join(set(CPPDEFINES)) Misc = tree.find('Targets/Target/TargetOption/TargetArmAds/LDads/Misc') Misc.text = LINKFLAGS @@ -373,6 +263,31 @@ def MDK5Project(target, script): out.write(etree.tostring(root, encoding='utf-8')) out.close() +def MDK4Project(target, script): + template_tree = etree.parse('template.uvproj') + + MDK45Project(template_tree, target, script) + + # remove project.uvopt file + project_uvopt = os.path.abspath(target).replace('uvproj', 'uvopt') + if os.path.isfile(project_uvopt): + os.unlink(project_uvopt) + + # copy uvopt file + if os.path.exists('template.uvopt'): + import shutil + shutil.copy2('template.uvopt', 'project.uvopt') + +def MDK5Project(target, script): + + template_tree = etree.parse('template.uvprojx') + + MDK45Project(template_tree, target, script) + + # remove project.uvopt file + project_uvopt = os.path.abspath(target).replace('uvprojx', 'uvoptx') + if os.path.isfile(project_uvopt): + os.unlink(project_uvopt) # copy uvopt file if os.path.exists('template.uvoptx'): import shutil |
