|
1.使用std庫(kù)
2.移植了contiki
3.運(yùn)行兩個(gè)thread正常
單片機(jī)源程序如下:
- #include "contiki.h"
- unsigned int idle_count = 0;
- static struct etimer et_on;
- PROCESS(led_on, "led_on");
- PROCESS_THREAD(led_on, ev, data)
- {
- static int on = 0;
- PROCESS_BEGIN();
- while(1)
- {
- on++;
- etimer_set(&et_on, CLOCK_SECOND); // etimer溢出時(shí)間為5s
- PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_on)); // 等待定時(shí)器溢出
- }
- PROCESS_END();
- }
- static struct etimer et_off;
- PROCESS(led_off, "led_off");
- PROCESS_THREAD(led_off, ev, data)
- {
- static int off = 0;
- PROCESS_BEGIN();
- while(1)
- {
- off++;
- etimer_set(&et_off, CLOCK_SECOND); // etimer溢出時(shí)間為5s
- PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_off)); // 等待定時(shí)器溢出
- }
- PROCESS_END();
- }
- AUTOSTART_PROCESSES(&led_on,&led_off);
- int main(void*arg)
- {
- clock_init();
- process_init();
- process_start(&etimer_process,NULL);
- autostart_start(autostart_processes);
- while(1){
- while(process_run()> 0);
- idle_count++;
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
stm32-contiki-master.zip
(350.96 KB, 下載次數(shù): 11)
2019-7-8 22:06 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|