Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /***************************************************************************//**
sahilmgandhi 18:6a4db94011d3 2 * @file pa.h
sahilmgandhi 18:6a4db94011d3 3 * @brief RADIO PA API
sahilmgandhi 18:6a4db94011d3 4 *******************************************************************************
sahilmgandhi 18:6a4db94011d3 5 * @section License
sahilmgandhi 18:6a4db94011d3 6 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
sahilmgandhi 18:6a4db94011d3 7 *******************************************************************************
sahilmgandhi 18:6a4db94011d3 8 *
sahilmgandhi 18:6a4db94011d3 9 * Permission is granted to anyone to use this software for any purpose,
sahilmgandhi 18:6a4db94011d3 10 * including commercial applications, and to alter it and redistribute it
sahilmgandhi 18:6a4db94011d3 11 * freely, subject to the following restrictions:
sahilmgandhi 18:6a4db94011d3 12 *
sahilmgandhi 18:6a4db94011d3 13 * 1. The origin of this software must not be misrepresented; you must not
sahilmgandhi 18:6a4db94011d3 14 * claim that you wrote the original software.
sahilmgandhi 18:6a4db94011d3 15 * 2. Altered source versions must be plainly marked as such, and must not be
sahilmgandhi 18:6a4db94011d3 16 * misrepresented as being the original software.
sahilmgandhi 18:6a4db94011d3 17 * 3. This notice may not be removed or altered from any source distribution.
sahilmgandhi 18:6a4db94011d3 18 *
sahilmgandhi 18:6a4db94011d3 19 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
sahilmgandhi 18:6a4db94011d3 20 * obligation to support this Software. Silicon Labs is providing the
sahilmgandhi 18:6a4db94011d3 21 * Software "AS IS", with no express or implied warranties of any kind,
sahilmgandhi 18:6a4db94011d3 22 * including, but not limited to, any implied warranties of merchantability
sahilmgandhi 18:6a4db94011d3 23 * or fitness for any particular purpose or warranties against infringement
sahilmgandhi 18:6a4db94011d3 24 * of any proprietary rights of a third party.
sahilmgandhi 18:6a4db94011d3 25 *
sahilmgandhi 18:6a4db94011d3 26 * Silicon Labs will not be liable for any consequential, incidental, or
sahilmgandhi 18:6a4db94011d3 27 * special damages, or any other relief, or for any claim by any third party,
sahilmgandhi 18:6a4db94011d3 28 * arising from your use of this Software.
sahilmgandhi 18:6a4db94011d3 29 *
sahilmgandhi 18:6a4db94011d3 30 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 31 #ifndef __RADIO_PA_H
sahilmgandhi 18:6a4db94011d3 32 #define __RADIO_PA_H
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34 #include <stdint.h>
sahilmgandhi 18:6a4db94011d3 35 #include <stdbool.h>
sahilmgandhi 18:6a4db94011d3 36
sahilmgandhi 18:6a4db94011d3 37 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 38 extern "C" {
sahilmgandhi 18:6a4db94011d3 39 #endif
sahilmgandhi 18:6a4db94011d3 40
sahilmgandhi 18:6a4db94011d3 41 /***************************************************************************//**
sahilmgandhi 18:6a4db94011d3 42 * @addtogroup Chip_Specific
sahilmgandhi 18:6a4db94011d3 43 * @{
sahilmgandhi 18:6a4db94011d3 44 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 /***************************************************************************//**
sahilmgandhi 18:6a4db94011d3 47 * @addtogroup EFR32xG1x_PA
sahilmgandhi 18:6a4db94011d3 48 * @{
sahilmgandhi 18:6a4db94011d3 49 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 50
sahilmgandhi 18:6a4db94011d3 51 /*******************************************************************************
sahilmgandhi 18:6a4db94011d3 52 **************************** CONFIGURATION ********************************
sahilmgandhi 18:6a4db94011d3 53 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 54 /** Scaling factor applied to all dBm power level inputs and outputs * */
sahilmgandhi 18:6a4db94011d3 55 #define PA_SCALING_FACTOR 10
sahilmgandhi 18:6a4db94011d3 56
sahilmgandhi 18:6a4db94011d3 57 /**
sahilmgandhi 18:6a4db94011d3 58 * @brief Selection of the rf power amplifier (PA) to use
sahilmgandhi 18:6a4db94011d3 59 */
sahilmgandhi 18:6a4db94011d3 60 typedef enum RADIO_PASel
sahilmgandhi 18:6a4db94011d3 61 {
sahilmgandhi 18:6a4db94011d3 62 /** High power PA */
sahilmgandhi 18:6a4db94011d3 63 PA_SEL_2P4_HP,
sahilmgandhi 18:6a4db94011d3 64 /** Low power PA */
sahilmgandhi 18:6a4db94011d3 65 PA_SEL_2P4_LP,
sahilmgandhi 18:6a4db94011d3 66 /** SubGig PA*/
sahilmgandhi 18:6a4db94011d3 67 PA_SEL_SUBGIG,
sahilmgandhi 18:6a4db94011d3 68 /** Invalid PA Selection */
sahilmgandhi 18:6a4db94011d3 69 PA_SEL_INVALID
sahilmgandhi 18:6a4db94011d3 70 } RADIO_PASel_t;
sahilmgandhi 18:6a4db94011d3 71
sahilmgandhi 18:6a4db94011d3 72 /**
sahilmgandhi 18:6a4db94011d3 73 * @brief Selection should match the configuration of the voltage on the vPa pin
sahilmgandhi 18:6a4db94011d3 74 * of the chip.
sahilmgandhi 18:6a4db94011d3 75 */
sahilmgandhi 18:6a4db94011d3 76 typedef enum RADIO_PAVoltMode
sahilmgandhi 18:6a4db94011d3 77 {
sahilmgandhi 18:6a4db94011d3 78 /** Vpa = Vbat = 3.3V */
sahilmgandhi 18:6a4db94011d3 79 PA_VOLTMODE_VBAT,
sahilmgandhi 18:6a4db94011d3 80 /** Vpa = DCDC Vout = 1.8V */
sahilmgandhi 18:6a4db94011d3 81 PA_VOLTMODE_DCDC
sahilmgandhi 18:6a4db94011d3 82 } RADIO_PAVoltMode_t;
sahilmgandhi 18:6a4db94011d3 83
sahilmgandhi 18:6a4db94011d3 84 /**
sahilmgandhi 18:6a4db94011d3 85 * @brief Configuration structure for the rf power amplifier (PA)
sahilmgandhi 18:6a4db94011d3 86 */
sahilmgandhi 18:6a4db94011d3 87 typedef struct RADIO_PAInit {
sahilmgandhi 18:6a4db94011d3 88 /** Power Amplifier mode */
sahilmgandhi 18:6a4db94011d3 89 RADIO_PASel_t paSel;
sahilmgandhi 18:6a4db94011d3 90 /** Power Amplifier vPA Voltage mode */
sahilmgandhi 18:6a4db94011d3 91 RADIO_PAVoltMode_t voltMode;
sahilmgandhi 18:6a4db94011d3 92 /** Desired output power in dBm * \ref PA_SCALING_FACTOR */
sahilmgandhi 18:6a4db94011d3 93 int16_t power;
sahilmgandhi 18:6a4db94011d3 94 /** Output power offset in dBm * \ref PA_SCALING_FACTOR */
sahilmgandhi 18:6a4db94011d3 95 int16_t offset;
sahilmgandhi 18:6a4db94011d3 96 /** Desired ramp time in us */
sahilmgandhi 18:6a4db94011d3 97 uint16_t rampTime;
sahilmgandhi 18:6a4db94011d3 98 } RADIO_PAInit_t;
sahilmgandhi 18:6a4db94011d3 99
sahilmgandhi 18:6a4db94011d3 100 /*******************************************************************************
sahilmgandhi 18:6a4db94011d3 101 ****************************** PROTOTYPES *********************************
sahilmgandhi 18:6a4db94011d3 102 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 103
sahilmgandhi 18:6a4db94011d3 104 /**
sahilmgandhi 18:6a4db94011d3 105 * @brief
sahilmgandhi 18:6a4db94011d3 106 * Initilize the PA settings based on the settings provided in the paInit
sahilmgandhi 18:6a4db94011d3 107 * structure.
sahilmgandhi 18:6a4db94011d3 108 *
sahilmgandhi 18:6a4db94011d3 109 * @param[in] paInit
sahilmgandhi 18:6a4db94011d3 110 * Pointer to a structure containing the desired PA configuration settings.
sahilmgandhi 18:6a4db94011d3 111 *
sahilmgandhi 18:6a4db94011d3 112 * @return
sahilmgandhi 18:6a4db94011d3 113 * True if the settings were accepted.
sahilmgandhi 18:6a4db94011d3 114 * False if settings were invalid.
sahilmgandhi 18:6a4db94011d3 115 *
sahilmgandhi 18:6a4db94011d3 116 * @warning
sahilmgandhi 18:6a4db94011d3 117 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 118 */
sahilmgandhi 18:6a4db94011d3 119 bool RADIO_PA_Init(RADIO_PAInit_t * paInit);
sahilmgandhi 18:6a4db94011d3 120
sahilmgandhi 18:6a4db94011d3 121 /**
sahilmgandhi 18:6a4db94011d3 122 * @brief
sahilmgandhi 18:6a4db94011d3 123 * Returns the current power level of transmit power
sahilmgandhi 18:6a4db94011d3 124 *
sahilmgandhi 18:6a4db94011d3 125 * @return
sahilmgandhi 18:6a4db94011d3 126 * Current power level in dBm * \ref PA_SCALING_FACTOR
sahilmgandhi 18:6a4db94011d3 127 */
sahilmgandhi 18:6a4db94011d3 128 int32_t PA_OutputPowerGet(void);
sahilmgandhi 18:6a4db94011d3 129
sahilmgandhi 18:6a4db94011d3 130 /**
sahilmgandhi 18:6a4db94011d3 131 * @brief
sahilmgandhi 18:6a4db94011d3 132 * Sets the output power of the PA.
sahilmgandhi 18:6a4db94011d3 133 *
sahilmgandhi 18:6a4db94011d3 134 * Each PA has distinct maximum power, minimum power, and power step sizes.
sahilmgandhi 18:6a4db94011d3 135 * This API will calculate the best pa output power level setting to acheieve
sahilmgandhi 18:6a4db94011d3 136 * the desired output power.
sahilmgandhi 18:6a4db94011d3 137 *
sahilmgandhi 18:6a4db94011d3 138 * @note
sahilmgandhi 18:6a4db94011d3 139 * Board and chip variations will affect the accuracy of this API. Use
sahilmgandhi 18:6a4db94011d3 140 * of the RADIO_PAInit_t.offset paramter can help account for this variation.
sahilmgandhi 18:6a4db94011d3 141 *
sahilmgandhi 18:6a4db94011d3 142 * @param[in] power
sahilmgandhi 18:6a4db94011d3 143 * Power value in dBm * \ref PA_SCALING_FACTOR
sahilmgandhi 18:6a4db94011d3 144 *
sahilmgandhi 18:6a4db94011d3 145 * Examples with \ref PA_SCALING_FACTOR of 10:
sahilmgandhi 18:6a4db94011d3 146 * - 10 dBm --> 100
sahilmgandhi 18:6a4db94011d3 147 * - 5.5 dBm --> 55
sahilmgandhi 18:6a4db94011d3 148 *
sahilmgandhi 18:6a4db94011d3 149 * @return
sahilmgandhi 18:6a4db94011d3 150 * Returns the actual power that was set in dBm * \ref PA_SCALING_FACTOR
sahilmgandhi 18:6a4db94011d3 151 *
sahilmgandhi 18:6a4db94011d3 152 * @warning
sahilmgandhi 18:6a4db94011d3 153 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 154 */
sahilmgandhi 18:6a4db94011d3 155 int32_t PA_OutputPowerSet(int32_t power);
sahilmgandhi 18:6a4db94011d3 156
sahilmgandhi 18:6a4db94011d3 157 /**
sahilmgandhi 18:6a4db94011d3 158 * @brief
sahilmgandhi 18:6a4db94011d3 159 * Set the maximum possible output power for the selected PA.
sahilmgandhi 18:6a4db94011d3 160 *
sahilmgandhi 18:6a4db94011d3 161 * @return
sahilmgandhi 18:6a4db94011d3 162 * Returns the actual power that was set in dBm * \ref PA_SCALING_FACTOR
sahilmgandhi 18:6a4db94011d3 163 *
sahilmgandhi 18:6a4db94011d3 164 * @warning
sahilmgandhi 18:6a4db94011d3 165 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 166 */
sahilmgandhi 18:6a4db94011d3 167 int32_t PA_MaxOutputPowerSet(void);
sahilmgandhi 18:6a4db94011d3 168
sahilmgandhi 18:6a4db94011d3 169 /**
sahilmgandhi 18:6a4db94011d3 170 * @brief
sahilmgandhi 18:6a4db94011d3 171 * Return the current ramp time in microseconds
sahilmgandhi 18:6a4db94011d3 172 *
sahilmgandhi 18:6a4db94011d3 173 * @return
sahilmgandhi 18:6a4db94011d3 174 * Current ramp time in microseconds
sahilmgandhi 18:6a4db94011d3 175 */
sahilmgandhi 18:6a4db94011d3 176 uint32_t PA_RampTimeGet(void);
sahilmgandhi 18:6a4db94011d3 177
sahilmgandhi 18:6a4db94011d3 178 /**
sahilmgandhi 18:6a4db94011d3 179 * @brief
sahilmgandhi 18:6a4db94011d3 180 * Sets up the ramp configuration so that it best matches the given ramp time
sahilmgandhi 18:6a4db94011d3 181 *
sahilmgandhi 18:6a4db94011d3 182 * @details
sahilmgandhi 18:6a4db94011d3 183 * Each PA has a distinct ramp level and ramp rate that can be used to
sahilmgandhi 18:6a4db94011d3 184 * achieve various ramp times. This API will pick the ramp rate that closest
sahilmgandhi 18:6a4db94011d3 185 * approximates the desired ramp time.
sahilmgandhi 18:6a4db94011d3 186 *
sahilmgandhi 18:6a4db94011d3 187 * @param[in] ramptime
sahilmgandhi 18:6a4db94011d3 188 * Desired ramp time in microseconds
sahilmgandhi 18:6a4db94011d3 189 *
sahilmgandhi 18:6a4db94011d3 190 * @return
sahilmgandhi 18:6a4db94011d3 191 * The actual ramp time that was set in microseconds.
sahilmgandhi 18:6a4db94011d3 192 *
sahilmgandhi 18:6a4db94011d3 193 * @warning
sahilmgandhi 18:6a4db94011d3 194 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 195 */
sahilmgandhi 18:6a4db94011d3 196 uint32_t PA_RampTimeSet(uint32_t ramptime);
sahilmgandhi 18:6a4db94011d3 197
sahilmgandhi 18:6a4db94011d3 198 /***************************************************************************//**
sahilmgandhi 18:6a4db94011d3 199 * @addtogroup EFR32xG1x_PA_Advanced
sahilmgandhi 18:6a4db94011d3 200 * @{
sahilmgandhi 18:6a4db94011d3 201 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 202
sahilmgandhi 18:6a4db94011d3 203 /**
sahilmgandhi 18:6a4db94011d3 204 * @brief
sahilmgandhi 18:6a4db94011d3 205 * Set PACTUNE value for TX and RX mode.
sahilmgandhi 18:6a4db94011d3 206 *
sahilmgandhi 18:6a4db94011d3 207 * This value can vary depending on band and match and board design.
sahilmgandhi 18:6a4db94011d3 208 *
sahilmgandhi 18:6a4db94011d3 209 * @param[in] txPaCtuneValue
sahilmgandhi 18:6a4db94011d3 210 * Transmit value for pa ctune
sahilmgandhi 18:6a4db94011d3 211 * @param[in] rxPaCtuneValue
sahilmgandhi 18:6a4db94011d3 212 * Receive value for pa ctune
sahilmgandhi 18:6a4db94011d3 213 *
sahilmgandhi 18:6a4db94011d3 214 * @note PACTUNE will reset to default values when RADIO_PA_Init() or
sahilmgandhi 18:6a4db94011d3 215 * RAIL_RadioConfig() are called.
sahilmgandhi 18:6a4db94011d3 216 *
sahilmgandhi 18:6a4db94011d3 217 * @warning
sahilmgandhi 18:6a4db94011d3 218 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 219 */
sahilmgandhi 18:6a4db94011d3 220 void PA_CTuneSet(uint8_t txPaCtuneValue, uint8_t rxPaCtuneValue);
sahilmgandhi 18:6a4db94011d3 221
sahilmgandhi 18:6a4db94011d3 222 /**
sahilmgandhi 18:6a4db94011d3 223 * @brief
sahilmgandhi 18:6a4db94011d3 224 * Set the output power level based on power steps available in the chosen PA.
sahilmgandhi 18:6a4db94011d3 225 *
sahilmgandhi 18:6a4db94011d3 226 * @details
sahilmgandhi 18:6a4db94011d3 227 * Each PA has distinct maximum power, minimum power, and power step sizes.
sahilmgandhi 18:6a4db94011d3 228 * This API allows direct access to these power steps to tune between the
sahilmgandhi 18:6a4db94011d3 229 * maximum and minimum output power the selected PA is capable of.
sahilmgandhi 18:6a4db94011d3 230 *
sahilmgandhi 18:6a4db94011d3 231 * @param[in] pwrLevel
sahilmgandhi 18:6a4db94011d3 232 * Output power level. Note that the maximum power level will change
sahilmgandhi 18:6a4db94011d3 233 * depending on PA selection.
sahilmgandhi 18:6a4db94011d3 234 * @param[in] boostMode
sahilmgandhi 18:6a4db94011d3 235 * Output boost mode. Some PA selections have a mode that will increase the
sahilmgandhi 18:6a4db94011d3 236 * output power for each step if this is enabled.
sahilmgandhi 18:6a4db94011d3 237 *
sahilmgandhi 18:6a4db94011d3 238 * @return
sahilmgandhi 18:6a4db94011d3 239 * MSB Configured boost mode. \n
sahilmgandhi 18:6a4db94011d3 240 * LSB Configured power level
sahilmgandhi 18:6a4db94011d3 241 *
sahilmgandhi 18:6a4db94011d3 242 * @warning
sahilmgandhi 18:6a4db94011d3 243 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 244 */
sahilmgandhi 18:6a4db94011d3 245 uint16_t PA_PowerLevelSet(uint8_t pwrLevel, uint8_t boostMode);
sahilmgandhi 18:6a4db94011d3 246
sahilmgandhi 18:6a4db94011d3 247 /**
sahilmgandhi 18:6a4db94011d3 248 * @brief
sahilmgandhi 18:6a4db94011d3 249 * Optimize the PA settings based on expected output power level.
sahilmgandhi 18:6a4db94011d3 250 *
sahilmgandhi 18:6a4db94011d3 251 * @details
sahilmgandhi 18:6a4db94011d3 252 * This API optimizes the current consumption of the radio based on the
sahilmgandhi 18:6a4db94011d3 253 * provided output power. This is only necessary when output power is
sahilmgandhi 18:6a4db94011d3 254 * controlled by PA_PowerLevelSet().
sahilmgandhi 18:6a4db94011d3 255 *
sahilmgandhi 18:6a4db94011d3 256 * @param[in] power
sahilmgandhi 18:6a4db94011d3 257 * Power value in dBm * \ref PA_SCALING_FACTOR
sahilmgandhi 18:6a4db94011d3 258 *
sahilmgandhi 18:6a4db94011d3 259 * @warning
sahilmgandhi 18:6a4db94011d3 260 * The radio should not be transmitting when this function is called!
sahilmgandhi 18:6a4db94011d3 261 */
sahilmgandhi 18:6a4db94011d3 262 void PA_PowerLevelOptimize(int32_t power);
sahilmgandhi 18:6a4db94011d3 263
sahilmgandhi 18:6a4db94011d3 264 /** @} (end addtogroup EFR32xG1x_PA_Advanced) */
sahilmgandhi 18:6a4db94011d3 265 /** @} (end addtogroup EFR32xG1x_PA) */
sahilmgandhi 18:6a4db94011d3 266 /** @} (end addtogroup Chip_Specific) */
sahilmgandhi 18:6a4db94011d3 267
sahilmgandhi 18:6a4db94011d3 268 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 269 }
sahilmgandhi 18:6a4db94011d3 270 #endif
sahilmgandhi 18:6a4db94011d3 271
sahilmgandhi 18:6a4db94011d3 272
sahilmgandhi 18:6a4db94011d3 273 #endif /* __RADIO_PA_H */