Erik - / mbed-src2

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Apr 28 11:45:12 2015 +0100
Revision:
525:c320967f86b9
Synchronized with git revision 299385b8331142b9dc524da7a986536f60b14553

Full URL: https://github.com/mbedmicro/mbed/commit/299385b8331142b9dc524da7a986536f60b14553/

Add in Silicon Labs targets with asynchronous API support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 525:c320967f86b9 1 /***************************************************************************//**
mbed_official 525:c320967f86b9 2 * @file em_lesense.h
mbed_official 525:c320967f86b9 3 * @brief Low Energy Sensor (LESENSE) peripheral API
mbed_official 525:c320967f86b9 4 * @version 3.20.12
mbed_official 525:c320967f86b9 5 *******************************************************************************
mbed_official 525:c320967f86b9 6 * @section License
mbed_official 525:c320967f86b9 7 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
mbed_official 525:c320967f86b9 8 *******************************************************************************
mbed_official 525:c320967f86b9 9 *
mbed_official 525:c320967f86b9 10 * Permission is granted to anyone to use this software for any purpose,
mbed_official 525:c320967f86b9 11 * including commercial applications, and to alter it and redistribute it
mbed_official 525:c320967f86b9 12 * freely, subject to the following restrictions:
mbed_official 525:c320967f86b9 13 *
mbed_official 525:c320967f86b9 14 * 1. The origin of this software must not be misrepresented; you must not
mbed_official 525:c320967f86b9 15 * claim that you wrote the original software.
mbed_official 525:c320967f86b9 16 * 2. Altered source versions must be plainly marked as such, and must not be
mbed_official 525:c320967f86b9 17 * misrepresented as being the original software.
mbed_official 525:c320967f86b9 18 * 3. This notice may not be removed or altered from any source distribution.
mbed_official 525:c320967f86b9 19 *
mbed_official 525:c320967f86b9 20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
mbed_official 525:c320967f86b9 21 * obligation to support this Software. Silicon Labs is providing the
mbed_official 525:c320967f86b9 22 * Software "AS IS", with no express or implied warranties of any kind,
mbed_official 525:c320967f86b9 23 * including, but not limited to, any implied warranties of merchantability
mbed_official 525:c320967f86b9 24 * or fitness for any particular purpose or warranties against infringement
mbed_official 525:c320967f86b9 25 * of any proprietary rights of a third party.
mbed_official 525:c320967f86b9 26 *
mbed_official 525:c320967f86b9 27 * Silicon Labs will not be liable for any consequential, incidental, or
mbed_official 525:c320967f86b9 28 * special damages, or any other relief, or for any claim by any third party,
mbed_official 525:c320967f86b9 29 * arising from your use of this Software.
mbed_official 525:c320967f86b9 30 *
mbed_official 525:c320967f86b9 31 ******************************************************************************/
mbed_official 525:c320967f86b9 32
mbed_official 525:c320967f86b9 33
mbed_official 525:c320967f86b9 34 #ifndef __SILICON_LABS_EM_LESENSE_H_
mbed_official 525:c320967f86b9 35 #define __SILICON_LABS_EM_LESENSE_H_
mbed_official 525:c320967f86b9 36
mbed_official 525:c320967f86b9 37 #include "em_device.h"
mbed_official 525:c320967f86b9 38
mbed_official 525:c320967f86b9 39 #if defined(LESENSE_COUNT) && (LESENSE_COUNT > 0)
mbed_official 525:c320967f86b9 40 #include <stdint.h>
mbed_official 525:c320967f86b9 41 #include <stdbool.h>
mbed_official 525:c320967f86b9 42
mbed_official 525:c320967f86b9 43 #ifdef __cplusplus
mbed_official 525:c320967f86b9 44 extern "C" {
mbed_official 525:c320967f86b9 45 #endif
mbed_official 525:c320967f86b9 46
mbed_official 525:c320967f86b9 47
mbed_official 525:c320967f86b9 48 /***************************************************************************//**
mbed_official 525:c320967f86b9 49 * @addtogroup EM_Library
mbed_official 525:c320967f86b9 50 * @{
mbed_official 525:c320967f86b9 51 ******************************************************************************/
mbed_official 525:c320967f86b9 52
mbed_official 525:c320967f86b9 53 /***************************************************************************//**
mbed_official 525:c320967f86b9 54 * @addtogroup LESENSE
mbed_official 525:c320967f86b9 55 * @{
mbed_official 525:c320967f86b9 56 ******************************************************************************/
mbed_official 525:c320967f86b9 57
mbed_official 525:c320967f86b9 58 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
mbed_official 525:c320967f86b9 59
mbed_official 525:c320967f86b9 60
mbed_official 525:c320967f86b9 61
mbed_official 525:c320967f86b9 62 /** @endcond */
mbed_official 525:c320967f86b9 63
mbed_official 525:c320967f86b9 64 /*******************************************************************************
mbed_official 525:c320967f86b9 65 ******************************** ENUMS ************************************
mbed_official 525:c320967f86b9 66 ******************************************************************************/
mbed_official 525:c320967f86b9 67
mbed_official 525:c320967f86b9 68 /** Clock divisors for controlling the prescaling factor of the period
mbed_official 525:c320967f86b9 69 * counter.
mbed_official 525:c320967f86b9 70 * Note: these enumeration values are being used for different clock division
mbed_official 525:c320967f86b9 71 * related configuration parameters (hfPresc, lfPresc, pcPresc). */
mbed_official 525:c320967f86b9 72 typedef enum
mbed_official 525:c320967f86b9 73 {
mbed_official 525:c320967f86b9 74 lesenseClkDiv_1 = 0, /**< Divide clock by 1. */
mbed_official 525:c320967f86b9 75 lesenseClkDiv_2 = 1, /**< Divide clock by 2. */
mbed_official 525:c320967f86b9 76 lesenseClkDiv_4 = 2, /**< Divide clock by 4. */
mbed_official 525:c320967f86b9 77 lesenseClkDiv_8 = 3, /**< Divide clock by 8. */
mbed_official 525:c320967f86b9 78 lesenseClkDiv_16 = 4, /**< Divide clock by 16. */
mbed_official 525:c320967f86b9 79 lesenseClkDiv_32 = 5, /**< Divide clock by 32. */
mbed_official 525:c320967f86b9 80 lesenseClkDiv_64 = 6, /**< Divide clock by 64. */
mbed_official 525:c320967f86b9 81 lesenseClkDiv_128 = 7 /**< Divide clock by 128. */
mbed_official 525:c320967f86b9 82 } LESENSE_ClkPresc_TypeDef;
mbed_official 525:c320967f86b9 83
mbed_official 525:c320967f86b9 84
mbed_official 525:c320967f86b9 85 /** Scan modes. */
mbed_official 525:c320967f86b9 86 typedef enum
mbed_official 525:c320967f86b9 87 {
mbed_official 525:c320967f86b9 88 /** New scan is started each time the period counter overflows. */
mbed_official 525:c320967f86b9 89 lesenseScanStartPeriodic = LESENSE_CTRL_SCANMODE_PERIODIC,
mbed_official 525:c320967f86b9 90
mbed_official 525:c320967f86b9 91 /** Single scan is performed when LESENSE_ScanStart() is called. */
mbed_official 525:c320967f86b9 92 lesenseScanStartOneShot = LESENSE_CTRL_SCANMODE_ONESHOT,
mbed_official 525:c320967f86b9 93
mbed_official 525:c320967f86b9 94 /** New scan is triggered by pulse on PRS channel. */
mbed_official 525:c320967f86b9 95 lesenseScanStartPRS = LESENSE_CTRL_SCANMODE_PRS
mbed_official 525:c320967f86b9 96 } LESENSE_ScanMode_TypeDef;
mbed_official 525:c320967f86b9 97
mbed_official 525:c320967f86b9 98
mbed_official 525:c320967f86b9 99 /** PRS sources.
mbed_official 525:c320967f86b9 100 * Note: these enumeration values are being used for different PRS related
mbed_official 525:c320967f86b9 101 * configuration parameters. */
mbed_official 525:c320967f86b9 102 typedef enum
mbed_official 525:c320967f86b9 103 {
mbed_official 525:c320967f86b9 104 lesensePRSCh0 = 0, /**< PRS channel 0. */
mbed_official 525:c320967f86b9 105 lesensePRSCh1 = 1, /**< PRS channel 1. */
mbed_official 525:c320967f86b9 106 lesensePRSCh2 = 2, /**< PRS channel 2. */
mbed_official 525:c320967f86b9 107 lesensePRSCh3 = 3, /**< PRS channel 3. */
mbed_official 525:c320967f86b9 108 #if defined( LESENSE_CTRL_PRSSEL_PRSCH4 )
mbed_official 525:c320967f86b9 109 lesensePRSCh4 = 4, /**< PRS channel 4. */
mbed_official 525:c320967f86b9 110 #endif
mbed_official 525:c320967f86b9 111 #if defined( LESENSE_CTRL_PRSSEL_PRSCH5 )
mbed_official 525:c320967f86b9 112 lesensePRSCh5 = 5, /**< PRS channel 5. */
mbed_official 525:c320967f86b9 113 #endif
mbed_official 525:c320967f86b9 114 #if defined( LESENSE_CTRL_PRSSEL_PRSCH6 )
mbed_official 525:c320967f86b9 115 lesensePRSCh6 = 6, /**< PRS channel 6. */
mbed_official 525:c320967f86b9 116 #endif
mbed_official 525:c320967f86b9 117 #if defined( LESENSE_CTRL_PRSSEL_PRSCH7 )
mbed_official 525:c320967f86b9 118 lesensePRSCh7 = 7, /**< PRS channel 7. */
mbed_official 525:c320967f86b9 119 #endif
mbed_official 525:c320967f86b9 120 #if defined( LESENSE_CTRL_PRSSEL_PRSCH8 )
mbed_official 525:c320967f86b9 121 lesensePRSCh8 = 8, /**< PRS channel 8. */
mbed_official 525:c320967f86b9 122 #endif
mbed_official 525:c320967f86b9 123 #if defined( LESENSE_CTRL_PRSSEL_PRSCH9 )
mbed_official 525:c320967f86b9 124 lesensePRSCh9 = 9, /**< PRS channel 9. */
mbed_official 525:c320967f86b9 125 #endif
mbed_official 525:c320967f86b9 126 #if defined( LESENSE_CTRL_PRSSEL_PRSCH10 )
mbed_official 525:c320967f86b9 127 lesensePRSCh10 = 10, /**< PRS channel 10.*/
mbed_official 525:c320967f86b9 128 #endif
mbed_official 525:c320967f86b9 129 #if defined( LESENSE_CTRL_PRSSEL_PRSCH11 )
mbed_official 525:c320967f86b9 130 lesensePRSCh11 = 11, /**< PRS channel 11.*/
mbed_official 525:c320967f86b9 131 #endif
mbed_official 525:c320967f86b9 132 } LESENSE_PRSSel_TypeDef;
mbed_official 525:c320967f86b9 133
mbed_official 525:c320967f86b9 134
mbed_official 525:c320967f86b9 135 /** Locations of the alternate excitation function. */
mbed_official 525:c320967f86b9 136 typedef enum
mbed_official 525:c320967f86b9 137 {
mbed_official 525:c320967f86b9 138 /** Alternate excitation is mapped to the LES_ALTEX pins. */
mbed_official 525:c320967f86b9 139 lesenseAltExMapALTEX = _LESENSE_CTRL_ALTEXMAP_ALTEX,
mbed_official 525:c320967f86b9 140
mbed_official 525:c320967f86b9 141 /** Alternate excitation is mapped to the pins of the other ACMP. */
mbed_official 525:c320967f86b9 142 lesenseAltExMapACMP = _LESENSE_CTRL_ALTEXMAP_ACMP
mbed_official 525:c320967f86b9 143 } LESENSE_AltExMap_TypeDef;
mbed_official 525:c320967f86b9 144
mbed_official 525:c320967f86b9 145
mbed_official 525:c320967f86b9 146 /** Result buffer interrupt and DMA trigger levels. */
mbed_official 525:c320967f86b9 147 typedef enum
mbed_official 525:c320967f86b9 148 {
mbed_official 525:c320967f86b9 149 /** DMA and interrupt flags are set when result buffer is halffull. */
mbed_official 525:c320967f86b9 150 lesenseBufTrigHalf = LESENSE_CTRL_BUFIDL_HALFFULL,
mbed_official 525:c320967f86b9 151
mbed_official 525:c320967f86b9 152 /** DMA and interrupt flags set when result buffer is full. */
mbed_official 525:c320967f86b9 153 lesenseBufTrigFull = LESENSE_CTRL_BUFIDL_FULL
mbed_official 525:c320967f86b9 154 } LESENSE_BufTrigLevel_TypeDef;
mbed_official 525:c320967f86b9 155
mbed_official 525:c320967f86b9 156
mbed_official 525:c320967f86b9 157 /** Modes of operation for DMA wakeup from EM2. */
mbed_official 525:c320967f86b9 158 typedef enum
mbed_official 525:c320967f86b9 159 {
mbed_official 525:c320967f86b9 160 /** No DMA wakeup from EM2. */
mbed_official 525:c320967f86b9 161 lesenseDMAWakeUpDisable = LESENSE_CTRL_DMAWU_DISABLE,
mbed_official 525:c320967f86b9 162
mbed_official 525:c320967f86b9 163 /** DMA wakeup from EM2 when data is valid in the result buffer. */
mbed_official 525:c320967f86b9 164 lesenseDMAWakeUpBufValid = LESENSE_CTRL_DMAWU_BUFDATAV,
mbed_official 525:c320967f86b9 165
mbed_official 525:c320967f86b9 166 /** DMA wakeup from EM2 when the resultbuffer is full/halffull, depending on
mbed_official 525:c320967f86b9 167 * RESBIDL configuration in LESENSE_CTRL register (selected by
mbed_official 525:c320967f86b9 168 * resBufTrigLevel in LESENSE_ResBufTrigLevel_TypeDef descriptor structure). */
mbed_official 525:c320967f86b9 169 lesenseDMAWakeUpBufLevel = LESENSE_CTRL_DMAWU_BUFLEVEL
mbed_official 525:c320967f86b9 170 } LESENSE_DMAWakeUp_TypeDef;
mbed_official 525:c320967f86b9 171
mbed_official 525:c320967f86b9 172
mbed_official 525:c320967f86b9 173 /** Bias modes. */
mbed_official 525:c320967f86b9 174 typedef enum
mbed_official 525:c320967f86b9 175 {
mbed_official 525:c320967f86b9 176 /** Duty cycle bias module between low power and high accuracy mode. */
mbed_official 525:c320967f86b9 177 lesenseBiasModeDutyCycle = LESENSE_BIASCTRL_BIASMODE_DUTYCYCLE,
mbed_official 525:c320967f86b9 178
mbed_official 525:c320967f86b9 179 /** Bias module is always in high accuracy mode. */
mbed_official 525:c320967f86b9 180 lesenseBiasModeHighAcc = LESENSE_BIASCTRL_BIASMODE_HIGHACC,
mbed_official 525:c320967f86b9 181
mbed_official 525:c320967f86b9 182 /** Bias module is controlled by the EMU and not affected by LESENSE. */
mbed_official 525:c320967f86b9 183 lesenseBiasModeDontTouch = LESENSE_BIASCTRL_BIASMODE_DONTTOUCH
mbed_official 525:c320967f86b9 184 } LESENSE_BiasMode_TypeDef;
mbed_official 525:c320967f86b9 185
mbed_official 525:c320967f86b9 186
mbed_official 525:c320967f86b9 187 /** Scan configuration. */
mbed_official 525:c320967f86b9 188 typedef enum
mbed_official 525:c320967f86b9 189 {
mbed_official 525:c320967f86b9 190 /** The channel configuration registers (CHx_CONF) used are directly mapped to
mbed_official 525:c320967f86b9 191 * the channel number. */
mbed_official 525:c320967f86b9 192 lesenseScanConfDirMap = LESENSE_CTRL_SCANCONF_DIRMAP,
mbed_official 525:c320967f86b9 193
mbed_official 525:c320967f86b9 194 /** The channel configuration registers used are CHx+8_CONF for channels 0-7
mbed_official 525:c320967f86b9 195 * and CHx-8_CONF for channels 8-15. */
mbed_official 525:c320967f86b9 196 lesenseScanConfInvMap = LESENSE_CTRL_SCANCONF_INVMAP,
mbed_official 525:c320967f86b9 197
mbed_official 525:c320967f86b9 198 /** The channel configuration registers used toggles between CHX_SCANCONF and
mbed_official 525:c320967f86b9 199 * CHX+8_SCANCONF when channel x triggers. */
mbed_official 525:c320967f86b9 200 lesenseScanConfToggle = LESENSE_CTRL_SCANCONF_TOGGLE,
mbed_official 525:c320967f86b9 201
mbed_official 525:c320967f86b9 202 /** The decoder state defines the channel configuration register (CHx_CONF) to
mbed_official 525:c320967f86b9 203 * be used. */
mbed_official 525:c320967f86b9 204 lesenseScanConfDecDef = LESENSE_CTRL_SCANCONF_DECDEF
mbed_official 525:c320967f86b9 205 } LESENSE_ScanConfSel_TypeDef;
mbed_official 525:c320967f86b9 206
mbed_official 525:c320967f86b9 207
mbed_official 525:c320967f86b9 208 /** DAC CHx data control configuration. */
mbed_official 525:c320967f86b9 209 typedef enum
mbed_official 525:c320967f86b9 210 {
mbed_official 525:c320967f86b9 211 /** DAC channel x data is defined by DAC_CHxDATA register.
mbed_official 525:c320967f86b9 212 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 213 lesenseDACIfData = _LESENSE_PERCTRL_DACCH0DATA_DACDATA,
mbed_official 525:c320967f86b9 214
mbed_official 525:c320967f86b9 215 /** DAC channel x data is defined by ACMPTHRES in LESENSE_CHx_INTERACT.
mbed_official 525:c320967f86b9 216 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 217 lesenseACMPThres = _LESENSE_PERCTRL_DACCH0DATA_ACMPTHRES
mbed_official 525:c320967f86b9 218 } LESENSE_ControlDACData_TypeDef;
mbed_official 525:c320967f86b9 219
mbed_official 525:c320967f86b9 220
mbed_official 525:c320967f86b9 221 /** DAC channel x conversion mode configuration. */
mbed_official 525:c320967f86b9 222 typedef enum
mbed_official 525:c320967f86b9 223 {
mbed_official 525:c320967f86b9 224 /** LESENSE doesn't control DAC channel x.
mbed_official 525:c320967f86b9 225 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 226 lesenseDACConvModeDisable = _LESENSE_PERCTRL_DACCH0CONV_DISABLE,
mbed_official 525:c320967f86b9 227
mbed_official 525:c320967f86b9 228 /** DAC channel x is driven in continuous mode.
mbed_official 525:c320967f86b9 229 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 230 lesenseDACConvModeContinuous = _LESENSE_PERCTRL_DACCH0CONV_CONTINUOUS,
mbed_official 525:c320967f86b9 231
mbed_official 525:c320967f86b9 232 /** DAC channel x is driven in sample hold mode.
mbed_official 525:c320967f86b9 233 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 234 lesenseDACConvModeSampleHold = _LESENSE_PERCTRL_DACCH0CONV_SAMPLEHOLD,
mbed_official 525:c320967f86b9 235
mbed_official 525:c320967f86b9 236 /** DAC channel x is driven in sample off mode.
mbed_official 525:c320967f86b9 237 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 238 lesenseDACConvModeSampleOff = _LESENSE_PERCTRL_DACCH0CONV_SAMPLEOFF
mbed_official 525:c320967f86b9 239 } LESENSE_ControlDACConv_TypeDef;
mbed_official 525:c320967f86b9 240
mbed_official 525:c320967f86b9 241
mbed_official 525:c320967f86b9 242 /** DAC channel x output mode configuration. */
mbed_official 525:c320967f86b9 243 typedef enum
mbed_official 525:c320967f86b9 244 {
mbed_official 525:c320967f86b9 245 /** DAC CHx output to pin and ACMP/ADC disabled.
mbed_official 525:c320967f86b9 246 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 247 lesenseDACOutModeDisable = _LESENSE_PERCTRL_DACCH0OUT_DISABLE,
mbed_official 525:c320967f86b9 248
mbed_official 525:c320967f86b9 249 /** DAC CHx output to pin enabled, output to ADC and ACMP disabled.
mbed_official 525:c320967f86b9 250 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 251 lesenseDACOutModePin = _LESENSE_PERCTRL_DACCH0OUT_PIN,
mbed_official 525:c320967f86b9 252
mbed_official 525:c320967f86b9 253 /** DAC CHx output to pin disabled, output to ADC and ACMP enabled.
mbed_official 525:c320967f86b9 254 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 255 lesenseDACOutModeADCACMP = _LESENSE_PERCTRL_DACCH0OUT_ADCACMP,
mbed_official 525:c320967f86b9 256
mbed_official 525:c320967f86b9 257 /** DAC CHx output to pin, ADC, and ACMP enabled.
mbed_official 525:c320967f86b9 258 * Note: this value could be used for both DAC Ch0 and Ch1. */
mbed_official 525:c320967f86b9 259 lesenseDACOutModePinADCACMP = _LESENSE_PERCTRL_DACCH0OUT_PINADCACMP
mbed_official 525:c320967f86b9 260 } LESENSE_ControlDACOut_TypeDef;
mbed_official 525:c320967f86b9 261
mbed_official 525:c320967f86b9 262
mbed_official 525:c320967f86b9 263 /** DAC reference configuration. */
mbed_official 525:c320967f86b9 264 typedef enum
mbed_official 525:c320967f86b9 265 {
mbed_official 525:c320967f86b9 266 /** DAC uses VDD reference. */
mbed_official 525:c320967f86b9 267 lesenseDACRefVdd = LESENSE_PERCTRL_DACREF_VDD,
mbed_official 525:c320967f86b9 268
mbed_official 525:c320967f86b9 269 /** DAC uses bandgap reference. */
mbed_official 525:c320967f86b9 270 lesenseDACRefBandGap = LESENSE_PERCTRL_DACREF_BANDGAP
mbed_official 525:c320967f86b9 271 } LESENSE_DACRef_TypeDef;
mbed_official 525:c320967f86b9 272
mbed_official 525:c320967f86b9 273
mbed_official 525:c320967f86b9 274 /** ACMPx control configuration. */
mbed_official 525:c320967f86b9 275 typedef enum
mbed_official 525:c320967f86b9 276 {
mbed_official 525:c320967f86b9 277 /** LESENSE does not control the ACMPx.
mbed_official 525:c320967f86b9 278 * Note: this value could be used for both ACMP0 and ACMP1. */
mbed_official 525:c320967f86b9 279 lesenseACMPModeDisable = _LESENSE_PERCTRL_ACMP0MODE_DISABLE,
mbed_official 525:c320967f86b9 280
mbed_official 525:c320967f86b9 281 /** LESENSE controls the input mux of ACMPx.
mbed_official 525:c320967f86b9 282 * Note: this value could be used for both ACMP0 and ACMP1. */
mbed_official 525:c320967f86b9 283 lesenseACMPModeMux = _LESENSE_PERCTRL_ACMP0MODE_MUX,
mbed_official 525:c320967f86b9 284
mbed_official 525:c320967f86b9 285 /** LESENSE controls the input mux of and the threshold value of ACMPx.
mbed_official 525:c320967f86b9 286 * Note: this value could be used for both ACMP0 and ACMP1. */
mbed_official 525:c320967f86b9 287 lesenseACMPModeMuxThres = _LESENSE_PERCTRL_ACMP0MODE_MUXTHRES
mbed_official 525:c320967f86b9 288 } LESENSE_ControlACMP_TypeDef;
mbed_official 525:c320967f86b9 289
mbed_official 525:c320967f86b9 290
mbed_official 525:c320967f86b9 291 /** Warm up modes. ACMP and DAC duty cycle mode configuration. */
mbed_official 525:c320967f86b9 292 typedef enum
mbed_official 525:c320967f86b9 293 {
mbed_official 525:c320967f86b9 294 /** ACMPs and DACs are shut down when LESENSE is idle. */
mbed_official 525:c320967f86b9 295 lesenseWarmupModeNormal = LESENSE_PERCTRL_WARMUPMODE_NORMAL,
mbed_official 525:c320967f86b9 296
mbed_official 525:c320967f86b9 297 /** ACMPs are kept powered up when LESENSE is idle. */
mbed_official 525:c320967f86b9 298 lesenseWarmupModeACMP = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPWARM,
mbed_official 525:c320967f86b9 299
mbed_official 525:c320967f86b9 300 /** The DAC is kept powered up when LESENSE is idle. */
mbed_official 525:c320967f86b9 301 lesenseWarmupModeDAC = LESENSE_PERCTRL_WARMUPMODE_KEEPDACWARM,
mbed_official 525:c320967f86b9 302
mbed_official 525:c320967f86b9 303 /** ACMPs and the DAC are kept powered up when LESENSE is idle. */
mbed_official 525:c320967f86b9 304 lesenseWarmupModeKeepWarm = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPDACWARM
mbed_official 525:c320967f86b9 305 } LESENSE_WarmupMode_TypeDef;
mbed_official 525:c320967f86b9 306
mbed_official 525:c320967f86b9 307
mbed_official 525:c320967f86b9 308 /** Decoder input source configuration. */
mbed_official 525:c320967f86b9 309 typedef enum
mbed_official 525:c320967f86b9 310 {
mbed_official 525:c320967f86b9 311 /** The SENSORSTATE register is used as input to the decoder. */
mbed_official 525:c320967f86b9 312 lesenseDecInputSensorSt = LESENSE_DECCTRL_INPUT_SENSORSTATE,
mbed_official 525:c320967f86b9 313
mbed_official 525:c320967f86b9 314 /** PRS channels are used as input to the decoder. */
mbed_official 525:c320967f86b9 315 lesenseDecInputPRS = LESENSE_DECCTRL_INPUT_PRS
mbed_official 525:c320967f86b9 316 } LESENSE_DecInput_TypeDef;
mbed_official 525:c320967f86b9 317
mbed_official 525:c320967f86b9 318
mbed_official 525:c320967f86b9 319 /** Compare source selection for sensor sampling. */
mbed_official 525:c320967f86b9 320 typedef enum
mbed_official 525:c320967f86b9 321 {
mbed_official 525:c320967f86b9 322 /** Counter output will be used in comparison. */
mbed_official 525:c320967f86b9 323 lesenseSampleModeCounter = LESENSE_CH_INTERACT_SAMPLE_COUNTER,
mbed_official 525:c320967f86b9 324
mbed_official 525:c320967f86b9 325 /** ACMP output will be used in comparison. */
mbed_official 525:c320967f86b9 326 lesenseSampleModeACMP = LESENSE_CH_INTERACT_SAMPLE_ACMP
mbed_official 525:c320967f86b9 327 } LESENSE_ChSampleMode_TypeDef;
mbed_official 525:c320967f86b9 328
mbed_official 525:c320967f86b9 329
mbed_official 525:c320967f86b9 330 /** Interrupt generation setup for CHx interrupt flag. */
mbed_official 525:c320967f86b9 331 typedef enum
mbed_official 525:c320967f86b9 332 {
mbed_official 525:c320967f86b9 333 /** No interrupt is generated. */
mbed_official 525:c320967f86b9 334 lesenseSetIntNone = LESENSE_CH_INTERACT_SETIF_NONE,
mbed_official 525:c320967f86b9 335
mbed_official 525:c320967f86b9 336 /** Set interrupt flag if the sensor triggers. */
mbed_official 525:c320967f86b9 337 lesenseSetIntLevel = LESENSE_CH_INTERACT_SETIF_LEVEL,
mbed_official 525:c320967f86b9 338
mbed_official 525:c320967f86b9 339 /** Set interrupt flag on positive edge of the sensor state. */
mbed_official 525:c320967f86b9 340 lesenseSetIntPosEdge = LESENSE_CH_INTERACT_SETIF_POSEDGE,
mbed_official 525:c320967f86b9 341
mbed_official 525:c320967f86b9 342 /** Set interrupt flag on negative edge of the sensor state. */
mbed_official 525:c320967f86b9 343 lesenseSetIntNegEdge = LESENSE_CH_INTERACT_SETIF_NEGEDGE
mbed_official 525:c320967f86b9 344 } LESENSE_ChIntMode_TypeDef;
mbed_official 525:c320967f86b9 345
mbed_official 525:c320967f86b9 346
mbed_official 525:c320967f86b9 347 /** Channel pin mode for the excitation phase of the scan sequence. */
mbed_official 525:c320967f86b9 348 typedef enum
mbed_official 525:c320967f86b9 349 {
mbed_official 525:c320967f86b9 350 /** Channel pin is disabled. */
mbed_official 525:c320967f86b9 351 lesenseChPinExDis = LESENSE_CH_INTERACT_EXMODE_DISABLE,
mbed_official 525:c320967f86b9 352
mbed_official 525:c320967f86b9 353 /** Channel pin is configured as push-pull, driven HIGH. */
mbed_official 525:c320967f86b9 354 lesenseChPinExHigh = LESENSE_CH_INTERACT_EXMODE_HIGH,
mbed_official 525:c320967f86b9 355
mbed_official 525:c320967f86b9 356 /** Channel pin is configured as push-pull, driven LOW. */
mbed_official 525:c320967f86b9 357 lesenseChPinExLow = LESENSE_CH_INTERACT_EXMODE_LOW,
mbed_official 525:c320967f86b9 358
mbed_official 525:c320967f86b9 359 /** DAC output (only available on channel 0, 1, 2, 3, 12, 13, 14 and 15) */
mbed_official 525:c320967f86b9 360 lesenseChPinExDACOut = LESENSE_CH_INTERACT_EXMODE_DACOUT
mbed_official 525:c320967f86b9 361 } LESENSE_ChPinExMode_TypeDef;
mbed_official 525:c320967f86b9 362
mbed_official 525:c320967f86b9 363
mbed_official 525:c320967f86b9 364 /** Channel pin mode for the idle phase of the scan sequence. */
mbed_official 525:c320967f86b9 365 typedef enum
mbed_official 525:c320967f86b9 366 {
mbed_official 525:c320967f86b9 367 /** Channel pin is disabled in idle phase.
mbed_official 525:c320967f86b9 368 * Note: this value could be used for all channels. */
mbed_official 525:c320967f86b9 369 lesenseChPinIdleDis = _LESENSE_IDLECONF_CH0_DISABLE,
mbed_official 525:c320967f86b9 370
mbed_official 525:c320967f86b9 371 /** Channel pin is configured as push-pull, driven HIGH in idle phase.
mbed_official 525:c320967f86b9 372 * Note: this value could be used for all channels. */
mbed_official 525:c320967f86b9 373 lesenseChPinIdleHigh = _LESENSE_IDLECONF_CH0_HIGH,
mbed_official 525:c320967f86b9 374
mbed_official 525:c320967f86b9 375 /** Channel pin is configured as push-pull, driven LOW in idle phase.
mbed_official 525:c320967f86b9 376 * Note: this value could be used for all channels. */
mbed_official 525:c320967f86b9 377 lesenseChPinIdleLow = _LESENSE_IDLECONF_CH0_LOW,
mbed_official 525:c320967f86b9 378
mbed_official 525:c320967f86b9 379 /** Channel pin is connected to DAC CH0 output in idle phase.
mbed_official 525:c320967f86b9 380 * Note: only applies to channel 0, 1, 2, 3. */
mbed_official 525:c320967f86b9 381 lesenseChPinIdleDACCh0 = _LESENSE_IDLECONF_CH0_DACCH0,
mbed_official 525:c320967f86b9 382
mbed_official 525:c320967f86b9 383 /** Channel pin is connected to DAC CH1 output in idle phase.
mbed_official 525:c320967f86b9 384 * Note: only applies to channel 12, 13, 14, 15. */
mbed_official 525:c320967f86b9 385 lesenseChPinIdleDACCh1 = _LESENSE_IDLECONF_CH12_DACCH1
mbed_official 525:c320967f86b9 386 } LESENSE_ChPinIdleMode_TypeDef;
mbed_official 525:c320967f86b9 387
mbed_official 525:c320967f86b9 388
mbed_official 525:c320967f86b9 389 /** Clock used for excitation and sample delay timing. */
mbed_official 525:c320967f86b9 390 typedef enum
mbed_official 525:c320967f86b9 391 {
mbed_official 525:c320967f86b9 392 /** LFACLK (LF clock) is used. */
mbed_official 525:c320967f86b9 393 lesenseClkLF = _LESENSE_CH_INTERACT_EXCLK_LFACLK,
mbed_official 525:c320967f86b9 394
mbed_official 525:c320967f86b9 395 /** AUXHFRCO (HF clock) is used. */
mbed_official 525:c320967f86b9 396 lesenseClkHF = _LESENSE_CH_INTERACT_EXCLK_AUXHFRCO
mbed_official 525:c320967f86b9 397 } LESENSE_ChClk_TypeDef;
mbed_official 525:c320967f86b9 398
mbed_official 525:c320967f86b9 399
mbed_official 525:c320967f86b9 400 /** Compare modes for counter comparison. */
mbed_official 525:c320967f86b9 401 typedef enum
mbed_official 525:c320967f86b9 402 {
mbed_official 525:c320967f86b9 403 /** Set interrupt flag if counter value is less than CTRTHRESHOLD, or if the
mbed_official 525:c320967f86b9 404 * ACMP output is 0. */
mbed_official 525:c320967f86b9 405 lesenseCompModeLess = LESENSE_CH_EVAL_COMP_LESS,
mbed_official 525:c320967f86b9 406
mbed_official 525:c320967f86b9 407 /** Set interrupt flag if counter value is greater than, or equal to
mbed_official 525:c320967f86b9 408 * CTRTHRESHOLD, or if the ACMP output is 1. */
mbed_official 525:c320967f86b9 409 lesenseCompModeGreaterOrEq = LESENSE_CH_EVAL_COMP_GE
mbed_official 525:c320967f86b9 410 } LESENSE_ChCompMode_TypeDef;
mbed_official 525:c320967f86b9 411
mbed_official 525:c320967f86b9 412
mbed_official 525:c320967f86b9 413 /** Idle phase configuration of alternate excitation channels. */
mbed_official 525:c320967f86b9 414 typedef enum
mbed_official 525:c320967f86b9 415 {
mbed_official 525:c320967f86b9 416 /** ALTEX output is disabled in idle phase.
mbed_official 525:c320967f86b9 417 * Note: this value could be used for all alternate excitation channels. */
mbed_official 525:c320967f86b9 418 lesenseAltExPinIdleDis = _LESENSE_ALTEXCONF_IDLECONF0_DISABLE,
mbed_official 525:c320967f86b9 419
mbed_official 525:c320967f86b9 420 /** ALTEX output is high in idle phase.
mbed_official 525:c320967f86b9 421 * Note: this value could be used for all alternate excitation channels. */
mbed_official 525:c320967f86b9 422 lesenseAltExPinIdleHigh = _LESENSE_ALTEXCONF_IDLECONF0_HIGH,
mbed_official 525:c320967f86b9 423
mbed_official 525:c320967f86b9 424 /** ALTEX output is low in idle phase.
mbed_official 525:c320967f86b9 425 * Note: this value could be used for all alternate excitation channels. */
mbed_official 525:c320967f86b9 426 lesenseAltExPinIdleLow = _LESENSE_ALTEXCONF_IDLECONF0_LOW
mbed_official 525:c320967f86b9 427 } LESENSE_AltExPinIdle_TypeDef;
mbed_official 525:c320967f86b9 428
mbed_official 525:c320967f86b9 429
mbed_official 525:c320967f86b9 430 /** Transition action modes. */
mbed_official 525:c320967f86b9 431 typedef enum
mbed_official 525:c320967f86b9 432 {
mbed_official 525:c320967f86b9 433 /** No PRS pulses generated (if PRSCOUNT == 0).
mbed_official 525:c320967f86b9 434 * Do not count (if PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 435 lesenseTransActNone = LESENSE_ST_TCONFA_PRSACT_NONE,
mbed_official 525:c320967f86b9 436
mbed_official 525:c320967f86b9 437 /** Generate pulse on LESPRS0 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 438 lesenseTransActPRS0 = LESENSE_ST_TCONFA_PRSACT_PRS0,
mbed_official 525:c320967f86b9 439
mbed_official 525:c320967f86b9 440 /** Generate pulse on LESPRS1 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 441 lesenseTransActPRS1 = LESENSE_ST_TCONFA_PRSACT_PRS1,
mbed_official 525:c320967f86b9 442
mbed_official 525:c320967f86b9 443 /** Generate pulse on LESPRS0 and LESPRS1 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 444 lesenseTransActPRS01 = LESENSE_ST_TCONFA_PRSACT_PRS01,
mbed_official 525:c320967f86b9 445
mbed_official 525:c320967f86b9 446 /** Generate pulse on LESPRS2 (for both PRSCOUNT == 0 and PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 447 lesenseTransActPRS2 = LESENSE_ST_TCONFA_PRSACT_PRS2,
mbed_official 525:c320967f86b9 448
mbed_official 525:c320967f86b9 449 /** Generate pulse on LESPRS0 and LESPRS2 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 450 lesenseTransActPRS02 = LESENSE_ST_TCONFA_PRSACT_PRS02,
mbed_official 525:c320967f86b9 451
mbed_official 525:c320967f86b9 452 /** Generate pulse on LESPRS1 and LESPRS2 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 453 lesenseTransActPRS12 = LESENSE_ST_TCONFA_PRSACT_PRS12,
mbed_official 525:c320967f86b9 454
mbed_official 525:c320967f86b9 455 /** Generate pulse on LESPRS0, LESPRS1 and LESPRS2 (if PRSCOUNT == 0). */
mbed_official 525:c320967f86b9 456 lesenseTransActPRS012 = LESENSE_ST_TCONFA_PRSACT_PRS012,
mbed_official 525:c320967f86b9 457
mbed_official 525:c320967f86b9 458 /** Count up (if PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 459 lesenseTransActUp = LESENSE_ST_TCONFA_PRSACT_UP,
mbed_official 525:c320967f86b9 460
mbed_official 525:c320967f86b9 461 /** Count down (if PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 462 lesenseTransActDown = LESENSE_ST_TCONFA_PRSACT_DOWN,
mbed_official 525:c320967f86b9 463
mbed_official 525:c320967f86b9 464 /** Count up and generate pulse on LESPRS2 (if PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 465 lesenseTransActUpAndPRS2 = LESENSE_ST_TCONFA_PRSACT_UPANDPRS2,
mbed_official 525:c320967f86b9 466
mbed_official 525:c320967f86b9 467 /** Count down and generate pulse on LESPRS2 (if PRSCOUNT == 1). */
mbed_official 525:c320967f86b9 468 lesenseTransActDownAndPRS2 = LESENSE_ST_TCONFA_PRSACT_DOWNANDPRS2
mbed_official 525:c320967f86b9 469 } LESENSE_StTransAct_TypeDef;
mbed_official 525:c320967f86b9 470
mbed_official 525:c320967f86b9 471
mbed_official 525:c320967f86b9 472 /*******************************************************************************
mbed_official 525:c320967f86b9 473 ******************************* STRUCTS ***********************************
mbed_official 525:c320967f86b9 474 ******************************************************************************/
mbed_official 525:c320967f86b9 475
mbed_official 525:c320967f86b9 476 /** Core control (LESENSE_CTRL) descriptor structure. */
mbed_official 525:c320967f86b9 477 typedef struct
mbed_official 525:c320967f86b9 478 {
mbed_official 525:c320967f86b9 479 /** Select scan start mode to control how the scan start is being triggered.*/
mbed_official 525:c320967f86b9 480 LESENSE_ScanMode_TypeDef scanStart;
mbed_official 525:c320967f86b9 481
mbed_official 525:c320967f86b9 482 /** Select PRS source for scan start if scanMode is set to lesensePrsPulse. */
mbed_official 525:c320967f86b9 483 LESENSE_PRSSel_TypeDef prsSel;
mbed_official 525:c320967f86b9 484
mbed_official 525:c320967f86b9 485 /** Select scan configuration register usage strategy. */
mbed_official 525:c320967f86b9 486 LESENSE_ScanConfSel_TypeDef scanConfSel;
mbed_official 525:c320967f86b9 487
mbed_official 525:c320967f86b9 488 /** Set to true to invert ACMP0 output. */
mbed_official 525:c320967f86b9 489 bool invACMP0;
mbed_official 525:c320967f86b9 490
mbed_official 525:c320967f86b9 491 /** Set to true to invert ACMP1 output. */
mbed_official 525:c320967f86b9 492 bool invACMP1;
mbed_official 525:c320967f86b9 493
mbed_official 525:c320967f86b9 494 /** Set to true to sample both ACMPs simultaneously. */
mbed_official 525:c320967f86b9 495 bool dualSample;
mbed_official 525:c320967f86b9 496
mbed_official 525:c320967f86b9 497 /** Set to true in order to to store SCANRES in RAM (accessible via RESDATA)
mbed_official 525:c320967f86b9 498 * after each scan. */
mbed_official 525:c320967f86b9 499 bool storeScanRes;
mbed_official 525:c320967f86b9 500
mbed_official 525:c320967f86b9 501 /** Set to true in order to always make LESENSE write to the result buffer,
mbed_official 525:c320967f86b9 502 * even if it is full. */
mbed_official 525:c320967f86b9 503 bool bufOverWr;
mbed_official 525:c320967f86b9 504
mbed_official 525:c320967f86b9 505 /** Select trigger conditions for interrupt and DMA. */
mbed_official 525:c320967f86b9 506 LESENSE_BufTrigLevel_TypeDef bufTrigLevel;
mbed_official 525:c320967f86b9 507
mbed_official 525:c320967f86b9 508 /** Configure trigger condition for DMA wakeup from EM2. */
mbed_official 525:c320967f86b9 509 LESENSE_DMAWakeUp_TypeDef wakeupOnDMA;
mbed_official 525:c320967f86b9 510
mbed_official 525:c320967f86b9 511 /** Select bias mode. */
mbed_official 525:c320967f86b9 512 LESENSE_BiasMode_TypeDef biasMode;
mbed_official 525:c320967f86b9 513
mbed_official 525:c320967f86b9 514 /** Set to true to keep LESENSE running in debug mode. */
mbed_official 525:c320967f86b9 515 bool debugRun;
mbed_official 525:c320967f86b9 516 } LESENSE_CoreCtrlDesc_TypeDef;
mbed_official 525:c320967f86b9 517
mbed_official 525:c320967f86b9 518 /** Default configuration for LESENSE_CtrlDesc_TypeDef structure. */
mbed_official 525:c320967f86b9 519 #define LESENSE_CORECTRL_DESC_DEFAULT \
mbed_official 525:c320967f86b9 520 { \
mbed_official 525:c320967f86b9 521 lesenseScanStartPeriodic, /* Start new scan each time the period counter overflows. */ \
mbed_official 525:c320967f86b9 522 lesensePRSCh0, /* Default PRS channel is selected. */ \
mbed_official 525:c320967f86b9 523 lesenseScanConfDirMap, /* Direct mapping SCANCONF register usage strategy. */ \
mbed_official 525:c320967f86b9 524 false, /* Don't invert ACMP0 output. */ \
mbed_official 525:c320967f86b9 525 false, /* Don't invert ACMP1 output. */ \
mbed_official 525:c320967f86b9 526 false, /* Disable dual sampling. */ \
mbed_official 525:c320967f86b9 527 true, /* Store scan result after each scan. */ \
mbed_official 525:c320967f86b9 528 true, /* Overwrite result buffer register even if it is full. */ \
mbed_official 525:c320967f86b9 529 lesenseBufTrigHalf, /* Trigger interrupt and DMA request if result buffer is half full. */ \
mbed_official 525:c320967f86b9 530 lesenseDMAWakeUpDisable, /* Don't wake up on DMA from EM2. */ \
mbed_official 525:c320967f86b9 531 lesenseBiasModeDontTouch, /* Don't touch bias configuration. */ \
mbed_official 525:c320967f86b9 532 true /* Keep LESENSE running in debug mode. */ \
mbed_official 525:c320967f86b9 533 }
mbed_official 525:c320967f86b9 534
mbed_official 525:c320967f86b9 535
mbed_official 525:c320967f86b9 536 /** LESENSE timing control descriptor structure. */
mbed_official 525:c320967f86b9 537 typedef struct
mbed_official 525:c320967f86b9 538 {
mbed_official 525:c320967f86b9 539 /** Set the number of LFACLK cycles to delay sensor interaction on
mbed_official 525:c320967f86b9 540 * each channel. Valid range: 0-3 (2 bit). */
mbed_official 525:c320967f86b9 541 uint8_t startDelay;
mbed_official 525:c320967f86b9 542 } LESENSE_TimeCtrlDesc_TypeDef;
mbed_official 525:c320967f86b9 543
mbed_official 525:c320967f86b9 544 /** Default configuration for LESENSE_TimeCtrlDesc_TypeDef structure. */
mbed_official 525:c320967f86b9 545 #define LESENSE_TIMECTRL_DESC_DEFAULT \
mbed_official 525:c320967f86b9 546 { \
mbed_official 525:c320967f86b9 547 0U /* No sensor interaction delay. */ \
mbed_official 525:c320967f86b9 548 }
mbed_official 525:c320967f86b9 549
mbed_official 525:c320967f86b9 550
mbed_official 525:c320967f86b9 551 /** LESENSE peripheral control descriptor structure. */
mbed_official 525:c320967f86b9 552 typedef struct
mbed_official 525:c320967f86b9 553 {
mbed_official 525:c320967f86b9 554 /** Configure DAC channel 0 data control. */
mbed_official 525:c320967f86b9 555 LESENSE_ControlDACData_TypeDef dacCh0Data;
mbed_official 525:c320967f86b9 556
mbed_official 525:c320967f86b9 557 /** Configure how LESENSE controls conversion on DAC channel 0. */
mbed_official 525:c320967f86b9 558 LESENSE_ControlDACConv_TypeDef dacCh0ConvMode;
mbed_official 525:c320967f86b9 559
mbed_official 525:c320967f86b9 560 /** Configure how LESENSE controls output on DAC channel 0. */
mbed_official 525:c320967f86b9 561 LESENSE_ControlDACOut_TypeDef dacCh0OutMode;
mbed_official 525:c320967f86b9 562
mbed_official 525:c320967f86b9 563 /** Configure DAC channel 1 data control. */
mbed_official 525:c320967f86b9 564 LESENSE_ControlDACData_TypeDef dacCh1Data;
mbed_official 525:c320967f86b9 565
mbed_official 525:c320967f86b9 566 /** Configure how LESENSE controls conversion on DAC channel 1. */
mbed_official 525:c320967f86b9 567 LESENSE_ControlDACConv_TypeDef dacCh1ConvMode;
mbed_official 525:c320967f86b9 568
mbed_official 525:c320967f86b9 569 /** Configure how LESENSE controls output on DAC channel 1. */
mbed_official 525:c320967f86b9 570 LESENSE_ControlDACOut_TypeDef dacCh1OutMode;
mbed_official 525:c320967f86b9 571
mbed_official 525:c320967f86b9 572 /** Configure the prescaling factor for the LESENSE - DAC interface.
mbed_official 525:c320967f86b9 573 * Valid range: 0-31 (5bit). */
mbed_official 525:c320967f86b9 574 uint8_t dacPresc;
mbed_official 525:c320967f86b9 575
mbed_official 525:c320967f86b9 576 /** Configure the DAC reference to be used. Set to #lesenseDACRefVdd to use
mbed_official 525:c320967f86b9 577 * VDD and set to #lesenseDACRefBandGap to use bandgap as reference. */
mbed_official 525:c320967f86b9 578 LESENSE_DACRef_TypeDef dacRef;
mbed_official 525:c320967f86b9 579
mbed_official 525:c320967f86b9 580 /** Configure how LESENSE controls ACMP 0. */
mbed_official 525:c320967f86b9 581 LESENSE_ControlACMP_TypeDef acmp0Mode;
mbed_official 525:c320967f86b9 582
mbed_official 525:c320967f86b9 583 /** Configure how LESENSE controls ACMP 1. */
mbed_official 525:c320967f86b9 584 LESENSE_ControlACMP_TypeDef acmp1Mode;
mbed_official 525:c320967f86b9 585
mbed_official 525:c320967f86b9 586 /** Configure how LESENSE controls ACMPs and the DAC in idle mode. */
mbed_official 525:c320967f86b9 587 LESENSE_WarmupMode_TypeDef warmupMode;
mbed_official 525:c320967f86b9 588 } LESENSE_PerCtrlDesc_TypeDef;
mbed_official 525:c320967f86b9 589
mbed_official 525:c320967f86b9 590 /** Default configuration for LESENSE_PerCtrl_TypeDef structure. */
mbed_official 525:c320967f86b9 591 #define LESENSE_PERCTRL_DESC_DEFAULT \
mbed_official 525:c320967f86b9 592 { \
mbed_official 525:c320967f86b9 593 lesenseDACIfData, /**/ \
mbed_official 525:c320967f86b9 594 lesenseDACConvModeDisable, /**/ \
mbed_official 525:c320967f86b9 595 lesenseDACOutModeDisable, /**/ \
mbed_official 525:c320967f86b9 596 lesenseDACIfData, /**/ \
mbed_official 525:c320967f86b9 597 lesenseDACConvModeDisable, /**/ \
mbed_official 525:c320967f86b9 598 lesenseDACOutModeDisable, /**/ \
mbed_official 525:c320967f86b9 599 0U, /**/ \
mbed_official 525:c320967f86b9 600 lesenseDACRefVdd, /**/ \
mbed_official 525:c320967f86b9 601 lesenseACMPModeMuxThres, /**/ \
mbed_official 525:c320967f86b9 602 lesenseACMPModeMuxThres, /**/ \
mbed_official 525:c320967f86b9 603 lesenseWarmupModeKeepWarm, /**/ \
mbed_official 525:c320967f86b9 604 }
mbed_official 525:c320967f86b9 605
mbed_official 525:c320967f86b9 606
mbed_official 525:c320967f86b9 607 /** LESENSE decoder control descriptor structure. */
mbed_official 525:c320967f86b9 608 typedef struct
mbed_official 525:c320967f86b9 609 {
mbed_official 525:c320967f86b9 610 /** Select the input to the LESENSE decoder. */
mbed_official 525:c320967f86b9 611 LESENSE_DecInput_TypeDef decInput;
mbed_official 525:c320967f86b9 612
mbed_official 525:c320967f86b9 613 /** Initial state of the LESENSE decoder. */
mbed_official 525:c320967f86b9 614 uint32_t initState;
mbed_official 525:c320967f86b9 615
mbed_official 525:c320967f86b9 616 /** Set to enable the decoder to check the present state in addition
mbed_official 525:c320967f86b9 617 * to the states defined in DECCONF. */
mbed_official 525:c320967f86b9 618 bool chkState;
mbed_official 525:c320967f86b9 619
mbed_official 525:c320967f86b9 620 /** When set, a transition from state x in the decoder will set interrupt flag
mbed_official 525:c320967f86b9 621 * CHx. */
mbed_official 525:c320967f86b9 622 bool intMap;
mbed_official 525:c320967f86b9 623
mbed_official 525:c320967f86b9 624 /** Set to enable hysteresis in the decoder for suppressing changes on PRS
mbed_official 525:c320967f86b9 625 * channel 0. */
mbed_official 525:c320967f86b9 626 bool hystPRS0;
mbed_official 525:c320967f86b9 627
mbed_official 525:c320967f86b9 628 /** Set to enable hysteresis in the decoder for suppressing changes on PRS
mbed_official 525:c320967f86b9 629 * channel 1. */
mbed_official 525:c320967f86b9 630 bool hystPRS1;
mbed_official 525:c320967f86b9 631
mbed_official 525:c320967f86b9 632 /** Set to enable hysteresis in the decoder for suppressing changes on PRS
mbed_official 525:c320967f86b9 633 * channel 2. */
mbed_official 525:c320967f86b9 634 bool hystPRS2;
mbed_official 525:c320967f86b9 635
mbed_official 525:c320967f86b9 636 /** Set to enable hysteresis in the decoder for suppressing interrupt
mbed_official 525:c320967f86b9 637 * requests. */
mbed_official 525:c320967f86b9 638 bool hystIRQ;
mbed_official 525:c320967f86b9 639
mbed_official 525:c320967f86b9 640 /** Set to enable count mode on decoder PRS channels 0 and 1 to produce
mbed_official 525:c320967f86b9 641 * outputs which can be used by a PCNT to count up or down. */
mbed_official 525:c320967f86b9 642 bool prsCount;
mbed_official 525:c320967f86b9 643
mbed_official 525:c320967f86b9 644 /** Select PRS channel input for bit 0 of the LESENSE decoder. */
mbed_official 525:c320967f86b9 645 LESENSE_PRSSel_TypeDef prsChSel0;
mbed_official 525:c320967f86b9 646
mbed_official 525:c320967f86b9 647 /** Select PRS channel input for bit 1 of the LESENSE decoder. */
mbed_official 525:c320967f86b9 648 LESENSE_PRSSel_TypeDef prsChSel1;
mbed_official 525:c320967f86b9 649
mbed_official 525:c320967f86b9 650 /** Select PRS channel input for bit 2 of the LESENSE decoder. */
mbed_official 525:c320967f86b9 651 LESENSE_PRSSel_TypeDef prsChSel2;
mbed_official 525:c320967f86b9 652
mbed_official 525:c320967f86b9 653 /** Select PRS channel input for bit 3 of the LESENSE decoder. */
mbed_official 525:c320967f86b9 654 LESENSE_PRSSel_TypeDef prsChSel3;
mbed_official 525:c320967f86b9 655 } LESENSE_DecCtrlDesc_TypeDef;
mbed_official 525:c320967f86b9 656
mbed_official 525:c320967f86b9 657 /** Default configuration for LESENSE_PerCtrl_TypeDef structure. */
mbed_official 525:c320967f86b9 658 #define LESENSE_DECCTRL_DESC_DEFAULT \
mbed_official 525:c320967f86b9 659 { \
mbed_official 525:c320967f86b9 660 lesenseDecInputSensorSt, /**/ \
mbed_official 525:c320967f86b9 661 0U, /**/ \
mbed_official 525:c320967f86b9 662 false, /**/ \
mbed_official 525:c320967f86b9 663 true, /**/ \
mbed_official 525:c320967f86b9 664 true, /**/ \
mbed_official 525:c320967f86b9 665 true, /**/ \
mbed_official 525:c320967f86b9 666 true, /**/ \
mbed_official 525:c320967f86b9 667 true, /**/ \
mbed_official 525:c320967f86b9 668 false, /**/ \
mbed_official 525:c320967f86b9 669 lesensePRSCh0, /**/ \
mbed_official 525:c320967f86b9 670 lesensePRSCh1, /**/ \
mbed_official 525:c320967f86b9 671 lesensePRSCh2, /**/ \
mbed_official 525:c320967f86b9 672 lesensePRSCh3, /**/ \
mbed_official 525:c320967f86b9 673 }
mbed_official 525:c320967f86b9 674
mbed_official 525:c320967f86b9 675
mbed_official 525:c320967f86b9 676 /** LESENSE module initialization structure. */
mbed_official 525:c320967f86b9 677 typedef struct
mbed_official 525:c320967f86b9 678 {
mbed_official 525:c320967f86b9 679 /** LESENSE core configuration parameters. */
mbed_official 525:c320967f86b9 680 LESENSE_CoreCtrlDesc_TypeDef coreCtrl;
mbed_official 525:c320967f86b9 681
mbed_official 525:c320967f86b9 682 /** LESENSE timing configuration parameters. */
mbed_official 525:c320967f86b9 683 LESENSE_TimeCtrlDesc_TypeDef timeCtrl;
mbed_official 525:c320967f86b9 684
mbed_official 525:c320967f86b9 685 /** LESENSE peripheral configuration parameters. */
mbed_official 525:c320967f86b9 686 LESENSE_PerCtrlDesc_TypeDef perCtrl;
mbed_official 525:c320967f86b9 687
mbed_official 525:c320967f86b9 688 /** LESENSE decoder configuration parameters. */
mbed_official 525:c320967f86b9 689 LESENSE_DecCtrlDesc_TypeDef decCtrl;
mbed_official 525:c320967f86b9 690 } LESENSE_Init_TypeDef;
mbed_official 525:c320967f86b9 691
mbed_official 525:c320967f86b9 692 /** Default configuration for LESENSE_Init_TypeDef structure. */
mbed_official 525:c320967f86b9 693 #define LESENSE_INIT_DEFAULT \
mbed_official 525:c320967f86b9 694 { \
mbed_official 525:c320967f86b9 695 .coreCtrl = LESENSE_CORECTRL_DESC_DEFAULT, /* Default core control parameters. */ \
mbed_official 525:c320967f86b9 696 .timeCtrl = LESENSE_TIMECTRL_DESC_DEFAULT, /* Default time control parameters. */ \
mbed_official 525:c320967f86b9 697 .perCtrl = LESENSE_PERCTRL_DESC_DEFAULT, /* Default peripheral control parameters. */ \
mbed_official 525:c320967f86b9 698 .decCtrl = LESENSE_DECCTRL_DESC_DEFAULT /* Default decoder control parameters. */ \
mbed_official 525:c320967f86b9 699 }
mbed_official 525:c320967f86b9 700
mbed_official 525:c320967f86b9 701
mbed_official 525:c320967f86b9 702 /** Channel descriptor structure. */
mbed_official 525:c320967f86b9 703 typedef struct
mbed_official 525:c320967f86b9 704 {
mbed_official 525:c320967f86b9 705 /** Set to enable scan channel CHx. */
mbed_official 525:c320967f86b9 706 bool enaScanCh;
mbed_official 525:c320967f86b9 707
mbed_official 525:c320967f86b9 708 /** Set to enable CHx pin. */
mbed_official 525:c320967f86b9 709 bool enaPin;
mbed_official 525:c320967f86b9 710
mbed_official 525:c320967f86b9 711 /** Enable/disable channel interrupts after configuring all the sensor channel
mbed_official 525:c320967f86b9 712 * parameters. */
mbed_official 525:c320967f86b9 713 bool enaInt;
mbed_official 525:c320967f86b9 714
mbed_official 525:c320967f86b9 715 /** Configure channel pin mode for the excitation phase of the scan sequence.
mbed_official 525:c320967f86b9 716 * Note: OPAOUT is only available on channels 2, 3, 4, and 5. */
mbed_official 525:c320967f86b9 717 LESENSE_ChPinExMode_TypeDef chPinExMode;
mbed_official 525:c320967f86b9 718
mbed_official 525:c320967f86b9 719 /** Configure channel pin idle setup in LESENSE idle phase. */
mbed_official 525:c320967f86b9 720 LESENSE_ChPinIdleMode_TypeDef chPinIdleMode;
mbed_official 525:c320967f86b9 721
mbed_official 525:c320967f86b9 722 /** Set to use alternate excite pin for excitation. */
mbed_official 525:c320967f86b9 723 bool useAltEx;
mbed_official 525:c320967f86b9 724
mbed_official 525:c320967f86b9 725 /** Set to enable the result from this channel being shifted into the decoder
mbed_official 525:c320967f86b9 726 * register. */
mbed_official 525:c320967f86b9 727 bool shiftRes;
mbed_official 525:c320967f86b9 728
mbed_official 525:c320967f86b9 729 /** Set to invert the result bit stored in SCANRES register. */
mbed_official 525:c320967f86b9 730 bool invRes;
mbed_official 525:c320967f86b9 731
mbed_official 525:c320967f86b9 732 /** Set to store the counter value in RAM (accessible via RESDATA) and make
mbed_official 525:c320967f86b9 733 * the comparison result available in the SCANRES register. */
mbed_official 525:c320967f86b9 734 bool storeCntRes;
mbed_official 525:c320967f86b9 735
mbed_official 525:c320967f86b9 736 /** Select clock used for excitation timing. */
mbed_official 525:c320967f86b9 737 LESENSE_ChClk_TypeDef exClk;
mbed_official 525:c320967f86b9 738
mbed_official 525:c320967f86b9 739 /** Select clock used for sample delay timing. */
mbed_official 525:c320967f86b9 740 LESENSE_ChClk_TypeDef sampleClk;
mbed_official 525:c320967f86b9 741
mbed_official 525:c320967f86b9 742 /** Configure excitation time. Excitation will last exTime+1 excitation clock
mbed_official 525:c320967f86b9 743 * cycles. Valid range: 0-63 (6 bits). */
mbed_official 525:c320967f86b9 744 uint8_t exTime;
mbed_official 525:c320967f86b9 745
mbed_official 525:c320967f86b9 746 /** Configure sample delay. Sampling will occur after sampleDelay+1 sample
mbed_official 525:c320967f86b9 747 * clock cycles. Valid range: 0-127 (7 bits). */
mbed_official 525:c320967f86b9 748 uint8_t sampleDelay;
mbed_official 525:c320967f86b9 749
mbed_official 525:c320967f86b9 750 /** Configure measure delay. Sensor measuring is delayed for measDelay
mbed_official 525:c320967f86b9 751 * excitation clock cycles. Valid range: 0-127 (7 bits). */
mbed_official 525:c320967f86b9 752 uint8_t measDelay;
mbed_official 525:c320967f86b9 753
mbed_official 525:c320967f86b9 754 /** Configure ACMP threshold.
mbed_official 525:c320967f86b9 755 * If perCtrl.dacCh0Data or perCtrl.dacCh1Data is set to #lesenseDACIfData,
mbed_official 525:c320967f86b9 756 * acmpThres defines the 12-bit DAC data in the corresponding data register
mbed_official 525:c320967f86b9 757 * of the DAC interface (DACn_CH0DATA and DACn_CH1DATA).
mbed_official 525:c320967f86b9 758 * In this case, the valid range is: 0-4095 (12 bits).
mbed_official 525:c320967f86b9 759 * If perCtrl.dacCh0Data or perCtrl.dacCh1Data is set to #lesenseACMPThres,
mbed_official 525:c320967f86b9 760 * acmpThres defines the 6-bit Vdd scaling factor of ACMP negative input
mbed_official 525:c320967f86b9 761 * (VDDLEVEL in ACMP_INPUTSEL register).
mbed_official 525:c320967f86b9 762 * In this case, the valid range is: 0-63 (6 bits). */
mbed_official 525:c320967f86b9 763 uint16_t acmpThres;
mbed_official 525:c320967f86b9 764
mbed_official 525:c320967f86b9 765 /** Select if ACMP output or counter output should be used in comparison. */
mbed_official 525:c320967f86b9 766 LESENSE_ChSampleMode_TypeDef sampleMode;
mbed_official 525:c320967f86b9 767
mbed_official 525:c320967f86b9 768 /** Configure interrupt generation mode for CHx interrupt flag. */
mbed_official 525:c320967f86b9 769 LESENSE_ChIntMode_TypeDef intMode;
mbed_official 525:c320967f86b9 770
mbed_official 525:c320967f86b9 771 /** Configure decision threshold for counter comparison.
mbed_official 525:c320967f86b9 772 * Valid range: 0-65535 (16 bits). */
mbed_official 525:c320967f86b9 773 uint16_t cntThres;
mbed_official 525:c320967f86b9 774
mbed_official 525:c320967f86b9 775 /** Select mode for counter comparison. */
mbed_official 525:c320967f86b9 776 LESENSE_ChCompMode_TypeDef compMode;
mbed_official 525:c320967f86b9 777 } LESENSE_ChDesc_TypeDef;
mbed_official 525:c320967f86b9 778
mbed_official 525:c320967f86b9 779
mbed_official 525:c320967f86b9 780 /** Configuration structure for all scan channels. */
mbed_official 525:c320967f86b9 781 typedef struct
mbed_official 525:c320967f86b9 782 {
mbed_official 525:c320967f86b9 783 /** Channel descriptor for all 16 channels. */
mbed_official 525:c320967f86b9 784 LESENSE_ChDesc_TypeDef Ch[16];
mbed_official 525:c320967f86b9 785 } LESENSE_ChAll_TypeDef;
mbed_official 525:c320967f86b9 786
mbed_official 525:c320967f86b9 787 /** Default configuration for scan channel. */
mbed_official 525:c320967f86b9 788 #define LESENSE_CH_CONF_DEFAULT \
mbed_official 525:c320967f86b9 789 { \
mbed_official 525:c320967f86b9 790 true, /* Enable scan channel. */ \
mbed_official 525:c320967f86b9 791 true, /* Enable the assigned pin on scan channel. */ \
mbed_official 525:c320967f86b9 792 true, /* Enable interrupts on channel. */ \
mbed_official 525:c320967f86b9 793 lesenseChPinExHigh, /* Channel pin is high during the excitation period. */ \
mbed_official 525:c320967f86b9 794 lesenseChPinIdleLow, /* Channel pin is low during the idle period. */ \
mbed_official 525:c320967f86b9 795 false, /* Don't use alternate excitation pins for excitation. */ \
mbed_official 525:c320967f86b9 796 false, /* Disabled to shift results from this channel to the decoder register. */ \
mbed_official 525:c320967f86b9 797 false, /* Disabled to invert the scan result bit. */ \
mbed_official 525:c320967f86b9 798 false, /* Disabled to store counter value in the result buffer. */ \
mbed_official 525:c320967f86b9 799 lesenseClkLF, /* Use the LF clock for excitation timing. */ \
mbed_official 525:c320967f86b9 800 lesenseClkLF, /* Use the LF clock for sample timing. */ \
mbed_official 525:c320967f86b9 801 0x03U, /* Excitation time is set to 3(+1) excitation clock cycles. */ \
mbed_official 525:c320967f86b9 802 0x09U, /* Sample delay is set to 9(+1) sample clock cycles. */ \
mbed_official 525:c320967f86b9 803 0x06U, /* Measure delay is set to 6 excitation clock cycles.*/ \
mbed_official 525:c320967f86b9 804 0x00U, /* ACMP threshold has been set to 0. */ \
mbed_official 525:c320967f86b9 805 lesenseSampleModeACMP, /* ACMP output will be used in comparison. */ \
mbed_official 525:c320967f86b9 806 lesenseSetIntNone, /* No interrupt is generated by the channel. */ \
mbed_official 525:c320967f86b9 807 0xFFU, /* Counter threshold has bee set to 0xFF. */ \
mbed_official 525:c320967f86b9 808 lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \
mbed_official 525:c320967f86b9 809 }
mbed_official 525:c320967f86b9 810
mbed_official 525:c320967f86b9 811 /** Default configuration for all sensor channels. */
mbed_official 525:c320967f86b9 812 #define LESENSE_SCAN_CONF_DEFAULT \
mbed_official 525:c320967f86b9 813 { \
mbed_official 525:c320967f86b9 814 { \
mbed_official 525:c320967f86b9 815 LESENSE_CH_CONF_DEFAULT, /* Scan channel 0. */ \
mbed_official 525:c320967f86b9 816 LESENSE_CH_CONF_DEFAULT, /* Scan channel 1. */ \
mbed_official 525:c320967f86b9 817 LESENSE_CH_CONF_DEFAULT, /* Scan channel 2. */ \
mbed_official 525:c320967f86b9 818 LESENSE_CH_CONF_DEFAULT, /* Scan channel 3. */ \
mbed_official 525:c320967f86b9 819 LESENSE_CH_CONF_DEFAULT, /* Scan channel 4. */ \
mbed_official 525:c320967f86b9 820 LESENSE_CH_CONF_DEFAULT, /* Scan channel 5. */ \
mbed_official 525:c320967f86b9 821 LESENSE_CH_CONF_DEFAULT, /* Scan channel 6. */ \
mbed_official 525:c320967f86b9 822 LESENSE_CH_CONF_DEFAULT, /* Scan channel 7. */ \
mbed_official 525:c320967f86b9 823 LESENSE_CH_CONF_DEFAULT, /* Scan channel 8. */ \
mbed_official 525:c320967f86b9 824 LESENSE_CH_CONF_DEFAULT, /* Scan channel 9. */ \
mbed_official 525:c320967f86b9 825 LESENSE_CH_CONF_DEFAULT, /* Scan channel 10. */ \
mbed_official 525:c320967f86b9 826 LESENSE_CH_CONF_DEFAULT, /* Scan channel 11. */ \
mbed_official 525:c320967f86b9 827 LESENSE_CH_CONF_DEFAULT, /* Scan channel 12. */ \
mbed_official 525:c320967f86b9 828 LESENSE_CH_CONF_DEFAULT, /* Scan channel 13. */ \
mbed_official 525:c320967f86b9 829 LESENSE_CH_CONF_DEFAULT, /* Scan channel 14. */ \
mbed_official 525:c320967f86b9 830 LESENSE_CH_CONF_DEFAULT, /* Scan channel 15. */ \
mbed_official 525:c320967f86b9 831 } \
mbed_official 525:c320967f86b9 832 }
mbed_official 525:c320967f86b9 833
mbed_official 525:c320967f86b9 834
mbed_official 525:c320967f86b9 835 /** Alternate excitation descriptor structure. */
mbed_official 525:c320967f86b9 836 typedef struct
mbed_official 525:c320967f86b9 837 {
mbed_official 525:c320967f86b9 838 /** Configure alternate excitation pins. If set, the corresponding alternate
mbed_official 525:c320967f86b9 839 * excitation pin/signal is enabled. */
mbed_official 525:c320967f86b9 840 bool enablePin;
mbed_official 525:c320967f86b9 841
mbed_official 525:c320967f86b9 842 /** Configure idle phase setup of alternate excitation pins.
mbed_official 525:c320967f86b9 843 The idleConf parameter is not valid when altExMap==lesenseAltExMapACMP. */
mbed_official 525:c320967f86b9 844 LESENSE_AltExPinIdle_TypeDef idleConf;
mbed_official 525:c320967f86b9 845
mbed_official 525:c320967f86b9 846 /** Configure how to control the external alternate excitation pins. Only
mbed_official 525:c320967f86b9 847 * applies if altExMap has been set to lesenseAltExMapALTEX.
mbed_official 525:c320967f86b9 848 * If true, the excitation happens on the corresponding alternate excitation
mbed_official 525:c320967f86b9 849 * pin during the excitation periods of all enabled channels.
mbed_official 525:c320967f86b9 850 * If false, the excitation happens on the corresponding alternate excitation
mbed_official 525:c320967f86b9 851 * pin ONLY during the excitation period of the corresponding channel.
mbed_official 525:c320967f86b9 852 * The alwaysEx parameter is not valid when altExMap==lesenseAltExMapACMP. */
mbed_official 525:c320967f86b9 853 bool alwaysEx;
mbed_official 525:c320967f86b9 854 } LESENSE_AltExDesc_TypeDef;
mbed_official 525:c320967f86b9 855
mbed_official 525:c320967f86b9 856
mbed_official 525:c320967f86b9 857 /** Configuration structure for alternate excitation. */
mbed_official 525:c320967f86b9 858 typedef struct
mbed_official 525:c320967f86b9 859 {
mbed_official 525:c320967f86b9 860 /** Select alternate excitation mapping. */
mbed_official 525:c320967f86b9 861 LESENSE_AltExMap_TypeDef altExMap;
mbed_official 525:c320967f86b9 862
mbed_official 525:c320967f86b9 863 /** Alternate excitation channel descriptors.
mbed_official 525:c320967f86b9 864 * When altExMap==lesenseAltExMapALTEX only the 8 first descriptors are used.
mbed_official 525:c320967f86b9 865 * In this mode they describe the configuration of the LES_ALTEX0-7 pins.
mbed_official 525:c320967f86b9 866 * When altExMap==lesenseAltExMapACMP all 16 descriptors are used. In this
mbed_official 525:c320967f86b9 867 * mode they describe the configuration of the 16 possible ACMP0-1 excitation
mbed_official 525:c320967f86b9 868 * channels. Please refer to the user manual for a complete mapping of the
mbed_official 525:c320967f86b9 869 * routing.
mbed_official 525:c320967f86b9 870 * NOTE:
mbed_official 525:c320967f86b9 871 * Some parameters in the descriptors are not valid when
mbed_official 525:c320967f86b9 872 * altExMap==lesenseAltExMapACMP. Please refer to the definition of the
mbed_official 525:c320967f86b9 873 * LESENSE_AltExDesc_TypeDef structure for details regarding which parameters
mbed_official 525:c320967f86b9 874 * are valid. */
mbed_official 525:c320967f86b9 875 LESENSE_AltExDesc_TypeDef AltEx[16];
mbed_official 525:c320967f86b9 876
mbed_official 525:c320967f86b9 877 } LESENSE_ConfAltEx_TypeDef;
mbed_official 525:c320967f86b9 878
mbed_official 525:c320967f86b9 879
mbed_official 525:c320967f86b9 880 /** Default configuration for alternate excitation channel. */
mbed_official 525:c320967f86b9 881 #define LESENSE_ALTEX_CH_CONF_DEFAULT \
mbed_official 525:c320967f86b9 882 { \
mbed_official 525:c320967f86b9 883 true, /* Alternate excitation enabled.*/ \
mbed_official 525:c320967f86b9 884 lesenseAltExPinIdleDis,/* Alternate excitation pin is disabled in idle. */ \
mbed_official 525:c320967f86b9 885 false /* Excite only for corresponding channel. */ \
mbed_official 525:c320967f86b9 886 }
mbed_official 525:c320967f86b9 887
mbed_official 525:c320967f86b9 888 /** Default configuration for all alternate excitation channels. */
mbed_official 525:c320967f86b9 889 #define LESENSE_ALTEX_CONF_DEFAULT \
mbed_official 525:c320967f86b9 890 { \
mbed_official 525:c320967f86b9 891 lesenseAltExMapACMP, \
mbed_official 525:c320967f86b9 892 { \
mbed_official 525:c320967f86b9 893 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 0. */ \
mbed_official 525:c320967f86b9 894 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 1. */ \
mbed_official 525:c320967f86b9 895 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 2. */ \
mbed_official 525:c320967f86b9 896 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 3. */ \
mbed_official 525:c320967f86b9 897 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 4. */ \
mbed_official 525:c320967f86b9 898 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 5. */ \
mbed_official 525:c320967f86b9 899 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 6. */ \
mbed_official 525:c320967f86b9 900 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 7. */ \
mbed_official 525:c320967f86b9 901 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 8. */ \
mbed_official 525:c320967f86b9 902 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 9. */ \
mbed_official 525:c320967f86b9 903 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 10. */ \
mbed_official 525:c320967f86b9 904 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 11. */ \
mbed_official 525:c320967f86b9 905 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 12. */ \
mbed_official 525:c320967f86b9 906 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 13. */ \
mbed_official 525:c320967f86b9 907 LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 14. */ \
mbed_official 525:c320967f86b9 908 LESENSE_ALTEX_CH_CONF_DEFAULT /* Alternate excitation channel 15. */ \
mbed_official 525:c320967f86b9 909 } \
mbed_official 525:c320967f86b9 910 }
mbed_official 525:c320967f86b9 911
mbed_official 525:c320967f86b9 912
mbed_official 525:c320967f86b9 913 /** Decoder state condition descriptor structure. */
mbed_official 525:c320967f86b9 914 typedef struct
mbed_official 525:c320967f86b9 915 {
mbed_official 525:c320967f86b9 916 /** Configure compare value. State transition is triggered when sensor state
mbed_official 525:c320967f86b9 917 * equals to this value. Valid range: 0-15 (4 bits). */
mbed_official 525:c320967f86b9 918 uint8_t compVal;
mbed_official 525:c320967f86b9 919
mbed_official 525:c320967f86b9 920 /** Configure compare mask. Set bit X to exclude sensor X from evaluation.
mbed_official 525:c320967f86b9 921 * Note: decoder can handle sensor inputs from up to 4 sensors, therefore
mbed_official 525:c320967f86b9 922 * this mask is 4 bit long. */
mbed_official 525:c320967f86b9 923 uint8_t compMask;
mbed_official 525:c320967f86b9 924
mbed_official 525:c320967f86b9 925 /** Configure index of state to be entered if the sensor state equals to
mbed_official 525:c320967f86b9 926 * compVal. Valid range: 0-15 (4 bits). */
mbed_official 525:c320967f86b9 927 uint8_t nextState;
mbed_official 525:c320967f86b9 928
mbed_official 525:c320967f86b9 929 /** Configure which PRS action to perform when sensor state equals to
mbed_official 525:c320967f86b9 930 * compVal. */
mbed_official 525:c320967f86b9 931 LESENSE_StTransAct_TypeDef prsAct;
mbed_official 525:c320967f86b9 932
mbed_official 525:c320967f86b9 933 /** If enabled, interrupt flag is set when sensor state equals to compVal. */
mbed_official 525:c320967f86b9 934 bool setInt;
mbed_official 525:c320967f86b9 935 } LESENSE_DecStCond_TypeDef;
mbed_official 525:c320967f86b9 936
mbed_official 525:c320967f86b9 937 /** Default configuration for decoder state condition. */
mbed_official 525:c320967f86b9 938 #define LESENSE_ST_CONF_DEFAULT \
mbed_official 525:c320967f86b9 939 { \
mbed_official 525:c320967f86b9 940 0x0FU, /* Compare value set to 0x0F. */ \
mbed_official 525:c320967f86b9 941 0x00U, /* All decoder inputs masked. */ \
mbed_official 525:c320967f86b9 942 0U, /* Next state is state 0. */ \
mbed_official 525:c320967f86b9 943 lesenseTransActNone, /* No PRS action performed on compare match. */ \
mbed_official 525:c320967f86b9 944 false /* No interrupt triggered on compare match. */ \
mbed_official 525:c320967f86b9 945 }
mbed_official 525:c320967f86b9 946
mbed_official 525:c320967f86b9 947
mbed_official 525:c320967f86b9 948 /** Decoder state x configuration structure. */
mbed_official 525:c320967f86b9 949 typedef struct
mbed_official 525:c320967f86b9 950 {
mbed_official 525:c320967f86b9 951 /** If enabled, the state descriptor pair in the next location will also be
mbed_official 525:c320967f86b9 952 * evaluated. */
mbed_official 525:c320967f86b9 953 bool chainDesc;
mbed_official 525:c320967f86b9 954
mbed_official 525:c320967f86b9 955 /** State condition descriptor A (high level descriptor of
mbed_official 525:c320967f86b9 956 * LESENSE_STx_DECCONFA). */
mbed_official 525:c320967f86b9 957 LESENSE_DecStCond_TypeDef confA;
mbed_official 525:c320967f86b9 958
mbed_official 525:c320967f86b9 959 /** State condition descriptor B (high level descriptor of
mbed_official 525:c320967f86b9 960 * LESENSE_STx_DECCONFB). */
mbed_official 525:c320967f86b9 961 LESENSE_DecStCond_TypeDef confB;
mbed_official 525:c320967f86b9 962 } LESENSE_DecStDesc_TypeDef;
mbed_official 525:c320967f86b9 963
mbed_official 525:c320967f86b9 964
mbed_official 525:c320967f86b9 965 /** Configuration structure for the decoder. */
mbed_official 525:c320967f86b9 966 typedef struct
mbed_official 525:c320967f86b9 967 {
mbed_official 525:c320967f86b9 968 /** Descriptor of the 16 decoder states. */
mbed_official 525:c320967f86b9 969 LESENSE_DecStDesc_TypeDef St[16];
mbed_official 525:c320967f86b9 970 } LESENSE_DecStAll_TypeDef;
mbed_official 525:c320967f86b9 971
mbed_official 525:c320967f86b9 972 /** Default configuration for all decoder states. */
mbed_official 525:c320967f86b9 973 #define LESENSE_DECODER_CONF_DEFAULT \
mbed_official 525:c320967f86b9 974 { /* chain | Descriptor A | Descriptor B */ \
mbed_official 525:c320967f86b9 975 { \
mbed_official 525:c320967f86b9 976 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 0. */ \
mbed_official 525:c320967f86b9 977 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 1. */ \
mbed_official 525:c320967f86b9 978 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 2. */ \
mbed_official 525:c320967f86b9 979 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 3. */ \
mbed_official 525:c320967f86b9 980 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 4. */ \
mbed_official 525:c320967f86b9 981 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 5. */ \
mbed_official 525:c320967f86b9 982 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 6. */ \
mbed_official 525:c320967f86b9 983 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 7. */ \
mbed_official 525:c320967f86b9 984 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 8. */ \
mbed_official 525:c320967f86b9 985 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 9. */ \
mbed_official 525:c320967f86b9 986 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 10. */ \
mbed_official 525:c320967f86b9 987 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 11. */ \
mbed_official 525:c320967f86b9 988 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 12. */ \
mbed_official 525:c320967f86b9 989 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 13. */ \
mbed_official 525:c320967f86b9 990 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT }, /* Decoder state 14. */ \
mbed_official 525:c320967f86b9 991 { false, LESENSE_ST_CONF_DEFAULT, LESENSE_ST_CONF_DEFAULT } /* Decoder state 15. */ \
mbed_official 525:c320967f86b9 992 } \
mbed_official 525:c320967f86b9 993 }
mbed_official 525:c320967f86b9 994
mbed_official 525:c320967f86b9 995 /*******************************************************************************
mbed_official 525:c320967f86b9 996 ***************************** PROTOTYPES **********************************
mbed_official 525:c320967f86b9 997 ******************************************************************************/
mbed_official 525:c320967f86b9 998 void LESENSE_Init(LESENSE_Init_TypeDef const *init, bool const reqReset);
mbed_official 525:c320967f86b9 999 void LESENSE_Reset(void);
mbed_official 525:c320967f86b9 1000
mbed_official 525:c320967f86b9 1001 uint32_t LESENSE_ScanFreqSet(uint32_t refFreq, uint32_t const scanFreq);
mbed_official 525:c320967f86b9 1002 void LESENSE_ScanModeSet(LESENSE_ScanMode_TypeDef const scanMode,
mbed_official 525:c320967f86b9 1003 bool const start);
mbed_official 525:c320967f86b9 1004
mbed_official 525:c320967f86b9 1005 void LESENSE_StartDelaySet(uint8_t const startDelay);
mbed_official 525:c320967f86b9 1006
mbed_official 525:c320967f86b9 1007 void LESENSE_ClkDivSet(LESENSE_ChClk_TypeDef const clk,
mbed_official 525:c320967f86b9 1008 LESENSE_ClkPresc_TypeDef const clkDiv);
mbed_official 525:c320967f86b9 1009
mbed_official 525:c320967f86b9 1010 void LESENSE_ChannelAllConfig(LESENSE_ChAll_TypeDef const *confChAll);
mbed_official 525:c320967f86b9 1011 void LESENSE_ChannelConfig(LESENSE_ChDesc_TypeDef const *confCh,
mbed_official 525:c320967f86b9 1012 uint32_t const chIdx);
mbed_official 525:c320967f86b9 1013 void LESENSE_ChannelEnable(uint8_t const chIdx,
mbed_official 525:c320967f86b9 1014 bool const enaScanCh,
mbed_official 525:c320967f86b9 1015 bool const enaPin);
mbed_official 525:c320967f86b9 1016 void LESENSE_ChannelEnableMask(uint16_t chMask, uint16_t pinMask);
mbed_official 525:c320967f86b9 1017 void LESENSE_ChannelTimingSet(uint8_t const chIdx,
mbed_official 525:c320967f86b9 1018 uint8_t const exTime,
mbed_official 525:c320967f86b9 1019 uint8_t const sampleDelay,
mbed_official 525:c320967f86b9 1020 uint8_t const measDelay);
mbed_official 525:c320967f86b9 1021 void LESENSE_ChannelThresSet(uint8_t const chIdx,
mbed_official 525:c320967f86b9 1022 uint16_t const acmpThres,
mbed_official 525:c320967f86b9 1023 uint16_t const cntThres);
mbed_official 525:c320967f86b9 1024
mbed_official 525:c320967f86b9 1025 void LESENSE_AltExConfig(LESENSE_ConfAltEx_TypeDef const *confAltEx);
mbed_official 525:c320967f86b9 1026
mbed_official 525:c320967f86b9 1027 void LESENSE_DecoderStateAllConfig(LESENSE_DecStAll_TypeDef const *confDecStAll);
mbed_official 525:c320967f86b9 1028 void LESENSE_DecoderStateConfig(LESENSE_DecStDesc_TypeDef const *confDecSt,
mbed_official 525:c320967f86b9 1029 uint32_t const decSt);
mbed_official 525:c320967f86b9 1030 void LESENSE_DecoderStateSet(uint32_t decSt);
mbed_official 525:c320967f86b9 1031 uint32_t LESENSE_DecoderStateGet(void);
mbed_official 525:c320967f86b9 1032
mbed_official 525:c320967f86b9 1033 void LESENSE_ScanStart(void);
mbed_official 525:c320967f86b9 1034 void LESENSE_ScanStop(void);
mbed_official 525:c320967f86b9 1035 void LESENSE_DecoderStart(void);
mbed_official 525:c320967f86b9 1036 void LESENSE_ResultBufferClear(void);
mbed_official 525:c320967f86b9 1037
mbed_official 525:c320967f86b9 1038 __STATIC_INLINE void LESENSE_DecoderStop(void);
mbed_official 525:c320967f86b9 1039 __STATIC_INLINE uint32_t LESENSE_StatusGet(void);
mbed_official 525:c320967f86b9 1040 __STATIC_INLINE void LESENSE_StatusWait(uint32_t flag);
mbed_official 525:c320967f86b9 1041 __STATIC_INLINE uint32_t LESENSE_ChannelActiveGet(void);
mbed_official 525:c320967f86b9 1042 __STATIC_INLINE uint32_t LESENSE_ScanResultGet(void);
mbed_official 525:c320967f86b9 1043 __STATIC_INLINE uint32_t LESENSE_ScanResultDataGet(void);
mbed_official 525:c320967f86b9 1044 __STATIC_INLINE uint32_t LESENSE_ScanResultDataBufferGet(uint32_t idx);
mbed_official 525:c320967f86b9 1045 __STATIC_INLINE uint32_t LESENSE_SensorStateGet(void);
mbed_official 525:c320967f86b9 1046 __STATIC_INLINE void LESENSE_RAMPowerDown(void);
mbed_official 525:c320967f86b9 1047
mbed_official 525:c320967f86b9 1048 __STATIC_INLINE void LESENSE_IntClear(uint32_t flags);
mbed_official 525:c320967f86b9 1049 __STATIC_INLINE void LESENSE_IntEnable(uint32_t flags);
mbed_official 525:c320967f86b9 1050 __STATIC_INLINE void LESENSE_IntDisable(uint32_t flags);
mbed_official 525:c320967f86b9 1051 __STATIC_INLINE void LESENSE_IntSet(uint32_t flags);
mbed_official 525:c320967f86b9 1052 __STATIC_INLINE uint32_t LESENSE_IntGet(void);
mbed_official 525:c320967f86b9 1053 __STATIC_INLINE uint32_t LESENSE_IntGetEnabled(void);
mbed_official 525:c320967f86b9 1054
mbed_official 525:c320967f86b9 1055
mbed_official 525:c320967f86b9 1056 /***************************************************************************//**
mbed_official 525:c320967f86b9 1057 * @brief
mbed_official 525:c320967f86b9 1058 * Stop LESENSE decoder.
mbed_official 525:c320967f86b9 1059 *
mbed_official 525:c320967f86b9 1060 * @details
mbed_official 525:c320967f86b9 1061 * This function disables the LESENSE decoder by setting the command to the
mbed_official 525:c320967f86b9 1062 * LESENSE_DECCTRL register.
mbed_official 525:c320967f86b9 1063 ******************************************************************************/
mbed_official 525:c320967f86b9 1064 __STATIC_INLINE void LESENSE_DecoderStop(void)
mbed_official 525:c320967f86b9 1065 {
mbed_official 525:c320967f86b9 1066 /* Stop the decoder */
mbed_official 525:c320967f86b9 1067 LESENSE->DECCTRL |= LESENSE_DECCTRL_DISABLE;
mbed_official 525:c320967f86b9 1068 }
mbed_official 525:c320967f86b9 1069
mbed_official 525:c320967f86b9 1070
mbed_official 525:c320967f86b9 1071 /***************************************************************************//**
mbed_official 525:c320967f86b9 1072 * @brief
mbed_official 525:c320967f86b9 1073 * Get the current status of LESENSE.
mbed_official 525:c320967f86b9 1074 *
mbed_official 525:c320967f86b9 1075 * @return
mbed_official 525:c320967f86b9 1076 * This function returns the value of LESENSE_STATUS register that
mbed_official 525:c320967f86b9 1077 * contains the OR combination of the following status bits:
mbed_official 525:c320967f86b9 1078 * @li LESENSE_STATUS_RESV - Result data valid. Set when data is available
mbed_official 525:c320967f86b9 1079 * in the result buffer. Cleared when the buffer is empty.
mbed_official 525:c320967f86b9 1080 * @li LESENSE_STATUS_RESFULL - Result buffer full. Set when the result
mbed_official 525:c320967f86b9 1081 * buffer is full.
mbed_official 525:c320967f86b9 1082 * @li LESENSE_STATUS_RUNNING - LESENSE is active.
mbed_official 525:c320967f86b9 1083 * @li LESENSE_STATUS_SCANACTIVE - LESENSE is currently interfacing sensors.
mbed_official 525:c320967f86b9 1084 ******************************************************************************/
mbed_official 525:c320967f86b9 1085 __STATIC_INLINE uint32_t LESENSE_StatusGet(void)
mbed_official 525:c320967f86b9 1086 {
mbed_official 525:c320967f86b9 1087 return LESENSE->STATUS;
mbed_official 525:c320967f86b9 1088 }
mbed_official 525:c320967f86b9 1089
mbed_official 525:c320967f86b9 1090
mbed_official 525:c320967f86b9 1091 /***************************************************************************//**
mbed_official 525:c320967f86b9 1092 * @brief
mbed_official 525:c320967f86b9 1093 * Wait until the status of LESENSE is equal to what requested.
mbed_official 525:c320967f86b9 1094 *
mbed_official 525:c320967f86b9 1095 * @details
mbed_official 525:c320967f86b9 1096 * This function is polling the LESENSE_STATUS register and waits until the
mbed_official 525:c320967f86b9 1097 * requested combination of flags are set.
mbed_official 525:c320967f86b9 1098 *
mbed_official 525:c320967f86b9 1099 * @param[in] flag
mbed_official 525:c320967f86b9 1100 * The OR combination of the following status bits:
mbed_official 525:c320967f86b9 1101 * @li LESENSE_STATUS_BUFDATAV - Result data valid. Set when data is available
mbed_official 525:c320967f86b9 1102 * in the result buffer. Cleared when the buffer is empty.
mbed_official 525:c320967f86b9 1103 * @li LESENSE_STATUS_BUFHALFFULL - Result buffer half full. Set when the
mbed_official 525:c320967f86b9 1104 * result buffer is half full.
mbed_official 525:c320967f86b9 1105 * @li LESENSE_STATUS_BUFFULL - Result buffer full. Set when the result
mbed_official 525:c320967f86b9 1106 * buffer is full.
mbed_official 525:c320967f86b9 1107 * @li LESENSE_STATUS_RUNNING - LESENSE is active.
mbed_official 525:c320967f86b9 1108 * @li LESENSE_STATUS_SCANACTIVE - LESENSE is currently interfacing sensors.
mbed_official 525:c320967f86b9 1109 * @li LESENSE_STATUS_DACACTIVE - The DAC interface is currently active.
mbed_official 525:c320967f86b9 1110 ******************************************************************************/
mbed_official 525:c320967f86b9 1111 __STATIC_INLINE void LESENSE_StatusWait(uint32_t flag)
mbed_official 525:c320967f86b9 1112 {
mbed_official 525:c320967f86b9 1113 while (!(LESENSE->STATUS & flag))
mbed_official 525:c320967f86b9 1114 ;
mbed_official 525:c320967f86b9 1115 }
mbed_official 525:c320967f86b9 1116
mbed_official 525:c320967f86b9 1117
mbed_official 525:c320967f86b9 1118 /***************************************************************************//**
mbed_official 525:c320967f86b9 1119 * @brief
mbed_official 525:c320967f86b9 1120 * Get the currently active channel index.
mbed_official 525:c320967f86b9 1121 *
mbed_official 525:c320967f86b9 1122 * @return
mbed_official 525:c320967f86b9 1123 * This function returns the value of LESENSE_CHINDEX register that
mbed_official 525:c320967f86b9 1124 * contains the index of the currently active channel (0-15).
mbed_official 525:c320967f86b9 1125 ******************************************************************************/
mbed_official 525:c320967f86b9 1126 __STATIC_INLINE uint32_t LESENSE_ChannelActiveGet(void)
mbed_official 525:c320967f86b9 1127 {
mbed_official 525:c320967f86b9 1128 return LESENSE->CURCH;
mbed_official 525:c320967f86b9 1129 }
mbed_official 525:c320967f86b9 1130
mbed_official 525:c320967f86b9 1131
mbed_official 525:c320967f86b9 1132 /***************************************************************************//**
mbed_official 525:c320967f86b9 1133 * @brief
mbed_official 525:c320967f86b9 1134 * Get the latest scan comparison result (1 bit / channel).
mbed_official 525:c320967f86b9 1135 *
mbed_official 525:c320967f86b9 1136 * @return
mbed_official 525:c320967f86b9 1137 * This function returns the value of LESENSE_SCANRES register that
mbed_official 525:c320967f86b9 1138 * contains the comparison result of the last scan on all channels.
mbed_official 525:c320967f86b9 1139 * Bit x is set if a comparison triggered on channel x, which means that the
mbed_official 525:c320967f86b9 1140 * LESENSE counter met the comparison criteria set in LESENSE_CHx_EVAL by
mbed_official 525:c320967f86b9 1141 * COMPMODE and CNTTHRES.
mbed_official 525:c320967f86b9 1142 ******************************************************************************/
mbed_official 525:c320967f86b9 1143 __STATIC_INLINE uint32_t LESENSE_ScanResultGet(void)
mbed_official 525:c320967f86b9 1144 {
mbed_official 525:c320967f86b9 1145 return LESENSE->SCANRES;
mbed_official 525:c320967f86b9 1146 }
mbed_official 525:c320967f86b9 1147
mbed_official 525:c320967f86b9 1148
mbed_official 525:c320967f86b9 1149 /***************************************************************************//**
mbed_official 525:c320967f86b9 1150 * @brief
mbed_official 525:c320967f86b9 1151 * Get the oldest unread data from the result buffer.
mbed_official 525:c320967f86b9 1152 *
mbed_official 525:c320967f86b9 1153 * @note
mbed_official 525:c320967f86b9 1154 * Make sure that the STORERES bit is set in LESENSE_CHx_EVAL, or
mbed_official 525:c320967f86b9 1155 * STRSCANRES bit is set in LESENSE_CTRL, otherwise this function will return
mbed_official 525:c320967f86b9 1156 * undefined value.
mbed_official 525:c320967f86b9 1157 *
mbed_official 525:c320967f86b9 1158 * @return
mbed_official 525:c320967f86b9 1159 * This function returns the value of LESENSE_RESDATA register that
mbed_official 525:c320967f86b9 1160 * contains the oldest unread counter result from the result buffer.
mbed_official 525:c320967f86b9 1161 ******************************************************************************/
mbed_official 525:c320967f86b9 1162 __STATIC_INLINE uint32_t LESENSE_ScanResultDataGet(void)
mbed_official 525:c320967f86b9 1163 {
mbed_official 525:c320967f86b9 1164 return LESENSE->BUFDATA;
mbed_official 525:c320967f86b9 1165 }
mbed_official 525:c320967f86b9 1166
mbed_official 525:c320967f86b9 1167
mbed_official 525:c320967f86b9 1168 /***************************************************************************//**
mbed_official 525:c320967f86b9 1169 * @brief
mbed_official 525:c320967f86b9 1170 * Get data from the result data buffer.
mbed_official 525:c320967f86b9 1171 *
mbed_official 525:c320967f86b9 1172 * @note
mbed_official 525:c320967f86b9 1173 * Make sure that the STORERES bit is set in LESENSE_CHx_EVAL, or
mbed_official 525:c320967f86b9 1174 * STRSCANRES bit is set in LESENSE_CTRL, otherwise this function will return
mbed_official 525:c320967f86b9 1175 * undefined value.
mbed_official 525:c320967f86b9 1176 *
mbed_official 525:c320967f86b9 1177 * @param[in] idx
mbed_official 525:c320967f86b9 1178 * Result data buffer index. Valid range: 0-15.
mbed_official 525:c320967f86b9 1179 *
mbed_official 525:c320967f86b9 1180 * @return
mbed_official 525:c320967f86b9 1181 * This function returns the selected word from the result data buffer.
mbed_official 525:c320967f86b9 1182 ******************************************************************************/
mbed_official 525:c320967f86b9 1183 __STATIC_INLINE uint32_t LESENSE_ScanResultDataBufferGet(uint32_t idx)
mbed_official 525:c320967f86b9 1184 {
mbed_official 525:c320967f86b9 1185 /* Note: masking is needed to avoid over-indexing! */
mbed_official 525:c320967f86b9 1186 return LESENSE->BUF[idx & 0x0FU].DATA;
mbed_official 525:c320967f86b9 1187 }
mbed_official 525:c320967f86b9 1188
mbed_official 525:c320967f86b9 1189 /***************************************************************************//**
mbed_official 525:c320967f86b9 1190 * @brief
mbed_official 525:c320967f86b9 1191 * Get the current state of the LESENSE sensor.
mbed_official 525:c320967f86b9 1192 *
mbed_official 525:c320967f86b9 1193 * @return
mbed_official 525:c320967f86b9 1194 * This function returns the value of LESENSE_SENSORSTATE register that
mbed_official 525:c320967f86b9 1195 * represents the current state of the LESENSE sensor.
mbed_official 525:c320967f86b9 1196 ******************************************************************************/
mbed_official 525:c320967f86b9 1197 __STATIC_INLINE uint32_t LESENSE_SensorStateGet(void)
mbed_official 525:c320967f86b9 1198 {
mbed_official 525:c320967f86b9 1199 return LESENSE->SENSORSTATE;
mbed_official 525:c320967f86b9 1200 }
mbed_official 525:c320967f86b9 1201
mbed_official 525:c320967f86b9 1202
mbed_official 525:c320967f86b9 1203 /***************************************************************************//**
mbed_official 525:c320967f86b9 1204 * @brief
mbed_official 525:c320967f86b9 1205 * Shut off power to the LESENSE RAM, disables LESENSE.
mbed_official 525:c320967f86b9 1206 *
mbed_official 525:c320967f86b9 1207 * @details
mbed_official 525:c320967f86b9 1208 * This function shuts off the LESENSE RAM in order to decrease the leakage
mbed_official 525:c320967f86b9 1209 * current of EFM32 if LESENSE is not used in your application.
mbed_official 525:c320967f86b9 1210 *
mbed_official 525:c320967f86b9 1211 * @note
mbed_official 525:c320967f86b9 1212 * Warning! Once the LESENSE RAM is powered down, it cannot be powered up
mbed_official 525:c320967f86b9 1213 * again.
mbed_official 525:c320967f86b9 1214 ******************************************************************************/
mbed_official 525:c320967f86b9 1215 __STATIC_INLINE void LESENSE_RAMPowerDown(void)
mbed_official 525:c320967f86b9 1216 {
mbed_official 525:c320967f86b9 1217 /* Power down LESENSE RAM */
mbed_official 525:c320967f86b9 1218 LESENSE->POWERDOWN = LESENSE_POWERDOWN_RAM;
mbed_official 525:c320967f86b9 1219 }
mbed_official 525:c320967f86b9 1220
mbed_official 525:c320967f86b9 1221
mbed_official 525:c320967f86b9 1222 /***************************************************************************//**
mbed_official 525:c320967f86b9 1223 * @brief
mbed_official 525:c320967f86b9 1224 * Clear one or more pending LESENSE interrupts.
mbed_official 525:c320967f86b9 1225 *
mbed_official 525:c320967f86b9 1226 * @param[in] flags
mbed_official 525:c320967f86b9 1227 * Pending LESENSE interrupt sources to clear. Use a set of interrupt flags
mbed_official 525:c320967f86b9 1228 * OR-ed together to clear multiple interrupt sources of the LESENSE module
mbed_official 525:c320967f86b9 1229 * (LESENSE_IF_nnn).
mbed_official 525:c320967f86b9 1230 ******************************************************************************/
mbed_official 525:c320967f86b9 1231 __STATIC_INLINE void LESENSE_IntClear(uint32_t flags)
mbed_official 525:c320967f86b9 1232 {
mbed_official 525:c320967f86b9 1233 LESENSE->IFC = flags;
mbed_official 525:c320967f86b9 1234 }
mbed_official 525:c320967f86b9 1235
mbed_official 525:c320967f86b9 1236
mbed_official 525:c320967f86b9 1237 /***************************************************************************//**
mbed_official 525:c320967f86b9 1238 * @brief
mbed_official 525:c320967f86b9 1239 * Enable one or more LESENSE interrupts.
mbed_official 525:c320967f86b9 1240 *
mbed_official 525:c320967f86b9 1241 * @param[in] flags
mbed_official 525:c320967f86b9 1242 * LESENSE interrupt sources to enable. Use a set of interrupt flags OR-ed
mbed_official 525:c320967f86b9 1243 * together to enable multiple interrupt sources of the LESENSE module
mbed_official 525:c320967f86b9 1244 * (LESENSE_IF_nnn).
mbed_official 525:c320967f86b9 1245 ******************************************************************************/
mbed_official 525:c320967f86b9 1246 __STATIC_INLINE void LESENSE_IntEnable(uint32_t flags)
mbed_official 525:c320967f86b9 1247 {
mbed_official 525:c320967f86b9 1248 LESENSE->IEN |= flags;
mbed_official 525:c320967f86b9 1249 }
mbed_official 525:c320967f86b9 1250
mbed_official 525:c320967f86b9 1251
mbed_official 525:c320967f86b9 1252 /***************************************************************************//**
mbed_official 525:c320967f86b9 1253 * @brief
mbed_official 525:c320967f86b9 1254 * Disable one or more LESENSE interrupts.
mbed_official 525:c320967f86b9 1255 *
mbed_official 525:c320967f86b9 1256 * @param[in] flags
mbed_official 525:c320967f86b9 1257 * LESENSE interrupt sources to disable. Use a set of interrupt flags OR-ed
mbed_official 525:c320967f86b9 1258 * together to disable multiple interrupt sources of the LESENSE module
mbed_official 525:c320967f86b9 1259 * (LESENSE_IF_nnn).
mbed_official 525:c320967f86b9 1260 ******************************************************************************/
mbed_official 525:c320967f86b9 1261 __STATIC_INLINE void LESENSE_IntDisable(uint32_t flags)
mbed_official 525:c320967f86b9 1262 {
mbed_official 525:c320967f86b9 1263 LESENSE->IEN &= ~(flags);
mbed_official 525:c320967f86b9 1264 }
mbed_official 525:c320967f86b9 1265
mbed_official 525:c320967f86b9 1266
mbed_official 525:c320967f86b9 1267 /***************************************************************************//**
mbed_official 525:c320967f86b9 1268 * @brief
mbed_official 525:c320967f86b9 1269 * Set one or more pending LESENSE interrupts from SW.
mbed_official 525:c320967f86b9 1270 *
mbed_official 525:c320967f86b9 1271 * @param[in] flags
mbed_official 525:c320967f86b9 1272 * LESENSE interrupt sources to set to pending. Use a set of interrupt
mbed_official 525:c320967f86b9 1273 * flags OR-ed together to set multiple interrupt sources of the LESENSE
mbed_official 525:c320967f86b9 1274 * module (LESENSE_IFS_nnn).
mbed_official 525:c320967f86b9 1275 ******************************************************************************/
mbed_official 525:c320967f86b9 1276 __STATIC_INLINE void LESENSE_IntSet(uint32_t flags)
mbed_official 525:c320967f86b9 1277 {
mbed_official 525:c320967f86b9 1278 LESENSE->IFS = flags;
mbed_official 525:c320967f86b9 1279 }
mbed_official 525:c320967f86b9 1280
mbed_official 525:c320967f86b9 1281
mbed_official 525:c320967f86b9 1282 /***************************************************************************//**
mbed_official 525:c320967f86b9 1283 * @brief
mbed_official 525:c320967f86b9 1284 * Get pending LESENSE interrupt flags.
mbed_official 525:c320967f86b9 1285 *
mbed_official 525:c320967f86b9 1286 * @note
mbed_official 525:c320967f86b9 1287 * The event bits are not cleared by the use of this function.
mbed_official 525:c320967f86b9 1288 *
mbed_official 525:c320967f86b9 1289 * @return
mbed_official 525:c320967f86b9 1290 * Pending LESENSE interrupt sources. The OR combination of valid interrupt
mbed_official 525:c320967f86b9 1291 * flags of the LESENSE module (LESENSE_IF_nnn).
mbed_official 525:c320967f86b9 1292 ******************************************************************************/
mbed_official 525:c320967f86b9 1293 __STATIC_INLINE uint32_t LESENSE_IntGet(void)
mbed_official 525:c320967f86b9 1294 {
mbed_official 525:c320967f86b9 1295 return LESENSE->IF;
mbed_official 525:c320967f86b9 1296 }
mbed_official 525:c320967f86b9 1297
mbed_official 525:c320967f86b9 1298
mbed_official 525:c320967f86b9 1299 /***************************************************************************//**
mbed_official 525:c320967f86b9 1300 * @brief
mbed_official 525:c320967f86b9 1301 * Get enabled and pending LESENSE interrupt flags.
mbed_official 525:c320967f86b9 1302 *
mbed_official 525:c320967f86b9 1303 * @details
mbed_official 525:c320967f86b9 1304 * Useful for handling more interrupt sources in the same interrupt handler.
mbed_official 525:c320967f86b9 1305 *
mbed_official 525:c320967f86b9 1306 * @note
mbed_official 525:c320967f86b9 1307 * The event bits are not cleared by the use of this function.
mbed_official 525:c320967f86b9 1308 *
mbed_official 525:c320967f86b9 1309 * @return
mbed_official 525:c320967f86b9 1310 * Pending and enabled LESENSE interrupt sources.
mbed_official 525:c320967f86b9 1311 * The return value is the bitwise AND combination of
mbed_official 525:c320967f86b9 1312 * - the OR combination of enabled interrupt sources in LESENSE_IEN_nnn
mbed_official 525:c320967f86b9 1313 * register (LESENSE_IEN_nnn) and
mbed_official 525:c320967f86b9 1314 * - the OR combination of valid interrupt flags of the LESENSE module
mbed_official 525:c320967f86b9 1315 * (LESENSE_IF_nnn).
mbed_official 525:c320967f86b9 1316 ******************************************************************************/
mbed_official 525:c320967f86b9 1317 __STATIC_INLINE uint32_t LESENSE_IntGetEnabled(void)
mbed_official 525:c320967f86b9 1318 {
mbed_official 525:c320967f86b9 1319 uint32_t tmp;
mbed_official 525:c320967f86b9 1320
mbed_official 525:c320967f86b9 1321 /* Store LESENSE->IEN in temporary variable in order to define explicit order
mbed_official 525:c320967f86b9 1322 * of volatile accesses. */
mbed_official 525:c320967f86b9 1323 tmp = LESENSE->IEN;
mbed_official 525:c320967f86b9 1324
mbed_official 525:c320967f86b9 1325 /* Bitwise AND of pending and enabled interrupts */
mbed_official 525:c320967f86b9 1326 return LESENSE->IF & tmp;
mbed_official 525:c320967f86b9 1327 }
mbed_official 525:c320967f86b9 1328
mbed_official 525:c320967f86b9 1329
mbed_official 525:c320967f86b9 1330 /** @} (end addtogroup LESENSE) */
mbed_official 525:c320967f86b9 1331 /** @} (end addtogroup EM_Library) */
mbed_official 525:c320967f86b9 1332
mbed_official 525:c320967f86b9 1333 #ifdef __cplusplus
mbed_official 525:c320967f86b9 1334 }
mbed_official 525:c320967f86b9 1335 #endif
mbed_official 525:c320967f86b9 1336
mbed_official 525:c320967f86b9 1337 #endif /* defined(LESENSE_COUNT) && (LESENSE_COUNT > 0) */
mbed_official 525:c320967f86b9 1338
mbed_official 525:c320967f86b9 1339 #endif /* __SILICON_LABS_EM_LESENSE_H_ */