Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.

Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo

Currently supported boards:

Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:

  • Unmount resistor R4
  • Mount resistor R7

Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!

This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).

Committer:
Wolfgang Betz
Date:
Fri Feb 02 14:13:24 2018 +0100
Revision:
82:a18c22d2b83a
Parent:
75:8dc65c09af67
Correct comments/documentation

Who changed what in which revision?

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