Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve timer accuracy and realize #6926

Merged
merged 12 commits into from
Feb 15, 2023
Merged

Conversation

zhkag
Copy link
Member

@zhkag zhkag commented Feb 11, 2023

拉取/合并请求描述:(PR description)

[
实现 cputime 可设置超时函数功能
依据 cputime 实现高精度定时器,以及延时功能
]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

include/rtthread.h Outdated Show resolved Hide resolved
@heyuanjie87
Copy link
Contributor

cputime的初始化可以先放在bsp

2 similar comments
@heyuanjie87
Copy link
Contributor

cputime的初始化可以先放在bsp

@heyuanjie87
Copy link
Contributor

cputime的初始化可以先放在bsp

src/timer.c Outdated Show resolved Hide resolved
@Guozhanxin
Copy link
Member

对了,cputimer 的文档也需要写一份。提交到文档中心

@Guozhanxin Guozhanxin added the +1 Agree +1 label Feb 13, 2023
@BernardXiong
Copy link
Member

cputime,cputimer?好具备迷惑性,或者cputime_timer?

@zhkag
Copy link
Member Author

zhkag commented Feb 13, 2023

cputime,cputimer?好具备迷惑性,或者cputime_timer?

改完之后也挺迷惑的

image

@BernardXiong
Copy link
Member

@mysterywolf 对名字这块有洁癖,有建议的吗?

@mysterywolf
Copy link
Member

好 我晚上看一下

@mysterywolf mysterywolf added the in progress PR/issue in progress. label Feb 14, 2023
@mysterywolf
Copy link
Member

@zhkag 请稍微写一下PR的描述

@mysterywolf
Copy link
Member

我个人建议cputime_timer 直接缩写成cputimer即可,rt_cputimer_create 。这个与cputime之前没有太多的迷惑性,rt_cputime_timer有些啰嗦。

@mysterywolf
Copy link
Member

后续rt_hw_delay_us可否直接调用cputime框架 或者说 rt_hw_delay_us的内容可以整合作为cputime的驱动

@mysterywolf mysterywolf added +2 Agree +2 and removed in progress PR/issue in progress. labels Feb 15, 2023
@zhkag
Copy link
Member Author

zhkag commented Feb 15, 2023

里面tick的含义不太清晰,它到底表示ns us等时间单位还是定时器硬件计数器的值。 这里建议定义成时间

tick 表示的是 定时器硬件计数器的值 时间相关的都是使用的 ns us ms 等变量表示的

@heyuanjie87
Copy link
Contributor

rt_cputimer_create并没申请内存,不如叫init

@heyuanjie87
Copy link
Contributor

void rt_cputimer_create(rt_cputimer_t timer,
const char *name,
void (*timeout)(void *parameter),
void *parameter,
rt_uint64_t time,
rt_uint8_t flag)

这个time 也改成tick统一点

zhkag and others added 2 commits February 15, 2023 17:55
* Remove RT_USING_CPUTIME in cputimer.c
* Set set_next_timeout as static function.
@BernardXiong BernardXiong merged commit 0f85648 into RT-Thread:master Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
+1 Agree +1 +2 Agree +2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants