⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testuartm.nc

📁 this is for tinyon to test the Uart
💻 NC
字号:
module TestUARTM {	provides interface StdControl;	provides command result_t Writes(uint8_t *buf);	provides command result_t Write(uint8_t ch);	provides interface IntOutput as RadioRxOut;	uses interface Leds;	uses interface HPLUART as UART;	uses interface IntOutput as RadioTxOut;}implementation{	uint8_t *txBuf, txBufLen, txCnt;	uint8_t rxCnt;	task void SendChar() {		atomic {			if (txCnt < txBufLen)				call UART.put(txBuf[txCnt++]);		}	}	command result_t Writes(uint8_t *buf) {		atomic {			txBuf = buf; txBufLen = strlen(txBuf);			txCnt = 0; post SendChar();		}		return SUCCESS;	}	command result_t Write(uint8_t ch) {		atomic {			txBuf = &ch; txBufLen = 1;			txCnt = 0; post SendChar();		}		return SUCCESS;	}	command result_t StdControl.init() {		call Leds.init();		call UART.init();		rxCnt=48;		return SUCCESS;	}	command result_t StdControl.start() {		call Writes("Ready!");		return SUCCESS;	}	command result_t StdControl.stop() {		call UART.stop();		return SUCCESS;	}	async event result_t UART.get(uint8_t data) {		call RadioTxOut.output(data);		return SUCCESS;	}	async event result_t UART.putDone() {		post SendChar();		return SUCCESS;	}	event result_t RadioTxOut.outputComplete(result_t success) {		call Leds.redToggle();		return SUCCESS;	}	task void outputDone() {		signal RadioRxOut.outputComplete(1);	}	command result_t RadioRxOut.output(uint16_t value) {		call Write(value&0xFF);		post outputDone();		return SUCCESS;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -