Easily add all supported connectivity methods to your mbed OS project

Dependencies:   type-yd-driver

Committer:
MACRUM
Date:
Wed Jul 12 10:52:58 2017 +0000
Revision:
0:615f90842ce8
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:615f90842ce8 1 /**
MACRUM 0:615f90842ce8 2 ******************************************************************************
MACRUM 0:615f90842ce8 3 * @file SPIRIT_Types.h
MACRUM 0:615f90842ce8 4 * @author VMA division - AMS
MACRUM 0:615f90842ce8 5 * @version 3.2.2
MACRUM 0:615f90842ce8 6 * @date 08-July-2015
MACRUM 0:615f90842ce8 7 * @brief Header file for SPIRIT types.
MACRUM 0:615f90842ce8 8 * @details
MACRUM 0:615f90842ce8 9 *
MACRUM 0:615f90842ce8 10 * This module provide some types definitions which will be used in
MACRUM 0:615f90842ce8 11 * all the modules of this library. Here is defined also the global
MACRUM 0:615f90842ce8 12 * variable @ref g_xStatus which contains the status of Spirit and
MACRUM 0:615f90842ce8 13 * is updated every time an SPI transaction occurs.
MACRUM 0:615f90842ce8 14 *
MACRUM 0:615f90842ce8 15 * @attention
MACRUM 0:615f90842ce8 16 *
MACRUM 0:615f90842ce8 17 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
MACRUM 0:615f90842ce8 18 *
MACRUM 0:615f90842ce8 19 * Redistribution and use in source and binary forms, with or without modification,
MACRUM 0:615f90842ce8 20 * are permitted provided that the following conditions are met:
MACRUM 0:615f90842ce8 21 * 1. Redistributions of source code must retain the above copyright notice,
MACRUM 0:615f90842ce8 22 * this list of conditions and the following disclaimer.
MACRUM 0:615f90842ce8 23 * 2. Redistributions in binary form must reproduce the above copyright notice,
MACRUM 0:615f90842ce8 24 * this list of conditions and the following disclaimer in the documentation
MACRUM 0:615f90842ce8 25 * and/or other materials provided with the distribution.
MACRUM 0:615f90842ce8 26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
MACRUM 0:615f90842ce8 27 * may be used to endorse or promote products derived from this software
MACRUM 0:615f90842ce8 28 * without specific prior written permission.
MACRUM 0:615f90842ce8 29 *
MACRUM 0:615f90842ce8 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
MACRUM 0:615f90842ce8 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
MACRUM 0:615f90842ce8 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
MACRUM 0:615f90842ce8 33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
MACRUM 0:615f90842ce8 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
MACRUM 0:615f90842ce8 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
MACRUM 0:615f90842ce8 36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
MACRUM 0:615f90842ce8 37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
MACRUM 0:615f90842ce8 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
MACRUM 0:615f90842ce8 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MACRUM 0:615f90842ce8 40 *
MACRUM 0:615f90842ce8 41 ******************************************************************************
MACRUM 0:615f90842ce8 42 */
MACRUM 0:615f90842ce8 43
MACRUM 0:615f90842ce8 44 /* Define to prevent recursive inclusion -------------------------------------*/
MACRUM 0:615f90842ce8 45 #ifndef __SPIRIT_GENERICTYPES_H
MACRUM 0:615f90842ce8 46 #define __SPIRIT_GENERICTYPES_H
MACRUM 0:615f90842ce8 47
MACRUM 0:615f90842ce8 48
MACRUM 0:615f90842ce8 49 /* Includes ------------------------------------------------------------------*/
MACRUM 0:615f90842ce8 50
MACRUM 0:615f90842ce8 51 /* Include all integer types definitions */
MACRUM 0:615f90842ce8 52 #include <stdint.h>
MACRUM 0:615f90842ce8 53 #include <stdio.h>
MACRUM 0:615f90842ce8 54 #include "SPIRIT_Regs.h"
MACRUM 0:615f90842ce8 55
MACRUM 0:615f90842ce8 56
MACRUM 0:615f90842ce8 57
MACRUM 0:615f90842ce8 58 #ifdef __cplusplus
MACRUM 0:615f90842ce8 59 extern "C" {
MACRUM 0:615f90842ce8 60 #endif
MACRUM 0:615f90842ce8 61
MACRUM 0:615f90842ce8 62
MACRUM 0:615f90842ce8 63 /**
MACRUM 0:615f90842ce8 64 * @addtogroup SPIRIT_Libraries
MACRUM 0:615f90842ce8 65 * @{
MACRUM 0:615f90842ce8 66 */
MACRUM 0:615f90842ce8 67
MACRUM 0:615f90842ce8 68
MACRUM 0:615f90842ce8 69 /**
MACRUM 0:615f90842ce8 70 * @defgroup SPIRIT_Types Types
MACRUM 0:615f90842ce8 71 * @brief Module for SPIRIT types definition.
MACRUM 0:615f90842ce8 72 * * @details See the file <i>@ref SPIRIT_Types.h</i> for more details.
MACRUM 0:615f90842ce8 73 * @{
MACRUM 0:615f90842ce8 74 */
MACRUM 0:615f90842ce8 75
MACRUM 0:615f90842ce8 76 /**
MACRUM 0:615f90842ce8 77 * @defgroup Types_Exported_Types Types Exported Types
MACRUM 0:615f90842ce8 78 * @{
MACRUM 0:615f90842ce8 79 */
MACRUM 0:615f90842ce8 80
MACRUM 0:615f90842ce8 81 /**
MACRUM 0:615f90842ce8 82 * @brief Spirit Functional state. Used to enable or disable a specific option.
MACRUM 0:615f90842ce8 83 */
MACRUM 0:615f90842ce8 84 typedef enum
MACRUM 0:615f90842ce8 85 {
MACRUM 0:615f90842ce8 86 S_DISABLE = 0,
MACRUM 0:615f90842ce8 87 S_ENABLE = !S_DISABLE
MACRUM 0:615f90842ce8 88
MACRUM 0:615f90842ce8 89 } SpiritFunctionalState;
MACRUM 0:615f90842ce8 90
MACRUM 0:615f90842ce8 91 #define IS_SPIRIT_FUNCTIONAL_STATE(STATE) (STATE == S_DISABLE || STATE == S_ENABLE)
MACRUM 0:615f90842ce8 92
MACRUM 0:615f90842ce8 93 /**
MACRUM 0:615f90842ce8 94 * @brief Spirit Flag status. Used to control the state of a flag.
MACRUM 0:615f90842ce8 95 */
MACRUM 0:615f90842ce8 96 typedef enum
MACRUM 0:615f90842ce8 97 {
MACRUM 0:615f90842ce8 98 S_RESET = 0,
MACRUM 0:615f90842ce8 99 S_SET = !S_RESET
MACRUM 0:615f90842ce8 100
MACRUM 0:615f90842ce8 101 } SpiritFlagStatus;
MACRUM 0:615f90842ce8 102
MACRUM 0:615f90842ce8 103 #define IS_SPIRIT_FLAG_STATUS(STATUS) (STATUS == S_RESET || STATUS == S_SET)
MACRUM 0:615f90842ce8 104
MACRUM 0:615f90842ce8 105
MACRUM 0:615f90842ce8 106 /**
MACRUM 0:615f90842ce8 107 * @brief boolean type enumeration.
MACRUM 0:615f90842ce8 108 */
MACRUM 0:615f90842ce8 109 typedef enum
MACRUM 0:615f90842ce8 110 {
MACRUM 0:615f90842ce8 111 S_FALSE = 0,
MACRUM 0:615f90842ce8 112 S_TRUE = !S_FALSE
MACRUM 0:615f90842ce8 113
MACRUM 0:615f90842ce8 114 } SpiritBool;
MACRUM 0:615f90842ce8 115
MACRUM 0:615f90842ce8 116
MACRUM 0:615f90842ce8 117 /**
MACRUM 0:615f90842ce8 118 * @brief SPIRIT States enumeration.
MACRUM 0:615f90842ce8 119 */
MACRUM 0:615f90842ce8 120 typedef enum
MACRUM 0:615f90842ce8 121 {
MACRUM 0:615f90842ce8 122 MC_STATE_STANDBY =0x40, /*!< STANDBY */
MACRUM 0:615f90842ce8 123 MC_STATE_SLEEP =0x36, /*!< SLEEP */
MACRUM 0:615f90842ce8 124 MC_STATE_READY =0x03, /*!< READY */
MACRUM 0:615f90842ce8 125 MC_STATE_PM_SETUP =0x3D, /*!< PM_SETUP */
MACRUM 0:615f90842ce8 126 MC_STATE_XO_SETTLING =0x23, /*!< XO_SETTLING */
MACRUM 0:615f90842ce8 127 MC_STATE_SYNTH_SETUP =0x53, /*!< SYNT_SETUP */
MACRUM 0:615f90842ce8 128 MC_STATE_PROTOCOL =0x1F, /*!< PROTOCOL */
MACRUM 0:615f90842ce8 129 MC_STATE_SYNTH_CALIBRATION =0x4F, /*!< SYNTH */
MACRUM 0:615f90842ce8 130 MC_STATE_LOCK =0x0F, /*!< LOCK */
MACRUM 0:615f90842ce8 131 MC_STATE_RX =0x33, /*!< RX */
MACRUM 0:615f90842ce8 132 MC_STATE_TX =0x5F /*!< TX */
MACRUM 0:615f90842ce8 133
MACRUM 0:615f90842ce8 134 } SpiritState;
MACRUM 0:615f90842ce8 135
MACRUM 0:615f90842ce8 136
MACRUM 0:615f90842ce8 137
MACRUM 0:615f90842ce8 138 /**
MACRUM 0:615f90842ce8 139 * @brief SPIRIT Status. This definition represents the single field of the SPIRIT
MACRUM 0:615f90842ce8 140 * status returned on each SPI transaction, equal also to the MC_STATE registers.
MACRUM 0:615f90842ce8 141 * This field-oriented structure allows user to address in simple way the single
MACRUM 0:615f90842ce8 142 * field of the SPIRIT status.
MACRUM 0:615f90842ce8 143 * The user shall define a variable of SpiritStatus type to access on SPIRIT status fields.
MACRUM 0:615f90842ce8 144 * @note The fields order in the structure depends on used endianness (little or big
MACRUM 0:615f90842ce8 145 * endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to
MACRUM 0:615f90842ce8 146 * change opportunely the fields order when use a different endianness.
MACRUM 0:615f90842ce8 147 */
MACRUM 0:615f90842ce8 148
MACRUM 0:615f90842ce8 149 typedef struct
MACRUM 0:615f90842ce8 150 {
MACRUM 0:615f90842ce8 151 uint8_t XO_ON:1; /*!< This one bit field notifies if XO is operating
MACRUM 0:615f90842ce8 152 (XO_ON is 1) or not (XO_On is 0) */
MACRUM 0:615f90842ce8 153 SpiritState MC_STATE: 7; /*!< This 7 bits field indicates the state of the
MACRUM 0:615f90842ce8 154 Main Controller of SPIRIT. The possible states
MACRUM 0:615f90842ce8 155 and their corresponding values are defined in
MACRUM 0:615f90842ce8 156 @ref SpiritState */
MACRUM 0:615f90842ce8 157 uint8_t ERROR_LOCK: 1; /*!< This one bit field notifies if there is an
MACRUM 0:615f90842ce8 158 error on RCO calibration (ERROR_LOCK is 1) or
MACRUM 0:615f90842ce8 159 not (ERROR_LOCK is 0) */
MACRUM 0:615f90842ce8 160 uint8_t RX_FIFO_EMPTY: 1; /*!< This one bit field notifies if RX FIFO is empty
MACRUM 0:615f90842ce8 161 (RX_FIFO_EMPTY is 1) or not (RX_FIFO_EMPTY is 0) */
MACRUM 0:615f90842ce8 162 uint8_t TX_FIFO_FULL: 1; /*!< This one bit field notifies if TX FIFO is full
MACRUM 0:615f90842ce8 163 (TX_FIFO_FULL is 1) or not (TX_FIFO_FULL is 0) */
MACRUM 0:615f90842ce8 164 uint8_t ANT_SELECT: 1; /*!< This one bit field notifies the currently selected
MACRUM 0:615f90842ce8 165 antenna */
MACRUM 0:615f90842ce8 166 uint8_t : 4; /*!< This 4 bits field are reserved and equal to 5 */
MACRUM 0:615f90842ce8 167
MACRUM 0:615f90842ce8 168 }SpiritStatus;
MACRUM 0:615f90842ce8 169
MACRUM 0:615f90842ce8 170
MACRUM 0:615f90842ce8 171
MACRUM 0:615f90842ce8 172 /**
MACRUM 0:615f90842ce8 173 * @}
MACRUM 0:615f90842ce8 174 */
MACRUM 0:615f90842ce8 175
MACRUM 0:615f90842ce8 176
MACRUM 0:615f90842ce8 177 /**
MACRUM 0:615f90842ce8 178 * @defgroup Types_Exported_Constants Types Exported Constants
MACRUM 0:615f90842ce8 179 * @{
MACRUM 0:615f90842ce8 180 */
MACRUM 0:615f90842ce8 181
MACRUM 0:615f90842ce8 182
MACRUM 0:615f90842ce8 183 /**
MACRUM 0:615f90842ce8 184 * @}
MACRUM 0:615f90842ce8 185 */
MACRUM 0:615f90842ce8 186
MACRUM 0:615f90842ce8 187 /**
MACRUM 0:615f90842ce8 188 * @defgroup Types_Exported_Variables Types Exported Variables
MACRUM 0:615f90842ce8 189 * @{
MACRUM 0:615f90842ce8 190 */
MACRUM 0:615f90842ce8 191
MACRUM 0:615f90842ce8 192 extern volatile SpiritStatus g_xStatus;
MACRUM 0:615f90842ce8 193
MACRUM 0:615f90842ce8 194 /**
MACRUM 0:615f90842ce8 195 * @}
MACRUM 0:615f90842ce8 196 */
MACRUM 0:615f90842ce8 197
MACRUM 0:615f90842ce8 198 /**
MACRUM 0:615f90842ce8 199 * @defgroup Types_Exported_Macros Types Exported Macros
MACRUM 0:615f90842ce8 200 * @{
MACRUM 0:615f90842ce8 201 */
MACRUM 0:615f90842ce8 202
MACRUM 0:615f90842ce8 203 #ifdef SPIRIT_USE_FULL_ASSERT
MACRUM 0:615f90842ce8 204 /**
MACRUM 0:615f90842ce8 205 * @brief The s_assert_param macro is used for function's parameters check.
MACRUM 0:615f90842ce8 206 * @param expr If expr is false, it calls assert_failed function which reports
MACRUM 0:615f90842ce8 207 * the name of the source file and the source line number of the call
MACRUM 0:615f90842ce8 208 * that failed. If expr is true, it returns no value.
MACRUM 0:615f90842ce8 209 * @retval None
MACRUM 0:615f90842ce8 210 */
MACRUM 0:615f90842ce8 211 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__))
MACRUM 0:615f90842ce8 212 void s_assert_failed(uint8_t* file, uint32_t line);
MACRUM 0:615f90842ce8 213 #elif SPIRIT_USE_VCOM_ASSERT
MACRUM 0:615f90842ce8 214 /**
MACRUM 0:615f90842ce8 215 * @brief The s_assert_param macro is used for function's parameters check.
MACRUM 0:615f90842ce8 216 * @param expr If expr is false, it calls assert_failed function which reports
MACRUM 0:615f90842ce8 217 * the name of the source file and the source line number of the call
MACRUM 0:615f90842ce8 218 * that failed. If expr is true, it returns no value.
MACRUM 0:615f90842ce8 219 * @retval None
MACRUM 0:615f90842ce8 220 */
MACRUM 0:615f90842ce8 221 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed((uint8_t *)__FILE__, __LINE__,#expr))
MACRUM 0:615f90842ce8 222 void s_assert_failed(uint8_t* file, uint32_t line, char* expression);
MACRUM 0:615f90842ce8 223
MACRUM 0:615f90842ce8 224 #elif SPIRIT_USE_FRAME_ASSERT
MACRUM 0:615f90842ce8 225 /**
MACRUM 0:615f90842ce8 226 * @brief The s_assert_param macro is used for function's parameters check.
MACRUM 0:615f90842ce8 227 * @param expr If expr is false, it calls assert_failed function which reports
MACRUM 0:615f90842ce8 228 * the name of the source file and the source line number of the call
MACRUM 0:615f90842ce8 229 * that failed. If expr is true, it returns no value.
MACRUM 0:615f90842ce8 230 * @retval None
MACRUM 0:615f90842ce8 231 */
MACRUM 0:615f90842ce8 232 #define s_assert_param(expr) ((expr) ? (void)0 : s_assert_failed(#expr))
MACRUM 0:615f90842ce8 233 void s_assert_failed(char* expression);
MACRUM 0:615f90842ce8 234 #else
MACRUM 0:615f90842ce8 235 #define s_assert_param(expr) {}
MACRUM 0:615f90842ce8 236 #endif
MACRUM 0:615f90842ce8 237
MACRUM 0:615f90842ce8 238 /**
MACRUM 0:615f90842ce8 239 * @brief Returns the absolute value.
MACRUM 0:615f90842ce8 240 */
MACRUM 0:615f90842ce8 241 #define S_ABS(a) ((a)>0?(a):-(a))
MACRUM 0:615f90842ce8 242
MACRUM 0:615f90842ce8 243
MACRUM 0:615f90842ce8 244 /**
MACRUM 0:615f90842ce8 245 * @}
MACRUM 0:615f90842ce8 246 */
MACRUM 0:615f90842ce8 247
MACRUM 0:615f90842ce8 248
MACRUM 0:615f90842ce8 249 /**
MACRUM 0:615f90842ce8 250 * @defgroup Types_Exported_Functions Types Exported Functions
MACRUM 0:615f90842ce8 251 * @{
MACRUM 0:615f90842ce8 252 */
MACRUM 0:615f90842ce8 253
MACRUM 0:615f90842ce8 254 void SpiritRefreshStatus(void);
MACRUM 0:615f90842ce8 255
MACRUM 0:615f90842ce8 256 /**
MACRUM 0:615f90842ce8 257 *@}
MACRUM 0:615f90842ce8 258 */
MACRUM 0:615f90842ce8 259
MACRUM 0:615f90842ce8 260 /**
MACRUM 0:615f90842ce8 261 * @}
MACRUM 0:615f90842ce8 262 */
MACRUM 0:615f90842ce8 263
MACRUM 0:615f90842ce8 264
MACRUM 0:615f90842ce8 265 /**
MACRUM 0:615f90842ce8 266 * @}
MACRUM 0:615f90842ce8 267 */
MACRUM 0:615f90842ce8 268
MACRUM 0:615f90842ce8 269
MACRUM 0:615f90842ce8 270 #ifdef __cplusplus
MACRUM 0:615f90842ce8 271 }
MACRUM 0:615f90842ce8 272 #endif
MACRUM 0:615f90842ce8 273
MACRUM 0:615f90842ce8 274 #endif
MACRUM 0:615f90842ce8 275
MACRUM 0:615f90842ce8 276 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/