D:\Program Files (x86)\Arduino\libraries\Mirf\MirfHardwareSpiDriver.cpp: In member function 'virtual void MirfHardwareSpiDriver::begin()':
D:\Program Files (x86)\Arduino\libraries\Mirf\MirfHardwareSpiDriver.cpp:9:22: error: 'SPI_2XCLOCK_MASK' was not declared in this scope
SPI.setClockDivider(SPI_2XCLOCK_MASK);
如上所示,下面是代码,希望好心大佬帮忙看一下。感激不尽。
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte TXADDR[5] = {0xff, 0xff, 0xff, 0xff, 0xff};
void setup() {
Serial.begin(115200);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(2, INPUT);
//根据硬件电路使用的引脚
Mirf.cePin = 10; //CE
Mirf.csnPin = 9; //CSN
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
//设置发送目标 目标地址即接收端的自身地址
Mirf.setTADDR((byte *)TXADDR);
Mirf.payload = 32; //32字节payload
Mirf.channel = 0; //2.4GHz
Mirf.config();
Serial.println("Beginning ... ");
}
uint8_t data_buff[32];
void loop() {
//读取传感器
data_buff[0] = 10;
data_buff[1] = '{';
data_buff[2] = digitalRead(2)+'0';
data_buff[3] = '}';
data_buff[4] = '\r';
data_buff[5] = '\n';
//设置发送目标
Mirf.setTADDR((byte*)TXADDR);
//无线传输发送
Mirf.send((byte*)data_buff);
//等待发送完成
while (Mirf.isSending()) {
}
for (int i = 1; i < 5; i++)
{
Serial.print(data_buff);
}
Serial.println();
//延时一会儿
delay(100);
} |
|