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/spirit1/SPIRIT1_Library/Inc/SPIRIT_Aes.h@34:edda6a7238ec, 2016-11-22 (annotated)
- Committer:
- Wolfgang Betz
- Date:
- Tue Nov 22 11:40:10 2016 +0100
- Revision:
- 34:edda6a7238ec
- Child:
- 67:93bec0baf1de
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 | ****************************************************************************** |
| Wolfgang Betz |
34:edda6a7238ec | 3 | * @file SPIRIT_Aes.h |
| Wolfgang Betz |
34:edda6a7238ec | 4 | * @author VMA division - AMS |
| Wolfgang Betz |
34:edda6a7238ec | 5 | * @version 3.2.2 |
| Wolfgang Betz |
34:edda6a7238ec | 6 | * @date 08-July-2015 |
| Wolfgang Betz |
34:edda6a7238ec | 7 | * @brief Configuration and management of SPIRIT AES Engine. |
| Wolfgang Betz |
34:edda6a7238ec | 8 | * |
| Wolfgang Betz |
34:edda6a7238ec | 9 | * @details |
| Wolfgang Betz |
34:edda6a7238ec | 10 | * |
| Wolfgang Betz |
34:edda6a7238ec | 11 | * In order to encrypt data, the user must manage the AES_END IRQ. |
| Wolfgang Betz |
34:edda6a7238ec | 12 | * The data have to be splitted in blocks of 16 bytes and written |
| Wolfgang Betz |
34:edda6a7238ec | 13 | * into the <i>AES DATA IN registers</i>. Then, after the key is written |
| Wolfgang Betz |
34:edda6a7238ec | 14 | * into the <i>AES KEY registers</i>, a command of <i>Execute encryption</i> |
| Wolfgang Betz |
34:edda6a7238ec | 15 | * has to be sent. |
| Wolfgang Betz |
34:edda6a7238ec | 16 | * |
| Wolfgang Betz |
34:edda6a7238ec | 17 | * <b>Example:</b> |
| Wolfgang Betz |
34:edda6a7238ec | 18 | * @code |
| Wolfgang Betz |
34:edda6a7238ec | 19 | * |
| Wolfgang Betz |
34:edda6a7238ec | 20 | * SpiritAesWriteDataIn(data_buff , N_BYTES); |
| Wolfgang Betz |
34:edda6a7238ec | 21 | * SpiritAesExecuteEncryption(); |
| Wolfgang Betz |
34:edda6a7238ec | 22 | * |
| Wolfgang Betz |
34:edda6a7238ec | 23 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
| Wolfgang Betz |
34:edda6a7238ec | 24 | * aes_end_flag=RESET; |
| Wolfgang Betz |
34:edda6a7238ec | 25 | * |
| Wolfgang Betz |
34:edda6a7238ec | 26 | * SpiritAesReadDataOut(enc_data_buff , N_BYTES); |
| Wolfgang Betz |
34:edda6a7238ec | 27 | * |
| Wolfgang Betz |
34:edda6a7238ec | 28 | * @endcode |
| Wolfgang Betz |
34:edda6a7238ec | 29 | * |
| Wolfgang Betz |
34:edda6a7238ec | 30 | * In order to decrypt data, the user must manage the AES_END IRQ and have a decryption key. |
| Wolfgang Betz |
34:edda6a7238ec | 31 | * There are two operative modes to make the data decryption: |
| Wolfgang Betz |
34:edda6a7238ec | 32 | * <ul> |
| Wolfgang Betz |
34:edda6a7238ec | 33 | * <li> Derive the decryption key from the encryption key and decrypt data directly |
| Wolfgang Betz |
34:edda6a7238ec | 34 | * using the <i>SpiritAesDeriveDecKeyExecuteDec()</i> function |
| Wolfgang Betz |
34:edda6a7238ec | 35 | * |
| Wolfgang Betz |
34:edda6a7238ec | 36 | * <b>Example:</b> |
| Wolfgang Betz |
34:edda6a7238ec | 37 | * @code |
| Wolfgang Betz |
34:edda6a7238ec | 38 | * |
| Wolfgang Betz |
34:edda6a7238ec | 39 | * SpiritAesWriteDataIn(enc_data_buff , N_BYTES); |
| Wolfgang Betz |
34:edda6a7238ec | 40 | * SpiritAesDeriveDecKeyExecuteDec(); |
| Wolfgang Betz |
34:edda6a7238ec | 41 | * |
| Wolfgang Betz |
34:edda6a7238ec | 42 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
| Wolfgang Betz |
34:edda6a7238ec | 43 | * aes_end_flag=RESET; |
| Wolfgang Betz |
34:edda6a7238ec | 44 | * |
| Wolfgang Betz |
34:edda6a7238ec | 45 | * SpiritAesReadDataOut(data_buff , N_BYTES); |
| Wolfgang Betz |
34:edda6a7238ec | 46 | * |
| Wolfgang Betz |
34:edda6a7238ec | 47 | * @endcode |
| Wolfgang Betz |
34:edda6a7238ec | 48 | * </li> |
| Wolfgang Betz |
34:edda6a7238ec | 49 | * |
| Wolfgang Betz |
34:edda6a7238ec | 50 | * <li> Derive the decryption key from the encryption key using the <i>SpiritAesDeriveDecKeyFromEnc()</i> |
| Wolfgang Betz |
34:edda6a7238ec | 51 | * function, store it into the <i>AES KEY registers</i> and then decrypt data using the |
| Wolfgang Betz |
34:edda6a7238ec | 52 | * <i>SpiritAesExecuteDecryption()</i> function |
| Wolfgang Betz |
34:edda6a7238ec | 53 | * |
| Wolfgang Betz |
34:edda6a7238ec | 54 | * <b>Example:</b> |
| Wolfgang Betz |
34:edda6a7238ec | 55 | * @code |
| Wolfgang Betz |
34:edda6a7238ec | 56 | * |
| Wolfgang Betz |
34:edda6a7238ec | 57 | * SpiritAesWriteDataIn(key_enc , 16); |
| Wolfgang Betz |
34:edda6a7238ec | 58 | * SpiritAesDeriveDecKeyFromEnc(); |
| Wolfgang Betz |
34:edda6a7238ec | 59 | * |
| Wolfgang Betz |
34:edda6a7238ec | 60 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
| Wolfgang Betz |
34:edda6a7238ec | 61 | * aes_end_flag=RESET; |
| Wolfgang Betz |
34:edda6a7238ec | 62 | * |
| Wolfgang Betz |
34:edda6a7238ec | 63 | * SpiritAesReadDataOut(key_dec , 16); |
| Wolfgang Betz |
34:edda6a7238ec | 64 | * |
| Wolfgang Betz |
34:edda6a7238ec | 65 | * SpiritAesWriteKey(key_dec); |
| Wolfgang Betz |
34:edda6a7238ec | 66 | * SpiritAesWriteDataIn(enc_data_buff , 16); |
| Wolfgang Betz |
34:edda6a7238ec | 67 | * SpiritAesExecuteDecryption(); |
| Wolfgang Betz |
34:edda6a7238ec | 68 | * |
| Wolfgang Betz |
34:edda6a7238ec | 69 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
| Wolfgang Betz |
34:edda6a7238ec | 70 | * aes_end_flag=RESET; |
| Wolfgang Betz |
34:edda6a7238ec | 71 | * |
| Wolfgang Betz |
34:edda6a7238ec | 72 | * SpiritAesReadDataOut(data_buff , N_BYTES); |
| Wolfgang Betz |
34:edda6a7238ec | 73 | * |
| Wolfgang Betz |
34:edda6a7238ec | 74 | * @endcode |
| Wolfgang Betz |
34:edda6a7238ec | 75 | * </li> |
| Wolfgang Betz |
34:edda6a7238ec | 76 | * </ul> |
| Wolfgang Betz |
34:edda6a7238ec | 77 | * |
| Wolfgang Betz |
34:edda6a7238ec | 78 | * @attention |
| Wolfgang Betz |
34:edda6a7238ec | 79 | * |
| Wolfgang Betz |
34:edda6a7238ec | 80 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| Wolfgang Betz |
34:edda6a7238ec | 81 | * |
| Wolfgang Betz |
34:edda6a7238ec | 82 | * Redistribution and use in source and binary forms, with or without modification, |
| Wolfgang Betz |
34:edda6a7238ec | 83 | * are permitted provided that the following conditions are met: |
| Wolfgang Betz |
34:edda6a7238ec | 84 | * 1. Redistributions of source code must retain the above copyright notice, |
| Wolfgang Betz |
34:edda6a7238ec | 85 | * this list of conditions and the following disclaimer. |
| Wolfgang Betz |
34:edda6a7238ec | 86 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| Wolfgang Betz |
34:edda6a7238ec | 87 | * this list of conditions and the following disclaimer in the documentation |
| Wolfgang Betz |
34:edda6a7238ec | 88 | * and/or other materials provided with the distribution. |
| Wolfgang Betz |
34:edda6a7238ec | 89 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| Wolfgang Betz |
34:edda6a7238ec | 90 | * may be used to endorse or promote products derived from this software |
| Wolfgang Betz |
34:edda6a7238ec | 91 | * without specific prior written permission. |
| Wolfgang Betz |
34:edda6a7238ec | 92 | * |
| Wolfgang Betz |
34:edda6a7238ec | 93 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| Wolfgang Betz |
34:edda6a7238ec | 94 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| Wolfgang Betz |
34:edda6a7238ec | 95 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| Wolfgang Betz |
34:edda6a7238ec | 96 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| Wolfgang Betz |
34:edda6a7238ec | 97 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| Wolfgang Betz |
34:edda6a7238ec | 98 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| Wolfgang Betz |
34:edda6a7238ec | 99 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| Wolfgang Betz |
34:edda6a7238ec | 100 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| Wolfgang Betz |
34:edda6a7238ec | 101 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| Wolfgang Betz |
34:edda6a7238ec | 102 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| Wolfgang Betz |
34:edda6a7238ec | 103 | * |
| Wolfgang Betz |
34:edda6a7238ec | 104 | ****************************************************************************** |
| Wolfgang Betz |
34:edda6a7238ec | 105 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 106 | |
| Wolfgang Betz |
34:edda6a7238ec | 107 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| Wolfgang Betz |
34:edda6a7238ec | 108 | #ifndef __SPIRIT_AES_H |
| Wolfgang Betz |
34:edda6a7238ec | 109 | #define __SPIRIT_AES_H |
| Wolfgang Betz |
34:edda6a7238ec | 110 | |
| Wolfgang Betz |
34:edda6a7238ec | 111 | |
| Wolfgang Betz |
34:edda6a7238ec | 112 | /* Includes ------------------------------------------------------------------*/ |
| Wolfgang Betz |
34:edda6a7238ec | 113 | |
| Wolfgang Betz |
34:edda6a7238ec | 114 | #include "SPIRIT_Regs.h" |
| Wolfgang Betz |
34:edda6a7238ec | 115 | #include "SPIRIT_Types.h" |
| Wolfgang Betz |
34:edda6a7238ec | 116 | |
| Wolfgang Betz |
34:edda6a7238ec | 117 | |
| Wolfgang Betz |
34:edda6a7238ec | 118 | #ifdef __cplusplus |
| Wolfgang Betz |
34:edda6a7238ec | 119 | extern "C" { |
| Wolfgang Betz |
34:edda6a7238ec | 120 | #endif |
| Wolfgang Betz |
34:edda6a7238ec | 121 | |
| Wolfgang Betz |
34:edda6a7238ec | 122 | |
| Wolfgang Betz |
34:edda6a7238ec | 123 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 124 | * @addtogroup SPIRIT_Libraries |
| Wolfgang Betz |
34:edda6a7238ec | 125 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 126 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 127 | |
| Wolfgang Betz |
34:edda6a7238ec | 128 | |
| Wolfgang Betz |
34:edda6a7238ec | 129 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 130 | * @defgroup SPIRIT_Aes AES |
| Wolfgang Betz |
34:edda6a7238ec | 131 | * @brief Configuration and management of SPIRIT AES Engine. |
| Wolfgang Betz |
34:edda6a7238ec | 132 | * @details See the file <i>@ref SPIRIT_Aes.h</i> for more details. |
| Wolfgang Betz |
34:edda6a7238ec | 133 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 134 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 135 | |
| Wolfgang Betz |
34:edda6a7238ec | 136 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 137 | * @defgroup Aes_Exported_Types AES Exported Types |
| Wolfgang Betz |
34:edda6a7238ec | 138 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 139 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 140 | |
| Wolfgang Betz |
34:edda6a7238ec | 141 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 142 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 143 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 144 | |
| Wolfgang Betz |
34:edda6a7238ec | 145 | |
| Wolfgang Betz |
34:edda6a7238ec | 146 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 147 | * @defgroup Aes_Exported_Constants AES Exported Constants |
| Wolfgang Betz |
34:edda6a7238ec | 148 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 149 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 150 | |
| Wolfgang Betz |
34:edda6a7238ec | 151 | |
| Wolfgang Betz |
34:edda6a7238ec | 152 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 153 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 154 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 155 | |
| Wolfgang Betz |
34:edda6a7238ec | 156 | |
| Wolfgang Betz |
34:edda6a7238ec | 157 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 158 | * @defgroup Aes_Exported_Macros AES Exported Macros |
| Wolfgang Betz |
34:edda6a7238ec | 159 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 160 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 161 | |
| Wolfgang Betz |
34:edda6a7238ec | 162 | |
| Wolfgang Betz |
34:edda6a7238ec | 163 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 164 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 165 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 166 | |
| Wolfgang Betz |
34:edda6a7238ec | 167 | |
| Wolfgang Betz |
34:edda6a7238ec | 168 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 169 | * @defgroup Aes_Exported_Functions AES Exported Functions |
| Wolfgang Betz |
34:edda6a7238ec | 170 | * @{ |
| Wolfgang Betz |
34:edda6a7238ec | 171 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 172 | |
| Wolfgang Betz |
34:edda6a7238ec | 173 | void SpiritAesMode(SpiritFunctionalState xNewState); |
| Wolfgang Betz |
34:edda6a7238ec | 174 | void SpiritAesWriteDataIn(uint8_t* pcBufferDataIn, uint8_t cDataLength); |
| Wolfgang Betz |
34:edda6a7238ec | 175 | void SpiritAesReadDataOut(uint8_t* pcBufferDataOut, uint8_t cDataLength); |
| Wolfgang Betz |
34:edda6a7238ec | 176 | void SpiritAesWriteKey(uint8_t* pcKey); |
| Wolfgang Betz |
34:edda6a7238ec | 177 | void SpiritAesReadKey(uint8_t* pcKey); |
| Wolfgang Betz |
34:edda6a7238ec | 178 | void SpiritAesDeriveDecKeyFromEnc(void); |
| Wolfgang Betz |
34:edda6a7238ec | 179 | void SpiritAesExecuteEncryption(void); |
| Wolfgang Betz |
34:edda6a7238ec | 180 | void SpiritAesExecuteDecryption(void); |
| Wolfgang Betz |
34:edda6a7238ec | 181 | void SpiritAesDeriveDecKeyExecuteDec(void); |
| Wolfgang Betz |
34:edda6a7238ec | 182 | |
| Wolfgang Betz |
34:edda6a7238ec | 183 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 184 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 185 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 186 | |
| Wolfgang Betz |
34:edda6a7238ec | 187 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 188 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 189 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 190 | |
| Wolfgang Betz |
34:edda6a7238ec | 191 | |
| Wolfgang Betz |
34:edda6a7238ec | 192 | /** |
| Wolfgang Betz |
34:edda6a7238ec | 193 | * @} |
| Wolfgang Betz |
34:edda6a7238ec | 194 | */ |
| Wolfgang Betz |
34:edda6a7238ec | 195 | |
| Wolfgang Betz |
34:edda6a7238ec | 196 | |
| Wolfgang Betz |
34:edda6a7238ec | 197 | |
| Wolfgang Betz |
34:edda6a7238ec | 198 | |
| Wolfgang Betz |
34:edda6a7238ec | 199 | #ifdef __cplusplus |
| Wolfgang Betz |
34:edda6a7238ec | 200 | } |
| Wolfgang Betz |
34:edda6a7238ec | 201 | #endif |
| Wolfgang Betz |
34:edda6a7238ec | 202 | |
| Wolfgang Betz |
34:edda6a7238ec | 203 | #endif |
| Wolfgang Betz |
34:edda6a7238ec | 204 | |
| Wolfgang Betz |
34:edda6a7238ec | 205 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |
X-NUCLEO-IDS01A4 Sub-1GHz RF Expansion Board