Added support for the WNC M14A2A Cellular LTE Data Module.

Dependencies:   WNC14A2AInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPIRIT_Types.h Source File

SPIRIT_Types.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003  * @file    SPIRIT_Types.h
00004   * @author  VMA division - AMS
00005   * @version 3.2.2
00006   * @date    08-July-2015
00007  * @brief   Header file for SPIRIT types.
00008  * @details
00009  *
00010  * This module provide some types definitions which will be used in
00011  * all the modules of this library. Here is defined also the global
00012  * variable @ref g_xStatus which contains the status of Spirit and
00013  * is updated every time an SPI transaction occurs.
00014  *
00015   * @attention
00016  *
00017   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00018   *
00019   * Redistribution and use in source and binary forms, with or without modification,
00020   * are permitted provided that the following conditions are met:
00021   *   1. Redistributions of source code must retain the above copyright notice,
00022   *      this list of conditions and the following disclaimer.
00023   *   2. Redistributions in binary form must reproduce the above copyright notice,
00024   *      this list of conditions and the following disclaimer in the documentation
00025   *      and/or other materials provided with the distribution.
00026   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00027   *      may be used to endorse or promote products derived from this software
00028   *      without specific prior written permission.
00029   *
00030   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00031   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00032   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00033   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00034   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00035   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00036   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00037   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00038   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00039   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00040   *
00041   ******************************************************************************
00042  */
00043 
00044 /* Define to prevent recursive inclusion -------------------------------------*/
00045 #ifndef __SPIRIT_GENERICTYPES_H
00046 #define __SPIRIT_GENERICTYPES_H
00047 
00048 
00049 /* Includes ------------------------------------------------------------------*/
00050 
00051 /* Include all integer types definitions */
00052 #include <stdint.h>
00053 #include <stdio.h>
00054 #include "SPIRIT_Regs.h"
00055 
00056 
00057 
00058 #ifdef __cplusplus
00059  extern "C" {
00060 #endif
00061 
00062 
00063 /**
00064  * @addtogroup SPIRIT_Libraries
00065  * @{
00066  */
00067 
00068 
00069 /**
00070  * @defgroup SPIRIT_Types       Types
00071  * @brief Module for SPIRIT types definition.
00072  * * @details See the file <i>@ref SPIRIT_Types.h</i> for more details.
00073  * @{
00074  */
00075 
00076 /**
00077  * @defgroup Types_Exported_Types       Types Exported Types
00078  * @{
00079  */
00080 
00081 /**
00082  * @brief  Spirit Functional state. Used to enable or disable a specific option.
00083  */
00084 typedef enum
00085 {
00086   S_DISABLE = 0,
00087   S_ENABLE = !S_DISABLE
00088 
00089 } SpiritFunctionalState;
00090 
00091 #define IS_SPIRIT_FUNCTIONAL_STATE(STATE)   (STATE == S_DISABLE || STATE == S_ENABLE)
00092 
00093 /**
00094  * @brief  Spirit Flag status. Used to control the state of a flag.
00095  */
00096 typedef enum
00097 {
00098   S_RESET = 0,
00099   S_SET = !S_RESET
00100 
00101 } SpiritFlagStatus;
00102 
00103 #define IS_SPIRIT_FLAG_STATUS(STATUS)   (STATUS == S_RESET || STATUS == S_SET)
00104 
00105 
00106 /**
00107  * @brief  boolean type enumeration.
00108  */
00109 typedef enum
00110 {
00111   S_FALSE = 0,
00112   S_TRUE  = !S_FALSE
00113 
00114 } SpiritBool;
00115 
00116 
00117 /**
00118  * @brief  SPIRIT States enumeration.
00119  */
00120 typedef enum
00121 {
00122   MC_STATE_STANDBY           =0x40, /*!< STANDBY */
00123   MC_STATE_SLEEP             =0x36, /*!< SLEEP */
00124   MC_STATE_READY             =0x03, /*!< READY */
00125   MC_STATE_PM_SETUP          =0x3D, /*!< PM_SETUP */
00126   MC_STATE_XO_SETTLING       =0x23, /*!< XO_SETTLING */
00127   MC_STATE_SYNTH_SETUP       =0x53, /*!< SYNT_SETUP */
00128   MC_STATE_PROTOCOL          =0x1F, /*!< PROTOCOL */
00129   MC_STATE_SYNTH_CALIBRATION =0x4F, /*!< SYNTH */
00130   MC_STATE_LOCK              =0x0F, /*!< LOCK */
00131   MC_STATE_RX                =0x33, /*!< RX */
00132   MC_STATE_TX                =0x5F  /*!< TX */
00133 
00134 } SpiritState;
00135 
00136 
00137 
00138 /**
00139  * @brief SPIRIT Status. This definition represents the single field of the SPIRIT
00140  *        status returned on each SPI transaction, equal also to the MC_STATE registers.
00141  *        This field-oriented structure allows user to address in simple way the single
00142  *        field of the SPIRIT status.
00143  *        The user shall define a variable of SpiritStatus type to access on SPIRIT status fields.
00144  * @note  The fields order in the structure depends on used endianness (little or big
00145  *        endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to
00146  *        change opportunely the fields order when use a different endianness.
00147  */
00148 
00149 typedef struct
00150 {
00151   uint8_t XO_ON:1;      /*!< This one bit field notifies if XO is operating
00152                      (XO_ON is 1) or not (XO_On is 0) */
00153   SpiritState MC_STATE: 7;  /*!< This 7 bits field indicates the state of the
00154                      Main Controller of SPIRIT. The possible states
00155                      and their corresponding values are defined in
00156                      @ref SpiritState */
00157   uint8_t ERROR_LOCK: 1;       /*!< This one bit field notifies if there is an
00158                      error on RCO calibration (ERROR_LOCK is 1) or
00159                      not (ERROR_LOCK is 0) */
00160   uint8_t RX_FIFO_EMPTY: 1;    /*!< This one bit field notifies if RX FIFO is empty
00161                      (RX_FIFO_EMPTY is 1) or not (RX_FIFO_EMPTY is 0) */
00162   uint8_t TX_FIFO_FULL: 1;  /*!< This one bit field notifies if TX FIFO is full
00163                      (TX_FIFO_FULL is 1) or not (TX_FIFO_FULL is 0) */
00164   uint8_t ANT_SELECT: 1;       /*!< This one bit field notifies the currently selected
00165                      antenna */
00166   uint8_t : 4;          /*!< This 4 bits field are reserved and equal to 5 */
00167 
00168 }SpiritStatus;
00169 
00170 
00171 
00172 /**
00173  * @}
00174  */
00175 
00176 
00177 /**
00178  * @defgroup Types_Exported_Constants   Types Exported Constants
00179  * @{
00180  */
00181 
00182 
00183 /**
00184  * @}
00185  */
00186 
00187 /**
00188  * @defgroup Types_Exported_Variables   Types Exported Variables
00189  * @{
00190  */
00191 
00192 extern volatile SpiritStatus g_xStatus;
00193 
00194 /**
00195  * @}
00196  */
00197 
00198 /**
00199  * @defgroup Types_Exported_Macros              Types Exported Macros
00200  * @{
00201  */
00202 
00203 #ifdef  SPIRIT_USE_FULL_ASSERT
00204  /**
00205    * @brief  The s_assert_param macro is used for function's parameters check.
00206    * @param  expr If expr is false, it calls assert_failed function which reports
00207    *         the name of the source file and the source line number of the call
00208    *         that failed. If expr is true, it returns no value.
00209    * @retval None
00210    */
00211   #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__))
00212   void s_assert_failed(uint8_t* file, uint32_t line);
00213 #elif  SPIRIT_USE_VCOM_ASSERT
00214   /**
00215    * @brief  The s_assert_param macro is used for function's parameters check.
00216    * @param  expr  If expr is false, it calls assert_failed function which reports
00217    *         the name of the source file and the source line number of the call
00218    *         that failed. If expr is true, it returns no value.
00219    * @retval None
00220    */
00221   #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__,#expr))
00222   void s_assert_failed(uint8_t* file, uint32_t line, char* expression);
00223 
00224 #elif SPIRIT_USE_FRAME_ASSERT
00225    /**
00226    * @brief  The s_assert_param macro is used for function's parameters check.
00227    * @param  expr  If expr is false, it calls assert_failed function which reports
00228    *         the name of the source file and the source line number of the call
00229    *         that failed. If expr is true, it returns no value.
00230    * @retval None
00231    */
00232 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed(#expr))
00233   void s_assert_failed(char* expression);
00234 #else
00235 #define s_assert_param(expr)        {}
00236 #endif
00237 
00238 /**
00239  * @brief  Returns the absolute value.
00240  */
00241 #define S_ABS(a) ((a)>0?(a):-(a))
00242 
00243 
00244 /**
00245  * @}
00246  */
00247 
00248 
00249 /**
00250  * @defgroup Types_Exported_Functions   Types Exported Functions
00251  * @{
00252  */
00253 
00254 void SpiritRefreshStatus(void);
00255 
00256 /**
00257  *@}
00258  */
00259 
00260 /**
00261  * @}
00262  */
00263 
00264 
00265 /**
00266  * @}
00267  */
00268 
00269 
00270 #ifdef __cplusplus
00271 }
00272 #endif
00273 
00274 #endif
00275 
00276 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/