Contiki clock模块
一、functions for handling system time
clock_time_t clock_time(void);//return the current system time in clock ticks
unsigned long clock_seconds(void);//return the system time in seconds
void clock_set_seconds(unsigned long ec);//set the value of the platform seconds
这些函数都是platform dependent的,我们是在stm8中实现的。
#if USE_RTC_CLK
#if USE_LSE // 32768Hz
#define CLOCK_CONF_SECOND 1024
#else // 38000Hz
#define CLOCK_CONF_SECOND 1000
#endif
#else
#define CLOCK_CONF_SECOND 1024
#endif
typedef unsigned long clock_time_t;
/**
* A second, measured in system clock time.
*
* \hideinitializer
*/
#ifdef CLOCK_CONF_SECOND
#define CLOCK_SECOND CLOCK_CONF_SECOND
#else
#define CLOCK_SECOND (clock_time_t)32
#endif
其中我们的clock_time_t是unsigned long型的,在stm8中unsigned long是32bit,最大数值是4294967295。
The number of clock ticks per second is specified with the constant CLOCK_SECOND.
CLOCK_SECOND 按1024来算,clock_time函数wrap around的时间是:
4294967295/1024/(60*60*24*365) = 0.133年
clock_seconds函数wrap aound的时间是:
4294967295/(60*60*24*365) = 136.2年
The system time starts from zero when the Contiki system starts.
二、functions for blocking the CPU
/**
* Wait for a given number of ticks.
* \param t How many ticks.
*
*/
void clock_wait(clock_time_t t); /**
* Delay a given number of microseconds.
* \param dt How many microseconds to delay.
*
* \note Interrupts could increase the delay by a variable amount.
*/
void clock_delay_usec(uint16_t dt);
These functions are normally only used in low-level drivers where it sometimes is necessary to wait a short time without giving up the control over the CPU.
The function clock_init() is called by the system during the boot-up procedure to initialize the clock module.
main函数:
int
main(void)
{
reset_sr = RST->SR;
RST->SR = 0xFF; clock_init(); leds_init();
leds_on(LEDS_GREEN);
HALT_LED_ON(); rs232_init(RS232_PORT_0, USART_BAUD_9600, USART_PARITY_NONE); node_id_restore();
node_init(); process_init(); process_start(&etimer_process, NULL); ctimer_init(); 略…… return ;
}
三、Porting the Clock Module
The clock module is platform dependent and is implemented in the file clock.c. Since the clock module handles the system time, the clock module implementation usually also handles the notifications to the etimer library when it is time to check for expired event timers.
具体相关代码如下:
if(etimer_pending() && etimer_next_expiration_time() <= current_clock) {
etimer_request_poll();
}
Contiki clock模块的更多相关文章
- Contiki Etimer 模块
一.Etimer概述 Etimer提供产生时间事件(timed event)的机制,当设定好的timer到期时,将会给设定etimer的process发送一个PROCESS_EVENT_TIMER 事 ...
- Contiki Rtimer 模块
一.rtimer概述 The Contiki rtimer library provides scheduling and execution of real-time tasks (with pre ...
- Contiki Ctimer模块
Ctimer 提供和Etimer类似的功能,只是Ctimer是在一段时间后调用回调函数,没有和特定进程相关联. 而Etimer是在一段时间后发送PROCESS_EVENT_TIMER事件给特定的进程. ...
- [置顶] STM32移植contiki进阶之三(中):timer 中文版
鉴于自己英语水平不高,在这里,将上一篇关于contiki 的timer的文章翻译为中文,让自己在学习的时候,更方便点.文中有许多不是很通顺的地方,将就吧. Timers Contiki系统提供了一套时 ...
- Contiki-Timer 概述
Contiki有一个clock模块和一系列timer模块:timer,stimer,ctimer,etimer,和rtimer. 一.clock模块 clock模块提供一些处理系统时间的函数,还有一些 ...
- Linux时间子系统之(二):软件架构
专题文档汇总目录 Notes:从框架上讲解了时间子系统,从底向上包括CPU Local TImer.Global Counter.Clock Souce/Clock Events模块管理.Tick D ...
- Linux时间子系统(二) 软件架构
一.前言 本文的主要内容是描述内核时间子系统的软件框架.首先介绍了从旧的时间子系统迁移到新的时间子系统的源由,介绍新的时间子系统的优势.第三章汇整了时间子系统的相关文件以及内核配置.最后描述各种内核配 ...
- 体系编程、SOC编程那些事儿
转:https://blog.csdn.net/yueqian_scut/article/details/49968897 笔者将从芯片IC的系统设计的角度去诠释如何掌握体系编程和SOC编程.笔者有超 ...
- SYS/BIOS实例分析
SYS/BIOS简介 SYS/BIOS是一个可扩展的实时内核(或者说是操作系统),其提供了许多模块化的APIs(应用程序接口),支持抢占式多线程,硬件抽象,实时分析和配置工具,其设计目的是为了最大限度 ...
随机推荐
- 【Python】合并(拼接)字符串
在很多情况下,我们都需要合并字符串.例如:需要将姓氏与名字存储在不同的变量中,然后显示的时候再将他们合二为一 first_name = 'oliver' last_name = 'smith' ful ...
- 【解决方法】INF file txtsetup.sif is corrupt or missing /// 使用WinSetupFromUSB来U盘安装windows2003(不使用win PE系统)
[解决方法]INF file txtsetup.sif is corrupt or missing http://blog.csdn.net/zhyl8157121/article/details/8 ...
- 关于PM的认识
1 我眼中的PM 1.1 人云“一个管理,半个专家”,我说“一个管理,两个专家” 如今,我发现我们不得不面对这样一个现实——角色兼职.我习惯上把项目分为三类:性命攸关的项目(涉及到人身安全的项目,如铁 ...
- Ant Problem: failed to create task or type foreach 问题
用eclipse导出android时总是会出现有类没有导出的现象,感觉非常麻烦,就用ant些了脚本.在eclipse中运行脚本没问题.可是在命令行下运行会出现 Problem: failed to c ...
- AndroidX86模拟器Genymotion的一些使用和另一款Andy模拟器
命令行启动虚拟机 当我们下载安装好,可以通过命令行运行指定名字模拟器 D:\ProgramFiles\Genymobile\Genymotion\player --vm-name "Sam ...
- javascript关闭弹出窗体时刷新父窗体和居中显示弹出窗
居中显示用到了moveTO()方法: 关闭弹出窗时刷新父窗体用到了window.opener方法: 父窗体代码例如以下: <%@ Page Language="C#" Aut ...
- linux SPI驱动——spi协议(一)
一:SPI简介以及应用 SPI, Serial Perripheral Interface, 串行外围设备接口, 是 Motorola 公司推出的一种同步串行接口技术. SPI 总线在物理上是通过接在 ...
- Android studio 混淆打包问题
参考 : Android Studio代码混淆设置以及上传mapping文件 AndroidStudio 混淆打包 在app 目录下 proguard-rules.pro中加入 通用 混淆 #指定代 ...
- onvif 开发之video streamer---onvif实现功能和经验
目录(?)[-] 一产生onvif源码框架 从wsdl生成C头文件 从头文件生成源码框架 二创建soap运行环境 三RTSP视频对接 实现GetCapabilities命令 实现GetServices ...
- Emgu安装配置及使用
前言:项目需要,需使用图像处理来完成机械臂从运动的皮带上抓取物体的功能,所以又重拾视觉与图像处理内容. 内容:Emgu是OpenCV的一个跨平台的.NET封装,结构如下图所示: 下载地址:http:/ ...