2 * Copyright 2010 Grygoriy Fuchedzhy <grygoriy.fuchedzhy@gmail.com>
4 * This file is part of mrf-link.
6 * mrf-link is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * mrf-link is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with mrf-link. If not, see <http://www.gnu.org/licenses/>.
26 uint8_t mrf_read_short_addr(uint8_t addr
);
27 uint8_t mrf_read_long_addr(uint16_t addr
);
28 void mrf_write_short_addr(uint8_t addr
, uint8_t val
);
29 void mrf_write_long_addr(uint16_t addr
, uint8_t val
);
30 void mrf_set_channel(uint8_t ch
);
32 void mrf_tx(uint16_t pan_id
, uint16_t short_addr
, const uint8_t* data
, uint8_t data_length
);
34 // wrapper function, with constant addr parameter and optimization compiles into
35 // direct call to appropriate function
36 __attribute__ ((always_inline
)) static void
37 mrf_set_reg(uint16_t addr
, uint8_t val
)
40 mrf_write_short_addr(addr
, val
);
42 mrf_write_long_addr(addr
, val
);
45 // wrapper function, with constant addr parameter and optimization compiles into
46 // direct call to appropriate function
47 __attribute__ ((always_inline
)) static uint8_t
48 mrf_get_reg(uint16_t addr
)
51 return mrf_read_short_addr(addr
);
53 return mrf_read_long_addr(addr
);
56 // tx power, small scale must be: 0x0 - 0x1F, small_scale = 0x0 is max power
57 // large scale must be: 0x0 - 0x3, large_scale = 0x0 is max power
58 static inline void mrf_set_tx_power(uint8_t large_scale
, uint8_t small_scale
)
60 mrf_set_reg(MRF_R_RFCON3
, (large_scale
<<6) | (small_scale
<<3));
64 static inline uint8_t mrf_get_txretry()
66 return mrf_get_reg(MRF_R_TXSTAT
) >> 6;