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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers capsenseconfig_tg_stk.h Source File

capsenseconfig_tg_stk.h

Go to the documentation of this file.
00001 /***************************************************************************//**
00002  * @file
00003  * @brief Low Energy Sensor (LESENSE) configuration file for capacitive slider
00004  *        on EFM32 Tiny Gecko STK (STK_3300).
00005  * @version 3.20.5
00006  *******************************************************************************
00007  * @section License
00008  * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
00009  *******************************************************************************
00010  *
00011  * This file is licensensed under the Silabs License Agreement. See the file
00012  * "Silabs_License_Agreement.txt" for details. Before using this software for
00013  * any purpose, you must agree to the terms of that agreement.
00014  *
00015  ******************************************************************************/
00016 
00017 
00018 #include "em_lesense.h"
00019 
00020 /***************************************************************************//**
00021  * @addtogroup Drivers
00022  * @{
00023  ******************************************************************************/
00024 
00025 /***************************************************************************//**
00026  * @addtogroup CapSense
00027  * @{
00028  ******************************************************************************/
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /**************************************************************************//**
00035  * Macro definitions
00036  *****************************************************************************/
00037 #define CAPLESENSE_SENSITIVITY_OFFS    1U
00038 #define CAPLESENSE_NUMOF_SLIDERS       4                          /**< Number of sliders */
00039 #define CAPLESENSE_ACMP_VDD_SCALE      LESENSE_ACMP_VDD_SCALE     /**< Upper voltage threshold */
00040 
00041 #define CAPLESENSE_SLIDER_PORT0        gpioPortC                  /**< Slider Port. GPIO Port C */
00042 #define CAPLESENSE_SLIDER0_PORT        CAPSENSE_SLIDER_PORT0      /**< Slider 0 Port. GPIO Port C */
00043 #define CAPLESENSE_SLIDER0_PIN         5UL                        /**< Slider 0 Pin 5 */
00044 #define CAPLESENSE_SLIDER1_PORT        CAPSENSE_SLIDER_PORT0      /**< Slider 1 Port. GPIO Port C */
00045 #define CAPLESENSE_SLIDER1_PIN         7UL                        /**< Slider 1 Pin 7 */
00046 #define CAPLESENSE_SLIDER2_PORT        CAPSENSE_SLIDER_PORT0      /**< Slider 2 Port. GPIO Port C */
00047 #define CAPLESENSE_SLIDER2_PIN         12UL                       /**< Slider 2 Pin 12 */
00048 #define CAPLESENSE_SLIDER3_PORT        CAPSENSE_SLIDER_PORT0      /**< Slider 3 Port. GPIO Port C */
00049 #define CAPLESENSE_SLIDER3_PIN         13UL                       /**< Slider 3 Pin 13 */
00050 
00051 
00052 #define LESENSE_CHANNELS        16  /**< Number of channels for the Low Energy Sensor Interface. */
00053 
00054 #define SLIDER_PART0_CHANNEL    5   /**< Touch slider channel Part 0 */
00055 #define SLIDER_PART1_CHANNEL    7   /**< Touch slider channel Part 1 */
00056 #define SLIDER_PART2_CHANNEL    12  /**< Touch slider channel Part 2 */
00057 #define SLIDER_PART3_CHANNEL    13  /**< Touch slider channel Part 3 */
00058 
00059 #define CAPLESENSE_CHANNEL_INT  (LESENSE_IF_CH5 | LESENSE_IF_CH7 | LESENSE_IF_CH12 | LESENSE_IF_CH13)
00060 
00061 /** Upper voltage threshold. */
00062 #define LESENSE_ACMP_VDD_SCALE    0x37U
00063 
00064 /**************************************************************************//**
00065  * @brief  A bit vector which represents the channels to iterate through
00066  * @param LESENSE_CHANNELS Vector of channels.
00067  *****************************************************************************/
00068 #define LESENSE_CAPSENSE_CH_IN_USE {\
00069 /*  Ch0,   Ch1,   Ch2,   Ch3,   Ch4,   Ch5,   Ch6,   Ch7    */\
00070   false, false, false, false, false, true, false, true,\
00071 /*  Ch8,   Ch9,   Ch10,  Ch11,  Ch12,  Ch13,  Ch14,  Ch15   */\
00072   false, false, false, false, true,  true, false, false\
00073 }
00074 
00075 /** Configuration for capacitive sense channels in sense mode. */
00076 #define LESENSE_CAPSENSE_CH_CONF_SENSE                                                                   \
00077   {                                                                                                      \
00078     true,                     /* Enable scan channel. */                                                 \
00079     true,                     /* Enable the assigned pin on scan channel. */                             \
00080     false,                    /* Disable interrupts on channel. */                                       \
00081     lesenseChPinExDis,        /* GPIO pin is disabled during the excitation period. */                   \
00082     lesenseChPinIdleDis,      /* GPIO pin is disabled during the idle period. */                         \
00083     false,                    /* Don't use alternate excitation pins for excitation. */                  \
00084     false,                    /* Disabled to shift results from this channel to the decoder register. */ \
00085     false,                    /* Disabled to invert the scan result bit. */                              \
00086     true,                     /* Enabled to store counter value in the result buffer. */                 \
00087     lesenseClkLF,             /* Use the LF clock for excitation timing. */                              \
00088     lesenseClkLF,             /* Use the LF clock for sample timing. */                                  \
00089     0x00U,                    /* Excitation time is set to 0 excitation clock cycles. */                 \
00090     0x0FU,                    /* Sample delay is set to 15(+1) sample clock cycles. */                   \
00091     0x00U,                    /* Measure delay is set to 0 excitation clock cycles.*/                    \
00092     LESENSE_ACMP_VDD_SCALE,   /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */               \
00093     lesenseSampleModeCounter, /* ACMP will be used in comparison. */                                     \
00094     lesenseSetIntLevel,       /* Interrupt is generated if the sensor triggers. */                       \
00095     0x00U,                    /* Counter threshold has been set to 0x00. */                              \
00096     lesenseCompModeLess       /* Compare mode has been set to trigger interrupt on "less". */            \
00097   }
00098 
00099 /** Configuration for capacitive sense channels in sleep mode. */
00100 #define LESENSE_CAPSENSE_CH_CONF_SLEEP                                                                   \
00101   {                                                                                                      \
00102     true,                     /* Enable scan channel. */                                                 \
00103     true,                     /* Enable the assigned pin on scan channel. */                             \
00104     true,                     /* Enable interrupts on channel. */                                        \
00105     lesenseChPinExDis,        /* GPIO pin is disabled during the excitation period. */                   \
00106     lesenseChPinIdleDis,      /* GPIO pin is disabled during the idle period. */                         \
00107     false,                    /* Don't use alternate excitation pins for excitation. */                  \
00108     false,                    /* Disabled to shift results from this channel to the decoder register. */ \
00109     false,                    /* Disabled to invert the scan result bit. */                              \
00110     true,                     /* Enabled to store counter value in the result buffer. */                 \
00111     lesenseClkLF,             /* Use the LF clock for excitation timing. */                              \
00112     lesenseClkLF,             /* Use the LF clock for sample timing. */                                  \
00113     0x00U,                    /* Excitation time is set to 0 excitation clock cycles. */                 \
00114     0x01U,                    /* Sample delay is set to 1(+1) sample clock cycles. */                    \
00115     0x00U,                    /* Measure delay is set to 0 excitation clock cycles.*/                    \
00116     LESENSE_ACMP_VDD_SCALE,   /* ACMP threshold has been set to LESENSE_ACMP_VDD_SCALE. */               \
00117     lesenseSampleModeCounter, /* Counter will be used in comparison. */                                  \
00118     lesenseSetIntLevel,       /* Interrupt is generated if the sensor triggers. */                       \
00119     0x0EU,                    /* Counter threshold has been set to 0x0E. */                              \
00120     lesenseCompModeLess       /* Compare mode has been set to trigger interrupt on "less". */            \
00121   }
00122 
00123 /** Configuration for disabled channels. */
00124 #define LESENSE_DISABLED_CH_CONF                                                                         \
00125   {                                                                                                      \
00126     false,                    /* Disable scan channel. */                                                \
00127     false,                    /* Disable the assigned pin on scan channel. */                            \
00128     false,                    /* Disable interrupts on channel. */                                       \
00129     lesenseChPinExDis,        /* GPIO pin is disabled during the excitation period. */                   \
00130     lesenseChPinIdleDis,      /* GPIO pin is disabled during the idle period. */                         \
00131     false,                    /* Don't use alternate excitation pins for excitation. */                  \
00132     false,                    /* Disabled to shift results from this channel to the decoder register. */ \
00133     false,                    /* Disabled to invert the scan result bit. */                              \
00134     false,                    /* Disabled to store counter value in the result buffer. */                \
00135     lesenseClkLF,             /* Use the LF clock for excitation timing. */                              \
00136     lesenseClkLF,             /* Use the LF clock for sample timing. */                                  \
00137     0x00U,                    /* Excitation time is set to 5(+1) excitation clock cycles. */             \
00138     0x00U,                    /* Sample delay is set to 7(+1) sample clock cycles. */                    \
00139     0x00U,                    /* Measure delay is set to 0 excitation clock cycles.*/                    \
00140     0x00U,                    /* ACMP threshold has been set to 0. */                                    \
00141     lesenseSampleModeCounter, /* ACMP output will be used in comparison. */                              \
00142     lesenseSetIntNone,        /* No interrupt is generated by the channel. */                            \
00143     0x00U,                    /* Counter threshold has been set to 0x01. */                              \
00144     lesenseCompModeLess       /* Compare mode has been set to trigger interrupt on "less". */            \
00145   }
00146 
00147 /** Configuration for scan in sense mode. */
00148 #define LESENSE_CAPSENSE_SCAN_CONF_SENSE                 \
00149   {                                                      \
00150     {                                                    \
00151       LESENSE_DISABLED_CH_CONF,        /* Channel 0. */  \
00152       LESENSE_DISABLED_CH_CONF,        /* Channel 1. */  \
00153       LESENSE_DISABLED_CH_CONF,        /* Channel 2. */  \
00154       LESENSE_DISABLED_CH_CONF,        /* Channel 3. */  \
00155       LESENSE_DISABLED_CH_CONF,        /* Channel 4. */  \
00156       LESENSE_CAPSENSE_CH_CONF_SENSE,  /* Channel 5. */  \
00157       LESENSE_DISABLED_CH_CONF,        /* Channel 6. */  \
00158       LESENSE_CAPSENSE_CH_CONF_SENSE,  /* Channel 7. */  \
00159       LESENSE_DISABLED_CH_CONF,        /* Channel 8. */  \
00160       LESENSE_DISABLED_CH_CONF,        /* Channel 9. */  \
00161       LESENSE_DISABLED_CH_CONF,        /* Channel 10. */ \
00162       LESENSE_DISABLED_CH_CONF,        /* Channel 11. */ \
00163       LESENSE_CAPSENSE_CH_CONF_SENSE,  /* Channel 12. */ \
00164       LESENSE_CAPSENSE_CH_CONF_SENSE,  /* Channel 13. */ \
00165       LESENSE_DISABLED_CH_CONF,        /* Channel 14. */ \
00166       LESENSE_DISABLED_CH_CONF         /* Channel 15. */ \
00167     }                                                    \
00168   }
00169 
00170 /** Configuration for scan in sleep mode. */
00171 #define LESENSE_CAPSENSE_SCAN_CONF_SLEEP                 \
00172   {                                                      \
00173     {                                                    \
00174       LESENSE_DISABLED_CH_CONF,        /* Channel 0. */  \
00175       LESENSE_DISABLED_CH_CONF,        /* Channel 1. */  \
00176       LESENSE_DISABLED_CH_CONF,        /* Channel 2. */  \
00177       LESENSE_DISABLED_CH_CONF,        /* Channel 3. */  \
00178       LESENSE_DISABLED_CH_CONF,        /* Channel 4. */  \
00179       LESENSE_CAPSENSE_CH_CONF_SLEEP,  /* Channel 5. */  \
00180       LESENSE_DISABLED_CH_CONF,        /* Channel 6. */  \
00181       LESENSE_CAPSENSE_CH_CONF_SLEEP,  /* Channel 7. */  \
00182       LESENSE_DISABLED_CH_CONF,        /* Channel 8. */  \
00183       LESENSE_DISABLED_CH_CONF,        /* Channel 9. */  \
00184       LESENSE_DISABLED_CH_CONF,        /* Channel 10. */ \
00185       LESENSE_DISABLED_CH_CONF,        /* Channel 11. */ \
00186       LESENSE_CAPSENSE_CH_CONF_SLEEP,  /* Channel 12. */ \
00187       LESENSE_CAPSENSE_CH_CONF_SLEEP,  /* Channel 13. */ \
00188       LESENSE_DISABLED_CH_CONF,        /* Channel 14. */ \
00189       LESENSE_DISABLED_CH_CONF         /* Channel 15. */ \
00190     }                                                    \
00191   }
00192 
00193 #ifdef __cplusplus
00194 }
00195 #endif
00196 
00197 /** @} (end group CapSense) */
00198 /** @} (end group Drivers) */