Ben Katz / mbed-dev-f303

Dependents:   Hobbyking_Cheetah_Compact Hobbyking_Cheetah_Compact_DRV8323_14bit Hobbyking_Cheetah_Compact_DRV8323_V51_201907 HKC_MiniCheetah ... more

Fork of mbed-dev by mbed official

Committer:
benkatz
Date:
Mon Jul 30 20:31:44 2018 +0000
Revision:
181:36facd806e4a
Parent:
161:2cc1468da177
going on the robot.  fixed a dumb bug in float_to_uint

Who changed what in which revision?

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