Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of stm-spirit1-rf-driver by
spirit1.h
00001 /* 00002 * Copyright (c) 2012, STMicroelectronics. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the Institute nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00018 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 * 00029 * This file is part of the Contiki operating system. 00030 * 00031 */ 00032 /*---------------------------------------------------------------------------*/ 00033 #ifndef __SPIRIT_H__ 00034 #define __SPIRIT_H__ 00035 /*---------------------------------------------------------------------------*/ 00036 #include "radio.h" 00037 #include "SPIRIT_Config.h" 00038 #include "spirit1-config.h" 00039 //#include "spirit1_appli.h" 00040 #include "spirit1-const.h" 00041 /*---------------------------------------------------------------------------*/ 00042 extern const struct radio_driver spirit_radio_driver; 00043 void spirit1_interrupt_callback(void); 00044 00045 /* exported from spirit1appli.h */ 00046 00047 #include "radio_shield_config.h" 00048 #include "MCU_Interface.h" 00049 #include "SPIRIT_Config.h" 00050 // betzw - WAS: #include "SPIRIT1_Util.h" 00051 00052 00053 #if defined(X_NUCLEO_IDS01A3) 00054 #define USE_SPIRIT1_433MHz 00055 #elif defined(X_NUCLEO_IDS01A4) 00056 #define USE_SPIRIT1_868MHz 00057 #elif defined(X_NUCLEO_IDS01A5) 00058 #define USE_SPIRIT1_915MHz 00059 #else 00060 #error SPIRIT1 Nucleo Shield undefined or unsupported 00061 #endif 00062 00063 /* Uncomment the Link Layer features to be used */ 00064 // #define USE_AUTO_ACK 00065 // #define USE_AUTO_ACK_PIGGYBACKING 00066 // #define USE_AUTO_RETRANSMISSION 00067 00068 #if defined(USE_AUTO_ACK)&& defined(USE_AUTO_ACK_PIGGYBACKING)&& defined(USE_AUTO_RETRANSMISSION) 00069 #define USE_STack_PROTOCOL 00070 00071 /* LLP configuration parameters */ 00072 #define EN_AUTOACK S_ENABLE 00073 #define EN_PIGGYBACKING S_ENABLE 00074 #define MAX_RETRANSMISSIONS PKT_N_RETX_2 00075 00076 #else 00077 #define USE_BASIC_PROTOCOL 00078 00079 #endif 00080 00081 /* Uncomment the system Operating mode */ 00082 //#define USE_LOW_POWER_MODE 00083 00084 #if defined (USE_LOW_POWER_MODE) 00085 #define LPM_ENABLE 00086 #define MCU_STOP_MODE 00087 //#define MCU_SLEEP_MODE 00088 //#define RF_STANDBY 00089 #endif 00090 00091 00092 /* Exported constants --------------------------------------------------------*/ 00093 00094 /* Radio configuration parameters */ 00095 /* General Remarks: 00096 * Two SPSGRF modules will only communicate when both are having same frequency , same channel number, 00097 * same modulation scheme, same data rate, etc. 00098 * For example, the SPSGRF-915 module supports frequencies 902 to 928 MHz. User can select any frequency 00099 * between this band. 00100 */ 00101 #define XTAL_OFFSET_PPM 0 00102 #define INFINITE_TIMEOUT 0.0 00103 00104 #ifdef USE_SPIRIT1_433MHz 00105 #define BASE_FREQUENCY 433.4e6 00106 #endif 00107 00108 #ifdef USE_SPIRIT1_868MHz 00109 #define BASE_FREQUENCY 868.0e6 00110 #endif 00111 00112 #ifdef USE_SPIRIT1_915MHz 00113 #define BASE_FREQUENCY 915.0e6 00114 #endif 00115 00116 00117 /* Addresses configuration parameters */ 00118 #define EN_FILT_MY_ADDRESS S_DISABLE 00119 #define MY_ADDRESS 0x24 00120 #define EN_FILT_MULTICAST_ADDRESS S_DISABLE 00121 #define MULTICAST_ADDRESS 0xEE 00122 #define EN_FILT_BROADCAST_ADDRESS S_DISABLE 00123 #define BROADCAST_ADDRESS 0xFF 00124 #define DESTINATION_ADDRESS 0x44 00125 #define EN_FILT_SOURCE_ADDRESS S_DISABLE 00126 #define SOURCE_ADDR_MASK 0xf0 00127 #define SOURCE_ADDR_REF 0x37 00128 00129 #define APPLI_CMD 0x11 00130 #define NWK_CMD 0x22 00131 #define LED_TOGGLE 0xff 00132 #define ACK_OK 0x01 00133 #define MAX_BUFFER_LEN 96 00134 #define TIME_TO_EXIT_RX 3000 00135 #define DELAY_RX_LED_TOGGLE 200 00136 #define DELAY_TX_LED_GLOW 1000 00137 #define LPM_WAKEUP_TIME 100 00138 #define DATA_SEND_TIME 30 00139 00140 #define PREAMBLE_LENGTH PKT_PREAMBLE_LENGTH_04BYTES 00141 #define SYNC_LENGTH PKT_SYNC_LENGTH_4BYTES 00142 #define CONTROL_LENGTH PKT_CONTROL_LENGTH_0BYTES 00143 #define EN_ADDRESS S_DISABLE 00144 #define EN_FEC S_DISABLE 00145 #define CHANNEL_NUMBER 1 // betzw - WAS: 0 00146 #define LENGTH_TYPE PKT_LENGTH_VAR 00147 #define POWER_INDEX 7 00148 #define RECEIVE_TIMEOUT 2000.0 /*change the value for required timeout period*/ 00149 #define RSSI_THRESHOLD -120 00150 00151 00152 00153 #define POWER_DBM 11.6 00154 00155 00156 /* 송,수신 성공 셋팅 값 */ 00157 //------------915Mhz------------ 00158 #ifdef USE_SPIRIT1_915MHz 00159 #define CHANNEL_SPACE 20e3 //HJM : SPIRIT_Radio.h 참고, 디폴트 셋팅 값 00160 #define FREQ_DEVIATION 127e3 00161 #define BANDWIDTH 540.0e3 00162 #define MODULATION_SELECT GFSK_BT1 00163 #define DATARATE 250000 00164 #endif //USE_SPIRIT1_915MHz 00165 //------------915Mhz------------ 00166 00167 00168 //------------433Mhz------------ 00169 //작동 되는 셋팅 recv 00170 //#ifdef USE_SPIRIT1_433MHz 00171 //#define CHANNEL_SPACE 20e3 //해봄 00172 //#define FREQ_DEVIATION 127e3 //해봄 00173 //#define BANDWIDTH 540.0e3 //해봄 00174 //#define MODULATION_SELECT GFSK_BT1 00175 //#define DATARATE 250000 00176 ////#define DATARATE 38400 00177 //#endif //USE_SPIRIT1_433MHz 00178 //------------433Mhz------------ 00179 00180 //------------433Mhz------------ 00181 //작동 되는 셋팅 00182 //#ifdef USE_SPIRIT1_433MHz 00183 //#define CHANNEL_SPACE 20e3 //해봄 00184 //#define FREQ_DEVIATION 127e3 //recv 00185 ////#define FREQ_DEVIATION 50e3 //send 00186 ////#define BANDWIDTH 50.0e3 00187 ////#define BANDWIDTH 70.0e3 //printf 다 끄니까 1000바이트정도 보내다가 뻗음 00188 ////#define BANDWIDTH 100.0e3 //printf 다 끄니까 900바이트정도 보내다가 뻗음 00189 //#define BANDWIDTH 100.5e3 //printf 다 끄니까 900바이트정도 보내다가 뻗음 00190 // 00191 ////#define BANDWIDTH 540.0e3 00192 //#define MODULATION_SELECT GFSK_BT1 00193 //#define DATARATE 250000 //180326 HJM : 잘 됨 00194 ////#define DATARATE 500000 //180326 HJM : 잘 안됨 00195 ////#define DATARATE 300000 //180326 HJM : 잘 안됨 00196 ////#define DATARATE 38400 00197 //#endif //USE_SPIRIT1_433MHz 00198 //------------433Mhz------------ 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 //------------433Mhz------------ 00212 //HJM : 안테나 변경(방수 안테나)로 인한 셋팅 변경 00213 #ifdef USE_SPIRIT1_433MHz 00214 #define CHANNEL_SPACE 20e3 //해봄 00215 #define FREQ_DEVIATION 127e3 //recv 00216 //#define FREQ_DEVIATION 50e3 //send 00217 #define BANDWIDTH 50.0e3 00218 //#define BANDWIDTH 65.0e3 //printf 다 끄니까 1000바이트정도 보내다가 뻗음 00219 //#define BANDWIDTH 70.0e3 //printf 다 끄니까 1000바이트정도 보내다가 뻗음 00220 //#define BANDWIDTH 100.0e3 //printf 다 끄니까 900바이트정도 보내다가 뻗음 00221 //#define BANDWIDTH 100.5e3 //printf 다 끄니까 900바이트정도 보내다가 뻗음 00222 00223 //#define BANDWIDTH 540.0e3 00224 //#define MODULATION_SELECT GFSK_BT1 00225 #define MODULATION_SELECT FSK 00226 #define DATARATE 250000 //180326 HJM : 잘 됨 00227 //#define DATARATE 500000 //180326 HJM : 잘 안됨 00228 //#define DATARATE 300000 //180326 HJM : 잘 안됨 00229 //#define DATARATE 115200 //180326 HJM : 잘 안됨 00230 //#define DATARATE 38400 00231 #endif //USE_SPIRIT1_433MHz 00232 //------------433Mhz------------ 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 //#define CHANNEL_SPACE 100e3 00260 //#define FREQ_DEVIATION 127e3 00261 //#define BANDWIDTH 540.0e3 00262 ////#define MODULATION_SELECT GFSK_BT1 00263 //#define MODULATION_SELECT FSK 00264 //#define DATARATE 250000 00265 00266 00267 00268 00269 #define XTAL_OFFSET_PPM 0 00270 #define SYNC_WORD 0x88888888 00271 #define LENGTH_WIDTH 8 // betzw - NOTE: only 255 bytes for payload!!! 00272 #define CRC_MODE PKT_CRC_MODE_16BITS_2 00273 #define EN_WHITENING S_DISABLE 00274 #define INFINITE_TIMEOUT 0.0 00275 00276 // extern volatile FlagStatus xRxDoneFlag, xTxDoneFlag; 00277 // extern volatile FlagStatus PushButtonStatusWakeup; 00278 extern uint16_t wakeupCounter; 00279 extern uint16_t dataSendCounter ; 00280 // extern volatile FlagStatus PushButtonStatusData, datasendFlag; 00281 00282 typedef struct 00283 { 00284 uint8_t Cmdtag; 00285 uint8_t CmdType; 00286 uint8_t CmdLen; 00287 uint8_t Cmd; 00288 uint8_t DataLen; 00289 uint8_t* DataBuff; 00290 }AppliFrame_t; 00291 00292 /*---------------------------------------------------------------------------*/ 00293 #endif /* __SPIRIT_H__ */ 00294 /*---------------------------------------------------------------------------*/
Generated on Wed Jul 13 2022 00:11:56 by
