Hi,
Im not sure if im doing something wrong or what, but i've been hitting a wall when trying to use the radio example transmitter and receiver.
No matter what i send on the transmitter, the receiver always prints out 0. Here's the code that im using:
Transmitter:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <nrf52_radio.h>
nrf52 radio;
void setup() {
#ifdef DEBUG
Serial.begin(115200);
#endif
// SETUP RADIO
radio.init();
}
void loop()
{
radio.write(123);
}
Receiver:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <nrf52_radio.h>
nrf52 radio;
void setup() {
Serial.begin(115200);
radio.init();
}
void loop()
{
Serial.print("Received packet ");
uint32_t received = radio.read();
Serial.print("Received packet ");
Serial.print(received);
Serial.print(" ");
Serial.print(received, HEX);
Serial.print(" ");
And here's the "library" i made:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef NRF52_RADIO_H
#define NRF52_RADIO_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PACKET_BASE_ADDRESS_LENGTH (4UL) //!< Packet base address length field size in bytes
#define PACKET_STATIC_LENGTH (1UL) //!< Packet static length in bytes
#define PACKET_PAYLOAD_MAXSIZE (PACKET_STATIC_LENGTH) //!< Packet payload maximum size in bytes
class nrf52 {
public:
nrf52();
void init();
uint32_t read();
void write(uint32_t packet);
private:
uint32_t m_packet;
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "nrf52_radio.h"
#include "nrf.h"
#include "Arduino.h"
#define PACKET_S1_FIELD_SIZE (0UL) /**< Packet S1 field size in bits. */
#define PACKET_S0_FIELD_SIZE (0UL) /**< Packet S0 field size in bits. */
#define PACKET_LENGTH_FIELD_SIZE (0UL) /**< Packet length field size in bits. */
static uint32_t swap_bits(uint32_t inp);
static uint32_t bytewise_bitswap(uint32_t inp);
static uint32_t swap_bits(uint32_t inp)
{
uint32_t i;
uint32_t retval = 0;
inp = (inp & 0x000000FFUL);
for (i = 0; i < 8; i++)
{