Library to send and receive data using RF12B transceiver modules Big thanks to the tutorial at https://loee.jottit.com/rfm12b_and_avr_-_quick_start and madcowswe
Dependents: Measure_system Quadcopter_copy
RF_defs.h@6:98da0571ec31, 2011-03-11 (annotated)
- Committer:
- harryeakins
- Date:
- Fri Mar 11 15:47:06 2011 +0000
- Revision:
- 6:98da0571ec31
Added RFSerial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harryeakins | 6:98da0571ec31 | 1 | /* |
harryeakins | 6:98da0571ec31 | 2 | * Open HR20 |
harryeakins | 6:98da0571ec31 | 3 | * |
harryeakins | 6:98da0571ec31 | 4 | * target: ATmega169 @ 4 MHz in Honnywell Rondostat HR20E |
harryeakins | 6:98da0571ec31 | 5 | * |
harryeakins | 6:98da0571ec31 | 6 | * compiler: WinAVR-20071221 |
harryeakins | 6:98da0571ec31 | 7 | * avr-libc 1.6.0 |
harryeakins | 6:98da0571ec31 | 8 | * GCC 4.2.2 |
harryeakins | 6:98da0571ec31 | 9 | * |
harryeakins | 6:98da0571ec31 | 10 | * copyright: 2008 Dario Carluccio (hr20-at-carluccio-dot-de) |
harryeakins | 6:98da0571ec31 | 11 | * 2008 Jiri Dobry (jdobry-at-centrum-dot-cz) |
harryeakins | 6:98da0571ec31 | 12 | * 2008 Mario Fischer (MarioFischer-at-gmx-dot-net) |
harryeakins | 6:98da0571ec31 | 13 | * 2007 Michael Smola (Michael-dot-Smola-at-gmx-dot-net) |
harryeakins | 6:98da0571ec31 | 14 | * |
harryeakins | 6:98da0571ec31 | 15 | * license: This program is free software; you can redistribute it and/or |
harryeakins | 6:98da0571ec31 | 16 | * modify it under the terms of the GNU Library General Public |
harryeakins | 6:98da0571ec31 | 17 | * License as published by the Free Software Foundation; either |
harryeakins | 6:98da0571ec31 | 18 | * version 2 of the License, or (at your option) any later version. |
harryeakins | 6:98da0571ec31 | 19 | * |
harryeakins | 6:98da0571ec31 | 20 | * This program is distributed in the hope that it will be useful, |
harryeakins | 6:98da0571ec31 | 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
harryeakins | 6:98da0571ec31 | 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
harryeakins | 6:98da0571ec31 | 23 | * GNU General Public License for more details. |
harryeakins | 6:98da0571ec31 | 24 | * |
harryeakins | 6:98da0571ec31 | 25 | * You should have received a copy of the GNU General Public License |
harryeakins | 6:98da0571ec31 | 26 | * along with this program. If not, see http:*www.gnu.org/licenses |
harryeakins | 6:98da0571ec31 | 27 | */ |
harryeakins | 6:98da0571ec31 | 28 | |
harryeakins | 6:98da0571ec31 | 29 | /* |
harryeakins | 6:98da0571ec31 | 30 | * \file rfm.h |
harryeakins | 6:98da0571ec31 | 31 | * \brief functions to control the RFM12 Radio Transceiver Module |
harryeakins | 6:98da0571ec31 | 32 | * \author Mario Fischer <MarioFischer-at-gmx-dot-net>; Michael Smola <Michael-dot-Smola-at-gmx-dot-net> |
harryeakins | 6:98da0571ec31 | 33 | * \date $Date: 2010/04/17 17:57:02 $ |
harryeakins | 6:98da0571ec31 | 34 | * $Rev: 260 $ |
harryeakins | 6:98da0571ec31 | 35 | */ |
harryeakins | 6:98da0571ec31 | 36 | |
harryeakins | 6:98da0571ec31 | 37 | |
harryeakins | 6:98da0571ec31 | 38 | //#pragma once // multi-iclude prevention. gcc knows this pragma |
harryeakins | 6:98da0571ec31 | 39 | #ifndef rfm_H |
harryeakins | 6:98da0571ec31 | 40 | #define rfm_H |
harryeakins | 6:98da0571ec31 | 41 | |
harryeakins | 6:98da0571ec31 | 42 | |
harryeakins | 6:98da0571ec31 | 43 | #define RFM_SPI_16(OUTVAL) rfm_spi16(OUTVAL) //<! a function that gets a uint16_t (clocked out value) and returns a uint16_t (clocked in value) |
harryeakins | 6:98da0571ec31 | 44 | |
harryeakins | 6:98da0571ec31 | 45 | #define RFM_CLK_OUTPUT 0 |
harryeakins | 6:98da0571ec31 | 46 | |
harryeakins | 6:98da0571ec31 | 47 | /* |
harryeakins | 6:98da0571ec31 | 48 | #define RFM_TESTPIN_INIT |
harryeakins | 6:98da0571ec31 | 49 | #define RFM_TESTPIN_ON |
harryeakins | 6:98da0571ec31 | 50 | #define RFM_TESTPIN_OFF |
harryeakins | 6:98da0571ec31 | 51 | #define RFM_TESTPIN_TOG |
harryeakins | 6:98da0571ec31 | 52 | |
harryeakins | 6:98da0571ec31 | 53 | #define RFM_CONFIG_DISABLE 0x00 //<! RFM_CONFIG_*** are combinable flags, what the RFM shold do |
harryeakins | 6:98da0571ec31 | 54 | #define RFM_CONFIG_BROADCASTSTATUS 0x01 //<! Flag that enables the HR20's status broadcast every minute |
harryeakins | 6:98da0571ec31 | 55 | |
harryeakins | 6:98da0571ec31 | 56 | #define RFM_CONFIG_ENABLEALL 0xff |
harryeakins | 6:98da0571ec31 | 57 | */ |
harryeakins | 6:98da0571ec31 | 58 | |
harryeakins | 6:98da0571ec31 | 59 | |
harryeakins | 6:98da0571ec31 | 60 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 61 | // |
harryeakins | 6:98da0571ec31 | 62 | // RFM status bits |
harryeakins | 6:98da0571ec31 | 63 | // |
harryeakins | 6:98da0571ec31 | 64 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 65 | |
harryeakins | 6:98da0571ec31 | 66 | // Interrupt bits, latched //////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 67 | |
harryeakins | 6:98da0571ec31 | 68 | #define RFM_STATUS_FFIT 0x8000 // RX FIFO reached the progr. number of bits |
harryeakins | 6:98da0571ec31 | 69 | // Cleared by any FIFO read method |
harryeakins | 6:98da0571ec31 | 70 | |
harryeakins | 6:98da0571ec31 | 71 | #define RFM_STATUS_RGIT 0x8000 // TX register is ready to receive |
harryeakins | 6:98da0571ec31 | 72 | // Cleared by TX write |
harryeakins | 6:98da0571ec31 | 73 | |
harryeakins | 6:98da0571ec31 | 74 | #define RFM_STATUS_POR 0x4000 // Power On reset |
harryeakins | 6:98da0571ec31 | 75 | // Cleared by read status |
harryeakins | 6:98da0571ec31 | 76 | |
harryeakins | 6:98da0571ec31 | 77 | #define RFM_STATUS_RGUR 0x2000 // TX register underrun, register over write |
harryeakins | 6:98da0571ec31 | 78 | // Cleared by read status |
harryeakins | 6:98da0571ec31 | 79 | |
harryeakins | 6:98da0571ec31 | 80 | #define RFM_STATUS_FFOV 0x2000 // RX FIFO overflow |
harryeakins | 6:98da0571ec31 | 81 | // Cleared by read status |
harryeakins | 6:98da0571ec31 | 82 | |
harryeakins | 6:98da0571ec31 | 83 | #define RFM_STATUS_WKUP 0x1000 // Wake up timer overflow |
harryeakins | 6:98da0571ec31 | 84 | // Cleared by read status |
harryeakins | 6:98da0571ec31 | 85 | |
harryeakins | 6:98da0571ec31 | 86 | #define RFM_STATUS_EXT 0x0800 // Interupt changed to low |
harryeakins | 6:98da0571ec31 | 87 | // Cleared by read status |
harryeakins | 6:98da0571ec31 | 88 | |
harryeakins | 6:98da0571ec31 | 89 | #define RFM_STATUS_LBD 0x0400 // Low battery detect |
harryeakins | 6:98da0571ec31 | 90 | |
harryeakins | 6:98da0571ec31 | 91 | // Status bits //////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 92 | |
harryeakins | 6:98da0571ec31 | 93 | #define RFM_STATUS_FFEM 0x0200 // FIFO is empty |
harryeakins | 6:98da0571ec31 | 94 | #define RFM_STATUS_ATS 0x0100 // TX mode: Strong enough RF signal |
harryeakins | 6:98da0571ec31 | 95 | #define RFM_STATUS_RSSI 0x0100 // RX mode: signal strength above programmed limit |
harryeakins | 6:98da0571ec31 | 96 | #define RFM_STATUS_DQD 0x0080 // Data Quality detector output |
harryeakins | 6:98da0571ec31 | 97 | #define RFM_STATUS_CRL 0x0040 // Clock recovery lock |
harryeakins | 6:98da0571ec31 | 98 | #define RFM_STATUS_ATGL 0x0020 // Toggling in each AFC cycle |
harryeakins | 6:98da0571ec31 | 99 | |
harryeakins | 6:98da0571ec31 | 100 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 101 | // |
harryeakins | 6:98da0571ec31 | 102 | // 1. Configuration Setting Command |
harryeakins | 6:98da0571ec31 | 103 | // |
harryeakins | 6:98da0571ec31 | 104 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 105 | |
harryeakins | 6:98da0571ec31 | 106 | #define RFM_CONFIG 0x8000 |
harryeakins | 6:98da0571ec31 | 107 | |
harryeakins | 6:98da0571ec31 | 108 | #define RFM_CONFIG_EL 0x8080 // Enable TX Register |
harryeakins | 6:98da0571ec31 | 109 | #define RFM_CONFIG_EF 0x8040 // Enable RX FIFO buffer |
harryeakins | 6:98da0571ec31 | 110 | #define RFM_CONFIG_BAND_315 0x8000 // Frequency band |
harryeakins | 6:98da0571ec31 | 111 | #define RFM_CONFIG_BAND_433 0x8010 |
harryeakins | 6:98da0571ec31 | 112 | #define RFM_CONFIG_BAND_868 0x8020 |
harryeakins | 6:98da0571ec31 | 113 | #define RFM_CONFIG_BAND_915 0x8030 |
harryeakins | 6:98da0571ec31 | 114 | #define RFM_CONFIG_X_8_5pf 0x8000 // Crystal Load Capacitor |
harryeakins | 6:98da0571ec31 | 115 | #define RFM_CONFIG_X_9_0pf 0x8001 |
harryeakins | 6:98da0571ec31 | 116 | #define RFM_CONFIG_X_9_5pf 0x8002 |
harryeakins | 6:98da0571ec31 | 117 | #define RFM_CONFIG_X_10_0pf 0x8003 |
harryeakins | 6:98da0571ec31 | 118 | #define RFM_CONFIG_X_10_5pf 0x8004 |
harryeakins | 6:98da0571ec31 | 119 | #define RFM_CONFIG_X_11_0pf 0x8005 |
harryeakins | 6:98da0571ec31 | 120 | #define RFM_CONFIG_X_11_5pf 0x8006 |
harryeakins | 6:98da0571ec31 | 121 | #define RFM_CONFIG_X_12_0pf 0x8007 |
harryeakins | 6:98da0571ec31 | 122 | #define RFM_CONFIG_X_12_5pf 0x8008 |
harryeakins | 6:98da0571ec31 | 123 | #define RFM_CONFIG_X_13_0pf 0x8009 |
harryeakins | 6:98da0571ec31 | 124 | #define RFM_CONFIG_X_13_5pf 0x800A |
harryeakins | 6:98da0571ec31 | 125 | #define RFM_CONFIG_X_14_0pf 0x800B |
harryeakins | 6:98da0571ec31 | 126 | #define RFM_CONFIG_X_14_5pf 0x800C |
harryeakins | 6:98da0571ec31 | 127 | #define RFM_CONFIG_X_15_0pf 0x800D |
harryeakins | 6:98da0571ec31 | 128 | #define RFM_CONFIG_X_15_5pf 0x800E |
harryeakins | 6:98da0571ec31 | 129 | #define RFM_CONFIG_X_16_0pf 0x800F |
harryeakins | 6:98da0571ec31 | 130 | |
harryeakins | 6:98da0571ec31 | 131 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 132 | // |
harryeakins | 6:98da0571ec31 | 133 | // 2. Power Management Command |
harryeakins | 6:98da0571ec31 | 134 | // |
harryeakins | 6:98da0571ec31 | 135 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 136 | |
harryeakins | 6:98da0571ec31 | 137 | #define RFM_POWER_MANAGEMENT 0x8200 |
harryeakins | 6:98da0571ec31 | 138 | |
harryeakins | 6:98da0571ec31 | 139 | #define RFM_POWER_MANAGEMENT_ER 0x8280 // Enable receiver |
harryeakins | 6:98da0571ec31 | 140 | #define RFM_POWER_MANAGEMENT_EBB 0x8240 // Enable base band block |
harryeakins | 6:98da0571ec31 | 141 | #define RFM_POWER_MANAGEMENT_ET 0x8220 // Enable transmitter |
harryeakins | 6:98da0571ec31 | 142 | #define RFM_POWER_MANAGEMENT_ES 0x8210 // Enable synthesizer |
harryeakins | 6:98da0571ec31 | 143 | #define RFM_POWER_MANAGEMENT_EX 0x8208 // Enable crystal oscillator |
harryeakins | 6:98da0571ec31 | 144 | #define RFM_POWER_MANAGEMENT_EB 0x8204 // Enable low battery detector |
harryeakins | 6:98da0571ec31 | 145 | #define RFM_POWER_MANAGEMENT_EW 0x8202 // Enable wake-up timer |
harryeakins | 6:98da0571ec31 | 146 | #define RFM_POWER_MANAGEMENT_DC 0x8201 // Disable clock output of CLK pin |
harryeakins | 6:98da0571ec31 | 147 | |
harryeakins | 6:98da0571ec31 | 148 | #ifndef RFM_CLK_OUTPUT |
harryeakins | 6:98da0571ec31 | 149 | #error RFM_CLK_OUTPUT must be defined to 0 or 1 |
harryeakins | 6:98da0571ec31 | 150 | #endif |
harryeakins | 6:98da0571ec31 | 151 | #if RFM_CLK_OUTPUT |
harryeakins | 6:98da0571ec31 | 152 | #define RFM_TX_ON_PRE() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 153 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 154 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 155 | #define RFM_TX_ON() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 156 | RFM_POWER_MANAGEMENT_ET | \ |
harryeakins | 6:98da0571ec31 | 157 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 158 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 159 | #define RFM_RX_ON() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 160 | RFM_POWER_MANAGEMENT_ER | \ |
harryeakins | 6:98da0571ec31 | 161 | RFM_POWER_MANAGEMENT_EBB | \ |
harryeakins | 6:98da0571ec31 | 162 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 163 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 164 | #define RFM_OFF() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 165 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 166 | #else |
harryeakins | 6:98da0571ec31 | 167 | #define RFM_TX_ON_PRE() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 168 | RFM_POWER_MANAGEMENT_DC | \ |
harryeakins | 6:98da0571ec31 | 169 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 170 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 171 | #define RFM_TX_ON() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 172 | RFM_POWER_MANAGEMENT_DC | \ |
harryeakins | 6:98da0571ec31 | 173 | RFM_POWER_MANAGEMENT_ET | \ |
harryeakins | 6:98da0571ec31 | 174 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 175 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 176 | #define RFM_RX_ON() RFM_SPI_16( \ |
harryeakins | 6:98da0571ec31 | 177 | RFM_POWER_MANAGEMENT_DC | \ |
harryeakins | 6:98da0571ec31 | 178 | RFM_POWER_MANAGEMENT_ER | \ |
harryeakins | 6:98da0571ec31 | 179 | RFM_POWER_MANAGEMENT_EBB | \ |
harryeakins | 6:98da0571ec31 | 180 | RFM_POWER_MANAGEMENT_ES | \ |
harryeakins | 6:98da0571ec31 | 181 | RFM_POWER_MANAGEMENT_EX ) |
harryeakins | 6:98da0571ec31 | 182 | #define RFM_OFF() RFM_SPI_16(RFM_POWER_MANAGEMENT_DC) |
harryeakins | 6:98da0571ec31 | 183 | #endif |
harryeakins | 6:98da0571ec31 | 184 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 185 | // |
harryeakins | 6:98da0571ec31 | 186 | // 3. Frequency Setting Command |
harryeakins | 6:98da0571ec31 | 187 | // |
harryeakins | 6:98da0571ec31 | 188 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 189 | |
harryeakins | 6:98da0571ec31 | 190 | #define RFM_FREQUENCY 0xA000 |
harryeakins | 6:98da0571ec31 | 191 | |
harryeakins | 6:98da0571ec31 | 192 | #define RFM_FREQ_315Band(v) (uint16_t)((v/10.0-31)*4000) |
harryeakins | 6:98da0571ec31 | 193 | #define RFM_FREQ_433Band(v) (uint16_t)((v/10.0-43)*4000) |
harryeakins | 6:98da0571ec31 | 194 | #define RFM_FREQ_868Band(v) (uint16_t)((v/20.0-43)*4000) |
harryeakins | 6:98da0571ec31 | 195 | #define RFM_FREQ_915Band(v) (uint16_t)((v/30.0-30)*4000) |
harryeakins | 6:98da0571ec31 | 196 | |
harryeakins | 6:98da0571ec31 | 197 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 198 | // |
harryeakins | 6:98da0571ec31 | 199 | // 4. Data Rate Command |
harryeakins | 6:98da0571ec31 | 200 | // |
harryeakins | 6:98da0571ec31 | 201 | ///////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 202 | |
harryeakins | 6:98da0571ec31 | 203 | #define RFM_BAUD_RATE 9600 |
harryeakins | 6:98da0571ec31 | 204 | |
harryeakins | 6:98da0571ec31 | 205 | #define RFM_DATA_RATE 0xC600 |
harryeakins | 6:98da0571ec31 | 206 | |
harryeakins | 6:98da0571ec31 | 207 | #define RFM_DATA_RATE_CS 0xC680 |
harryeakins | 6:98da0571ec31 | 208 | #define RFM_DATA_RATE_4800 0xC647 |
harryeakins | 6:98da0571ec31 | 209 | #define RFM_DATA_RATE_9600 0xC623 |
harryeakins | 6:98da0571ec31 | 210 | #define RFM_DATA_RATE_19200 0xC611 |
harryeakins | 6:98da0571ec31 | 211 | #define RFM_DATA_RATE_38400 0xC608 |
harryeakins | 6:98da0571ec31 | 212 | #define RFM_DATA_RATE_57600 0xC605 |
harryeakins | 6:98da0571ec31 | 213 | |
harryeakins | 6:98da0571ec31 | 214 | #define RFM_SET_DATARATE(baud) ( ((baud)<5400) ? (RFM_DATA_RATE_CS|((43104/(baud))-1)) : (RFM_DATA_RATE|((344828UL/(baud))-1)) ) |
harryeakins | 6:98da0571ec31 | 215 | |
harryeakins | 6:98da0571ec31 | 216 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 217 | // |
harryeakins | 6:98da0571ec31 | 218 | // 5. Receiver Control Command |
harryeakins | 6:98da0571ec31 | 219 | // |
harryeakins | 6:98da0571ec31 | 220 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 221 | |
harryeakins | 6:98da0571ec31 | 222 | #define RFM_RX_CONTROL 0x9000 |
harryeakins | 6:98da0571ec31 | 223 | |
harryeakins | 6:98da0571ec31 | 224 | #define RFM_RX_CONTROL_P20_INT 0x9000 // Pin20 = ExternalInt |
harryeakins | 6:98da0571ec31 | 225 | #define RFM_RX_CONTROL_P20_VDI 0x9400 // Pin20 = VDI out |
harryeakins | 6:98da0571ec31 | 226 | |
harryeakins | 6:98da0571ec31 | 227 | #define RFM_RX_CONTROL_VDI_FAST 0x9000 // fast VDI Response time |
harryeakins | 6:98da0571ec31 | 228 | #define RFM_RX_CONTROL_VDI_MED 0x9100 // medium |
harryeakins | 6:98da0571ec31 | 229 | #define RFM_RX_CONTROL_VDI_SLOW 0x9200 // slow |
harryeakins | 6:98da0571ec31 | 230 | #define RFM_RX_CONTROL_VDI_ON 0x9300 // Always on |
harryeakins | 6:98da0571ec31 | 231 | |
harryeakins | 6:98da0571ec31 | 232 | #define RFM_RX_CONTROL_BW_400 0x9020 // bandwidth 400kHz |
harryeakins | 6:98da0571ec31 | 233 | #define RFM_RX_CONTROL_BW_340 0x9040 // bandwidth 340kHz |
harryeakins | 6:98da0571ec31 | 234 | #define RFM_RX_CONTROL_BW_270 0x9060 // bandwidth 270kHz |
harryeakins | 6:98da0571ec31 | 235 | #define RFM_RX_CONTROL_BW_200 0x9080 // bandwidth 200kHz |
harryeakins | 6:98da0571ec31 | 236 | #define RFM_RX_CONTROL_BW_134 0x90A0 // bandwidth 134kHz |
harryeakins | 6:98da0571ec31 | 237 | #define RFM_RX_CONTROL_BW_67 0x90C0 // bandwidth 67kHz |
harryeakins | 6:98da0571ec31 | 238 | |
harryeakins | 6:98da0571ec31 | 239 | #define RFM_RX_CONTROL_GAIN_0 0x9000 // LNA gain 0db |
harryeakins | 6:98da0571ec31 | 240 | #define RFM_RX_CONTROL_GAIN_6 0x9008 // LNA gain -6db |
harryeakins | 6:98da0571ec31 | 241 | #define RFM_RX_CONTROL_GAIN_14 0x9010 // LNA gain -14db |
harryeakins | 6:98da0571ec31 | 242 | #define RFM_RX_CONTROL_GAIN_20 0x9018 // LNA gain -20db |
harryeakins | 6:98da0571ec31 | 243 | |
harryeakins | 6:98da0571ec31 | 244 | #define RFM_RX_CONTROL_RSSI_103 0x9000 // DRSSI threshold -103dbm |
harryeakins | 6:98da0571ec31 | 245 | #define RFM_RX_CONTROL_RSSI_97 0x9001 // DRSSI threshold -97dbm |
harryeakins | 6:98da0571ec31 | 246 | #define RFM_RX_CONTROL_RSSI_91 0x9002 // DRSSI threshold -91dbm |
harryeakins | 6:98da0571ec31 | 247 | #define RFM_RX_CONTROL_RSSI_85 0x9003 // DRSSI threshold -85dbm |
harryeakins | 6:98da0571ec31 | 248 | #define RFM_RX_CONTROL_RSSI_79 0x9004 // DRSSI threshold -79dbm |
harryeakins | 6:98da0571ec31 | 249 | #define RFM_RX_CONTROL_RSSI_73 0x9005 // DRSSI threshold -73dbm |
harryeakins | 6:98da0571ec31 | 250 | //#define RFM_RX_CONTROL_RSSI_67 0x9006 // DRSSI threshold -67dbm // RF12B reserved |
harryeakins | 6:98da0571ec31 | 251 | //#define RFM_RX_CONTROL_RSSI_61 0x9007 // DRSSI threshold -61dbm // RF12B reserved |
harryeakins | 6:98da0571ec31 | 252 | |
harryeakins | 6:98da0571ec31 | 253 | #define RFM_RX_CONTROL_BW(baud) (((baud)<8000) ? \ |
harryeakins | 6:98da0571ec31 | 254 | RFM_RX_CONTROL_BW_67 : \ |
harryeakins | 6:98da0571ec31 | 255 | ( \ |
harryeakins | 6:98da0571ec31 | 256 | ((baud)<30000) ? \ |
harryeakins | 6:98da0571ec31 | 257 | RFM_RX_CONTROL_BW_134 : \ |
harryeakins | 6:98da0571ec31 | 258 | RFM_RX_CONTROL_BW_200 \ |
harryeakins | 6:98da0571ec31 | 259 | )) |
harryeakins | 6:98da0571ec31 | 260 | |
harryeakins | 6:98da0571ec31 | 261 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 262 | // |
harryeakins | 6:98da0571ec31 | 263 | // 6. Data Filter Command |
harryeakins | 6:98da0571ec31 | 264 | // |
harryeakins | 6:98da0571ec31 | 265 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 266 | |
harryeakins | 6:98da0571ec31 | 267 | #define RFM_DATA_FILTER 0xC228 |
harryeakins | 6:98da0571ec31 | 268 | |
harryeakins | 6:98da0571ec31 | 269 | #define RFM_DATA_FILTER_AL 0xC2A8 // clock recovery auto-lock |
harryeakins | 6:98da0571ec31 | 270 | #define RFM_DATA_FILTER_ML 0xC268 // clock recovery fast mode |
harryeakins | 6:98da0571ec31 | 271 | #define RFM_DATA_FILTER_DIG 0xC228 // data filter type digital |
harryeakins | 6:98da0571ec31 | 272 | #define RFM_DATA_FILTER_ANALOG 0xC238 // data filter type analog |
harryeakins | 6:98da0571ec31 | 273 | #define RFM_DATA_FILTER_DQD(level) (RFM_DATA_FILTER | (level & 0x7)) |
harryeakins | 6:98da0571ec31 | 274 | |
harryeakins | 6:98da0571ec31 | 275 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 276 | // |
harryeakins | 6:98da0571ec31 | 277 | // 7. FIFO and Reset Mode Command |
harryeakins | 6:98da0571ec31 | 278 | // |
harryeakins | 6:98da0571ec31 | 279 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 280 | |
harryeakins | 6:98da0571ec31 | 281 | #define RFM_FIFO 0xCA00 |
harryeakins | 6:98da0571ec31 | 282 | |
harryeakins | 6:98da0571ec31 | 283 | #define RFM_FIFO_AL 0xCA04 // FIFO Start condition sync-word/always |
harryeakins | 6:98da0571ec31 | 284 | #define RFM_FIFO_FF 0xCA02 // Enable FIFO fill |
harryeakins | 6:98da0571ec31 | 285 | #define RFM_FIFO_DR 0xCA01 // Disable hi sens reset mode |
harryeakins | 6:98da0571ec31 | 286 | #define RFM_FIFO_IT(level) (RFM_FIFO | (( (level) & 0xF)<<4)) |
harryeakins | 6:98da0571ec31 | 287 | |
harryeakins | 6:98da0571ec31 | 288 | #define RFM_FIFO_OFF() RFM_SPI_16(RFM_FIFO_IT(8) | RFM_FIFO_DR) |
harryeakins | 6:98da0571ec31 | 289 | #define RFM_FIFO_ON() RFM_SPI_16(RFM_FIFO_IT(8) | RFM_FIFO_FF | RFM_FIFO_DR) |
harryeakins | 6:98da0571ec31 | 290 | |
harryeakins | 6:98da0571ec31 | 291 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 292 | // |
harryeakins | 6:98da0571ec31 | 293 | // 8. Receiver FIFO Read |
harryeakins | 6:98da0571ec31 | 294 | // |
harryeakins | 6:98da0571ec31 | 295 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 296 | |
harryeakins | 6:98da0571ec31 | 297 | #define RFM_READ_FIFO() (RFM_SPI_16(0xB000) & 0xFF) |
harryeakins | 6:98da0571ec31 | 298 | |
harryeakins | 6:98da0571ec31 | 299 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 300 | // |
harryeakins | 6:98da0571ec31 | 301 | // 9. AFC Command |
harryeakins | 6:98da0571ec31 | 302 | // |
harryeakins | 6:98da0571ec31 | 303 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 304 | |
harryeakins | 6:98da0571ec31 | 305 | #define RFM_AFC 0xC400 |
harryeakins | 6:98da0571ec31 | 306 | |
harryeakins | 6:98da0571ec31 | 307 | #define RFM_AFC_EN 0xC401 |
harryeakins | 6:98da0571ec31 | 308 | #define RFM_AFC_OE 0xC402 |
harryeakins | 6:98da0571ec31 | 309 | #define RFM_AFC_FI 0xC404 |
harryeakins | 6:98da0571ec31 | 310 | #define RFM_AFC_ST 0xC408 |
harryeakins | 6:98da0571ec31 | 311 | |
harryeakins | 6:98da0571ec31 | 312 | // Limits the value of the frequency offset register to the next values: |
harryeakins | 6:98da0571ec31 | 313 | |
harryeakins | 6:98da0571ec31 | 314 | #define RFM_AFC_RANGE_LIMIT_NO 0xC400 // 0: No restriction |
harryeakins | 6:98da0571ec31 | 315 | #define RFM_AFC_RANGE_LIMIT_15_16 0xC410 // 1: +15 fres to -16 fres |
harryeakins | 6:98da0571ec31 | 316 | #define RFM_AFC_RANGE_LIMIT_7_8 0xC420 // 2: +7 fres to -8 fres |
harryeakins | 6:98da0571ec31 | 317 | #define RFM_AFC_RANGE_LIMIT_3_4 0xC430 // 3: +3 fres to -4 fres |
harryeakins | 6:98da0571ec31 | 318 | |
harryeakins | 6:98da0571ec31 | 319 | // fres=2.5 kHz in 315MHz and 433MHz Bands |
harryeakins | 6:98da0571ec31 | 320 | // fres=5.0 kHz in 868MHz Band |
harryeakins | 6:98da0571ec31 | 321 | // fres=7.5 kHz in 915MHz Band |
harryeakins | 6:98da0571ec31 | 322 | |
harryeakins | 6:98da0571ec31 | 323 | #define RFM_AFC_AUTO_OFF 0xC400 // 0: Auto mode off (Strobe is controlled by microcontroller) |
harryeakins | 6:98da0571ec31 | 324 | #define RFM_AFC_AUTO_ONCE 0xC440 // 1: Runs only once after each power-up |
harryeakins | 6:98da0571ec31 | 325 | #define RFM_AFC_AUTO_VDI 0xC480 // 2: Keep the foffset only during receiving(VDI=high) |
harryeakins | 6:98da0571ec31 | 326 | #define RFM_AFC_AUTO_INDEPENDENT 0xC4C0 // 3: Keep the foffset value independently trom the state of the VDI signal |
harryeakins | 6:98da0571ec31 | 327 | |
harryeakins | 6:98da0571ec31 | 328 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 329 | // |
harryeakins | 6:98da0571ec31 | 330 | // 10. TX Configuration Control Command |
harryeakins | 6:98da0571ec31 | 331 | // |
harryeakins | 6:98da0571ec31 | 332 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 333 | |
harryeakins | 6:98da0571ec31 | 334 | #define RFM_TX_CONTROL 0x9800 |
harryeakins | 6:98da0571ec31 | 335 | |
harryeakins | 6:98da0571ec31 | 336 | #define RFM_TX_CONTROL_POW_0 0x9800 |
harryeakins | 6:98da0571ec31 | 337 | #define RFM_TX_CONTROL_POW_3 0x9801 |
harryeakins | 6:98da0571ec31 | 338 | #define RFM_TX_CONTROL_POW_6 0x9802 |
harryeakins | 6:98da0571ec31 | 339 | #define RFM_TX_CONTROL_POW_9 0x9803 |
harryeakins | 6:98da0571ec31 | 340 | #define RFM_TX_CONTROL_POW_12 0x9804 |
harryeakins | 6:98da0571ec31 | 341 | #define RFM_TX_CONTROL_POW_15 0x9805 |
harryeakins | 6:98da0571ec31 | 342 | #define RFM_TX_CONTROL_POW_18 0x9806 |
harryeakins | 6:98da0571ec31 | 343 | #define RFM_TX_CONTROL_POW_21 0x9807 |
harryeakins | 6:98da0571ec31 | 344 | #define RFM_TX_CONTROL_MOD_15 0x9800 |
harryeakins | 6:98da0571ec31 | 345 | #define RFM_TX_CONTROL_MOD_30 0x9810 |
harryeakins | 6:98da0571ec31 | 346 | #define RFM_TX_CONTROL_MOD_45 0x9820 |
harryeakins | 6:98da0571ec31 | 347 | #define RFM_TX_CONTROL_MOD_60 0x9830 |
harryeakins | 6:98da0571ec31 | 348 | #define RFM_TX_CONTROL_MOD_75 0x9840 |
harryeakins | 6:98da0571ec31 | 349 | #define RFM_TX_CONTROL_MOD_90 0x9850 |
harryeakins | 6:98da0571ec31 | 350 | #define RFM_TX_CONTROL_MOD_105 0x9860 |
harryeakins | 6:98da0571ec31 | 351 | #define RFM_TX_CONTROL_MOD_120 0x9870 |
harryeakins | 6:98da0571ec31 | 352 | #define RFM_TX_CONTROL_MOD_135 0x9880 |
harryeakins | 6:98da0571ec31 | 353 | #define RFM_TX_CONTROL_MOD_150 0x9890 |
harryeakins | 6:98da0571ec31 | 354 | #define RFM_TX_CONTROL_MOD_165 0x98A0 |
harryeakins | 6:98da0571ec31 | 355 | #define RFM_TX_CONTROL_MOD_180 0x98B0 |
harryeakins | 6:98da0571ec31 | 356 | #define RFM_TX_CONTROL_MOD_195 0x98C0 |
harryeakins | 6:98da0571ec31 | 357 | #define RFM_TX_CONTROL_MOD_210 0x98D0 |
harryeakins | 6:98da0571ec31 | 358 | #define RFM_TX_CONTROL_MOD_225 0x98E0 |
harryeakins | 6:98da0571ec31 | 359 | #define RFM_TX_CONTROL_MOD_240 0x98F0 |
harryeakins | 6:98da0571ec31 | 360 | #define RFM_TX_CONTROL_MP 0x9900 |
harryeakins | 6:98da0571ec31 | 361 | |
harryeakins | 6:98da0571ec31 | 362 | #define RFM_TX_CONTROL_MOD(baud) (((baud)<8000) ? \ |
harryeakins | 6:98da0571ec31 | 363 | RFM_TX_CONTROL_MOD_45 : \ |
harryeakins | 6:98da0571ec31 | 364 | ( \ |
harryeakins | 6:98da0571ec31 | 365 | ((baud)<20000) ? \ |
harryeakins | 6:98da0571ec31 | 366 | RFM_TX_CONTROL_MOD_60 : \ |
harryeakins | 6:98da0571ec31 | 367 | ( \ |
harryeakins | 6:98da0571ec31 | 368 | ((baud)<30000) ? \ |
harryeakins | 6:98da0571ec31 | 369 | RFM_TX_CONTROL_MOD_75 : \ |
harryeakins | 6:98da0571ec31 | 370 | ( \ |
harryeakins | 6:98da0571ec31 | 371 | ((baud)<40000) ? \ |
harryeakins | 6:98da0571ec31 | 372 | RFM_TX_CONTROL_MOD_90 : \ |
harryeakins | 6:98da0571ec31 | 373 | RFM_TX_CONTROL_MOD_120 \ |
harryeakins | 6:98da0571ec31 | 374 | ) \ |
harryeakins | 6:98da0571ec31 | 375 | ) \ |
harryeakins | 6:98da0571ec31 | 376 | )) |
harryeakins | 6:98da0571ec31 | 377 | |
harryeakins | 6:98da0571ec31 | 378 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 379 | // |
harryeakins | 6:98da0571ec31 | 380 | // 11. Transmitter Register Write Command |
harryeakins | 6:98da0571ec31 | 381 | // |
harryeakins | 6:98da0571ec31 | 382 | ///////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 383 | |
harryeakins | 6:98da0571ec31 | 384 | //#define RFM_WRITE(byte) RFM_SPI_16(0xB800 | ((byte) & 0xFF)) |
harryeakins | 6:98da0571ec31 | 385 | #define RFM_WRITE(byte) RFM_SPI_16(0xB800 | (byte) ) |
harryeakins | 6:98da0571ec31 | 386 | |
harryeakins | 6:98da0571ec31 | 387 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 388 | // |
harryeakins | 6:98da0571ec31 | 389 | // 12. Wake-up Timer Command |
harryeakins | 6:98da0571ec31 | 390 | // |
harryeakins | 6:98da0571ec31 | 391 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 392 | |
harryeakins | 6:98da0571ec31 | 393 | #define RFM_WAKEUP_TIMER 0xE000 |
harryeakins | 6:98da0571ec31 | 394 | #define RFM_WAKEUP_SET(time) RFM_SPI_16(RFM_WAKEUP_TIMER | (time)) |
harryeakins | 6:98da0571ec31 | 395 | |
harryeakins | 6:98da0571ec31 | 396 | #define RFM_WAKEUP_480s (RFM_WAKEUP_TIMER |(11 << 8)| 234) |
harryeakins | 6:98da0571ec31 | 397 | #define RFM_WAKEUP_240s (RFM_WAKEUP_TIMER |(10 << 8)| 234) |
harryeakins | 6:98da0571ec31 | 398 | #define RFM_WAKEUP_120s (RFM_WAKEUP_TIMER |(9 << 8)| 234) |
harryeakins | 6:98da0571ec31 | 399 | #define RFM_WAKEUP_119s (RFM_WAKEUP_TIMER |(9 << 8)| 232) |
harryeakins | 6:98da0571ec31 | 400 | |
harryeakins | 6:98da0571ec31 | 401 | #define RFM_WAKEUP_60s (RFM_WAKEUP_TIMER |(8 << 8) | 235) |
harryeakins | 6:98da0571ec31 | 402 | #define RFM_WAKEUP_59s (RFM_WAKEUP_TIMER |(8 << 8) | 230) |
harryeakins | 6:98da0571ec31 | 403 | |
harryeakins | 6:98da0571ec31 | 404 | #define RFM_WAKEUP_30s (RFM_WAKEUP_TIMER |(7 << 8) | 235) |
harryeakins | 6:98da0571ec31 | 405 | #define RFM_WAKEUP_29s (RFM_WAKEUP_TIMER |(7 << 8) | 227) |
harryeakins | 6:98da0571ec31 | 406 | |
harryeakins | 6:98da0571ec31 | 407 | #define RFM_WAKEUP_8s (RFM_WAKEUP_TIMER |(5 << 8) | 250) |
harryeakins | 6:98da0571ec31 | 408 | #define RFM_WAKEUP_7s (RFM_WAKEUP_TIMER |(5 << 8) | 219) |
harryeakins | 6:98da0571ec31 | 409 | #define RFM_WAKEUP_6s (RFM_WAKEUP_TIMER |(6 << 8) | 94) |
harryeakins | 6:98da0571ec31 | 410 | #define RFM_WAKEUP_5s (RFM_WAKEUP_TIMER |(5 << 8) | 156) |
harryeakins | 6:98da0571ec31 | 411 | #define RFM_WAKEUP_4s (RFM_WAKEUP_TIMER |(5 << 8) | 125) |
harryeakins | 6:98da0571ec31 | 412 | #define RFM_WAKEUP_1s (RFM_WAKEUP_TIMER |(2 << 8) | 250) |
harryeakins | 6:98da0571ec31 | 413 | #define RFM_WAKEUP_900ms (RFM_WAKEUP_TIMER |(2 << 8) | 225) |
harryeakins | 6:98da0571ec31 | 414 | #define RFM_WAKEUP_800ms (RFM_WAKEUP_TIMER |(2 << 8) | 200) |
harryeakins | 6:98da0571ec31 | 415 | #define RFM_WAKEUP_700ms (RFM_WAKEUP_TIMER |(2 << 8) | 175) |
harryeakins | 6:98da0571ec31 | 416 | #define RFM_WAKEUP_600ms (RFM_WAKEUP_TIMER |(2 << 8) | 150) |
harryeakins | 6:98da0571ec31 | 417 | #define RFM_WAKEUP_500ms (RFM_WAKEUP_TIMER |(2 << 8) | 125) |
harryeakins | 6:98da0571ec31 | 418 | #define RFM_WAKEUP_400ms (RFM_WAKEUP_TIMER |(2 << 8) | 100) |
harryeakins | 6:98da0571ec31 | 419 | #define RFM_WAKEUP_300ms (RFM_WAKEUP_TIMER |(2 << 8) | 75) |
harryeakins | 6:98da0571ec31 | 420 | #define RFM_WAKEUP_200ms (RFM_WAKEUP_TIMER |(2 << 8) | 50) |
harryeakins | 6:98da0571ec31 | 421 | #define RFM_WAKEUP_100ms (RFM_WAKEUP_TIMER |(2 << 8) | 25) |
harryeakins | 6:98da0571ec31 | 422 | |
harryeakins | 6:98da0571ec31 | 423 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 424 | // |
harryeakins | 6:98da0571ec31 | 425 | // 13. Low Duty-Cycle Command |
harryeakins | 6:98da0571ec31 | 426 | // |
harryeakins | 6:98da0571ec31 | 427 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 428 | |
harryeakins | 6:98da0571ec31 | 429 | #define RFM_LOW_DUTY_CYCLE 0xC800 |
harryeakins | 6:98da0571ec31 | 430 | |
harryeakins | 6:98da0571ec31 | 431 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 432 | // |
harryeakins | 6:98da0571ec31 | 433 | // 14. Low Battery Detector Command |
harryeakins | 6:98da0571ec31 | 434 | // |
harryeakins | 6:98da0571ec31 | 435 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 436 | |
harryeakins | 6:98da0571ec31 | 437 | #define RFM_LOW_BATT_DETECT 0xC000 |
harryeakins | 6:98da0571ec31 | 438 | #define RFM_LOW_BATT_DETECT_D_1MHZ 0xC000 |
harryeakins | 6:98da0571ec31 | 439 | #define RFM_LOW_BATT_DETECT_D_1_25MHZ 0xC020 |
harryeakins | 6:98da0571ec31 | 440 | #define RFM_LOW_BATT_DETECT_D_1_66MHZ 0xC040 |
harryeakins | 6:98da0571ec31 | 441 | #define RFM_LOW_BATT_DETECT_D_2MHZ 0xC060 |
harryeakins | 6:98da0571ec31 | 442 | #define RFM_LOW_BATT_DETECT_D_2_5MHZ 0xC080 |
harryeakins | 6:98da0571ec31 | 443 | #define RFM_LOW_BATT_DETECT_D_3_33MHZ 0xC0A0 |
harryeakins | 6:98da0571ec31 | 444 | #define RFM_LOW_BATT_DETECT_D_5MHZ 0xC0C0 |
harryeakins | 6:98da0571ec31 | 445 | #define RFM_LOW_BATT_DETECT_D_10MHZ 0xC0E0 |
harryeakins | 6:98da0571ec31 | 446 | |
harryeakins | 6:98da0571ec31 | 447 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 448 | // |
harryeakins | 6:98da0571ec31 | 449 | // 15. Status Read Command |
harryeakins | 6:98da0571ec31 | 450 | // |
harryeakins | 6:98da0571ec31 | 451 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 452 | |
harryeakins | 6:98da0571ec31 | 453 | #define RFM_READ_STATUS() RFM_SPI_16(0x0000) |
harryeakins | 6:98da0571ec31 | 454 | #define RFM_READ_STATUS_FFIT() SPI_1 (0x00) |
harryeakins | 6:98da0571ec31 | 455 | #define RFM_READ_STATUS_RGIT RFM_READ_STATUS_FFIT |
harryeakins | 6:98da0571ec31 | 456 | |
harryeakins | 6:98da0571ec31 | 457 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 458 | |
harryeakins | 6:98da0571ec31 | 459 | // RFM air protocol flags: |
harryeakins | 6:98da0571ec31 | 460 | |
harryeakins | 6:98da0571ec31 | 461 | #define RFMPROTO_FLAGS_BITASK_PACKETTYPE 0b11000000 //!< the uppermost 2 bits of the flags field encode the packettype |
harryeakins | 6:98da0571ec31 | 462 | #define RFMPROTO_FLAGS_PACKETTYPE_BROADCAST 0b00000000 //!< broadcast packettype (message from hr20, protocol; step 1) |
harryeakins | 6:98da0571ec31 | 463 | #define RFMPROTO_FLAGS_PACKETTYPE_COMMAND 0b01000000 //!< command packettype (message to hr20, protocol; step 2) |
harryeakins | 6:98da0571ec31 | 464 | #define RFMPROTO_FLAGS_PACKETTYPE_REPLY 0b10000000 //!< reply packettype (message from hr20, protocol; step 3) |
harryeakins | 6:98da0571ec31 | 465 | #define RFMPROTO_FLAGS_PACKETTYPE_SPECIAL 0b11000000 //!< currently unused packettype |
harryeakins | 6:98da0571ec31 | 466 | |
harryeakins | 6:98da0571ec31 | 467 | #define RFMPROTO_FLAGS_BITASK_DEVICETYPE 0b00011111 //!< the lowermost 5 bytes denote the device type. this way other sensors and actors may coexist |
harryeakins | 6:98da0571ec31 | 468 | #define RFMPROTO_FLAGS_DEVICETYPE_OPENHR20 0b00010100 //!< topen HR20 device type. 10100 is for decimal 20 |
harryeakins | 6:98da0571ec31 | 469 | |
harryeakins | 6:98da0571ec31 | 470 | #define RFMPROTO_IS_PACKETTYPE_BROADCAST(FLAGS) ( RFMPROTO_FLAGS_PACKETTYPE_BROADCAST == ((FLAGS) & RFMPROTO_FLAGS_BITASK_PACKETTYPE) ) |
harryeakins | 6:98da0571ec31 | 471 | #define RFMPROTO_IS_PACKETTYPE_COMMAND(FLAGS) ( RFMPROTO_FLAGS_PACKETTYPE_COMMAND == ((FLAGS) & RFMPROTO_FLAGS_BITASK_PACKETTYPE) ) |
harryeakins | 6:98da0571ec31 | 472 | #define RFMPROTO_IS_PACKETTYPE_REPLY(FLAGS) ( RFMPROTO_FLAGS_PACKETTYPE_REPLY == ((FLAGS) & RFMPROTO_FLAGS_BITASK_PACKETTYPE) ) |
harryeakins | 6:98da0571ec31 | 473 | #define RFMPROTO_IS_PACKETTYPE_SPECIAL(FLAGS) ( RFMPROTO_FLAGS_PACKETTYPE_SPECIAL == ((FLAGS) & RFMPROTO_FLAGS_BITASK_PACKETTYPE) ) |
harryeakins | 6:98da0571ec31 | 474 | #define RFMPROTO_IS_DEVICETYPE_OPENHR20(FLAGS) ( RFMPROTO_FLAGS_DEVICETYPE_OPENHR20 == ((FLAGS) & RFMPROTO_FLAGS_BITASK_DEVICETYPE) ) |
harryeakins | 6:98da0571ec31 | 475 | |
harryeakins | 6:98da0571ec31 | 476 | /////////////////////////////////////////////////////////////////////////////// |
harryeakins | 6:98da0571ec31 | 477 | |
harryeakins | 6:98da0571ec31 | 478 | #endif |