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