Fork of my original MQTTGateway

Dependencies:   mbed-http

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPIRIT_Commands.h Source File

SPIRIT_Commands.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003  * @file    SPIRIT_Commands.h
00004   * @author  VMA division - AMS
00005   * @version 3.2.2
00006   * @date    08-July-2015
00007  * @brief   Management of SPIRIT Commands.
00008   *
00009  * @details
00010  *
00011  * In this module can be found all the API used to strobe commands to
00012  * Spirit.
00013  * Every command strobe is an SPI transaction with a specific command code.
00014  *
00015  * <b>Example:</b>
00016  * @code
00017  *   ...
00018  *
00019  *   SpiritCmdStrobeRx();
00020  *
00021  *   ...
00022  * @endcode
00023  *
00024  *
00025   * @attention
00026   *
00027   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00028   *
00029   * Redistribution and use in source and binary forms, with or without modification,
00030   * are permitted provided that the following conditions are met:
00031   *   1. Redistributions of source code must retain the above copyright notice,
00032   *      this list of conditions and the following disclaimer.
00033   *   2. Redistributions in binary form must reproduce the above copyright notice,
00034   *      this list of conditions and the following disclaimer in the documentation
00035   *      and/or other materials provided with the distribution.
00036   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00037   *      may be used to endorse or promote products derived from this software
00038   *      without specific prior written permission.
00039   *
00040   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00041   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00042   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00043   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00044   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00045   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00046   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00047   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00048   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00049   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00050   *
00051   ******************************************************************************
00052  */
00053 
00054 /* Define to prevent recursive inclusion -------------------------------------*/
00055 #ifndef __SPIRIT_COMMANDS_H
00056 #define __SPIRIT_COMMANDS_H
00057 
00058 
00059 /* Includes ------------------------------------------------------------------*/
00060 
00061 #include "SPIRIT_Regs.h"
00062 #include "SPIRIT_Types.h"
00063 
00064 
00065 #ifdef __cplusplus
00066  extern "C" {
00067 #endif
00068 
00069 
00070 /**
00071  * @addtogroup SPIRIT_Libraries
00072  * @{
00073  */
00074 
00075 
00076 /**
00077  * @defgroup SPIRIT_Commands    Commands
00078  * @brief Management of SPIRIT Commands.
00079  * @details See the file <i>@ref SPIRIT_Commands.h</i> for more details.
00080  * @{
00081  */
00082 
00083 /**
00084  * @defgroup Commands_Exported_Types    Commands Exported Types
00085  * @{
00086  */
00087 
00088 /**
00089   * @brief  SPIRIT Commands codes enumeration
00090   */
00091 typedef enum
00092 {
00093   CMD_TX =  COMMAND_TX,                           /*!< Start to transmit; valid only from READY */
00094   CMD_RX =  COMMAND_RX,                           /*!< Start to receive; valid only from READY */
00095   CMD_READY =  COMMAND_READY,                     /*!< Go to READY; valid only from STANDBY or SLEEP or LOCK */
00096   CMD_STANDBY =  COMMAND_STANDBY,                 /*!< Go to STANDBY; valid only from READY */
00097   CMD_SLEEP = COMMAND_SLEEP,                      /*!< Go to SLEEP; valid only from READY */
00098   CMD_LOCKRX = COMMAND_LOCKRX,                    /*!< Go to LOCK state by using the RX configuration of the synth; valid only from READY */
00099   CMD_LOCKTX = COMMAND_LOCKTX,                    /*!< Go to LOCK state by using the TX configuration of the synth; valid only from READY */
00100   CMD_SABORT = COMMAND_SABORT,                    /*!< Force exit form TX or RX states and go to READY state; valid only from TX or RX */
00101   CMD_LDC_RELOAD = COMMAND_LDC_RELOAD,            /*!< LDC Mode: Reload the LDC timer with the value stored in the  LDC_PRESCALER / COUNTER  registers; valid from all states  */
00102   CMD_SEQUENCE_UPDATE =  COMMAND_SEQUENCE_UPDATE, /*!< Autoretransmission: Reload the Packet sequence counter with the value stored in the PROTOCOL[2] register valid from all states */
00103   CMD_AES_ENC = COMMAND_AES_ENC,                  /*!< Commands: Start the encryption routine; valid from all states; valid from all states */
00104   CMD_AES_KEY = COMMAND_AES_KEY,                  /*!< Commands: Start the procedure to compute the key for the decryption; valid from all states */
00105   CMD_AES_DEC = COMMAND_AES_DEC,                  /*!< Commands: Start the decryption routine using the current key; valid from all states */
00106   CMD_AES_KEY_DEC = COMMAND_AES_KEY_DEC,          /*!< Commands: Compute the key and start the decryption; valid from all states */
00107   CMD_SRES = COMMAND_SRES,                        /*!< Reset of all digital part, except SPI registers */
00108   CMD_FLUSHRXFIFO = COMMAND_FLUSHRXFIFO,          /*!< Clean the RX FIFO; valid from all states */
00109   CMD_FLUSHTXFIFO = COMMAND_FLUSHTXFIFO,          /*!< Clean the TX FIFO; valid from all states */
00110 } SpiritCmd;
00111 
00112 #define IS_SPIRIT_CMD(CMD)  (CMD == CMD_TX || \
00113                              CMD == CMD_RX || \
00114                              CMD == CMD_READY || \
00115                              CMD == CMD_STANDBY || \
00116                              CMD == CMD_SLEEP || \
00117                              CMD == CMD_LOCKRX || \
00118                              CMD == CMD_LOCKTX || \
00119                              CMD == CMD_SABORT || \
00120                              CMD == CMD_LDC_RELOAD || \
00121                              CMD == CMD_SEQUENCE_UPDATE || \
00122                              CMD == CMD_AES_ENC || \
00123                              CMD == CMD_AES_KEY || \
00124                              CMD == CMD_AES_DEC || \
00125                              CMD == CMD_AES_KEY_DEC || \
00126                              CMD == CMD_SRES || \
00127                              CMD == CMD_FLUSHRXFIFO || \
00128                              CMD == CMD_FLUSHTXFIFO \
00129                             )
00130 
00131 /**
00132  * @}
00133  */
00134 
00135 
00136 /**
00137  * @defgroup Commands_Exported_Constants        Commands Exported Constants
00138  * @{
00139  */
00140 
00141 
00142 /**
00143  * @}
00144  */
00145 
00146 
00147 /**
00148  * @defgroup Commands_Exported_Macros   Commands Exported Macros
00149  * @{
00150  */
00151 
00152 /**
00153  * @brief  Sends the TX command to SPIRIT. Start to transmit.
00154  * @param  None.
00155  * @retval None.
00156  */
00157 #define SpiritCmdStrobeTx()      {SpiritManagementWaCmdStrobeTx(); \
00158                                   SpiritCmdStrobeCommand(CMD_TX);} 
00159 
00160 
00161 /**
00162  * @brief  Sends the RX command to SPIRIT. Start to receive.
00163  * @param  None.
00164  * @retval None.
00165  */
00166 #define SpiritCmdStrobeRx()      {SpiritManagementWaCmdStrobeRx(); \
00167                                   SpiritCmdStrobeCommand(CMD_RX); \
00168                                   } 
00169 
00170 
00171 /**
00172  * @brief  Sends the Ready state command to SPIRIT. Go to READY.
00173  * @param  None.
00174  * @retval None.
00175  */
00176 #define SpiritCmdStrobeReady()          SpiritCmdStrobeCommand(CMD_READY)
00177 
00178 
00179 
00180 /**
00181  * @brief  Sends the Standby command to SPIRIT. Go to STANDBY.
00182  * @param  None.
00183  * @retval None.
00184  */
00185 #define SpiritCmdStrobeStandby()        SpiritCmdStrobeCommand(CMD_STANDBY)
00186 
00187 
00188 
00189 /**
00190  * @brief  Sends the Sleep command to SPIRIT. Go to SLEEP.
00191  * @param  None.
00192  * @retval None.
00193  */
00194 #define SpiritCmdStrobeSleep()          SpiritCmdStrobeCommand(CMD_SLEEP)
00195 
00196 
00197 
00198 /**
00199  * @brief  Sends the LOCK_RX command to SPIRIT. Go to the LOCK state by using the RX configuration of the synthesizer.
00200  * @param  None.
00201  * @retval None.
00202  */
00203 #define SpiritCmdStrobeLockRx()         SpiritCmdStrobeCommand(CMD_LOCKRX)
00204 
00205 
00206 
00207 /**
00208  * @brief  Sends the LOCK_TX command to SPIRIT. Go to the LOCK state by using the TX configuration of the synthesizer.
00209  * @param  None.
00210  * @retval None.
00211  */
00212 #define SpiritCmdStrobeLockTx()         SpiritCmdStrobeCommand(CMD_LOCKTX)
00213 
00214 
00215 
00216 /**
00217  * @brief  Sends the SABORT command to SPIRIT. Exit from TX or RX states and go to READY state.
00218  * @param  None.
00219  * @retval None.
00220  */
00221 #define SpiritCmdStrobeSabort()         SpiritCmdStrobeCommand(CMD_SABORT)
00222 
00223 
00224 /**
00225  * @brief  Sends the LDC_RELOAD command to SPIRIT. Reload the LDC timer with the value stored in the LDC_PRESCALER / COUNTER registers.
00226  * @param  None.
00227  * @retval None.
00228  */
00229 #define SpiritCmdStrobeLdcReload()      SpiritCmdStrobeCommand(CMD_LDC_RELOAD)
00230 
00231 
00232 
00233 /**
00234  * @brief  Sends the SEQUENCE_UPDATE command to SPIRIT. Reload the Packet sequence counter with the value stored in the PROTOCOL[2] register.
00235  * @param  None.
00236  * @retval None.
00237  */
00238 #define SpiritCmdStrobeSequenceUpdate() SpiritCmdStrobeCommand(CMD_SEQUENCE_UPDATE)
00239 
00240 
00241 
00242 /**
00243  * @brief  Sends the AES_ENC command to SPIRIT. Starts the encryption routine.
00244  * @param  None.
00245  * @retval None.
00246  */
00247 #define SpiritCmdStrobeAesEnc()         SpiritCmdStrobeCommand(CMD_AES_ENC)
00248 
00249 
00250 
00251 /**
00252  * @brief  Sends the AES_KEY command to SPIRIT. Starts the procedure to compute the key for the decryption.
00253  * @param  None.
00254  * @retval None.
00255  */
00256 #define SpiritCmdStrobeAesKey()         SpiritCmdStrobeCommand(CMD_AES_KEY)
00257 
00258 
00259 
00260 /**
00261  * @brief  Sends the AES_DEC command to SPIRIT. Starts the decryption using the current key.
00262  * @param  None.
00263  * @retval None.
00264  */
00265 #define SpiritCmdStrobeAesDec()         SpiritCmdStrobeCommand(CMD_AES_DEC)
00266 
00267 
00268 
00269 /**
00270  * @brief  Sends the KEY_DEC command to SPIRIT. Computes the key derivation and start the decryption.
00271  * @param  None.
00272  * @retval None.
00273  */
00274 #define SpiritCmdStrobeAesKeyDec()     SpiritCmdStrobeCommand(CMD_AES_KEY_DEC)
00275 
00276 /**
00277  * @brief  Sends the SRES command to SPIRIT. Partial reset: all digital circuit will be reset (exception for SPI only).
00278  * @param  None.
00279  * @retval None.
00280  */
00281 #define SpiritCmdStrobeSres()          SpiritCmdStrobeCommand(CMD_SRES)  
00282   
00283 
00284 /**
00285  * @brief  Sends the FLUSHRXFIFO command to SPIRIT. Clean the RX FIFO.
00286  * @param  None.
00287  * @retval None.
00288  */
00289 #define SpiritCmdStrobeFlushRxFifo()    SpiritCmdStrobeCommand(CMD_FLUSHRXFIFO)
00290 
00291 
00292 
00293 /**
00294  * @brief  Sends the FLUSHTXFIFO command to SPIRIT. Clean the TX FIFO.
00295  * @param  None.
00296  * @retval None.
00297  */
00298 #define SpiritCmdStrobeFlushTxFifo()    SpiritCmdStrobeCommand(CMD_FLUSHTXFIFO)
00299 
00300 
00301 
00302 /**
00303  * @}
00304  */
00305 
00306 
00307 /**
00308  * @defgroup Commands_Exported_Functions    Commands Exported Functions
00309  * @{
00310  */
00311 void SpiritCmdStrobeCommand(SpiritCmd xCommandCode);
00312 
00313 
00314 /**
00315  * @}
00316  */
00317 
00318 /**
00319  * @}
00320  */
00321 
00322 
00323 /**
00324  * @}
00325  */
00326 
00327 
00328 
00329 
00330 #ifdef __cplusplus
00331 }
00332 #endif
00333 
00334 #endif
00335 
00336 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/