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