23 #define RADIO_OSC_STARTUP 1 // [ms] 28 #define RADIO_SLEEP_TO_RX 2 // [ms] 33 #define RADIO_WAKEUP_TIME (RADIO_OSC_STARTUP + RADIO_SLEEP_TO_RX) 36 enum { RADIO_RST=0, RADIO_TX=1, RADIO_RX=2, RADIO_RXON=3 };
38 enum _cr_t { CR_4_5 = 0, CR_4_6, CR_4_7, CR_4_8 };
39 enum _sf_t { FSK = 0, SF6, SF7, SF8, SF9, SF10, SF11, SF12 };
40 enum _bw_t { BW7_8 = 0, BW10_4, BW15_6, BW20_8, BW31_25, BW41_7, BW62_5, BW125, BW250, BW500 };
47 typedef uint32_t rps_t;
50 enum { STD_PREAMBLE_LEN = 8 };
51 enum { MAX_LEN_FRAME = 64 };
64 uint16_t preamble_len;
65 uint8_t payload_length;
76 uint8_t frame[MAX_LEN_FRAME];
82 #define MAKERPS(sf, bw, cr, ih, nocrc) ((rps_t) ((sf) | ((bw) << 3) | ((cr) << 7) | ((nocrc) ? (1 << 9) : 0) | ((ih & 0xFF) << 10))) 84 static inline sf_t getSf(rps_t params)
86 return (sf_t) (params & 0x7);
89 static inline rps_t setSf(rps_t params, sf_t sf)
91 return (rps_t) ((params & ~0x7) | sf);
94 static inline bw_t getBw(rps_t params)
96 return (bw_t) ((params >> 3) & 0xf);
99 static inline rps_t setBw(rps_t params, bw_t bw)
101 return (rps_t) ((params & ~(0xf << 3)) | (bw << 3));
104 static inline cr_t getCr(rps_t params)
106 return (cr_t) ((params >> 7) & 0x3);
109 static inline rps_t setCr(rps_t params, cr_t cr)
111 return (rps_t) ((params & ~(0x3 << 7)) | (cr << 7));
114 static inline int getNocrc(rps_t params)
116 return ((params >> 9) & 0x1);
119 static inline rps_t setNocrc(rps_t params,
int nocrc)
121 return (rps_t) ((params & ~(0x1 << 9)) | (nocrc << 9));
124 static inline int getIh(rps_t params)
126 return ((params >> 10) & 0xFF);
129 static inline rps_t setIh(rps_t params,
int ih)
131 return (rps_t) ((params & ~(0xff << 10)) | ((ih & 0xff) << 10));
134 static inline rps_t makeRps(sf_t sf, bw_t bw, cr_t cr,
int ih,
int nocrc)
136 return sf | (bw << 3) | (cr << 7) | (nocrc ? (1 << 9) : 0) | ((ih & 0xFF) << 10);
uint8_t radio_rssi(void)
Returns the current RSSI.
Definition: radio.c:1061
void os_radio(uint8_t mode)
Changes the radio mode.
Definition: radio.c:1188
void radio_init(void)
Initializes the radio driver.
Definition: radio.c:954
void radio_irq_handler(uint8_t dio)
The radio driver IRQ handler.
Definition: radio.c:1081
void radio_write(uint8_t addr, uint8_t data)
Writes a radio register.
Definition: radio.c:1183
uint8_t radio_read(uint8_t reg)
Reads a radio register.
Definition: radio.c:1178
uint8_t radio_rand1(void)
Returns a random byte.
Definition: radio.c:1048
void radio_reset(uint8_t val)
Resets the SX127x module.
Definition: radio.c:1033