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_DirectRF.c
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 Configuration and management of SPIRIT direct transmission / receive modes.
MACRUM 0:615f90842ce8 8 * @details
MACRUM 0:615f90842ce8 9 * @attention
MACRUM 0:615f90842ce8 10 *
MACRUM 0:615f90842ce8 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
MACRUM 0:615f90842ce8 12 *
MACRUM 0:615f90842ce8 13 * Redistribution and use in source and binary forms, with or without modification,
MACRUM 0:615f90842ce8 14 * are permitted provided that the following conditions are met:
MACRUM 0:615f90842ce8 15 * 1. Redistributions of source code must retain the above copyright notice,
MACRUM 0:615f90842ce8 16 * this list of conditions and the following disclaimer.
MACRUM 0:615f90842ce8 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
MACRUM 0:615f90842ce8 18 * this list of conditions and the following disclaimer in the documentation
MACRUM 0:615f90842ce8 19 * and/or other materials provided with the distribution.
MACRUM 0:615f90842ce8 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
MACRUM 0:615f90842ce8 21 * may be used to endorse or promote products derived from this software
MACRUM 0:615f90842ce8 22 * without specific prior written permission.
MACRUM 0:615f90842ce8 23 *
MACRUM 0:615f90842ce8 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
MACRUM 0:615f90842ce8 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
MACRUM 0:615f90842ce8 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
MACRUM 0:615f90842ce8 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
MACRUM 0:615f90842ce8 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
MACRUM 0:615f90842ce8 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
MACRUM 0:615f90842ce8 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
MACRUM 0:615f90842ce8 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
MACRUM 0:615f90842ce8 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
MACRUM 0:615f90842ce8 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MACRUM 0:615f90842ce8 34 *
MACRUM 0:615f90842ce8 35 ******************************************************************************
MACRUM 0:615f90842ce8 36 */
MACRUM 0:615f90842ce8 37
MACRUM 0:615f90842ce8 38 /* Includes ------------------------------------------------------------------*/
MACRUM 0:615f90842ce8 39 #include "SPIRIT_DirectRF.h"
MACRUM 0:615f90842ce8 40 #include "MCU_Interface.h"
MACRUM 0:615f90842ce8 41
MACRUM 0:615f90842ce8 42
MACRUM 0:615f90842ce8 43
MACRUM 0:615f90842ce8 44 /**
MACRUM 0:615f90842ce8 45 * @addtogroup SPIRIT_Libraries
MACRUM 0:615f90842ce8 46 * @{
MACRUM 0:615f90842ce8 47 */
MACRUM 0:615f90842ce8 48
MACRUM 0:615f90842ce8 49
MACRUM 0:615f90842ce8 50 /**
MACRUM 0:615f90842ce8 51 * @addtogroup SPIRIT_DirectRf
MACRUM 0:615f90842ce8 52 * @{
MACRUM 0:615f90842ce8 53 */
MACRUM 0:615f90842ce8 54
MACRUM 0:615f90842ce8 55
MACRUM 0:615f90842ce8 56 /**
MACRUM 0:615f90842ce8 57 * @defgroup DirectRf_Private_TypesDefinitions Direct RF Private Types Definitions
MACRUM 0:615f90842ce8 58 * @{
MACRUM 0:615f90842ce8 59 */
MACRUM 0:615f90842ce8 60
MACRUM 0:615f90842ce8 61 /**
MACRUM 0:615f90842ce8 62 *@}
MACRUM 0:615f90842ce8 63 */
MACRUM 0:615f90842ce8 64
MACRUM 0:615f90842ce8 65
MACRUM 0:615f90842ce8 66 /**
MACRUM 0:615f90842ce8 67 * @defgroup DirectRf_Private_Defines Direct RF Private Defines
MACRUM 0:615f90842ce8 68 * @{
MACRUM 0:615f90842ce8 69 */
MACRUM 0:615f90842ce8 70
MACRUM 0:615f90842ce8 71 /**
MACRUM 0:615f90842ce8 72 *@}
MACRUM 0:615f90842ce8 73 */
MACRUM 0:615f90842ce8 74
MACRUM 0:615f90842ce8 75
MACRUM 0:615f90842ce8 76 /**
MACRUM 0:615f90842ce8 77 * @defgroup DirectRf_Private_Macros Direct RF Private Macros
MACRUM 0:615f90842ce8 78 * @{
MACRUM 0:615f90842ce8 79 */
MACRUM 0:615f90842ce8 80
MACRUM 0:615f90842ce8 81 /**
MACRUM 0:615f90842ce8 82 *@}
MACRUM 0:615f90842ce8 83 */
MACRUM 0:615f90842ce8 84
MACRUM 0:615f90842ce8 85
MACRUM 0:615f90842ce8 86 /**
MACRUM 0:615f90842ce8 87 * @defgroup DirectRf_Private_Variables Direct RF Private Variables
MACRUM 0:615f90842ce8 88 * @{
MACRUM 0:615f90842ce8 89 */
MACRUM 0:615f90842ce8 90
MACRUM 0:615f90842ce8 91 /**
MACRUM 0:615f90842ce8 92 *@}
MACRUM 0:615f90842ce8 93 */
MACRUM 0:615f90842ce8 94
MACRUM 0:615f90842ce8 95
MACRUM 0:615f90842ce8 96
MACRUM 0:615f90842ce8 97 /**
MACRUM 0:615f90842ce8 98 * @defgroup DirectRf_Private_FunctionPrototypes Direct RF Private Function Prototypes
MACRUM 0:615f90842ce8 99 * @{
MACRUM 0:615f90842ce8 100 */
MACRUM 0:615f90842ce8 101
MACRUM 0:615f90842ce8 102 /**
MACRUM 0:615f90842ce8 103 *@}
MACRUM 0:615f90842ce8 104 */
MACRUM 0:615f90842ce8 105
MACRUM 0:615f90842ce8 106
MACRUM 0:615f90842ce8 107 /**
MACRUM 0:615f90842ce8 108 * @defgroup DirectRf_Private_Functions Direct RF Private Functions
MACRUM 0:615f90842ce8 109 * @{
MACRUM 0:615f90842ce8 110 */
MACRUM 0:615f90842ce8 111
MACRUM 0:615f90842ce8 112 /**
MACRUM 0:615f90842ce8 113 * @brief Sets the DirectRF RX mode of SPIRIT.
MACRUM 0:615f90842ce8 114 * @param xDirectRx code of the desired mode.
MACRUM 0:615f90842ce8 115 * This parameter can be any value of @ref DirectRx.
MACRUM 0:615f90842ce8 116 * @retval None.
MACRUM 0:615f90842ce8 117 */
MACRUM 0:615f90842ce8 118 void SpiritDirectRfSetRxMode(DirectRx xDirectRx)
MACRUM 0:615f90842ce8 119 {
MACRUM 0:615f90842ce8 120 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 121
MACRUM 0:615f90842ce8 122 /* Check the parameters */
MACRUM 0:615f90842ce8 123 s_assert_param(IS_DIRECT_RX(xDirectRx));
MACRUM 0:615f90842ce8 124
MACRUM 0:615f90842ce8 125 /* Reads the register value */
MACRUM 0:615f90842ce8 126 SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 127
MACRUM 0:615f90842ce8 128 /* Build the value to be stored */
MACRUM 0:615f90842ce8 129 tempRegValue &= ~PCKTCTRL3_RX_MODE_MASK;
MACRUM 0:615f90842ce8 130 tempRegValue |= (uint8_t)xDirectRx;
MACRUM 0:615f90842ce8 131
MACRUM 0:615f90842ce8 132 /* Writes value on register */
MACRUM 0:615f90842ce8 133 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 134
MACRUM 0:615f90842ce8 135 }
MACRUM 0:615f90842ce8 136
MACRUM 0:615f90842ce8 137
MACRUM 0:615f90842ce8 138 /**
MACRUM 0:615f90842ce8 139 * @brief Returns the DirectRF RX mode of SPIRIT.
MACRUM 0:615f90842ce8 140 * @param None.
MACRUM 0:615f90842ce8 141 * @retval DirectRx Direct Rx mode.
MACRUM 0:615f90842ce8 142 */
MACRUM 0:615f90842ce8 143 DirectRx SpiritDirectRfGetRxMode(void)
MACRUM 0:615f90842ce8 144 {
MACRUM 0:615f90842ce8 145 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 146
MACRUM 0:615f90842ce8 147 /* Reads the register value and mask the RX_Mode field */
MACRUM 0:615f90842ce8 148 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 149
MACRUM 0:615f90842ce8 150 /* Rebuild and return value */
MACRUM 0:615f90842ce8 151 return (DirectRx)(tempRegValue & 0x30);
MACRUM 0:615f90842ce8 152
MACRUM 0:615f90842ce8 153 }
MACRUM 0:615f90842ce8 154
MACRUM 0:615f90842ce8 155
MACRUM 0:615f90842ce8 156 /**
MACRUM 0:615f90842ce8 157 * @brief Sets the TX mode of SPIRIT.
MACRUM 0:615f90842ce8 158 * @param xDirectTx code of the desired source.
MACRUM 0:615f90842ce8 159 * This parameter can be any value of @ref DirectTx.
MACRUM 0:615f90842ce8 160 * @retval None.
MACRUM 0:615f90842ce8 161 */
MACRUM 0:615f90842ce8 162 void SpiritDirectRfSetTxMode(DirectTx xDirectTx)
MACRUM 0:615f90842ce8 163 {
MACRUM 0:615f90842ce8 164 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 165
MACRUM 0:615f90842ce8 166 /* Check the parameters */
MACRUM 0:615f90842ce8 167 s_assert_param(IS_DIRECT_TX(xDirectTx));
MACRUM 0:615f90842ce8 168
MACRUM 0:615f90842ce8 169 /* Reads the register value */
MACRUM 0:615f90842ce8 170 SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 171
MACRUM 0:615f90842ce8 172 /* Build the value to be stored */
MACRUM 0:615f90842ce8 173 tempRegValue &= ~PCKTCTRL1_TX_SOURCE_MASK;
MACRUM 0:615f90842ce8 174 tempRegValue |= (uint8_t)xDirectTx;
MACRUM 0:615f90842ce8 175
MACRUM 0:615f90842ce8 176 /* Writes value on register */
MACRUM 0:615f90842ce8 177 g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 178
MACRUM 0:615f90842ce8 179 }
MACRUM 0:615f90842ce8 180
MACRUM 0:615f90842ce8 181
MACRUM 0:615f90842ce8 182 /**
MACRUM 0:615f90842ce8 183 * @brief Returns the DirectRF TX mode of SPIRIT.
MACRUM 0:615f90842ce8 184 * @param None.
MACRUM 0:615f90842ce8 185 * @retval DirectTx Direct Tx mode.
MACRUM 0:615f90842ce8 186 */
MACRUM 0:615f90842ce8 187 DirectTx SpiritDirectRfGetTxMode(void)
MACRUM 0:615f90842ce8 188 {
MACRUM 0:615f90842ce8 189 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 190
MACRUM 0:615f90842ce8 191 /* Reads the register value and mask the RX_Mode field */
MACRUM 0:615f90842ce8 192 g_xStatus = SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 193
MACRUM 0:615f90842ce8 194 /* Returns value */
MACRUM 0:615f90842ce8 195 return (DirectTx)(tempRegValue & 0x0C);
MACRUM 0:615f90842ce8 196
MACRUM 0:615f90842ce8 197 }
MACRUM 0:615f90842ce8 198
MACRUM 0:615f90842ce8 199
MACRUM 0:615f90842ce8 200 /**
MACRUM 0:615f90842ce8 201 *@}
MACRUM 0:615f90842ce8 202 */
MACRUM 0:615f90842ce8 203
MACRUM 0:615f90842ce8 204 /**
MACRUM 0:615f90842ce8 205 *@}
MACRUM 0:615f90842ce8 206 */
MACRUM 0:615f90842ce8 207
MACRUM 0:615f90842ce8 208
MACRUM 0:615f90842ce8 209 /**
MACRUM 0:615f90842ce8 210 *@}
MACRUM 0:615f90842ce8 211 */
MACRUM 0:615f90842ce8 212
MACRUM 0:615f90842ce8 213
MACRUM 0:615f90842ce8 214
MACRUM 0:615f90842ce8 215 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/