阅读 108

RTX笔记2 - RTX5时间管理

 osStatus_t osDelay (uint32_t ticks):相对时间延时

  osStatus_t osDelayUntil (uint32_t ticks):绝对时间延时

复制代码

 1 static void 2 _Led1Task(void *argument) 3 { 4     (void)argument; 5      6     for(;;) { 7         ledOn(&led1); 8         osDelay(500); /** delay 500 RTOS ticks **/ 9         ledOff(&led1);10         osDelay(500); /** delay 500 RTOS ticks **/11     }12 }13 14 static void15 _segLedTask(void *argument)16 {17     (void)argument;18     uint32_t tick;19     static const uint8_t seg_code[] =20     {21         DEF_LED_0,22         DEF_LED_1,23         DEF_LED_2,24         DEF_LED_3,25         DEF_LED_4,26         DEF_LED_5,27         DEF_LED_6,28         DEF_LED_7,29         DEF_LED_8,30         DEF_LED_9,31     };32     uint8_t sc_sz;33     uint8_t start_ix;34     uint8_t ix;35     36     start_ix = 0;37     sc_sz = ARRAYSIZE(seg_code);38     tick = osKernelGetTickCount();39     40     for(;;) {41         tick += 1000;42         osDelayUntil(tick); /** waits until an absolute time (1000 kernel ticks) is reached **/43         44         for(ix=0; ix < LED_GRID_NBR_MAX; ix++) {45             seg_led.buf[ix] = seg_code[(start_ix+ix)%sc_sz];46         }47         48         start_ix ++;49         if(start_ix >= sc_sz) {50             start_ix = 0;51         }52         53         ledRefresh(&seg_led);54     }55 }

复制代码


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐