Driver for the capacitive sense slider available on the EFM32 Giant, Wonder and Leopard starter kits.

Dependents:   EFM32 RDA5807M RDS Radio EMF32-Segment-Touch-Demo EFM32_Bugs MFALHIMOHAMMED ... more

Information

All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.

/media/uploads/stevew817/screenshot_2015-03-17_13.40.06.png

Committer:
Steven Cooreman
Date:
Mon May 04 09:37:34 2015 -0700
Revision:
3:8d096e5bc045
Parent:
0:459a1af84a64
Merge

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Steven Cooreman 0:459a1af84a64 1 /***************************************************************************//**
Steven Cooreman 0:459a1af84a64 2 * @file
Steven Cooreman 0:459a1af84a64 3 * @brief Low Energy Sensor (LESENSE) configuration file for capacitive slider
Steven Cooreman 0:459a1af84a64 4 * on EFM32 Wonder Gecko STK (STK_3800).
Steven Cooreman 0:459a1af84a64 5 * @version 3.20.5
Steven Cooreman 0:459a1af84a64 6 *******************************************************************************
Steven Cooreman 0:459a1af84a64 7 * @section License
Steven Cooreman 0:459a1af84a64 8 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
Steven Cooreman 0:459a1af84a64 9 *******************************************************************************
Steven Cooreman 0:459a1af84a64 10 *
Steven Cooreman 0:459a1af84a64 11 * This file is licensensed under the Silabs License Agreement. See the file
Steven Cooreman 0:459a1af84a64 12 * "Silabs_License_Agreement.txt" for details. Before using this software for
Steven Cooreman 0:459a1af84a64 13 * any purpose, you must agree to the terms of that agreement.
Steven Cooreman 0:459a1af84a64 14 *
Steven Cooreman 0:459a1af84a64 15 ******************************************************************************/
Steven Cooreman 0:459a1af84a64 16
Steven Cooreman 0:459a1af84a64 17
Steven Cooreman 0:459a1af84a64 18 #include "em_lesense.h"
Steven Cooreman 0:459a1af84a64 19
Steven Cooreman 0:459a1af84a64 20 /***************************************************************************//**
Steven Cooreman 0:459a1af84a64 21 * @addtogroup Drivers
Steven Cooreman 0:459a1af84a64 22 * @{
Steven Cooreman 0:459a1af84a64 23 ******************************************************************************/
Steven Cooreman 0:459a1af84a64 24
Steven Cooreman 0:459a1af84a64 25 /***************************************************************************//**
Steven Cooreman 0:459a1af84a64 26 * @addtogroup CapSense
Steven Cooreman 0:459a1af84a64 27 * @{
Steven Cooreman 0:459a1af84a64 28 ******************************************************************************/
Steven Cooreman 0:459a1af84a64 29
Steven Cooreman 0:459a1af84a64 30 #ifdef __cplusplus
Steven Cooreman 0:459a1af84a64 31 extern "C" {
Steven Cooreman 0:459a1af84a64 32 #endif
Steven Cooreman 0:459a1af84a64 33
Steven Cooreman 0:459a1af84a64 34 /**************************************************************************//**
Steven Cooreman 0:459a1af84a64 35 * Macro definitions
Steven Cooreman 0:459a1af84a64 36 *****************************************************************************/
Steven Cooreman 0:459a1af84a64 37 #define CAPLESENSE_SENSITIVITY_OFFS 1U
Steven Cooreman 0:459a1af84a64 38 #define CAPLESENSE_NUMOF_SLIDERS 4 /**< Number of sliders */
Steven Cooreman 0:459a1af84a64 39 #define CAPLESENSE_ACMP_VDD_SCALE LESENSE_ACMP_VDD_SCALE /**< Upper voltage threshold */
Steven Cooreman 0:459a1af84a64 40
Steven Cooreman 0:459a1af84a64 41 #define CAPLESENSE_SLIDER_PORT0 gpioPortC /**< Slider Port. GPIO Port C */
Steven Cooreman 0:459a1af84a64 42 #define CAPLESENSE_SLIDER0_PORT CAPLESENSE_SLIDER_PORT0 /**< Slider 0 Port. GPIO Port C */
Steven Cooreman 0:459a1af84a64 43 #define CAPLESENSE_SLIDER0_PIN 8UL /**< Slider 0 Pin 8 */
Steven Cooreman 0:459a1af84a64 44 #define CAPLESENSE_SLIDER1_PORT CAPLESENSE_SLIDER_PORT0 /**< Slider 1 Port. GPIO Port C */
Steven Cooreman 0:459a1af84a64 45 #define CAPLESENSE_SLIDER1_PIN 9UL /**< Slider 1 Pin 9 */
Steven Cooreman 0:459a1af84a64 46 #define CAPLESENSE_SLIDER2_PORT CAPLESENSE_SLIDER_PORT0 /**< Slider 2 Port. GPIO Port C */
Steven Cooreman 0:459a1af84a64 47 #define CAPLESENSE_SLIDER2_PIN 10UL /**< Slider 2 Pin 10 */
Steven Cooreman 0:459a1af84a64 48 #define CAPLESENSE_SLIDER3_PORT CAPLESENSE_SLIDER_PORT0 /**< Slider 3 Port. GPIO Port C */
Steven Cooreman 0:459a1af84a64 49 #define CAPLESENSE_SLIDER3_PIN 11UL /**< Slider 3 Pin 11 */
Steven Cooreman 0:459a1af84a64 50
Steven Cooreman 0:459a1af84a64 51
Steven Cooreman 0:459a1af84a64 52 #define CAPLESENSE_CHANNEL_INT (LESENSE_IF_CH8 | LESENSE_IF_CH9 | LESENSE_IF_CH10 | LESENSE_IF_CH11)
Steven Cooreman 0:459a1af84a64 53 #define LESENSE_CHANNELS 16 /**< Number of channels for the Low Energy Sensor Interface. */
Steven Cooreman 0:459a1af84a64 54
Steven Cooreman 0:459a1af84a64 55 #define SLIDER_PART0_CHANNEL 8 /**< Touch slider channel Part 0 */
Steven Cooreman 0:459a1af84a64 56 #define SLIDER_PART1_CHANNEL 9 /**< Touch slider channel Part 1 */
Steven Cooreman 0:459a1af84a64 57 #define SLIDER_PART2_CHANNEL 10 /**< Touch slider channel Part 2 */
Steven Cooreman 0:459a1af84a64 58 #define SLIDER_PART3_CHANNEL 11 /**< Touch slider channel Part 3 */
Steven Cooreman 0:459a1af84a64 59
Steven Cooreman 0:459a1af84a64 60 /** Upper voltage threshold. */
Steven Cooreman 0:459a1af84a64 61 #define LESENSE_ACMP_VDD_SCALE 0x37U
Steven Cooreman 0:459a1af84a64 62
Steven Cooreman 0:459a1af84a64 63
Steven Cooreman 0:459a1af84a64 64 #define LESENSE_CAPSENSE_CH_IN_USE {\
Steven Cooreman 0:459a1af84a64 65 /* Ch0, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7 */\
Steven Cooreman 0:459a1af84a64 66 false, false, false, false, false, false, false, false,\
Steven Cooreman 0:459a1af84a64 67 /* Ch8, Ch9, Ch10, Ch11, Ch12, Ch13, Ch14, Ch15 */\
Steven Cooreman 0:459a1af84a64 68 true, true, true, true, false, false, false, false\
Steven Cooreman 0:459a1af84a64 69 }
Steven Cooreman 0:459a1af84a64 70
Steven Cooreman 0:459a1af84a64 71 /** Configuration for capacitive sense channels in sense mode. */
Steven Cooreman 0:459a1af84a64 72 #define LESENSE_CAPSENSE_CH_CONF_SENSE \
Steven Cooreman 0:459a1af84a64 73 { \
Steven Cooreman 0:459a1af84a64 74 true, /* Enable scan channel. */ \
Steven Cooreman 0:459a1af84a64 75 true, /* Enable the assigned pin on scan channel. */ \
Steven Cooreman 0:459a1af84a64 76 false, /* Disable interrupts on channel. */ \
Steven Cooreman 0:459a1af84a64 77 lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \
Steven Cooreman 0:459a1af84a64 78 lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \
Steven Cooreman 0:459a1af84a64 79 false, /* Don't use alternate excitation pins for excitation. */ \
Steven Cooreman 0:459a1af84a64 80 false, /* Disabled to shift results from this channel to the decoder register. */ \
Steven Cooreman 0:459a1af84a64 81 false, /* Disabled to invert the scan result bit. */ \
Steven Cooreman 0:459a1af84a64 82 true, /* Enabled to store counter value in the result buffer. */ \
Steven Cooreman 0:459a1af84a64 83 lesenseClkLF, /* Use the LF clock for excitation timing. */ \
Steven Cooreman 0:459a1af84a64 84 lesenseClkLF, /* Use the LF clock for sample timing. */ \
Steven Cooreman 0:459a1af84a64 85 0x00U, /* Excitation time is set to 0 excitation clock cycles. */ \
Steven Cooreman 0:459a1af84a64 86 0x0FU, /* Sample delay is set to 15(+1) sample clock cycles. */ \
Steven Cooreman 0:459a1af84a64 87 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \
Steven Cooreman 0:459a1af84a64 88 LESENSE_ACMP_VDD_SCALE, /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */ \
Steven Cooreman 0:459a1af84a64 89 lesenseSampleModeCounter, /* ACMP will be used in comparison. */ \
Steven Cooreman 0:459a1af84a64 90 lesenseSetIntLevel, /* Interrupt is generated if the sensor triggers. */ \
Steven Cooreman 0:459a1af84a64 91 0x00U, /* Counter threshold has been set to 0x00. */ \
Steven Cooreman 0:459a1af84a64 92 lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \
Steven Cooreman 0:459a1af84a64 93 }
Steven Cooreman 0:459a1af84a64 94
Steven Cooreman 0:459a1af84a64 95 /** Configuration for capacitive sense channels in sleep mode. */
Steven Cooreman 0:459a1af84a64 96 #define LESENSE_CAPSENSE_CH_CONF_SLEEP \
Steven Cooreman 0:459a1af84a64 97 { \
Steven Cooreman 0:459a1af84a64 98 true, /* Enable scan channel. */ \
Steven Cooreman 0:459a1af84a64 99 true, /* Enable the assigned pin on scan channel. */ \
Steven Cooreman 0:459a1af84a64 100 true, /* Enable interrupts on channel. */ \
Steven Cooreman 0:459a1af84a64 101 lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \
Steven Cooreman 0:459a1af84a64 102 lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \
Steven Cooreman 0:459a1af84a64 103 false, /* Don't use alternate excitation pins for excitation. */ \
Steven Cooreman 0:459a1af84a64 104 false, /* Disabled to shift results from this channel to the decoder register. */ \
Steven Cooreman 0:459a1af84a64 105 false, /* Disabled to invert the scan result bit. */ \
Steven Cooreman 0:459a1af84a64 106 true, /* Enabled to store counter value in the result buffer. */ \
Steven Cooreman 0:459a1af84a64 107 lesenseClkLF, /* Use the LF clock for excitation timing. */ \
Steven Cooreman 0:459a1af84a64 108 lesenseClkLF, /* Use the LF clock for sample timing. */ \
Steven Cooreman 0:459a1af84a64 109 0x00U, /* Excitation time is set to 0 excitation clock cycles. */ \
Steven Cooreman 0:459a1af84a64 110 0x01U, /* Sample delay is set to 1(+1) sample clock cycles. */ \
Steven Cooreman 0:459a1af84a64 111 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \
Steven Cooreman 0:459a1af84a64 112 LESENSE_ACMP_VDD_SCALE, /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */ \
Steven Cooreman 0:459a1af84a64 113 lesenseSampleModeCounter, /* Counter will be used in comparison. */ \
Steven Cooreman 0:459a1af84a64 114 lesenseSetIntLevel, /* Interrupt is generated if the sensor triggers. */ \
Steven Cooreman 0:459a1af84a64 115 0x0EU, /* Counter threshold has been set to 0x0E. */ \
Steven Cooreman 0:459a1af84a64 116 lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \
Steven Cooreman 0:459a1af84a64 117 }
Steven Cooreman 0:459a1af84a64 118
Steven Cooreman 0:459a1af84a64 119 /** Configuration for disabled channels. */
Steven Cooreman 0:459a1af84a64 120 #define LESENSE_DISABLED_CH_CONF \
Steven Cooreman 0:459a1af84a64 121 { \
Steven Cooreman 0:459a1af84a64 122 false, /* Disable scan channel. */ \
Steven Cooreman 0:459a1af84a64 123 false, /* Disable the assigned pin on scan channel. */ \
Steven Cooreman 0:459a1af84a64 124 false, /* Disable interrupts on channel. */ \
Steven Cooreman 0:459a1af84a64 125 lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \
Steven Cooreman 0:459a1af84a64 126 lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \
Steven Cooreman 0:459a1af84a64 127 false, /* Don't use alternate excitation pins for excitation. */ \
Steven Cooreman 0:459a1af84a64 128 false, /* Disabled to shift results from this channel to the decoder register. */ \
Steven Cooreman 0:459a1af84a64 129 false, /* Disabled to invert the scan result bit. */ \
Steven Cooreman 0:459a1af84a64 130 false, /* Disabled to store counter value in the result buffer. */ \
Steven Cooreman 0:459a1af84a64 131 lesenseClkLF, /* Use the LF clock for excitation timing. */ \
Steven Cooreman 0:459a1af84a64 132 lesenseClkLF, /* Use the LF clock for sample timing. */ \
Steven Cooreman 0:459a1af84a64 133 0x00U, /* Excitation time is set to 5(+1) excitation clock cycles. */ \
Steven Cooreman 0:459a1af84a64 134 0x00U, /* Sample delay is set to 7(+1) sample clock cycles. */ \
Steven Cooreman 0:459a1af84a64 135 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \
Steven Cooreman 0:459a1af84a64 136 0x00U, /* ACMP threshold has been set to 0. */ \
Steven Cooreman 0:459a1af84a64 137 lesenseSampleModeCounter, /* ACMP output will be used in comparison. */ \
Steven Cooreman 0:459a1af84a64 138 lesenseSetIntNone, /* No interrupt is generated by the channel. */ \
Steven Cooreman 0:459a1af84a64 139 0x00U, /* Counter threshold has been set to 0x01. */ \
Steven Cooreman 0:459a1af84a64 140 lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \
Steven Cooreman 0:459a1af84a64 141 }
Steven Cooreman 0:459a1af84a64 142
Steven Cooreman 0:459a1af84a64 143 /** Configuration for scan in sense mode. */
Steven Cooreman 0:459a1af84a64 144 #define LESENSE_CAPSENSE_SCAN_CONF_SENSE \
Steven Cooreman 0:459a1af84a64 145 { \
Steven Cooreman 0:459a1af84a64 146 { \
Steven Cooreman 0:459a1af84a64 147 LESENSE_DISABLED_CH_CONF, /* Channel 0. */ \
Steven Cooreman 0:459a1af84a64 148 LESENSE_DISABLED_CH_CONF, /* Channel 1. */ \
Steven Cooreman 0:459a1af84a64 149 LESENSE_DISABLED_CH_CONF, /* Channel 2. */ \
Steven Cooreman 0:459a1af84a64 150 LESENSE_DISABLED_CH_CONF, /* Channel 3. */ \
Steven Cooreman 0:459a1af84a64 151 LESENSE_DISABLED_CH_CONF, /* Channel 4. */ \
Steven Cooreman 0:459a1af84a64 152 LESENSE_DISABLED_CH_CONF, /* Channel 5. */ \
Steven Cooreman 0:459a1af84a64 153 LESENSE_DISABLED_CH_CONF, /* Channel 6. */ \
Steven Cooreman 0:459a1af84a64 154 LESENSE_DISABLED_CH_CONF, /* Channel 7. */ \
Steven Cooreman 0:459a1af84a64 155 LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 8. */ \
Steven Cooreman 0:459a1af84a64 156 LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 9. */ \
Steven Cooreman 0:459a1af84a64 157 LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 10. */ \
Steven Cooreman 0:459a1af84a64 158 LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 11. */ \
Steven Cooreman 0:459a1af84a64 159 LESENSE_DISABLED_CH_CONF, /* Channel 12. */ \
Steven Cooreman 0:459a1af84a64 160 LESENSE_DISABLED_CH_CONF, /* Channel 13. */ \
Steven Cooreman 0:459a1af84a64 161 LESENSE_DISABLED_CH_CONF, /* Channel 14. */ \
Steven Cooreman 0:459a1af84a64 162 LESENSE_DISABLED_CH_CONF /* Channel 15. */ \
Steven Cooreman 0:459a1af84a64 163 } \
Steven Cooreman 0:459a1af84a64 164 }
Steven Cooreman 0:459a1af84a64 165
Steven Cooreman 0:459a1af84a64 166 /** Configuration for scan in sleep mode. */
Steven Cooreman 0:459a1af84a64 167 #define LESENSE_CAPSENSE_SCAN_CONF_SLEEP \
Steven Cooreman 0:459a1af84a64 168 { \
Steven Cooreman 0:459a1af84a64 169 { \
Steven Cooreman 0:459a1af84a64 170 LESENSE_DISABLED_CH_CONF, /* Channel 0. */ \
Steven Cooreman 0:459a1af84a64 171 LESENSE_DISABLED_CH_CONF, /* Channel 1. */ \
Steven Cooreman 0:459a1af84a64 172 LESENSE_DISABLED_CH_CONF, /* Channel 2. */ \
Steven Cooreman 0:459a1af84a64 173 LESENSE_DISABLED_CH_CONF, /* Channel 3. */ \
Steven Cooreman 0:459a1af84a64 174 LESENSE_DISABLED_CH_CONF, /* Channel 4. */ \
Steven Cooreman 0:459a1af84a64 175 LESENSE_DISABLED_CH_CONF, /* Channel 5. */ \
Steven Cooreman 0:459a1af84a64 176 LESENSE_DISABLED_CH_CONF, /* Channel 6. */ \
Steven Cooreman 0:459a1af84a64 177 LESENSE_DISABLED_CH_CONF, /* Channel 7. */ \
Steven Cooreman 0:459a1af84a64 178 LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 8. */ \
Steven Cooreman 0:459a1af84a64 179 LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 9. */ \
Steven Cooreman 0:459a1af84a64 180 LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 10. */ \
Steven Cooreman 0:459a1af84a64 181 LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 11. */ \
Steven Cooreman 0:459a1af84a64 182 LESENSE_DISABLED_CH_CONF, /* Channel 12. */ \
Steven Cooreman 0:459a1af84a64 183 LESENSE_DISABLED_CH_CONF, /* Channel 13. */ \
Steven Cooreman 0:459a1af84a64 184 LESENSE_DISABLED_CH_CONF, /* Channel 14. */ \
Steven Cooreman 0:459a1af84a64 185 LESENSE_DISABLED_CH_CONF /* Channel 15. */ \
Steven Cooreman 0:459a1af84a64 186 } \
Steven Cooreman 0:459a1af84a64 187 }
Steven Cooreman 0:459a1af84a64 188
Steven Cooreman 0:459a1af84a64 189 #ifdef __cplusplus
Steven Cooreman 0:459a1af84a64 190 }
Steven Cooreman 0:459a1af84a64 191 #endif
Steven Cooreman 0:459a1af84a64 192
Steven Cooreman 0:459a1af84a64 193 /** @} (end group CapSense) */
Steven Cooreman 0:459a1af84a64 194 /** @} (end group Drivers) */