The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Thu Mar 30 13:26:47 2017 +0100
Revision:
139:856d2700e60b
Parent:
128:9bcdf88f62b0
Release 139 of the mbed library

Ports for Upcoming Targets

3934: [Silicon Labs] Update to HAL and devices https://github.com/ARMmbed/mbed-os/pull/3934

Known Issues

There is an issue with LPC1768 failing the 'Semihost file system' test with this release.

Fixes and Changes

3691: [TLS / hw acceleration] AES ECB for NUCLEO_F439ZI https://github.com/ARMmbed/mbed-os/pull/3691
3869: NCS36510: Default range changed from 0 to 950mV - ADC https://github.com/ARMmbed/mbed-os/pull/3869
3893: [STM32F7] Update STM32 Cube version v1.6.0 https://github.com/ARMmbed/mbed-os/pull/3893
3917: Fix mistake register setting in serial_format() https://github.com/ARMmbed/mbed-os/pull/3917
3927: [DELTA_DFBM_NQ620] Add RC calibration setting and revise mbed_overrides.c https://github.com/ARMmbed/mbed-os/pull/3927
3918: [NUC472/M453] Support unique locally administered MAC address and other driver updates https://github.com/ARMmbed/mbed-os/pull/3918
3920: Heap size adjusted to work for both tls-client and mbed-client https://github.com/ARMmbed/mbed-os/pull/3920
3969: NUCLEO_F302R8: Add missing PB_8/PB_9 CAN pins https://github.com/ARMmbed/mbed-os/pull/3969

Who changed what in which revision?

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