Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems encountered when using the Mrif library

Status
Not open for further replies.

Justinli

Member level 4
Member level 4
Joined
Apr 29, 2021
Messages
76
Helped
0
Reputation
0
Reaction score
2
Trophy points
8
Activity points
413
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);

As shown above, here is the code, thanks in advance.

C:
#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);

  //Depending on the pins used in the hardware circuit
  Mirf.cePin = 10;    //CE
  Mirf.csnPin = 9;    //CSN
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  //Set the send destination The destination address is the receiver's own address
  Mirf.setTADDR((byte *)TXADDR);

  Mirf.payload = 32; //32-byte payload
  Mirf.channel = 0;   //2.4GHz
  Mirf.config();

  Serial.println("Beginning ... ");
}

uint8_t data_buff[32];

void loop() {
  //Read the sensor
  data_buff[0] = 10;
  data_buff[1] = '{';
  data_buff[2] = digitalRead(2)+'0';
  data_buff[3] = '}';
  data_buff[4] = '\r';
  data_buff[5] = '\n';

  //Set the sending destination
  Mirf.setTADDR((byte*)TXADDR);
  //Wireless Transmission Sending
  Mirf.send((byte*)data_buff);
  //Wait for sending to complete
  while (Mirf.isSending()) {
  }

  for (int i = 1; i < 5; i++)
  {
    Serial.print(data_buff);
  }
  Serial.println();
  //Time delay
  delay(100);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top