?? senderm.nc
字號:
module senderM { provides { interface StdControl; } uses { interface SendMsg as tx; interface ReceiveMsg as rx; interface Leds as leds; interface Timer as ledTimer; interface Timer as timer; }}implementation {#include "config.h" TOS_Msg txBuf; bool txPending; command result_t StdControl.init() { call leds.init(); txPending = false; txBuf.data[0] = 0x1; txBuf.data[1] = 0x2; txBuf.data[2] = 0x3; txBuf.data[3] = 0x4; txBuf.length = 4; return SUCCESS; } command result_t StdControl.start() { call leds.redOn(); call leds.greenOn(); call leds.yellowOn(); call ledTimer.start(TIMER_ONE_SHOT, 500); call timer.start(TIMER_REPEAT, 1500); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } event result_t ledTimer.fired() { call leds.redOff(); call leds.greenOff(); call leds.yellowOff(); return SUCCESS; } event result_t timer.fired() { bool drop = true; atomic { if (!txPending) { drop = false; txPending = true; } } if (drop) return SUCCESS; call leds.greenOn(); call tx.send(TOS_UART_ADDR, txBuf.length, &txBuf); return SUCCESS; } event result_t tx.sendDone(TOS_MsgPtr m, result_t success) { atomic { txPending = false; } call leds.greenOff(); return SUCCESS; } event TOS_MsgPtr rx.receive(TOS_MsgPtr m) { call leds.yellowOn(); call ledTimer.start(TIMER_ONE_SHOT, 300); return m; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -