您的位置:首页 > 产品设计 > UI/UE

Arduino中RTOS学习笔记1

2020-03-02 00:06 525 查看

Arduino中RTOS学习笔记[1]

  • 任务
  • 本文是作者自己整理的学习资料,如果侵权请联系删除,如有错误也请指出。
    楼主常年生活在国外,所以一些中文译名会有些出入,请见谅。
    欢迎有兴趣的同学一起学习进步 =)

    常见名称

    变量

    ‘c’ — int8_t = char
    ‘s’ — int16_t = short
    ‘l’ — int32_t = long
    ‘b’ — BaseType_t

    ‘u’ — unsigned
    ‘p’ — pointer
    to be added
    eg.
    pointer to char : pc
    uint8_t :uc (unsigned char)

    方程

    前置首先声明 return type
    其次声明定义文件(definition file)
    e.g
    vTaskFunction() returns a void type and is defined within task.c
    xQueueFunction() returns a BaseType and is defined within queue.c
    pvTimerFunction() returns a pointer to void and is defined within Timer.c

    通常宏用大写,而前缀用小写。
    e.g

    Macro Value
    pdTRUE 1
    pdFALSE 0
    pdPASS 1
    pdFAIL 0

    任务

    什么是任务:

    task is implemented as a C function.
    e,g
    void ATaskFunction(void *pvParameters);
    is a function that returns void type and the input argument is a pointer to void.

    任务的状态

    Not running — Running
    to be added

    任务创立

    BaseType_t xTaskCreate( TaskFunction_t pvTaskCode,
    const char * const pcName,
    uyint16_t usStackDepth,
    void *pvParameters,
    UBaseType_t uxPriority,
    TaskHandle_t *pxCreatedTask
    );
    pvTaskCode: a pointer that points to a function that implement the task, i.e. the name of the task function
    pcName: descriptive task name, only for debugging purpose
    usStackDepth: stack size(number of words[32bits])
    *pvParameters: argument pass to the task function
    uxPriority: task priority from 0~highest
    TaskHandle_t: handle

    如果return是1则代表成功创立task,如果是0则失败,通常是因为heap memory不够了。

    • 点赞
    • 收藏
    • 分享
    • 文章举报
    weixin_38059978 发布了1 篇原创文章 · 获赞 0 · 访问量 15 私信 关注
    内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
    标签: