-
Notifications
You must be signed in to change notification settings - Fork 2
/
se8r01.h
62 lines (43 loc) · 1.35 KB
/
se8r01.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
#ifndef se8r01_h
#define se8r01_h
#include "se8r01_map.h"
/*
//PINS assignment
// CE:Chip Enable Activates RX or TX mode
#define CEq 7
// CSN:SPI Chip Select
#define CSNq 10
// IRQ:Maskable interrupt pin
#define IRQq 8
*/
extern uint8_t CE_pin, CS_pin, IRQ_pin;
extern byte payload_width;
//OPERATION MODES
enum {
TX_MODE = 0, RX_MODE = 1, STANDBY = 2
};
//********************************** RADIO functions
boolean init_rf(byte CS_pin, byte CE_pin, byte IRQ_pin, byte payloadWidth);
void changeMode(byte MODE);
//returns number of retransmits if succeed, or -1 if failed to get ACK
char sendWithAck(byte *address);
void pushTxPayload(byte *addr, byte dataSize);
//returns pipe number of received data, or 7 if no data
byte getRxData(byte *address);
void getRxPayload(byte *addr, byte width);
void setChannel(byte ch);
void setPower(byte power);
byte getStatusReg();
//sets the number of retransmits for transmitted package to get ACK (max 15)
void setRtr(byte rtr);
void selectTxPipe(byte pipe);
//************************************Low level register access
//Write
void writeCommand(byte command);
void writeToReg(byte reg, byte val);
void writeToReg(byte reg, byte *addr, byte dataSize);
void writeToRegMask(byte reg, byte val, byte mask);
//Read
byte readReg(byte reg);
void readReg(byte reg, byte *addr, byte dataSize);
#endif