-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNRF905.h
74 lines (60 loc) · 1.88 KB
/
NRF905.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
#ifndef NRF905_h
#define NRF905_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
/** nrf905 instruction set */
#define WC 0x00
#define RC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24
typedef enum
{
US = 0, /** 908.42Mhz */
EUROPE = 1, /** 868.42MHz */
AFRICA = 2, /** 868.42MHz */
CHINA = 3, /** 868.42MHz */
HK = 4, /** 919.82MHz */
JAPAN = 5, /** 853.42MHz */
AUSTRALIA = 6, /** 921.42MHz */
NEW_ZEALAND = 7, /** 921.42MHz */
BRASIL = 8, /** 921.42MHz */
RUSSIA = 9, /** 896.00MHz */
} nrf905_freq_type;
class NRF905
{
public:
NRF905(void);
NRF905(int css);
void init();
void write_config(unsigned char *conf_buf);
void write_config(nrf905_freq_type freq_band);
void read_config(unsigned char *conf_buf);
void RX(unsigned char *TxRxBuffer);
void RX(unsigned char *TxRxBuf, unsigned char *RxAddress);
void TX(unsigned char *TxRxBuf, unsigned char *TxAddress);
void TX(unsigned char *TxRxBuf);
private:
void set_rx(void);
void set_tx(void);
unsigned char check_ready(void);
void RxPacket(unsigned char *TxRxBuffer);
void TxPacket(unsigned char *TxAddress, unsigned char *TxRxBuf);
//----------------------------------------------NRF905 IO------------------------------------------------------
int TXEN;
int TRX_CE;
int PWR;
//----------------------------------------------NRF905 SPI---------------------------------------------------
int CSN;
//----------------------------------------nrf905 status IO---------------------------------------------------------
int AM;
int DR;
int CD;
};
extern NRF905 nrf905;
#endif