123r

Dependencies:   WNC14A2AInterface

Committer:
JMF
Date:
Wed Apr 19 01:13:10 2017 +0000
Revision:
0:2563b0415d1f
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JMF 0:2563b0415d1f 1 /*
JMF 0:2563b0415d1f 2 * Copyright (c) 2012, STMicroelectronics.
JMF 0:2563b0415d1f 3 * All rights reserved.
JMF 0:2563b0415d1f 4 *
JMF 0:2563b0415d1f 5 * Redistribution and use in source and binary forms, with or without
JMF 0:2563b0415d1f 6 * modification, are permitted provided that the following conditions
JMF 0:2563b0415d1f 7 * are met:
JMF 0:2563b0415d1f 8 * 1. Redistributions of source code must retain the above copyright
JMF 0:2563b0415d1f 9 * notice, this list of conditions and the following disclaimer.
JMF 0:2563b0415d1f 10 * 2. Redistributions in binary form must reproduce the above copyright
JMF 0:2563b0415d1f 11 * notice, this list of conditions and the following disclaimer in the
JMF 0:2563b0415d1f 12 * documentation and/or other materials provided with the distribution.
JMF 0:2563b0415d1f 13 * 3. Neither the name of the Institute nor the names of its contributors
JMF 0:2563b0415d1f 14 * may be used to endorse or promote products derived from this software
JMF 0:2563b0415d1f 15 * without specific prior written permission.
JMF 0:2563b0415d1f 16 *
JMF 0:2563b0415d1f 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
JMF 0:2563b0415d1f 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
JMF 0:2563b0415d1f 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
JMF 0:2563b0415d1f 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
JMF 0:2563b0415d1f 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
JMF 0:2563b0415d1f 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
JMF 0:2563b0415d1f 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
JMF 0:2563b0415d1f 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
JMF 0:2563b0415d1f 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
JMF 0:2563b0415d1f 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
JMF 0:2563b0415d1f 27 * SUCH DAMAGE.
JMF 0:2563b0415d1f 28 *
JMF 0:2563b0415d1f 29 * This file is part of the Contiki operating system.
JMF 0:2563b0415d1f 30 *
JMF 0:2563b0415d1f 31 */
JMF 0:2563b0415d1f 32 /*---------------------------------------------------------------------------*/
JMF 0:2563b0415d1f 33 #ifndef __SPIRIT_H__
JMF 0:2563b0415d1f 34 #define __SPIRIT_H__
JMF 0:2563b0415d1f 35 /*---------------------------------------------------------------------------*/
JMF 0:2563b0415d1f 36 #include "radio.h"
JMF 0:2563b0415d1f 37 #include "SPIRIT_Config.h"
JMF 0:2563b0415d1f 38 #include "spirit1-config.h"
JMF 0:2563b0415d1f 39 //#include "spirit1_appli.h"
JMF 0:2563b0415d1f 40 #include "spirit1-const.h"
JMF 0:2563b0415d1f 41 /*---------------------------------------------------------------------------*/
JMF 0:2563b0415d1f 42 extern const struct radio_driver spirit_radio_driver;
JMF 0:2563b0415d1f 43 void spirit1_interrupt_callback(void);
JMF 0:2563b0415d1f 44
JMF 0:2563b0415d1f 45 /* exported from spirit1appli.h */
JMF 0:2563b0415d1f 46
JMF 0:2563b0415d1f 47 #include "radio_shield_config.h"
JMF 0:2563b0415d1f 48 #include "MCU_Interface.h"
JMF 0:2563b0415d1f 49 #include "SPIRIT_Config.h"
JMF 0:2563b0415d1f 50 // betzw - WAS: #include "SPIRIT1_Util.h"
JMF 0:2563b0415d1f 51
JMF 0:2563b0415d1f 52
JMF 0:2563b0415d1f 53 #if defined(X_NUCLEO_IDS01A3)
JMF 0:2563b0415d1f 54 #define USE_SPIRIT1_433MHz
JMF 0:2563b0415d1f 55 #elif defined(X_NUCLEO_IDS01A4)
JMF 0:2563b0415d1f 56 #define USE_SPIRIT1_868MHz
JMF 0:2563b0415d1f 57 #elif defined(X_NUCLEO_IDS01A5)
JMF 0:2563b0415d1f 58 #define USE_SPIRIT1_915MHz
JMF 0:2563b0415d1f 59 #else
JMF 0:2563b0415d1f 60 #error SPIRIT1 Nucleo Shield undefined or unsupported
JMF 0:2563b0415d1f 61 #endif
JMF 0:2563b0415d1f 62
JMF 0:2563b0415d1f 63 /* Uncomment the Link Layer features to be used */
JMF 0:2563b0415d1f 64 // #define USE_AUTO_ACK
JMF 0:2563b0415d1f 65 // #define USE_AUTO_ACK_PIGGYBACKING
JMF 0:2563b0415d1f 66 // #define USE_AUTO_RETRANSMISSION
JMF 0:2563b0415d1f 67
JMF 0:2563b0415d1f 68 #if defined(USE_AUTO_ACK)&& defined(USE_AUTO_ACK_PIGGYBACKING)&& defined(USE_AUTO_RETRANSMISSION)
JMF 0:2563b0415d1f 69 #define USE_STack_PROTOCOL
JMF 0:2563b0415d1f 70
JMF 0:2563b0415d1f 71 /* LLP configuration parameters */
JMF 0:2563b0415d1f 72 #define EN_AUTOACK S_ENABLE
JMF 0:2563b0415d1f 73 #define EN_PIGGYBACKING S_ENABLE
JMF 0:2563b0415d1f 74 #define MAX_RETRANSMISSIONS PKT_N_RETX_2
JMF 0:2563b0415d1f 75
JMF 0:2563b0415d1f 76 #else
JMF 0:2563b0415d1f 77 #define USE_BASIC_PROTOCOL
JMF 0:2563b0415d1f 78
JMF 0:2563b0415d1f 79 #endif
JMF 0:2563b0415d1f 80
JMF 0:2563b0415d1f 81 /* Uncomment the system Operating mode */
JMF 0:2563b0415d1f 82 //#define USE_LOW_POWER_MODE
JMF 0:2563b0415d1f 83
JMF 0:2563b0415d1f 84 #if defined (USE_LOW_POWER_MODE)
JMF 0:2563b0415d1f 85 #define LPM_ENABLE
JMF 0:2563b0415d1f 86 #define MCU_STOP_MODE
JMF 0:2563b0415d1f 87 //#define MCU_SLEEP_MODE
JMF 0:2563b0415d1f 88 //#define RF_STANDBY
JMF 0:2563b0415d1f 89 #endif
JMF 0:2563b0415d1f 90
JMF 0:2563b0415d1f 91
JMF 0:2563b0415d1f 92 /* Exported constants --------------------------------------------------------*/
JMF 0:2563b0415d1f 93
JMF 0:2563b0415d1f 94 /* Radio configuration parameters */
JMF 0:2563b0415d1f 95 #define XTAL_OFFSET_PPM 0
JMF 0:2563b0415d1f 96 #define INFINITE_TIMEOUT 0.0
JMF 0:2563b0415d1f 97
JMF 0:2563b0415d1f 98 #ifdef USE_SPIRIT1_433MHz
JMF 0:2563b0415d1f 99 #define BASE_FREQUENCY 433.0e6
JMF 0:2563b0415d1f 100 #endif
JMF 0:2563b0415d1f 101
JMF 0:2563b0415d1f 102 #ifdef USE_SPIRIT1_868MHz
JMF 0:2563b0415d1f 103 #define BASE_FREQUENCY 868.0e6
JMF 0:2563b0415d1f 104 #endif
JMF 0:2563b0415d1f 105
JMF 0:2563b0415d1f 106 #ifdef USE_SPIRIT1_915MHz
JMF 0:2563b0415d1f 107 //#define BASE_FREQUENCY 915.0e6
JMF 0:2563b0415d1f 108 #define BASE_FREQUENCY 902.0e6
JMF 0:2563b0415d1f 109 #endif
JMF 0:2563b0415d1f 110
JMF 0:2563b0415d1f 111
JMF 0:2563b0415d1f 112 /* Addresses configuration parameters */
JMF 0:2563b0415d1f 113 #define EN_FILT_MY_ADDRESS S_DISABLE
JMF 0:2563b0415d1f 114 #define MY_ADDRESS 0x24
JMF 0:2563b0415d1f 115 #define EN_FILT_MULTICAST_ADDRESS S_DISABLE
JMF 0:2563b0415d1f 116 #define MULTICAST_ADDRESS 0xEE
JMF 0:2563b0415d1f 117 #define EN_FILT_BROADCAST_ADDRESS S_DISABLE
JMF 0:2563b0415d1f 118 #define BROADCAST_ADDRESS 0xFF
JMF 0:2563b0415d1f 119 #define DESTINATION_ADDRESS 0x44
JMF 0:2563b0415d1f 120 #define EN_FILT_SOURCE_ADDRESS S_DISABLE
JMF 0:2563b0415d1f 121 #define SOURCE_ADDR_MASK 0xf0
JMF 0:2563b0415d1f 122 #define SOURCE_ADDR_REF 0x37
JMF 0:2563b0415d1f 123
JMF 0:2563b0415d1f 124 #define APPLI_CMD 0x11
JMF 0:2563b0415d1f 125 #define NWK_CMD 0x22
JMF 0:2563b0415d1f 126 #define LED_TOGGLE 0xff
JMF 0:2563b0415d1f 127 #define ACK_OK 0x01
JMF 0:2563b0415d1f 128 #define MAX_BUFFER_LEN 96
JMF 0:2563b0415d1f 129 #define TIME_TO_EXIT_RX 3000
JMF 0:2563b0415d1f 130 #define DELAY_RX_LED_TOGGLE 200
JMF 0:2563b0415d1f 131 #define DELAY_TX_LED_GLOW 1000
JMF 0:2563b0415d1f 132 #define LPM_WAKEUP_TIME 100
JMF 0:2563b0415d1f 133 #define DATA_SEND_TIME 30
JMF 0:2563b0415d1f 134
JMF 0:2563b0415d1f 135 #define PREAMBLE_LENGTH PKT_PREAMBLE_LENGTH_04BYTES
JMF 0:2563b0415d1f 136 #define SYNC_LENGTH PKT_SYNC_LENGTH_4BYTES
JMF 0:2563b0415d1f 137 #define CONTROL_LENGTH PKT_CONTROL_LENGTH_0BYTES
JMF 0:2563b0415d1f 138 #define EN_ADDRESS S_DISABLE
JMF 0:2563b0415d1f 139 #define EN_FEC S_DISABLE
JMF 0:2563b0415d1f 140 #define CHANNEL_NUMBER 1 // betzw - WAS: 0
JMF 0:2563b0415d1f 141 #define LENGTH_TYPE PKT_LENGTH_VAR
JMF 0:2563b0415d1f 142 #define POWER_INDEX 7
JMF 0:2563b0415d1f 143 #define RECEIVE_TIMEOUT 2000.0 /*change the value for required timeout period*/
JMF 0:2563b0415d1f 144 #define RSSI_THRESHOLD -120
JMF 0:2563b0415d1f 145
JMF 0:2563b0415d1f 146
JMF 0:2563b0415d1f 147
JMF 0:2563b0415d1f 148 #define POWER_DBM 11.6
JMF 0:2563b0415d1f 149 #define CHANNEL_SPACE 100e3
JMF 0:2563b0415d1f 150 #define FREQ_DEVIATION 127e3
JMF 0:2563b0415d1f 151 #define BANDWIDTH 540.0e3
JMF 0:2563b0415d1f 152 #define MODULATION_SELECT GFSK_BT1
JMF 0:2563b0415d1f 153 #define DATARATE 250000
JMF 0:2563b0415d1f 154 #define XTAL_OFFSET_PPM 0
JMF 0:2563b0415d1f 155 #define SYNC_WORD 0x88888888
JMF 0:2563b0415d1f 156 #define LENGTH_WIDTH 8 // betzw - NOTE: only 255 bytes for payload!!!
JMF 0:2563b0415d1f 157 #define CRC_MODE PKT_CRC_MODE_16BITS_2
JMF 0:2563b0415d1f 158 #define EN_WHITENING S_DISABLE
JMF 0:2563b0415d1f 159 #define INFINITE_TIMEOUT 0.0
JMF 0:2563b0415d1f 160
JMF 0:2563b0415d1f 161 // extern volatile FlagStatus xRxDoneFlag, xTxDoneFlag;
JMF 0:2563b0415d1f 162 // extern volatile FlagStatus PushButtonStatusWakeup;
JMF 0:2563b0415d1f 163 extern uint16_t wakeupCounter;
JMF 0:2563b0415d1f 164 extern uint16_t dataSendCounter ;
JMF 0:2563b0415d1f 165 // extern volatile FlagStatus PushButtonStatusData, datasendFlag;
JMF 0:2563b0415d1f 166
JMF 0:2563b0415d1f 167 typedef struct
JMF 0:2563b0415d1f 168 {
JMF 0:2563b0415d1f 169 uint8_t Cmdtag;
JMF 0:2563b0415d1f 170 uint8_t CmdType;
JMF 0:2563b0415d1f 171 uint8_t CmdLen;
JMF 0:2563b0415d1f 172 uint8_t Cmd;
JMF 0:2563b0415d1f 173 uint8_t DataLen;
JMF 0:2563b0415d1f 174 uint8_t* DataBuff;
JMF 0:2563b0415d1f 175 }AppliFrame_t;
JMF 0:2563b0415d1f 176
JMF 0:2563b0415d1f 177 /*---------------------------------------------------------------------------*/
JMF 0:2563b0415d1f 178 #endif /* __SPIRIT_H__ */
JMF 0:2563b0415d1f 179 /*---------------------------------------------------------------------------*/