-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfm69.h
138 lines (120 loc) · 2.83 KB
/
rfm69.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* File: rfm69.h
* Author: [email protected]
*
* Created on 28. Januar 2025, 19:55
*/
#ifndef RFM69_H
#define RFM69_H
#include <stdbool.h>
#include <util/delay.h>
#include "rfm69.h"
#include "pins.h"
#include "spi.h"
#include "usart.h"
#define FIFO 0x00
#define OP_MODE 0x01
#define DATA_MOD 0x02
#define BITRATE_MSB 0x03
#define BITRATE_LSB 0x04
#define FDEV_MSB 0x05
#define FDEV_LSB 0x06
#define FRF_MSB 0x07
#define FRF_MID 0x08
#define FRF_LSB 0x09
#define OSC1 0x0a
#define PA_LEVEL 0x11
#define LNA 0x18
#define RX_BW 0x19
#define AFC_BW 0x20
#define RSSI_CONFIG 0x23
#define RSSI_VALUE 0x24
#define DIO_MAP1 0x25
#define DIO_MAP2 0x26
#define IRQ_FLAGS1 0x27
#define RSSI_THRESH 0x29
#define PREAMB_MSB 0x2c
#define PREAMB_LSB 0x2d
#define IRQ_FLAGS2 0x28
#define SYNC_CONF 0x2e
#define SYNC_VAL1 0x2f
#define SYNC_VAL2 0x30
#define SYNC_VAL3 0x31
#define SYNC_VAL4 0x32
#define SYNC_VAL5 0x33
#define SYNC_VAL6 0x34
#define SYNC_VAL7 0x35
#define SYNC_VAL8 0x36
#define PCK_CFG1 0x37
#define NODE_ADDR 0x39
#define CAST_ADDR 0x3a
#define AUTO_MODES 0x3b
#define FIFO_THRESH 0x3c
#define TEST_LNA 0x58
#define TEST_PA1 0x5a
#define TEST_PA2 0x5c
#define TEST_DAGC 0x6f
#define TEST_AFC 0x71
#define MASK_MODE 0x1c
#define MODE_SLEEP 0x00
#define MODE_STDBY 0x04
#define MODE_FS 0x08
#define MODE_TX 0x0c
#define MODE_RX 0x10
#define FIFO_SIZE 64
#define NODE_ADDRESS 0x42
#define CAST_ADDRESS 0x84
/**
* Initializes the radio module with the given carrier frequency in kilohertz.
*/
void initRadio(uint32_t kHz);
/**
* Shuts down the radio.
*/
void sleepRadio(void);
/**
* Wakes up the radio.
*/
void wakeRadio(void);
/**
* Sets the radio to receive mode and maps "PayloadReady" to DIO0.
*/
void startReceive(void);
/**
* Returns the current RSSI value.
*
* @return rssi value
*/
uint8_t readRssi(void);
/**
* Returns true if a "PayloadReady" interrupt arrived and clears the
* interrupt state.
*
* @return true if "PayloadReady"
*/
bool payloadReady(void);
/**
* Sets the radio in standby mode, puts the payload into the given array
* with the given size, and returns the length of the payload.
*
* @param payload
* @param size
* @return actual length of the payload
*/
size_t readPayload(uint8_t *payload, size_t size);
/**
* Waits for "PayloadReady", puts the payload into the given array with the
* given size, and returns the length of the payload.
*
* @param payload buffer for payload
* @return bytes actually received
*/
size_t receivePayload(uint8_t *payload, size_t size);
/**
* Transmits up to 64 bytes of the given payload.
*
* @param payload to be sent
* @return bytes actually sent
*/
size_t transmitPayload(uint8_t *payload, size_t size);
#endif /* RFM69_H */