免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1805 | 回复: 0
打印 上一主题 下一主题

Contiki学习笔记:应用编程接口API [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 01:19 |只看该作者 |倒序浏览

摘要:

    本文按自己理解的方式,对进程、事件、etimer的API进行整理,以便编程。


    网上有一份根据源码生成的文档Contiki 2.5: The Contiki Operating System(类似于ava SE 6 API Documentation),分门别类给出接口(系统和启动代码调用的接口、硬件驱动调用的接口、应用编程接口),本文只给出应用编程接口,并进行整理。另以下的大部分API在之前的博文几乎都有分析。

一、进程

1.1 进程声明和定义[1]

PROCESS_THREAD(name, ev, data)-----Define the body of a process. 

PROCESS_NAME(name)-----Declare the name of a process. 

PROCESS(name, strname)-----Declare a process.

1.2 process protothread方法

PROCESS_BEGIN()-----Define the beginning of a process. 

PROCESS_END()-----Define the end of a process. 

PROCESS_EXIT()-----Exit the currently running process.

PROCESS_CURRENT()-----Get a pointer to the currently running process. PROCESS_CONTEXT_BEGIN(p)-----Switch context to another process. PROCESS_CONTEXT_END(p)-----End a context switch.

PROCESS_POLLHANDLER(handler)-----Specify an action when a process is polled. PROCESS_EXITHANDLER(handler)-----Specify an action when a process exits.

1.3 进程内核函数[2]

void process_start (struct process *p, const char *arg)-----Start a process. 

void process_exit (struct process *p)-----Cause a process to exit. 

1.4 挂起进程相关[1][3]

PROCESS_WAIT_EVENT()-----Wait for an event to be posted to the process. PROCESS_WAIT_EVENT_UNTIL(c)-----Wait for an event to be posted to the process, with an extra condition. 

PROCESS_YIELD()-----Yield the currently running process. 

PROCESS_YIELD_UNTIL(c)-----Yield the currently running process until a condition occurs.

PROCESS_WAIT_UNTIL(c)-----Wait for a condition to occur. 

PROCESS_WAIT_WHILE(c)-----PT_WAIT_WHILE(process_pt, c) 

PROCESS_PT_SPAWN(pt, thread)-----Spawn a protothread from the process. 

PROCESS_PAUSE()-----Yield the process for a short while.

二、事件

2.1 新建事件[1]

process_event_t  process_alloc_event (void)-----Allocate a global event number.

2.2 传递事件[1][2]

int process_post (struct process *p, process_event_t ev, void *data)-----Post an asynchronous event. 

void process_post_synch (struct process *p, process_event_t ev, void *data)-----Post a synchronous event to a process.

三、etimer[4][5]

void etimer_set (struct etimer *et, clock_time_t interval)-----Set an event timer. 

void etimer_reset (struct etimer *et)-----Reset an event timer with the same interval as was previously set.

void etimer_restart (struct etimer *et)-----Restart an event timer from the current point in time. 

void etimer_adjust (struct etimer *et, int td)-----Adjust the expiration time for an event timer.

void etimer_stop (struct etimer *et)-----Stop a pending event timer. 

int etimer_expired (struct etimer *et)-----Check if an event timer has expired. 

clock_time_t etimer_expiration_time (struct etimer *et)-----Get the expiration time for the event timer.

clock_time_t etimer_start_time (struct etimer *et)-----Get the start time for the event timer.


参考资料:

[1] Contiki 2.5: core/sys/process.c File Reference

[2] Contiki 2.5: core/sys/process.h File Reference

[3] 博文《Contiki学习笔记:编程模式

[4] Contiki 2.5: core/sys/etimer.h File Reference

[5] Contiki 2.5: core/sys/etimer.c File Reference

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP