PX4时钟

最近开始学习飞控PX4,整理工作笔记,方便学习交流。

根据PX4的硬件配置,首先研究下针对PX4的时钟配置。

1.  配置主文件:drv_hrt.c

2.  配置1MHz

函数hrt_tim_init()中rPSC= (HRT_TIMER_CLOCK / 1000000) - 1;

其中rPSC为预定标器,CPU的频率除以你自己所设的预定标系数,得到的就是想要的时钟频率。

HRT_TIMER_CLOCK (168000 000)

3.  比较中断:

hrt_tim_isr,中断中执行序列实体

比较器地址:rCCR_HRT :(*(volatile uint32_t *)(0x40010000 +0x0038))

 

4.  外部调用

hrt_call_after :设置延迟时间,延迟结束后回调函数

参数:struct hrt_call *entry,hrt_abstimedelay, hrt_callout callout, void*arg。

Delay:延迟时间,单位us(微秒)

函数说明:根据delay计算entry的endline,并进入序列排序,在中断程序后执行hrt_call_invoke 执行实体回调,并从序列中删除。

程序调用:

PX4Scheduler::delay_microseconds(),通过信号量延时

static int main_loop(int argc, char**argv)分配时间片。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 HTML 时钟示例: ```html <!DOCTYPE html> <html> <head> <title>HTML 时钟</title> <style> .clock { display: block; margin: 50px auto; width: 200px; height: 200px; border-radius: 50%; border: 10px solid #333; position: relative; } .hour-hand { position: absolute; top: 50%; left: 50%; transform-origin: bottom; height: 40px; width: 6px; background: #333; margin-left: -3px; } .minute-hand { position: absolute; top: 50%; left: 50%; transform-origin: bottom; height: 60px; width: 4px; background: #333; margin-left: -2px; } .second-hand { position: absolute; top: 50%; left: 50%; transform-origin: bottom; height: 80px; width: 2px; background: red; margin-left: -1px; z-index: 1; } .dot { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 12px; height: 12px; border-radius: 50%; background: #333; z-index: 2; } </style> </head> <body> <div class="clock"> <div class="hour-hand"></div> <div class="minute-hand"></div> <div class="second-hand"></div> <div class="dot"></div> </div> <script> function updateClock() { let now = new Date(); let hour = now.getHours(); let minute = now.getMinutes(); let second = now.getSeconds(); let hourHand = document.querySelector(".hour-hand"); let minuteHand = document.querySelector(".minute-hand"); let secondHand = document.querySelector(".second-hand"); let hourDegree = hour * 30 + minute * 0.5; let minuteDegree = minute * 6; let secondDegree = second * 6; hourHand.style.transform = `rotate(${hourDegree}deg)`; minuteHand.style.transform = `rotate(${minuteDegree}deg)`; secondHand.style.transform = `rotate(${secondDegree}deg)`; } setInterval(updateClock, 1000); </script> </body> </html> ``` 这个时钟由一个圆形的表盘和三个时针组成,使用 CSS 进行样式设置,并使用 JavaScript 每秒更新时针的旋转角度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值