📄 hplspim.nc
字号:
module HPLSpiM { provides { interface SpiByte; } uses { interface HPLUSARTControl as USARTControl; }}implementation { /** * Initialize the SPI bus */ command result_t SpiByte.init() { call USARTControl.setModeSPI(); call USARTControl.disableRxIntr(); call USARTControl.disableTxIntr(); return SUCCESS; } /** * Enable the SPI bus functionality */ async command result_t SpiByte.enable() { call USARTControl.setModeSPI(); call USARTControl.disableRxIntr(); call USARTControl.disableTxIntr(); return SUCCESS; } /** * Disable the SPI bus functionality */ async command result_t SpiByte.disable() { return SUCCESS; } /** * Write a byte to the SPI bus * @param data value written to the MOSI pin * @return value read on the MISO pin */ async command uint8_t SpiByte.write(uint8_t data) { uint8_t retdata; atomic { call USARTControl.tx(data); while(!(call USARTControl.isRxIntrPending())) ; retdata = call USARTControl.rx(); } return retdata; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -