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:
2:f361a6f65884
Merge

Who changed what in which revision?

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