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.
capsenseconfig_tg_stk.h@0:459a1af84a64, 2015-03-17 (annotated)
- Committer:
- Steven Cooreman
- Date:
- Tue Mar 17 12:44:15 2015 -0500
- Revision:
- 0:459a1af84a64
Initial commit
Who changed what in which revision?
User | Revision | Line number | New 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 Tiny Gecko STK (STK_3300). |
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 CAPSENSE_SLIDER_PORT0 /**< Slider 0 Port. GPIO Port C */ |
Steven Cooreman |
0:459a1af84a64 | 43 | #define CAPLESENSE_SLIDER0_PIN 5UL /**< Slider 0 Pin 5 */ |
Steven Cooreman |
0:459a1af84a64 | 44 | #define CAPLESENSE_SLIDER1_PORT CAPSENSE_SLIDER_PORT0 /**< Slider 1 Port. GPIO Port C */ |
Steven Cooreman |
0:459a1af84a64 | 45 | #define CAPLESENSE_SLIDER1_PIN 7UL /**< Slider 1 Pin 7 */ |
Steven Cooreman |
0:459a1af84a64 | 46 | #define CAPLESENSE_SLIDER2_PORT CAPSENSE_SLIDER_PORT0 /**< Slider 2 Port. GPIO Port C */ |
Steven Cooreman |
0:459a1af84a64 | 47 | #define CAPLESENSE_SLIDER2_PIN 12UL /**< Slider 2 Pin 12 */ |
Steven Cooreman |
0:459a1af84a64 | 48 | #define CAPLESENSE_SLIDER3_PORT CAPSENSE_SLIDER_PORT0 /**< Slider 3 Port. GPIO Port C */ |
Steven Cooreman |
0:459a1af84a64 | 49 | #define CAPLESENSE_SLIDER3_PIN 13UL /**< Slider 3 Pin 13 */ |
Steven Cooreman |
0:459a1af84a64 | 50 | |
Steven Cooreman |
0:459a1af84a64 | 51 | |
Steven Cooreman |
0:459a1af84a64 | 52 | #define LESENSE_CHANNELS 16 /**< Number of channels for the Low Energy Sensor Interface. */ |
Steven Cooreman |
0:459a1af84a64 | 53 | |
Steven Cooreman |
0:459a1af84a64 | 54 | #define SLIDER_PART0_CHANNEL 5 /**< Touch slider channel Part 0 */ |
Steven Cooreman |
0:459a1af84a64 | 55 | #define SLIDER_PART1_CHANNEL 7 /**< Touch slider channel Part 1 */ |
Steven Cooreman |
0:459a1af84a64 | 56 | #define SLIDER_PART2_CHANNEL 12 /**< Touch slider channel Part 2 */ |
Steven Cooreman |
0:459a1af84a64 | 57 | #define SLIDER_PART3_CHANNEL 13 /**< Touch slider channel Part 3 */ |
Steven Cooreman |
0:459a1af84a64 | 58 | |
Steven Cooreman |
0:459a1af84a64 | 59 | #define CAPLESENSE_CHANNEL_INT (LESENSE_IF_CH5 | LESENSE_IF_CH7 | LESENSE_IF_CH12 | LESENSE_IF_CH13) |
Steven Cooreman |
0:459a1af84a64 | 60 | |
Steven Cooreman |
0:459a1af84a64 | 61 | /** Upper voltage threshold. */ |
Steven Cooreman |
0:459a1af84a64 | 62 | #define LESENSE_ACMP_VDD_SCALE 0x37U |
Steven Cooreman |
0:459a1af84a64 | 63 | |
Steven Cooreman |
0:459a1af84a64 | 64 | /**************************************************************************//** |
Steven Cooreman |
0:459a1af84a64 | 65 | * @brief A bit vector which represents the channels to iterate through |
Steven Cooreman |
0:459a1af84a64 | 66 | * @param LESENSE_CHANNELS Vector of channels. |
Steven Cooreman |
0:459a1af84a64 | 67 | *****************************************************************************/ |
Steven Cooreman |
0:459a1af84a64 | 68 | #define LESENSE_CAPSENSE_CH_IN_USE {\ |
Steven Cooreman |
0:459a1af84a64 | 69 | /* Ch0, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7 */\ |
Steven Cooreman |
0:459a1af84a64 | 70 | false, false, false, false, false, true, false, true,\ |
Steven Cooreman |
0:459a1af84a64 | 71 | /* Ch8, Ch9, Ch10, Ch11, Ch12, Ch13, Ch14, Ch15 */\ |
Steven Cooreman |
0:459a1af84a64 | 72 | false, false, false, false, true, true, false, false\ |
Steven Cooreman |
0:459a1af84a64 | 73 | } |
Steven Cooreman |
0:459a1af84a64 | 74 | |
Steven Cooreman |
0:459a1af84a64 | 75 | /** Configuration for capacitive sense channels in sense mode. */ |
Steven Cooreman |
0:459a1af84a64 | 76 | #define LESENSE_CAPSENSE_CH_CONF_SENSE \ |
Steven Cooreman |
0:459a1af84a64 | 77 | { \ |
Steven Cooreman |
0:459a1af84a64 | 78 | true, /* Enable scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 79 | true, /* Enable the assigned pin on scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 80 | false, /* Disable interrupts on channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 81 | lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 82 | lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 83 | false, /* Don't use alternate excitation pins for excitation. */ \ |
Steven Cooreman |
0:459a1af84a64 | 84 | false, /* Disabled to shift results from this channel to the decoder register. */ \ |
Steven Cooreman |
0:459a1af84a64 | 85 | false, /* Disabled to invert the scan result bit. */ \ |
Steven Cooreman |
0:459a1af84a64 | 86 | true, /* Enabled to store counter value in the result buffer. */ \ |
Steven Cooreman |
0:459a1af84a64 | 87 | lesenseClkLF, /* Use the LF clock for excitation timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 88 | lesenseClkLF, /* Use the LF clock for sample timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 89 | 0x00U, /* Excitation time is set to 0 excitation clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 90 | 0x0FU, /* Sample delay is set to 15(+1) sample clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 91 | 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \ |
Steven Cooreman |
0:459a1af84a64 | 92 | LESENSE_ACMP_VDD_SCALE, /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */ \ |
Steven Cooreman |
0:459a1af84a64 | 93 | lesenseSampleModeCounter, /* ACMP will be used in comparison. */ \ |
Steven Cooreman |
0:459a1af84a64 | 94 | lesenseSetIntLevel, /* Interrupt is generated if the sensor triggers. */ \ |
Steven Cooreman |
0:459a1af84a64 | 95 | 0x00U, /* Counter threshold has been set to 0x00. */ \ |
Steven Cooreman |
0:459a1af84a64 | 96 | lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \ |
Steven Cooreman |
0:459a1af84a64 | 97 | } |
Steven Cooreman |
0:459a1af84a64 | 98 | |
Steven Cooreman |
0:459a1af84a64 | 99 | /** Configuration for capacitive sense channels in sleep mode. */ |
Steven Cooreman |
0:459a1af84a64 | 100 | #define LESENSE_CAPSENSE_CH_CONF_SLEEP \ |
Steven Cooreman |
0:459a1af84a64 | 101 | { \ |
Steven Cooreman |
0:459a1af84a64 | 102 | true, /* Enable scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 103 | true, /* Enable the assigned pin on scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 104 | true, /* Enable interrupts on channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 105 | lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 106 | lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 107 | false, /* Don't use alternate excitation pins for excitation. */ \ |
Steven Cooreman |
0:459a1af84a64 | 108 | false, /* Disabled to shift results from this channel to the decoder register. */ \ |
Steven Cooreman |
0:459a1af84a64 | 109 | false, /* Disabled to invert the scan result bit. */ \ |
Steven Cooreman |
0:459a1af84a64 | 110 | true, /* Enabled to store counter value in the result buffer. */ \ |
Steven Cooreman |
0:459a1af84a64 | 111 | lesenseClkLF, /* Use the LF clock for excitation timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 112 | lesenseClkLF, /* Use the LF clock for sample timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 113 | 0x00U, /* Excitation time is set to 0 excitation clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 114 | 0x01U, /* Sample delay is set to 1(+1) sample clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 115 | 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \ |
Steven Cooreman |
0:459a1af84a64 | 116 | LESENSE_ACMP_VDD_SCALE, /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */ \ |
Steven Cooreman |
0:459a1af84a64 | 117 | lesenseSampleModeCounter, /* Counter will be used in comparison. */ \ |
Steven Cooreman |
0:459a1af84a64 | 118 | lesenseSetIntLevel, /* Interrupt is generated if the sensor triggers. */ \ |
Steven Cooreman |
0:459a1af84a64 | 119 | 0x0EU, /* Counter threshold has been set to 0x0E. */ \ |
Steven Cooreman |
0:459a1af84a64 | 120 | lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \ |
Steven Cooreman |
0:459a1af84a64 | 121 | } |
Steven Cooreman |
0:459a1af84a64 | 122 | |
Steven Cooreman |
0:459a1af84a64 | 123 | /** Configuration for disabled channels. */ |
Steven Cooreman |
0:459a1af84a64 | 124 | #define LESENSE_DISABLED_CH_CONF \ |
Steven Cooreman |
0:459a1af84a64 | 125 | { \ |
Steven Cooreman |
0:459a1af84a64 | 126 | false, /* Disable scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 127 | false, /* Disable the assigned pin on scan channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 128 | false, /* Disable interrupts on channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 129 | lesenseChPinExDis, /* GPIO pin is disabled during the excitation period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 130 | lesenseChPinIdleDis, /* GPIO pin is disabled during the idle period. */ \ |
Steven Cooreman |
0:459a1af84a64 | 131 | false, /* Don't use alternate excitation pins for excitation. */ \ |
Steven Cooreman |
0:459a1af84a64 | 132 | false, /* Disabled to shift results from this channel to the decoder register. */ \ |
Steven Cooreman |
0:459a1af84a64 | 133 | false, /* Disabled to invert the scan result bit. */ \ |
Steven Cooreman |
0:459a1af84a64 | 134 | false, /* Disabled to store counter value in the result buffer. */ \ |
Steven Cooreman |
0:459a1af84a64 | 135 | lesenseClkLF, /* Use the LF clock for excitation timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 136 | lesenseClkLF, /* Use the LF clock for sample timing. */ \ |
Steven Cooreman |
0:459a1af84a64 | 137 | 0x00U, /* Excitation time is set to 5(+1) excitation clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 138 | 0x00U, /* Sample delay is set to 7(+1) sample clock cycles. */ \ |
Steven Cooreman |
0:459a1af84a64 | 139 | 0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \ |
Steven Cooreman |
0:459a1af84a64 | 140 | 0x00U, /* ACMP threshold has been set to 0. */ \ |
Steven Cooreman |
0:459a1af84a64 | 141 | lesenseSampleModeCounter, /* ACMP output will be used in comparison. */ \ |
Steven Cooreman |
0:459a1af84a64 | 142 | lesenseSetIntNone, /* No interrupt is generated by the channel. */ \ |
Steven Cooreman |
0:459a1af84a64 | 143 | 0x00U, /* Counter threshold has been set to 0x01. */ \ |
Steven Cooreman |
0:459a1af84a64 | 144 | lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \ |
Steven Cooreman |
0:459a1af84a64 | 145 | } |
Steven Cooreman |
0:459a1af84a64 | 146 | |
Steven Cooreman |
0:459a1af84a64 | 147 | /** Configuration for scan in sense mode. */ |
Steven Cooreman |
0:459a1af84a64 | 148 | #define LESENSE_CAPSENSE_SCAN_CONF_SENSE \ |
Steven Cooreman |
0:459a1af84a64 | 149 | { \ |
Steven Cooreman |
0:459a1af84a64 | 150 | { \ |
Steven Cooreman |
0:459a1af84a64 | 151 | LESENSE_DISABLED_CH_CONF, /* Channel 0. */ \ |
Steven Cooreman |
0:459a1af84a64 | 152 | LESENSE_DISABLED_CH_CONF, /* Channel 1. */ \ |
Steven Cooreman |
0:459a1af84a64 | 153 | LESENSE_DISABLED_CH_CONF, /* Channel 2. */ \ |
Steven Cooreman |
0:459a1af84a64 | 154 | LESENSE_DISABLED_CH_CONF, /* Channel 3. */ \ |
Steven Cooreman |
0:459a1af84a64 | 155 | LESENSE_DISABLED_CH_CONF, /* Channel 4. */ \ |
Steven Cooreman |
0:459a1af84a64 | 156 | LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 5. */ \ |
Steven Cooreman |
0:459a1af84a64 | 157 | LESENSE_DISABLED_CH_CONF, /* Channel 6. */ \ |
Steven Cooreman |
0:459a1af84a64 | 158 | LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 7. */ \ |
Steven Cooreman |
0:459a1af84a64 | 159 | LESENSE_DISABLED_CH_CONF, /* Channel 8. */ \ |
Steven Cooreman |
0:459a1af84a64 | 160 | LESENSE_DISABLED_CH_CONF, /* Channel 9. */ \ |
Steven Cooreman |
0:459a1af84a64 | 161 | LESENSE_DISABLED_CH_CONF, /* Channel 10. */ \ |
Steven Cooreman |
0:459a1af84a64 | 162 | LESENSE_DISABLED_CH_CONF, /* Channel 11. */ \ |
Steven Cooreman |
0:459a1af84a64 | 163 | LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 12. */ \ |
Steven Cooreman |
0:459a1af84a64 | 164 | LESENSE_CAPSENSE_CH_CONF_SENSE, /* Channel 13. */ \ |
Steven Cooreman |
0:459a1af84a64 | 165 | LESENSE_DISABLED_CH_CONF, /* Channel 14. */ \ |
Steven Cooreman |
0:459a1af84a64 | 166 | LESENSE_DISABLED_CH_CONF /* Channel 15. */ \ |
Steven Cooreman |
0:459a1af84a64 | 167 | } \ |
Steven Cooreman |
0:459a1af84a64 | 168 | } |
Steven Cooreman |
0:459a1af84a64 | 169 | |
Steven Cooreman |
0:459a1af84a64 | 170 | /** Configuration for scan in sleep mode. */ |
Steven Cooreman |
0:459a1af84a64 | 171 | #define LESENSE_CAPSENSE_SCAN_CONF_SLEEP \ |
Steven Cooreman |
0:459a1af84a64 | 172 | { \ |
Steven Cooreman |
0:459a1af84a64 | 173 | { \ |
Steven Cooreman |
0:459a1af84a64 | 174 | LESENSE_DISABLED_CH_CONF, /* Channel 0. */ \ |
Steven Cooreman |
0:459a1af84a64 | 175 | LESENSE_DISABLED_CH_CONF, /* Channel 1. */ \ |
Steven Cooreman |
0:459a1af84a64 | 176 | LESENSE_DISABLED_CH_CONF, /* Channel 2. */ \ |
Steven Cooreman |
0:459a1af84a64 | 177 | LESENSE_DISABLED_CH_CONF, /* Channel 3. */ \ |
Steven Cooreman |
0:459a1af84a64 | 178 | LESENSE_DISABLED_CH_CONF, /* Channel 4. */ \ |
Steven Cooreman |
0:459a1af84a64 | 179 | LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 5. */ \ |
Steven Cooreman |
0:459a1af84a64 | 180 | LESENSE_DISABLED_CH_CONF, /* Channel 6. */ \ |
Steven Cooreman |
0:459a1af84a64 | 181 | LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 7. */ \ |
Steven Cooreman |
0:459a1af84a64 | 182 | LESENSE_DISABLED_CH_CONF, /* Channel 8. */ \ |
Steven Cooreman |
0:459a1af84a64 | 183 | LESENSE_DISABLED_CH_CONF, /* Channel 9. */ \ |
Steven Cooreman |
0:459a1af84a64 | 184 | LESENSE_DISABLED_CH_CONF, /* Channel 10. */ \ |
Steven Cooreman |
0:459a1af84a64 | 185 | LESENSE_DISABLED_CH_CONF, /* Channel 11. */ \ |
Steven Cooreman |
0:459a1af84a64 | 186 | LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 12. */ \ |
Steven Cooreman |
0:459a1af84a64 | 187 | LESENSE_CAPSENSE_CH_CONF_SLEEP, /* Channel 13. */ \ |
Steven Cooreman |
0:459a1af84a64 | 188 | LESENSE_DISABLED_CH_CONF, /* Channel 14. */ \ |
Steven Cooreman |
0:459a1af84a64 | 189 | LESENSE_DISABLED_CH_CONF /* Channel 15. */ \ |
Steven Cooreman |
0:459a1af84a64 | 190 | } \ |
Steven Cooreman |
0:459a1af84a64 | 191 | } |
Steven Cooreman |
0:459a1af84a64 | 192 | |
Steven Cooreman |
0:459a1af84a64 | 193 | #ifdef __cplusplus |
Steven Cooreman |
0:459a1af84a64 | 194 | } |
Steven Cooreman |
0:459a1af84a64 | 195 | #endif |
Steven Cooreman |
0:459a1af84a64 | 196 | |
Steven Cooreman |
0:459a1af84a64 | 197 | /** @} (end group CapSense) */ |
Steven Cooreman |
0:459a1af84a64 | 198 | /** @} (end group Drivers) */ |