![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Handheld controller (RF) for Pi Swarm system
Fork of Pi_Swarm_Handheld_Controller by
alpha433.h@0:d63a63feb104, 2014-06-10 (annotated)
- Committer:
- jah128
- Date:
- Tue Jun 10 11:05:23 2014 +0000
- Revision:
- 0:d63a63feb104
Handheld controller for Pi Swarm (old code)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:d63a63feb104 | 1 | /* University of York Robot Lab m3pi Library: 433MHz Alpha Transceiver |
jah128 | 0:d63a63feb104 | 2 | * |
jah128 | 0:d63a63feb104 | 3 | * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York |
jah128 | 0:d63a63feb104 | 4 | * |
jah128 | 0:d63a63feb104 | 5 | * October 2013 |
jah128 | 0:d63a63feb104 | 6 | * |
jah128 | 0:d63a63feb104 | 7 | * Designed for use with the enhanced MBED sensor board |
jah128 | 0:d63a63feb104 | 8 | * |
jah128 | 0:d63a63feb104 | 9 | * Based on code developed by Tobias Dipper, University of Stuttgart |
jah128 | 0:d63a63feb104 | 10 | * |
jah128 | 0:d63a63feb104 | 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
jah128 | 0:d63a63feb104 | 12 | * of this software and associated documentation files (the "Software"), to deal |
jah128 | 0:d63a63feb104 | 13 | * in the Software without restriction, including without limitation the rights |
jah128 | 0:d63a63feb104 | 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
jah128 | 0:d63a63feb104 | 15 | * copies of the Software, and to permit persons to whom the Software is |
jah128 | 0:d63a63feb104 | 16 | * furnished to do so, subject to the following conditions: |
jah128 | 0:d63a63feb104 | 17 | * |
jah128 | 0:d63a63feb104 | 18 | * The above copyright notice and this permission notice shall be included in |
jah128 | 0:d63a63feb104 | 19 | * all copies or substantial portions of the Software. |
jah128 | 0:d63a63feb104 | 20 | * |
jah128 | 0:d63a63feb104 | 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
jah128 | 0:d63a63feb104 | 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
jah128 | 0:d63a63feb104 | 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
jah128 | 0:d63a63feb104 | 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
jah128 | 0:d63a63feb104 | 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jah128 | 0:d63a63feb104 | 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
jah128 | 0:d63a63feb104 | 27 | * THE SOFTWARE. |
jah128 | 0:d63a63feb104 | 28 | */ |
jah128 | 0:d63a63feb104 | 29 | |
jah128 | 0:d63a63feb104 | 30 | #ifndef ALPHA433_H |
jah128 | 0:d63a63feb104 | 31 | #define ALPHA433_H |
jah128 | 0:d63a63feb104 | 32 | |
jah128 | 0:d63a63feb104 | 33 | |
jah128 | 0:d63a63feb104 | 34 | // |
jah128 | 0:d63a63feb104 | 35 | // Defines |
jah128 | 0:d63a63feb104 | 36 | // |
jah128 | 0:d63a63feb104 | 37 | #define ALPHA433_FREQUENCY_315 0x0000 |
jah128 | 0:d63a63feb104 | 38 | #define ALPHA433_FREQUENCY_433 0x0010 |
jah128 | 0:d63a63feb104 | 39 | #define ALPHA433_FREQUENCY_868 0x0020 |
jah128 | 0:d63a63feb104 | 40 | #define ALPHA433_FREQUENCY_915 0x0030 |
jah128 | 0:d63a63feb104 | 41 | #define ALPHA433_CRYSTAL_LOAD_85 0x0000 |
jah128 | 0:d63a63feb104 | 42 | #define ALPHA433_CRYSTAL_LOAD_90 0x0001 |
jah128 | 0:d63a63feb104 | 43 | #define ALPHA433_CRYSTAL_LOAD_95 0x0002 |
jah128 | 0:d63a63feb104 | 44 | #define ALPHA433_CRYSTAL_LOAD_100 0x0003 |
jah128 | 0:d63a63feb104 | 45 | #define ALPHA433_CRYSTAL_LOAD_105 0x0004 |
jah128 | 0:d63a63feb104 | 46 | #define ALPHA433_CRYSTAL_LOAD_110 0x0005 |
jah128 | 0:d63a63feb104 | 47 | #define ALPHA433_CRYSTAL_LOAD_115 0x0006 |
jah128 | 0:d63a63feb104 | 48 | #define ALPHA433_CRYSTAL_LOAD_120 0x0007 |
jah128 | 0:d63a63feb104 | 49 | #define ALPHA433_CRYSTAL_LOAD_125 0x0008 |
jah128 | 0:d63a63feb104 | 50 | #define ALPHA433_CRYSTAL_LOAD_130 0x0009 |
jah128 | 0:d63a63feb104 | 51 | #define ALPHA433_CRYSTAL_LOAD_135 0x000A |
jah128 | 0:d63a63feb104 | 52 | #define ALPHA433_CRYSTAL_LOAD_140 0x000B |
jah128 | 0:d63a63feb104 | 53 | #define ALPHA433_CRYSTAL_LOAD_145 0x000C |
jah128 | 0:d63a63feb104 | 54 | #define ALPHA433_CRYSTAL_LOAD_150 0x000D |
jah128 | 0:d63a63feb104 | 55 | #define ALPHA433_CRYSTAL_LOAD_155 0x000E |
jah128 | 0:d63a63feb104 | 56 | #define ALPHA433_CRYSTAL_LOAD_160 0x000F |
jah128 | 0:d63a63feb104 | 57 | #define ALPHA433_USE_FIFO_YES 0x00C0 |
jah128 | 0:d63a63feb104 | 58 | #define ALPHA433_USE_FIFO_NO 0x0000 |
jah128 | 0:d63a63feb104 | 59 | #define ALPHA433_PIN20_INTERRUPT_IN 0x0000 |
jah128 | 0:d63a63feb104 | 60 | #define ALPHA433_PIN20_VDI_OUT 0x0400 |
jah128 | 0:d63a63feb104 | 61 | #define ALPHA433_VDI_RESPONSE_FAST 0x0000 |
jah128 | 0:d63a63feb104 | 62 | #define ALPHA433_VDI_RESPONSE_MEDIUM 0x0100 |
jah128 | 0:d63a63feb104 | 63 | #define ALPHA433_VDI_RESPONSE_SLOW 0x0200 |
jah128 | 0:d63a63feb104 | 64 | #define ALPHA433_VDI_RESPONSE_ALWAYS 0x0300 |
jah128 | 0:d63a63feb104 | 65 | #define ALPHA433_BANDWIDTH_400 0x0020 |
jah128 | 0:d63a63feb104 | 66 | #define ALPHA433_BANDWIDTH_340 0x0040 |
jah128 | 0:d63a63feb104 | 67 | #define ALPHA433_BANDWIDTH_270 0x0060 |
jah128 | 0:d63a63feb104 | 68 | #define ALPHA433_BANDWIDTH_200 0x0080 |
jah128 | 0:d63a63feb104 | 69 | #define ALPHA433_BANDWIDTH_134 0x00A0 |
jah128 | 0:d63a63feb104 | 70 | #define ALPHA433_BANDWIDTH_67 0x00C0 |
jah128 | 0:d63a63feb104 | 71 | #define ALPHA433_LNA_GAIN_0 0x0000 |
jah128 | 0:d63a63feb104 | 72 | #define ALPHA433_LNA_GAIN_6 0x0080 |
jah128 | 0:d63a63feb104 | 73 | #define ALPHA433_LNA_GAIN_14 0x0100 |
jah128 | 0:d63a63feb104 | 74 | #define ALPHA433_LNA_GAIN_20 0x0180 |
jah128 | 0:d63a63feb104 | 75 | #define ALPHA433_RSSI_103 0x0000 |
jah128 | 0:d63a63feb104 | 76 | #define ALPHA433_RSSI_97 0x0001 |
jah128 | 0:d63a63feb104 | 77 | #define ALPHA433_RSSI_91 0x0002 |
jah128 | 0:d63a63feb104 | 78 | #define ALPHA433_RSSI_85 0x0003 |
jah128 | 0:d63a63feb104 | 79 | #define ALPHA433_RSSI_79 0x0004 |
jah128 | 0:d63a63feb104 | 80 | #define ALPHA433_RSSI_73 0x0005 |
jah128 | 0:d63a63feb104 | 81 | #define ALPHA433_RSSI_67 0x0006 |
jah128 | 0:d63a63feb104 | 82 | #define ALPHA433_RSSI_61 0x0007 |
jah128 | 0:d63a63feb104 | 83 | #define ALPHA433_CLOCK_RECOVERY_AUTO 0x0080 |
jah128 | 0:d63a63feb104 | 84 | #define ALPHA433_CLOCK_RECOVERY_FAST 0x0040 |
jah128 | 0:d63a63feb104 | 85 | #define ALPHA433_CLOCK_RECOVERY_SLOW 0x0000 |
jah128 | 0:d63a63feb104 | 86 | #define ALPHA433_FILTER_DIGITAL 0x0000 |
jah128 | 0:d63a63feb104 | 87 | #define ALPHA433_FILTER_ANALOG 0x0010 |
jah128 | 0:d63a63feb104 | 88 | #define ALPHA433_DQD_0 0x0000 |
jah128 | 0:d63a63feb104 | 89 | #define ALPHA433_DQD_1 0x0001 |
jah128 | 0:d63a63feb104 | 90 | #define ALPHA433_DQD_2 0x0002 |
jah128 | 0:d63a63feb104 | 91 | #define ALPHA433_DQD_3 0x0003 |
jah128 | 0:d63a63feb104 | 92 | #define ALPHA433_DQD_4 0x0004 |
jah128 | 0:d63a63feb104 | 93 | #define ALPHA433_DQD_5 0x0005 |
jah128 | 0:d63a63feb104 | 94 | #define ALPHA433_DQD_6 0x0006 |
jah128 | 0:d63a63feb104 | 95 | #define ALPHA433_DQD_7 0x0007 |
jah128 | 0:d63a63feb104 | 96 | #define ALPHA433_FIFO_LEVEL_0 0x0000 |
jah128 | 0:d63a63feb104 | 97 | #define ALPHA433_FIFO_LEVEL_1 0x0010 |
jah128 | 0:d63a63feb104 | 98 | #define ALPHA433_FIFO_LEVEL_2 0x0020 |
jah128 | 0:d63a63feb104 | 99 | #define ALPHA433_FIFO_LEVEL_3 0x0030 |
jah128 | 0:d63a63feb104 | 100 | #define ALPHA433_FIFO_LEVEL_4 0x0040 |
jah128 | 0:d63a63feb104 | 101 | #define ALPHA433_FIFO_LEVEL_5 0x0050 |
jah128 | 0:d63a63feb104 | 102 | #define ALPHA433_FIFO_LEVEL_6 0x0060 |
jah128 | 0:d63a63feb104 | 103 | #define ALPHA433_FIFO_LEVEL_7 0x0070 |
jah128 | 0:d63a63feb104 | 104 | #define ALPHA433_FIFO_LEVEL_8 0x0080 |
jah128 | 0:d63a63feb104 | 105 | #define ALPHA433_FIFO_LEVEL_9 0x0090 |
jah128 | 0:d63a63feb104 | 106 | #define ALPHA433_FIFO_LEVEL_10 0x00A0 |
jah128 | 0:d63a63feb104 | 107 | #define ALPHA433_FIFO_LEVEL_11 0x00B0 |
jah128 | 0:d63a63feb104 | 108 | #define ALPHA433_FIFO_LEVEL_12 0x00C0 |
jah128 | 0:d63a63feb104 | 109 | #define ALPHA433_FIFO_LEVEL_13 0x00D0 |
jah128 | 0:d63a63feb104 | 110 | #define ALPHA433_FIFO_LEVEL_14 0x00E0 |
jah128 | 0:d63a63feb104 | 111 | #define ALPHA433_FIFO_LEVEL_15 0x00F0 |
jah128 | 0:d63a63feb104 | 112 | #define ALPHA433_FIFO_FILL_PATTERN 0x0000 |
jah128 | 0:d63a63feb104 | 113 | #define ALPHA433_FIFO_FILL_ALWAYS 0x0004 |
jah128 | 0:d63a63feb104 | 114 | #define ALPHA433_HI_SENS_RESET_ENABLE 0x0000 |
jah128 | 0:d63a63feb104 | 115 | #define ALPHA433_HI_SENS_RESET_DISABLE 0x0001 |
jah128 | 0:d63a63feb104 | 116 | #define ALPHA433_AFC_MODE_NOAUTO 0x0000 |
jah128 | 0:d63a63feb104 | 117 | #define ALPHA433_AFC_MODE_ONCE 0x0040 |
jah128 | 0:d63a63feb104 | 118 | #define ALPHA433_AFC_MODE_VDI 0x0080 |
jah128 | 0:d63a63feb104 | 119 | #define ALPHA433_AFC_MODE_INDEPENDENT 0x00C0 |
jah128 | 0:d63a63feb104 | 120 | #define ALPHA433_AFC_RANGE_3TO4 0x0030 |
jah128 | 0:d63a63feb104 | 121 | #define ALPHA433_AFC_RANGE_7TO8 0x0020 |
jah128 | 0:d63a63feb104 | 122 | #define ALPHA433_AFC_RANGE_15TO16 0x0010 |
jah128 | 0:d63a63feb104 | 123 | #define ALPHA433_AFC_RANGE_NO_RES 0x0000 |
jah128 | 0:d63a63feb104 | 124 | #define ALPHA433_AFC_FINE_ENABLE 0x0004 |
jah128 | 0:d63a63feb104 | 125 | #define ALPHA433_AFC_FINE_DISABLE 0x0000 |
jah128 | 0:d63a63feb104 | 126 | #define ALPHA433_AFC_ENABLE 0x0003 |
jah128 | 0:d63a63feb104 | 127 | #define ALPHA433_AFC_DISABLE 0x0000 |
jah128 | 0:d63a63feb104 | 128 | #define ALPHA433_MOD_POLARITY_P 0x0000 |
jah128 | 0:d63a63feb104 | 129 | #define ALPHA433_MOD_POLARITY_N 0x0100 |
jah128 | 0:d63a63feb104 | 130 | #define ALPHA433_MOD_FREQUENCY_15 0x0000 |
jah128 | 0:d63a63feb104 | 131 | #define ALPHA433_MOD_FREQUENCY_30 0x0010 |
jah128 | 0:d63a63feb104 | 132 | #define ALPHA433_MOD_FREQUENCY_45 0x0020 |
jah128 | 0:d63a63feb104 | 133 | #define ALPHA433_MOD_FREQUENCY_60 0x0030 |
jah128 | 0:d63a63feb104 | 134 | #define ALPHA433_MOD_FREQUENCY_75 0x0040 |
jah128 | 0:d63a63feb104 | 135 | #define ALPHA433_MOD_FREQUENCY_90 0x0050 |
jah128 | 0:d63a63feb104 | 136 | #define ALPHA433_MOD_FREQUENCY_105 0x0060 |
jah128 | 0:d63a63feb104 | 137 | #define ALPHA433_MOD_FREQUENCY_120 0x0070 |
jah128 | 0:d63a63feb104 | 138 | #define ALPHA433_MOD_FREQUENCY_135 0x0080 |
jah128 | 0:d63a63feb104 | 139 | #define ALPHA433_MOD_FREQUENCY_150 0x0090 |
jah128 | 0:d63a63feb104 | 140 | #define ALPHA433_MOD_FREQUENCY_165 0x00A0 |
jah128 | 0:d63a63feb104 | 141 | #define ALPHA433_MOD_FREQUENCY_180 0x00B0 |
jah128 | 0:d63a63feb104 | 142 | #define ALPHA433_MOD_FREQUENCY_195 0x00C0 |
jah128 | 0:d63a63feb104 | 143 | #define ALPHA433_MOD_FREQUENCY_210 0x00D0 |
jah128 | 0:d63a63feb104 | 144 | #define ALPHA433_MOD_FREQUENCY_225 0x00E0 |
jah128 | 0:d63a63feb104 | 145 | #define ALPHA433_MOD_FREQUENCY_240 0x00F0 |
jah128 | 0:d63a63feb104 | 146 | #define ALPHA433_TX_POWER_0 0x0000 |
jah128 | 0:d63a63feb104 | 147 | #define ALPHA433_TX_POWER_3 0x0001 |
jah128 | 0:d63a63feb104 | 148 | #define ALPHA433_TX_POWER_6 0x0002 |
jah128 | 0:d63a63feb104 | 149 | #define ALPHA433_TX_POWER_9 0x0003 |
jah128 | 0:d63a63feb104 | 150 | #define ALPHA433_TX_POWER_12 0x0004 |
jah128 | 0:d63a63feb104 | 151 | #define ALPHA433_TX_POWER_15 0x0005 |
jah128 | 0:d63a63feb104 | 152 | #define ALPHA433_TX_POWER_18 0x0006 |
jah128 | 0:d63a63feb104 | 153 | #define ALPHA433_TX_POWER_21 0x0007 |
jah128 | 0:d63a63feb104 | 154 | #define ALPHA433_CLK_OUT_1 0x0000 |
jah128 | 0:d63a63feb104 | 155 | #define ALPHA433_CLK_OUT_125 0x0020 |
jah128 | 0:d63a63feb104 | 156 | #define ALPHA433_CLK_OUT_166 0x0040 |
jah128 | 0:d63a63feb104 | 157 | #define ALPHA433_CLK_OUT_2 0x0060 |
jah128 | 0:d63a63feb104 | 158 | #define ALPHA433_CLK_OUT_25 0x0080 |
jah128 | 0:d63a63feb104 | 159 | #define ALPHA433_CLK_OUT_333 0x00A0 |
jah128 | 0:d63a63feb104 | 160 | #define ALPHA433_CLK_OUT_5 0x00C0 |
jah128 | 0:d63a63feb104 | 161 | #define ALPHA433_CLK_OUT_10 0x00E0 |
jah128 | 0:d63a63feb104 | 162 | #define ALPHA433_LOW_BAT22 0x0000 |
jah128 | 0:d63a63feb104 | 163 | #define ALPHA433_STATUS_TX_NEXT_BYTE 0x8000 |
jah128 | 0:d63a63feb104 | 164 | #define ALPHA433_STATUS_FIFO_LIMIT_REACHED 0x8000 |
jah128 | 0:d63a63feb104 | 165 | #define ALPHA433_STATUS_POWER_ON_RESET 0x4000 |
jah128 | 0:d63a63feb104 | 166 | #define ALPHA433_STATUS_RX_OVERFLOW 0x2000 |
jah128 | 0:d63a63feb104 | 167 | #define ALPHA433_STATUS_TX_UNDERRUN 0x2000 |
jah128 | 0:d63a63feb104 | 168 | #define ALPHA433_STATUS_WAKEUP 0x1000 |
jah128 | 0:d63a63feb104 | 169 | #define ALPHA433_STATUS_EXT 0x0800 |
jah128 | 0:d63a63feb104 | 170 | #define ALPHA433_STATUS_LOW_BATTERY 0x0400 |
jah128 | 0:d63a63feb104 | 171 | #define ALPHA433_STATUS_FIFO_EMPTY 0x0200 |
jah128 | 0:d63a63feb104 | 172 | #define ALPHA433_STATUS_STRONG_SIGNAL 0x0100 |
jah128 | 0:d63a63feb104 | 173 | #define ALPHA433_STATUS_RSSI 0x0100 |
jah128 | 0:d63a63feb104 | 174 | #define ALPHA433_STATUS_DQD 0x0080 |
jah128 | 0:d63a63feb104 | 175 | #define ALPHA433_STATUS_CLOCK_LOCKED 0x0040 |
jah128 | 0:d63a63feb104 | 176 | #define ALPHA433_TRANSMIT_OK 0 |
jah128 | 0:d63a63feb104 | 177 | #define ALPHA433_TRANSMIT_TIMEOUT 1 |
jah128 | 0:d63a63feb104 | 178 | #define ALPHA433_TRANSMIT_PARITY_ERROR 2 |
jah128 | 0:d63a63feb104 | 179 | #define ALPHA433_RECEIVE_OK 0 |
jah128 | 0:d63a63feb104 | 180 | #define ALPHA433_RECEIVE_TIMEOUT 1 |
jah128 | 0:d63a63feb104 | 181 | #define ALPHA433_RECEIVE_PARITY_ERROR 2 |
jah128 | 0:d63a63feb104 | 182 | #define ALPHA433_NODATA 0 |
jah128 | 0:d63a63feb104 | 183 | #define ALPHA433_DATA_AVAIABLE 1 |
jah128 | 0:d63a63feb104 | 184 | #define ALPHA433_MODE_TRANSMITTING 1 |
jah128 | 0:d63a63feb104 | 185 | #define ALPHA433_MODE_RECEIVING 2 |
jah128 | 0:d63a63feb104 | 186 | #define ALPHA433_MODE_SWITCHING 0 |
jah128 | 0:d63a63feb104 | 187 | |
jah128 | 0:d63a63feb104 | 188 | // ----------------------------- default user configuration -------------------------------- |
jah128 | 0:d63a63feb104 | 189 | |
jah128 | 0:d63a63feb104 | 190 | #define ALPHA433_FREQUENCY ALPHA433_FREQUENCY_433 |
jah128 | 0:d63a63feb104 | 191 | #define ALPHA433_CRYSTAL_LOAD ALPHA433_CRYSTAL_LOAD_100 |
jah128 | 0:d63a63feb104 | 192 | #define ALPHA433_USE_FIFO ALPHA433_USE_FIFO_YES |
jah128 | 0:d63a63feb104 | 193 | #define ALPHA433_PIN20 ALPHA433_PIN20_INTERRUPT_IN |
jah128 | 0:d63a63feb104 | 194 | #define ALPHA433_VDI_RESPONSE ALPHA433_VDI_RESPONSE_SLOW |
jah128 | 0:d63a63feb104 | 195 | #define ALPHA433_BANDWIDTH ALPHA433_BANDWIDTH_134 |
jah128 | 0:d63a63feb104 | 196 | #define ALPHA433_LNA_GAIN ALPHA433_LNA_GAIN_0 |
jah128 | 0:d63a63feb104 | 197 | #define ALPHA433_RSSI ALPHA433_RSSI_97 |
jah128 | 0:d63a63feb104 | 198 | #define ALPHA433_CLOCK_RECOVERY ALPHA433_CLOCK_RECOVERY_SLOW |
jah128 | 0:d63a63feb104 | 199 | #define ALPHA433_FILTER ALPHA433_FILTER_DIGITAL |
jah128 | 0:d63a63feb104 | 200 | #define ALPHA433_DQD ALPHA433_DQD_4 |
jah128 | 0:d63a63feb104 | 201 | #define ALPHA433_FIFO_LEVEL ALPHA433_FIFO_LEVEL_8 |
jah128 | 0:d63a63feb104 | 202 | #define ALPHA433_FIFO_FILL ALPHA433_FIFO_FILL_PATTERN |
jah128 | 0:d63a63feb104 | 203 | #define ALPHA433_HI_SENS_RESET ALPHA433_HI_SENS_RESET_DISABLE |
jah128 | 0:d63a63feb104 | 204 | #define ALPHA433_AFC_MODE ALPHA433_AFC_MODE_INDEPENDENT |
jah128 | 0:d63a63feb104 | 205 | #define ALPHA433_AFC_RANGE ALPHA433_AFC_RANGE_3TO4 |
jah128 | 0:d63a63feb104 | 206 | #define ALPHA433_AFC_FINE_MODE ALPHA433_AFC_FINE_DISABLE |
jah128 | 0:d63a63feb104 | 207 | #define ALPHA433_AFC ALPHA433_AFC_DISABLE |
jah128 | 0:d63a63feb104 | 208 | #define ALPHA433_MOD_POLARITY ALPHA433_MOD_POLARITY_P |
jah128 | 0:d63a63feb104 | 209 | #define ALPHA433_MOD_FREQUENCY ALPHA433_MOD_FREQUENCY_90 |
jah128 | 0:d63a63feb104 | 210 | #define ALPHA433_TX_POWER ALPHA433_TX_POWER_0 |
jah128 | 0:d63a63feb104 | 211 | #define ALPHA433_CLK_OUT ALPHA433_CLK_OUT_2 |
jah128 | 0:d63a63feb104 | 212 | #define ALPHA433_LOW_BAT ALPHA433_LOW_BAT22 |
jah128 | 0:d63a63feb104 | 213 | #define ALPHA433_TIMEOUT 100 |
jah128 | 0:d63a63feb104 | 214 | #define TIMEOUT 5.0 |
jah128 | 0:d63a63feb104 | 215 | |
jah128 | 0:d63a63feb104 | 216 | class Alpha433 : public Stream { |
jah128 | 0:d63a63feb104 | 217 | |
jah128 | 0:d63a63feb104 | 218 | // Public Functions |
jah128 | 0:d63a63feb104 | 219 | |
jah128 | 0:d63a63feb104 | 220 | public: |
jah128 | 0:d63a63feb104 | 221 | |
jah128 | 0:d63a63feb104 | 222 | /** Create the alpha433 object connected to the default pins |
jah128 | 0:d63a63feb104 | 223 | * |
jah128 | 0:d63a63feb104 | 224 | * @param mosi pin - default is p5 |
jah128 | 0:d63a63feb104 | 225 | * @param miso pin - default is p6 |
jah128 | 0:d63a63feb104 | 226 | * @param sck pin - default is p7 |
jah128 | 0:d63a63feb104 | 227 | * @param fss pin - default is p8 |
jah128 | 0:d63a63feb104 | 228 | * @param nirq pin - default is p11 |
jah128 | 0:d63a63feb104 | 229 | */ |
jah128 | 0:d63a63feb104 | 230 | Alpha433(); |
jah128 | 0:d63a63feb104 | 231 | |
jah128 | 0:d63a63feb104 | 232 | /** Create the alpha433 object connected to specific pins |
jah128 | 0:d63a63feb104 | 233 | * |
jah128 | 0:d63a63feb104 | 234 | */ |
jah128 | 0:d63a63feb104 | 235 | Alpha433(PinName mosi, PinName miso, PinName sck, PinName fss, PinName nirq); |
jah128 | 0:d63a63feb104 | 236 | |
jah128 | 0:d63a63feb104 | 237 | |
jah128 | 0:d63a63feb104 | 238 | // Send a string to the RF transmitter |
jah128 | 0:d63a63feb104 | 239 | unsigned long sendString(char cCount, char* cBuffer); |
jah128 | 0:d63a63feb104 | 240 | |
jah128 | 0:d63a63feb104 | 241 | // Enable RF Transmitter |
jah128 | 0:d63a63feb104 | 242 | void enableTransmitter(void); |
jah128 | 0:d63a63feb104 | 243 | |
jah128 | 0:d63a63feb104 | 244 | // Disable RF Transmitter |
jah128 | 0:d63a63feb104 | 245 | void disableTransmitter(void); |
jah128 | 0:d63a63feb104 | 246 | |
jah128 | 0:d63a63feb104 | 247 | // Enable RF Receiver |
jah128 | 0:d63a63feb104 | 248 | void enableReceiver(void); |
jah128 | 0:d63a63feb104 | 249 | |
jah128 | 0:d63a63feb104 | 250 | // Disable RF Receiver |
jah128 | 0:d63a63feb104 | 251 | void disableReceiver(void); |
jah128 | 0:d63a63feb104 | 252 | |
jah128 | 0:d63a63feb104 | 253 | // SSI FiFo Clear |
jah128 | 0:d63a63feb104 | 254 | void clearBuffer(void); |
jah128 | 0:d63a63feb104 | 255 | |
jah128 | 0:d63a63feb104 | 256 | // Reset RF |
jah128 | 0:d63a63feb104 | 257 | void rf_reset(void); |
jah128 | 0:d63a63feb104 | 258 | |
jah128 | 0:d63a63feb104 | 259 | // Initialise RF |
jah128 | 0:d63a63feb104 | 260 | void rf_init(void); |
jah128 | 0:d63a63feb104 | 261 | |
jah128 | 0:d63a63feb104 | 262 | // RF Interrupt |
jah128 | 0:d63a63feb104 | 263 | void interrupt(void); |
jah128 | 0:d63a63feb104 | 264 | |
jah128 | 0:d63a63feb104 | 265 | // RF Set Datarate |
jah128 | 0:d63a63feb104 | 266 | void setDatarate(unsigned long ulValue); |
jah128 | 0:d63a63feb104 | 267 | |
jah128 | 0:d63a63feb104 | 268 | // RF Set Frequency |
jah128 | 0:d63a63feb104 | 269 | void setFrequency(unsigned long ulValue); |
jah128 | 0:d63a63feb104 | 270 | |
jah128 | 0:d63a63feb104 | 271 | // Enable RF Receiver FiFo fill |
jah128 | 0:d63a63feb104 | 272 | void enableFifoFill(void); |
jah128 | 0:d63a63feb104 | 273 | |
jah128 | 0:d63a63feb104 | 274 | // Disable RF Receiver FiFo fill |
jah128 | 0:d63a63feb104 | 275 | void disableFifoFill(void); |
jah128 | 0:d63a63feb104 | 276 | |
jah128 | 0:d63a63feb104 | 277 | // Handle new RF Data |
jah128 | 0:d63a63feb104 | 278 | void dataAvailable(char cCount, char* cBuffer); |
jah128 | 0:d63a63feb104 | 279 | |
jah128 | 0:d63a63feb104 | 280 | // Read status byte |
jah128 | 0:d63a63feb104 | 281 | int readStatusByte(); |
jah128 | 0:d63a63feb104 | 282 | |
jah128 | 0:d63a63feb104 | 283 | // Reset timeout: stops hanging on bad receive; resets alpha 433 |
jah128 | 0:d63a63feb104 | 284 | void timeout(); |
jah128 | 0:d63a63feb104 | 285 | |
jah128 | 0:d63a63feb104 | 286 | private : |
jah128 | 0:d63a63feb104 | 287 | |
jah128 | 0:d63a63feb104 | 288 | DigitalOut _fss; |
jah128 | 0:d63a63feb104 | 289 | SPI _spi; |
jah128 | 0:d63a63feb104 | 290 | DigitalIn _nirq_test; |
jah128 | 0:d63a63feb104 | 291 | InterruptIn _nirq; |
jah128 | 0:d63a63feb104 | 292 | |
jah128 | 0:d63a63feb104 | 293 | //Write a byte (data) to address |
jah128 | 0:d63a63feb104 | 294 | void _write(int address); |
jah128 | 0:d63a63feb104 | 295 | |
jah128 | 0:d63a63feb104 | 296 | //Read a byte (return val) from address |
jah128 | 0:d63a63feb104 | 297 | int _read(int address); |
jah128 | 0:d63a63feb104 | 298 | |
jah128 | 0:d63a63feb104 | 299 | virtual int _putc(int c); |
jah128 | 0:d63a63feb104 | 300 | virtual int _getc(); |
jah128 | 0:d63a63feb104 | 301 | |
jah128 | 0:d63a63feb104 | 302 | }; |
jah128 | 0:d63a63feb104 | 303 | |
jah128 | 0:d63a63feb104 | 304 | #endif // ALPHA433_H |