Chinaunix首页 | 论坛 | 博客
  • 博客访问: 90083
  • 博文数量: 34
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 275
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-13 23:05
文章分类

全部博文(34)

文章存档

2011年(1)

2010年(7)

2009年(26)

我的朋友

分类: 嵌入式

2010-03-08 22:37:27

freeRTOS学习使用(一)
(1)FreeRTOS是很好的嵌入式(单片机)操作系统, 免商用license, 源代码开放, 代码结构和ucos-ii差不多(估计是抄袭ucos-ii的思想, 其实操作系统内核不就是那些玩意儿呗), 但是由于免商用license, 看起来很不错。今天在LPC(NXP)的网站上看到freeRTOS的移植介绍, 不免手痒痒, 就去
  下载了一大通东西, 在迅雷叮叮叮之后, 打开 FreeRTOSV6.0.3.zip 解压缩, 发现好多的移植, 简直都做全了, 发现有个Windows的移植。 哈哈, 现在就用它

(2)
    建立工程, 使用VC++6.0, 原文是VS2005, 但是我没有装, 没关系, 打开.vcproj文件, 按照里面的信息一个一个做, 做好source, header, FreeRTOS,文件的添加,

     设置好头文件目录, 注意要在port.c里面添加

#define _WIN32_WINNT 0x04000
#include "windows.h"

   还有其他的编译错误, 很容易解决的, 然后就编译, 运行, 结果只有一个task, 没事, 多建立几个, 我是这么做的

static void vEcho( void *pvParameters )
{
    while(1) {
        printf("task vecho %s says hello to you!\n", (char *) pvParameters);
        Sleep( rand()%500 ); //这个可以修改为vTaskDelay(
rand()%500 )
    }
}
int main()
{
    /* Setup the microcontroller hardware for the demo. */
        //prvSetupHardware();

    
    vPrintInitialise();
    /* Create the common demo application tasks, for example: */
    vStartBlockingQueueTasks(mainQUEUE_BLOCK_PRIORITY);
    vCreateBlockTimeTasks();
    vStartSemaphoreTasks(mainSEMAPHORE_TASK_PRIORITY);

    /* Create the "Print" task as described at the top of the file. */
    xTaskCreate( vErrorChecks, "ErrorChk", 100, NULL, 0, NULL );

    xTaskCreate( vEcho, "hehe, 1", 200, "My name is hehe 1", 0, NULL );

    xTaskCreate( vEcho, "hehe, 2", 200, "My name is hehe 2", 0, NULL );





Sleep( rand()%500 ); //这个可以修改为vTaskDelay(rand()%500 )呵呵, OK

阅读(3781) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~