long/short reg manipulation functions renamed to address manipulation functions
[mrf-link.git] / mrf.h
blob27dff9facb6beb52f8f51fe4b20f0a5c53401754
1 #ifndef __MRF__
2 #define __MRF__
4 #include <mrf/defs.h>
6 uint8_t mrf_read_short_addr(uint8_t addr);
7 uint8_t mrf_read_long_addr(uint16_t addr);
8 void mrf_write_short_addr(uint8_t addr, uint8_t val);
9 void mrf_write_long_addr(uint16_t addr, uint8_t val);
10 void mrf_init();
12 // wrapper function, with constant addr parameter and optimization compiles into
13 // direct call to appropriate function
14 __attribute__ ((always_inline)) static void
15 mrf_set_reg(uint16_t addr, uint8_t val)
17 if(addr < 0x100)
18 mrf_write_short_addr(addr, val);
19 else
20 mrf_write_long_addr(addr, val);
23 // wrapper function, with constant addr parameter and optimization compiles into
24 // direct call to appropriate function
25 __attribute__ ((always_inline)) static uint8_t
26 mrf_get_reg(uint16_t addr)
28 if(addr < 0x100)
29 return mrf_read_short_addr(addr);
30 else
31 return mrf_read_long_addr(addr);
34 // tx power, val must be: 0x0 - 0x1F, val = 0x0 is max power
35 static inline void mrf_set_small_scale_tx_power(uint8_t val)
37 mrf_set_reg(MRF_R_RFCTRL3, val<<3);
40 // set channel, ch must be: 0x0 - 0xF
41 static inline void mrf_set_channel(uint8_t ch)
43 mrf_set_reg(MRF_R_RFCTRL0, ch<<4);
46 // get txretry number
47 static inline uint8_t mrf_get_txretry()
49 return mrf_get_reg(MRF_R_TXSR) >> 6;
52 #endif // __MRF__