CSENEMLIB

Detailed Description

Capacitive Sense (CSEN) Peripheral API.

Provides functions for controlling the capacitive sense peripheral of Silicon Labs' 32-bit MCUs and SoCs. The CSEN includes a capacitance-to-digital circuit that measures capacitance on selected inputs. Measurements are performed using either a Successive Approximation Register (SAR) or a Delta Modulator (DM) analog to digital converter.

The CSEN can be configured to measure capacitance on a single port pin or to automatically measure multiple port pins in succession using scan mode. Also, several port pins can be shorted together to measure the combined capacitance.

The CSEN includes an accumulator which can be configured to average multiple conversions on the selected input. Additionally, an Exponential Moving Average (EMA) calculator is included to provide data smoothing. A comparator is also included and can be used to terminate a continuous conversion when the configured threshold condition is met.

The following example shows how to initialize and start a single conversion on one input:

/* CSEN is a HFPERCLK peripheral. */
/* Initialize with default settings. */
CSEN_Init_TypeDef csenInit = CSEN_INIT_DEFAULT;
CSEN_Init ( CSEN , &csenInit);
/* Select the input pin and initialize the conversion mode. */
CSEN_InitMode_TypeDef csenInitMode = CSEN_INITMODE_DEFAULT;
csenInitMode. singleSel = csenSingleSelAPORT1XCH0;
CSEN_InitMode ( CSEN , &csenInitMode);
/* Enable CSEN and manually start the conversion. */

Data Structures

struct CSEN_Init_TypeDef
struct CSEN_InitMode_TypeDef

Macros

#define CSEN_INIT_DEFAULT
#define CSEN_INITMODE_DEFAULT

Enumerations

enum CSEN_AccMode_TypeDef {
csenAccMode1 = _CSEN_CTRL_ACU_ACC1,
csenAccMode2 = _CSEN_CTRL_ACU_ACC2,
csenAccMode4 = _CSEN_CTRL_ACU_ACC4,
csenAccMode8 = _CSEN_CTRL_ACU_ACC8,
csenAccMode16 = _CSEN_CTRL_ACU_ACC16,
csenAccMode32 = _CSEN_CTRL_ACU_ACC32,
csenAccMode64 = _CSEN_CTRL_ACU_ACC64
}
enum CSEN_CmpMode_TypeDef {
csenCmpModeDisabled = 0,
csenCmpModeGreater = CSEN_CTRL_CMPEN | CSEN_CTRL_CMPPOL_GT,
csenCmpModeLessOrEqual = CSEN_CTRL_CMPEN | CSEN_CTRL_CMPPOL_LTE,
csenCmpModeEMAWindow = CSEN_CTRL_EMACMPEN
}
enum CSEN_ConvSel_TypeDef {
csenConvSelSAR = CSEN_CTRL_CONVSEL_SAR,
csenConvSelSARChop = CSEN_CTRL_CONVSEL_SAR | CSEN_CTRL_CHOPEN_ENABLE,
csenConvSelDM = CSEN_CTRL_CONVSEL_DM,
csenConvSelDMChop = CSEN_CTRL_CONVSEL_DM | CSEN_CTRL_CHOPEN_ENABLE
}
enum CSEN_DMRes_TypeDef {
csenDMRes10 = _CSEN_DMCFG_CRMODE_DM10,
csenDMRes12 = _CSEN_DMCFG_CRMODE_DM12,
csenDMRes14 = _CSEN_DMCFG_CRMODE_DM14,
csenDMRes16 = _CSEN_DMCFG_CRMODE_DM16
}
enum CSEN_DriveSel_TypeDef {
csenDriveSelFull = 0,
csenDriveSel1 = 1,
csenDriveSel2 = 2,
csenDriveSel3 = 3,
csenDriveSel4 = 4,
csenDriveSel5 = 5,
csenDriveSel6 = 6,
csenDriveSel7 = 7
}
enum CSEN_EMASample_TypeDef {
csenEMASampleW1 = _CSEN_EMACTRL_EMASAMPLE_W1,
csenEMASampleW2 = _CSEN_EMACTRL_EMASAMPLE_W2,
csenEMASampleW4 = _CSEN_EMACTRL_EMASAMPLE_W4,
csenEMASampleW8 = _CSEN_EMACTRL_EMASAMPLE_W8,
csenEMASampleW16 = _CSEN_EMACTRL_EMASAMPLE_W16,
csenEMASampleW32 = _CSEN_EMACTRL_EMASAMPLE_W32,
csenEMASampleW64 = _CSEN_EMACTRL_EMASAMPLE_W64
}
enum CSEN_GainSel_TypeDef {
csenGainSel1X = 0,
csenGainSel2X = 1,
csenGainSel3X = 2,
csenGainSel4X = 3,
csenGainSel5X = 4,
csenGainSel6X = 5,
csenGainSel7X = 6,
csenGainSel8X = 7
}
enum CSEN_InputSel_TypeDef {
csenInputSelDefault = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_DEFAULT,
csenInputSelAPORT1CH0TO7 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT1CH0TO7,
csenInputSelAPORT1CH8TO15 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT1CH8TO15,
csenInputSelAPORT1CH16TO23 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT1CH16TO23,
csenInputSelAPORT1CH24TO31 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT1CH24TO31,
csenInputSelAPORT3CH0TO7 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT3CH0TO7,
csenInputSelAPORT3CH8TO15 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT3CH8TO15,
csenInputSelAPORT3CH16TO23 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT3CH16TO23,
csenInputSelAPORT3CH24TO31 = _CSEN_SCANINPUTSEL0_INPUT0TO7SEL_APORT3CH24TO31
}
enum CSEN_PCPrescale_TypeDef {
csenPCPrescaleDiv1 = _CSEN_TIMCTRL_PCPRESC_DIV1,
csenPCPrescaleDiv2 = _CSEN_TIMCTRL_PCPRESC_DIV2,
csenPCPrescaleDiv4 = _CSEN_TIMCTRL_PCPRESC_DIV4,
csenPCPrescaleDiv8 = _CSEN_TIMCTRL_PCPRESC_DIV8,
csenPCPrescaleDiv16 = _CSEN_TIMCTRL_PCPRESC_DIV16,
csenPCPrescaleDiv32 = _CSEN_TIMCTRL_PCPRESC_DIV32,
csenPCPrescaleDiv64 = _CSEN_TIMCTRL_PCPRESC_DIV64,
csenPCPrescaleDiv128 = _CSEN_TIMCTRL_PCPRESC_DIV128
}
enum CSEN_PRSSel_TypeDef {
csenPRSSELCh0 = _CSEN_PRSSEL_PRSSEL_PRSCH0,
csenPRSSELCh1 = _CSEN_PRSSEL_PRSSEL_PRSCH1,
csenPRSSELCh2 = _CSEN_PRSSEL_PRSSEL_PRSCH2,
csenPRSSELCh3 = _CSEN_PRSSEL_PRSSEL_PRSCH3,
csenPRSSELCh4 = _CSEN_PRSSEL_PRSSEL_PRSCH4,
csenPRSSELCh5 = _CSEN_PRSSEL_PRSSEL_PRSCH5,
csenPRSSELCh6 = _CSEN_PRSSEL_PRSSEL_PRSCH6,
csenPRSSELCh7 = _CSEN_PRSSEL_PRSSEL_PRSCH7,
csenPRSSELCh8 = _CSEN_PRSSEL_PRSSEL_PRSCH8,
csenPRSSELCh9 = _CSEN_PRSSEL_PRSSEL_PRSCH9,
csenPRSSELCh10 = _CSEN_PRSSEL_PRSSEL_PRSCH10,
csenPRSSELCh11 = _CSEN_PRSSEL_PRSSEL_PRSCH11
}
enum CSEN_ResetPhaseSel_TypeDef {
csenResetPhaseSel0 = 0,
csenResetPhaseSel1 = 1,
csenResetPhaseSel2 = 2,
csenResetPhaseSel3 = 3,
csenResetPhaseSel4 = 4,
csenResetPhaseSel5 = 5,
csenResetPhaseSel6 = 6,
csenResetPhaseSel7 = 7
}
enum CSEN_SampleMode_TypeDef {
csenSampleModeBonded = CSEN_CTRL_CM_SGL | CSEN_CTRL_MCEN_ENABLE,
csenSampleModeSingle = CSEN_CTRL_CM_SGL,
csenSampleModeScan = CSEN_CTRL_CM_SCAN,
csenSampleModeContBonded = CSEN_CTRL_CM_CONTSGL | CSEN_CTRL_MCEN_ENABLE,
csenSampleModeContSingle = CSEN_CTRL_CM_CONTSGL,
csenSampleModeContScan = CSEN_CTRL_CM_CONTSCAN
}
enum CSEN_SARRes_TypeDef {
csenSARRes10 = _CSEN_CTRL_SARCR_CLK10,
csenSARRes12 = _CSEN_CTRL_SARCR_CLK12,
csenSARRes14 = _CSEN_CTRL_SARCR_CLK14,
csenSARRes16 = _CSEN_CTRL_SARCR_CLK16
}
enum CSEN_SingleSel_TypeDef {
csenSingleSelDefault = _CSEN_SINGLECTRL_SINGLESEL_DEFAULT,
csenSingleSelAPORT1XCH0 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH0,
csenSingleSelAPORT1YCH1 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH1,
csenSingleSelAPORT1XCH2 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH2,
csenSingleSelAPORT1YCH3 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH3,
csenSingleSelAPORT1XCH4 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH4,
csenSingleSelAPORT1YCH5 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH5,
csenSingleSelAPORT1XCH6 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH6,
csenSingleSelAPORT1YCH7 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH7,
csenSingleSelAPORT1XCH8 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH8,
csenSingleSelAPORT1YCH9 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH9,
csenSingleSelAPORT1XCH10 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH10,
csenSingleSelAPORT1YCH11 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH11,
csenSingleSelAPORT1XCH12 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH12,
csenSingleSelAPORT1YCH13 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH13,
csenSingleSelAPORT1XCH14 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH14,
csenSingleSelAPORT1YCH15 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH15,
csenSingleSelAPORT1XCH16 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH16,
csenSingleSelAPORT1YCH17 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH17,
csenSingleSelAPORT1XCH18 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH18,
csenSingleSelAPORT1YCH19 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH19,
csenSingleSelAPORT1XCH20 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH20,
csenSingleSelAPORT1YCH21 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH21,
csenSingleSelAPORT1XCH22 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH22,
csenSingleSelAPORT1YCH23 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH23,
csenSingleSelAPORT1XCH24 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH24,
csenSingleSelAPORT1YCH25 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH25,
csenSingleSelAPORT1XCH26 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH26,
csenSingleSelAPORT1YCH27 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH27,
csenSingleSelAPORT1XCH28 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH28,
csenSingleSelAPORT1YCH29 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH29,
csenSingleSelAPORT1XCH30 = _CSEN_SINGLECTRL_SINGLESEL_APORT1XCH30,
csenSingleSelAPORT1YCH31 = _CSEN_SINGLECTRL_SINGLESEL_APORT1YCH31,
csenSingleSelAPORT3XCH0 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH0,
csenSingleSelAPORT3YCH1 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH1,
csenSingleSelAPORT3XCH2 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH2,
csenSingleSelAPORT3YCH3 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH3,
csenSingleSelAPORT3XCH4 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH4,
csenSingleSelAPORT3YCH5 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH5,
csenSingleSelAPORT3XCH6 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH6,
csenSingleSelAPORT3YCH7 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH7,
csenSingleSelAPORT3XCH8 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH8,
csenSingleSelAPORT3YCH9 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH9,
csenSingleSelAPORT3XCH10 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH10,
csenSingleSelAPORT3YCH11 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH11,
csenSingleSelAPORT3XCH12 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH12,
csenSingleSelAPORT3YCH13 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH13,
csenSingleSelAPORT3XCH14 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH14,
csenSingleSelAPORT3YCH15 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH15,
csenSingleSelAPORT3XCH16 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH16,
csenSingleSelAPORT3YCH17 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH17,
csenSingleSelAPORT3XCH18 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH18,
csenSingleSelAPORT3YCH19 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH19,
csenSingleSelAPORT3XCH20 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH20,
csenSingleSelAPORT3YCH21 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH21,
csenSingleSelAPORT3XCH22 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH22,
csenSingleSelAPORT3YCH23 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH23,
csenSingleSelAPORT3XCH24 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH24,
csenSingleSelAPORT3YCH25 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH25,
csenSingleSelAPORT3XCH26 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH26,
csenSingleSelAPORT3YCH27 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH27,
csenSingleSelAPORT3XCH28 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH28,
csenSingleSelAPORT3YCH29 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH29,
csenSingleSelAPORT3XCH30 = _CSEN_SINGLECTRL_SINGLESEL_APORT3XCH30,
csenSingleSelAPORT3YCH31 = _CSEN_SINGLECTRL_SINGLESEL_APORT3YCH31
}
enum CSEN_TrigSel_TypeDef {
csenTrigSelPRS = _CSEN_CTRL_STM_PRS,
csenTrigSelTimer = _CSEN_CTRL_STM_TIMER,
csenTrigSelStart = _CSEN_CTRL_STM_START
}

Functions

__STATIC_INLINE uint32_t CSEN_DataGet ( CSEN_TypeDef *csen)
Get last conversion result.
__STATIC_INLINE void CSEN_Disable ( CSEN_TypeDef *csen)
Disables the CSEN.
void CSEN_DMBaselineSet ( CSEN_TypeDef *csen, uint32_t up, uint32_t down)
Set the DM integrator initial value.
__STATIC_INLINE uint32_t CSEN_EMAGet ( CSEN_TypeDef *csen)
Get last exponential moving average.
__STATIC_INLINE void CSEN_EMASet ( CSEN_TypeDef *csen, uint32_t ema)
Set exponential moving average initial value.
__STATIC_INLINE void CSEN_Enable ( CSEN_TypeDef *csen)
Enables the CSEN.
void CSEN_Init ( CSEN_TypeDef *csen, const CSEN_Init_TypeDef *init)
Initialize CSEN.
void CSEN_InitMode ( CSEN_TypeDef *csen, const CSEN_InitMode_TypeDef *init)
Initialize a CSEN measurement mode.
__STATIC_INLINE void CSEN_IntClear ( CSEN_TypeDef *csen, uint32_t flags)
Clear one or more pending CSEN interrupts.
__STATIC_INLINE void CSEN_IntDisable ( CSEN_TypeDef *csen, uint32_t flags)
Disable one or more CSEN interrupts.
__STATIC_INLINE void CSEN_IntEnable ( CSEN_TypeDef *csen, uint32_t flags)
Enable one or more CSEN interrupts.
__STATIC_INLINE uint32_t CSEN_IntGet ( CSEN_TypeDef *csen)
Get pending CSEN interrupt flags.
__STATIC_INLINE uint32_t CSEN_IntGetEnabled ( CSEN_TypeDef *csen)
Get enabled and pending CSEN interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
__STATIC_INLINE void CSEN_IntSet ( CSEN_TypeDef *csen, uint32_t flags)
Set one or more pending CSEN interrupts from SW.
__STATIC_INLINE bool CSEN_IsBusy ( CSEN_TypeDef *csen)
Return CSEN conversion busy status.
void CSEN_Reset ( CSEN_TypeDef *csen)
Reset CSEN to same state that it was in after a hardware reset.
__STATIC_INLINE void CSEN_Start ( CSEN_TypeDef *csen)
Start scan sequence and/or single conversion.

Macro Definition Documentation

#define CSEN_INIT_DEFAULT
Value:
{ \
false, /* Charge pump low accuracy mode. */ \
false, /* Use external kelvin connection. */ \
false, /* Disable keep warm. */ \
0, /* 0+3 cycle warm-up time. */ \
0, /* Period counter reload. */ \
csenPCPrescaleDiv1, /* Period counter prescale. */ \
csenPRSSELCh0, /* PRS channel 0. */ \
csenInputSelAPORT1CH0TO7, /* input0To7 -> aport1ch0to7 */ \
csenInputSelAPORT1CH8TO15, /* input8To15 -> aport1ch8to15 */ \
csenInputSelAPORT1CH16TO23, /* input16To23 -> aport1ch16to23 */ \
csenInputSelAPORT1CH24TO31, /* input24To31 -> aport1ch24to31 */ \
csenInputSelAPORT3CH0TO7, /* input32To39 -> aport3ch0to7 */ \
csenInputSelAPORT3CH8TO15, /* input40To47 -> aport3ch8to15 */ \
csenInputSelAPORT3CH16TO23, /* input48To55 -> aport3ch16to23 */ \
csenInputSelAPORT3CH24TO31, /* input56To63 -> aport3ch24to31 */ \
}

Definition at line 374 of file em_csen.h .

#define CSEN_INITMODE_DEFAULT
Value:
{ \
csenSampleModeSingle, /* Sample one input and stop. */ \
csenTrigSelStart, /* Use start bit to trigger. */ \
false, /* Disable DMA. */ \
false, /* Average the accumulated result. */ \
csenAccMode1, /* Accumulate 1 sample. */ \
csenEMASampleW1, /* Disable the EMA. */ \
csenCmpModeDisabled, /* Disable the comparator. */ \
0, /* Comparator threshold not used. */ \
csenSingleSelDefault, /* Disconnect the single input. */ \
0, /* Disable inputs 0 to 31. */ \
0, /* Disable inputs 32 to 63. */ \
false, /* Do not ground inactive inputs. */ \
csenConvSelSAR, /* Use the SAR converter. */ \
csenSARRes10, /* Set SAR resolution to 10 bits. */ \
csenDMRes10, /* Set DM resolution to 10 bits. */ \
0, /* Set DM conv/cycle to default. */ \
0, /* Set DM cycles to default. */ \
0, /* Set DM initial delta to default. */ \
false, /* Use DM auto delta reduction. */ \
csenResetPhaseSel0, /* Use shortest reset phase time. */ \
csenDriveSelFull, /* Use full output current. */ \
csenGainSel8X, /* Use highest converter gain. */ \
}

Definition at line 474 of file em_csen.h .

Enumeration Type Documentation

Accumulator Mode Select.

Enumerator
csenAccMode1

Accumulate 1 sample.

csenAccMode2

Accumulate 2 samples.

csenAccMode4

Accumulate 4 samples.

csenAccMode8

Accumulate 8 samples.

csenAccMode16

Accumulate 16 samples.

csenAccMode32

Accumulate 32 samples.

csenAccMode64

Accumulate 64 samples.

Definition at line 144 of file em_csen.h .

Comparator Mode. Selects the operation of the digital comparator.

Enumerator
csenCmpModeDisabled

Comparator is disabled.

csenCmpModeGreater

Comparator trips when the result is greater than the threshold.

csenCmpModeLessOrEqual

Comparator trips when the result is less than or equal to the threshold.

csenCmpModeEMAWindow

Comparator trips when the EMA is within the threshold window.

Definition at line 86 of file em_csen.h .

Converter Select. Determines the converter operational mode.

Enumerator
csenConvSelSAR

Successive Approximation (SAR) converter.

csenConvSelSARChop

Successive Approximation (SAR) converter with low frequency attenuation.

csenConvSelDM

Delta Modulation (DM) converter.

csenConvSelDMChop

Delta Modulation (DM) converter with low frequency attenuation.

Definition at line 101 of file em_csen.h .

Delta Modulator (DM) Conversion Resolution.

Enumerator
csenDMRes10

10-bit resolution.

csenDMRes12

12-bit resolution.

csenDMRes14

14-bit resolution.

csenDMRes16

16-bit resolution.

Definition at line 163 of file em_csen.h .

Drive Strength Select. Scales the output current.

Enumerator
csenDriveSelFull

Drive strength = fully on.

csenDriveSel1

Drive strength = 1/8 full scale.

csenDriveSel2

Drive strength = 1/4 full scale.

csenDriveSel3

Drive strength = 3/8 full scale.

csenDriveSel4

Drive strength = 1/2 full scale.

csenDriveSel5

Drive strength = 5/8 full scale.

csenDriveSel6

Drive strength = 3/4 full scale.

csenDriveSel7

Drive strength = 7/8 full scale.

Definition at line 207 of file em_csen.h .

Exponential Moving Average sample weight.

Enumerator
csenEMASampleW1

Weight 1.

csenEMASampleW2

Weight 2.

csenEMASampleW4

Weight 4.

csenEMASampleW8

Weight 8.

csenEMASampleW16

Weight 16.

csenEMASampleW32

Weight 32.

csenEMASampleW64

Weight 64.

Definition at line 184 of file em_csen.h .

Gain Select. See reference manual for information on each setting.

Enumerator
csenGainSel1X

Gain = 1x.

csenGainSel2X

Gain = 2x.

csenGainSel3X

Gain = 3x.

csenGainSel4X

Gain = 4x.

csenGainSel5X

Gain = 5x.

csenGainSel6X

Gain = 6x.

csenGainSel7X

Gain = 7x.

csenGainSel8X

Gain = 8x.

Definition at line 219 of file em_csen.h .

APORT channel to CSEN input selection.

Definition at line 255 of file em_csen.h .

Period counter clock pre-scaler. See the reference manual for source clock information.

Enumerator
csenPCPrescaleDiv1

Divide by 1.

csenPCPrescaleDiv2

Divide by 2.

csenPCPrescaleDiv4

Divide by 4.

csenPCPrescaleDiv8

Divide by 8.

csenPCPrescaleDiv16

Divide by 16.

csenPCPrescaleDiv32

Divide by 32.

csenPCPrescaleDiv64

Divide by 64.

csenPCPrescaleDiv128

Divide by 128.

Definition at line 172 of file em_csen.h .

Peripheral Reflex System signal used to trigger conversion.

Enumerator
csenPRSSELCh0

PRS channel 0.

csenPRSSELCh1

PRS channel 1.

csenPRSSELCh2

PRS channel 2.

csenPRSSELCh3

PRS channel 3.

csenPRSSELCh4

PRS channel 4.

csenPRSSELCh5

PRS channel 5.

csenPRSSELCh6

PRS channel 6.

csenPRSSELCh7

PRS channel 7.

csenPRSSELCh8

PRS channel 8.

csenPRSSELCh9

PRS channel 9.

csenPRSSELCh10

PRS channel 10.

csenPRSSELCh11

PRS channel 11.

Definition at line 231 of file em_csen.h .

Reset Phase Timing Select (units are microseconds).

Enumerator
csenResetPhaseSel0

Reset phase time = 0.75 usec.

csenResetPhaseSel1

Reset phase time = 1.00 usec.

csenResetPhaseSel2

Reset phase time = 1.20 usec.

csenResetPhaseSel3

Reset phase time = 1.50 usec.

csenResetPhaseSel4

Reset phase time = 2.00 usec.

csenResetPhaseSel5

Reset phase time = 3.00 usec.

csenResetPhaseSel6

Reset phase time = 6.00 usec.

csenResetPhaseSel7

Reset phase time = 12.0 usec.

Definition at line 195 of file em_csen.h .

Sample Mode. Determines how inputs are sampled for a conversion.

Enumerator
csenSampleModeBonded

Converts multiple inputs shorted together and stop.

csenSampleModeSingle

Converts one input and stop.

csenSampleModeScan

Converts multiple inputs one at a time and stop.

csenSampleModeContBonded

Continuously converts multiple inputs shorted together.

csenSampleModeContSingle

Continuously converts one input.

csenSampleModeContScan

Continuously converts multiple inputs one at a time.

Definition at line 116 of file em_csen.h .

Successive Approximation (SAR) Conversion Resolution.

Enumerator
csenSARRes10

10-bit resolution.

csenSARRes12

12-bit resolution.

csenSARRes14

14-bit resolution.

csenSARRes16

16-bit resolution.

Definition at line 155 of file em_csen.h .

APORT channel to CSEN single input selection.

Definition at line 268 of file em_csen.h .

Starts Trigger Select.

Enumerator
csenTrigSelPRS

PRS system.

csenTrigSelTimer

CSEN PC timer.

csenTrigSelStart

Start bit.

Definition at line 137 of file em_csen.h .

Function Documentation

__STATIC_INLINE uint32_t CSEN_DataGet ( CSEN_TypeDef * csen )

Get last conversion result.

Note
Check conversion busy flag before calling this function. In addition, the result width and format depend on the parameters passed to the CSEN_InitMode() function.
Parameters
[in] csen Pointer to CSEN peripheral register block.
Returns
Result data from last conversion.

Definition at line 519 of file em_csen.h .

References CSEN_TypeDef::DATA .

__STATIC_INLINE void CSEN_Disable ( CSEN_TypeDef * csen )

Disables the CSEN.

Parameters
[in] csen Pointer to CSEN peripheral register block.

Definition at line 567 of file em_csen.h .

References _CSEN_CTRL_EN_SHIFT , BUS_RegBitWrite() , and CSEN_TypeDef::CTRL .

void CSEN_DMBaselineSet ( CSEN_TypeDef * csen,
uint32_t up,
uint32_t down
)

Set the DM integrator initial value.

Sets the initial value of the integrator(s) for the Delta Modulation (DM) converter. The initial value for the ramp-down integrator has no effect if the low-frequency attenuation was not selected by the mode initialization function CSEN_InitMode() .

Note
Confirm CSEN is idle before calling this function.
Parameters
[in] csen A pointer to the CSEN peripheral register block.
[in] up An initial value for the ramp-up integrator.
[in] down An initial value for the ramp-down integrator. Has no effect if low-frequency attenuation is not configured.

Definition at line 88 of file em_csen.c .

References _CSEN_DMBASELINE_BASELINEDN_SHIFT , _CSEN_DMBASELINE_BASELINEUP_SHIFT , and CSEN_TypeDef::DMBASELINE .

__STATIC_INLINE uint32_t CSEN_EMAGet ( CSEN_TypeDef * csen )

Get last exponential moving average.

Note
Confirm CSEN is idle before calling this function.
Parameters
[in] csen Pointer to CSEN peripheral register block.
Returns
Exponential moving average from last conversion.

Definition at line 537 of file em_csen.h .

References _CSEN_EMA_EMA_MASK , and CSEN_TypeDef::EMA .

__STATIC_INLINE void CSEN_EMASet ( CSEN_TypeDef * csen,
uint32_t ema
)

Set exponential moving average initial value.

Note
Call this function before starting a conversion.
Parameters
[in] csen Pointer to CSEN peripheral register block.
[in] ema Initial value for the exponential moving average.

Definition at line 555 of file em_csen.h .

References _CSEN_EMA_EMA_MASK , and CSEN_TypeDef::EMA .

__STATIC_INLINE void CSEN_Enable ( CSEN_TypeDef * csen )

Enables the CSEN.

Parameters
[in] csen Pointer to CSEN peripheral register block.

Definition at line 579 of file em_csen.h .

References _CSEN_CTRL_EN_SHIFT , BUS_RegBitWrite() , and CSEN_TypeDef::CTRL .

void CSEN_InitMode ( CSEN_TypeDef * csen,
const CSEN_InitMode_TypeDef * init
)

Initialize a CSEN measurement mode.

Used to configure any type of measurement mode. After the measurement has been configured, calling CSEN_Enable() will enable CSEN and allow it to start a conversion from the selected trigger source. To manually start a conversion, use CSEN_Start() . To check if a conversion is in progress, use CSEN_IsBusy() , or alternatively use the interrupt flags returned by CSEN_IntGet() to detect when a conversion is completed.

Note
This function will stop any ongoing conversion and disable CSEN.
Parameters
[in] csen A pointer to the CSEN peripheral register block.
[in] init A pointer to the CSEN measurement mode initialization structure.

Definition at line 181 of file em_csen.c .

References _CSEN_ANACTRL_IDACIREFS_SHIFT , _CSEN_ANACTRL_IREFPROG_SHIFT , _CSEN_ANACTRL_TRSTPROG_SHIFT , _CSEN_CMPTHR_CMPTHR_SHIFT , _CSEN_CTRL_ACU_SHIFT , _CSEN_CTRL_CPACCURACY_MASK , _CSEN_CTRL_LOCALSENS_MASK , _CSEN_CTRL_SARCR_SHIFT , _CSEN_CTRL_STM_SHIFT , _CSEN_CTRL_WARMUPMODE_MASK , _CSEN_DMCFG_CRMODE_SHIFT , _CSEN_DMCFG_DMCR_SHIFT , _CSEN_DMCFG_DMG_SHIFT , _CSEN_DMCFG_DMR_SHIFT , _CSEN_EMACTRL_EMASAMPLE_SHIFT , _CSEN_SINGLECTRL_SINGLESEL_SHIFT , CSEN_InitMode_TypeDef::accMode , CSEN_TypeDef::ANACTRL , CSEN_InitMode_TypeDef::autoGnd , CSEN_InitMode_TypeDef::cmpMode , CSEN_TypeDef::CMPTHR , CSEN_InitMode_TypeDef::cmpThr , CSEN_InitMode_TypeDef::convSel , CSEN_CTRL_AUTOGND_ENABLE , CSEN_CTRL_DMAEN_ENABLE , CSEN_CTRL_DRSF_ENABLE , CSEN_DMCFG_DMGRDIS , CSEN_TypeDef::CTRL , CSEN_TypeDef::DMCFG , CSEN_InitMode_TypeDef::dmCycles , CSEN_InitMode_TypeDef::dmDelta , CSEN_InitMode_TypeDef::dmFixedDelta , CSEN_InitMode_TypeDef::dmIterPerCycle , CSEN_InitMode_TypeDef::dmRes , CSEN_InitMode_TypeDef::driveSel , CSEN_TypeDef::EMACTRL , CSEN_InitMode_TypeDef::emaSample , CSEN_InitMode_TypeDef::enableDma , CSEN_InitMode_TypeDef::gainSel , CSEN_InitMode_TypeDef::inputMask0 , CSEN_InitMode_TypeDef::inputMask1 , CSEN_InitMode_TypeDef::resetPhase , CSEN_InitMode_TypeDef::sampleMode , CSEN_InitMode_TypeDef::sarRes , CSEN_TypeDef::SCANMASK0 , CSEN_TypeDef::SCANMASK1 , CSEN_TypeDef::SINGLECTRL , CSEN_InitMode_TypeDef::singleSel , CSEN_InitMode_TypeDef::sumOnly , and CSEN_InitMode_TypeDef::trigSel .

__STATIC_INLINE void CSEN_IntClear ( CSEN_TypeDef * csen,
uint32_t flags
)

Clear one or more pending CSEN interrupts.

Parameters
[in] csen Pointer to CSEN peripheral register block.
[in] flags Pending CSEN interrupt source to clear. Use a bitwise logic OR combination of valid interrupt flags for the CSEN module (CSEN_IF_nnn).

Definition at line 600 of file em_csen.h .

References CSEN_TypeDef::IFC .

__STATIC_INLINE void CSEN_IntDisable ( CSEN_TypeDef * csen,
uint32_t flags
)

Disable one or more CSEN interrupts.

Parameters
[in] csen Pointer to CSEN peripheral register block.
[in] flags CSEN interrupt sources to disable. Use a bitwise logic OR combination of valid interrupt flags for the CSEN module (CSEN_IF_nnn).

Definition at line 616 of file em_csen.h .

References CSEN_TypeDef::IEN .

__STATIC_INLINE void CSEN_IntEnable ( CSEN_TypeDef * csen,
uint32_t flags
)

Enable one or more CSEN interrupts.

Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using CSEN_IntClear() prior to enabling if such a pending interrupt should be ignored.
Parameters
[in] csen Pointer to CSEN peripheral register block.
[in] flags CSEN interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the CSEN module (CSEN_IF_nnn).

Definition at line 637 of file em_csen.h .

References CSEN_TypeDef::IEN .

__STATIC_INLINE uint32_t CSEN_IntGet ( CSEN_TypeDef * csen )

Get pending CSEN interrupt flags.

Note
The event bits are not cleared by the use of this function.
Parameters
[in] csen Pointer to CSEN peripheral register block.
Returns
CSEN interrupt sources pending. A bitwise logic OR combination of valid interrupt flags for the CSEN module (CSEN_IF_nnn).

Definition at line 656 of file em_csen.h .

References CSEN_TypeDef::IF .

__STATIC_INLINE uint32_t CSEN_IntGetEnabled ( CSEN_TypeDef * csen )

Get enabled and pending CSEN interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.

Parameters
[in] csen Pointer to CSEN peripheral register block.
Note
Interrupt flags are not cleared by the use of this function.
Returns
Pending and enabled CSEN interrupt sources. The return value is the bitwise AND combination of
  • the OR combination of enabled interrupt sources in CSENx_IEN_nnn register (CSENx_IEN_nnn) and
  • the OR combination of valid interrupt flags of the CSEN module (CSENx_IF_nnn).

Definition at line 680 of file em_csen.h .

References CSEN_TypeDef::IEN , and CSEN_TypeDef::IF .

__STATIC_INLINE void CSEN_IntSet ( CSEN_TypeDef * csen,
uint32_t flags
)

Set one or more pending CSEN interrupts from SW.

Parameters
[in] csen Pointer to CSEN peripheral register block.
[in] flags CSEN interrupt sources to set to pending. Use a bitwise logic OR combination of valid interrupt flags for the CSEN module (CSEN_IF_nnn).

Definition at line 703 of file em_csen.h .

References CSEN_TypeDef::IFS .

__STATIC_INLINE bool CSEN_IsBusy ( CSEN_TypeDef * csen )

Return CSEN conversion busy status.

Parameters
[in] csen Pointer to CSEN peripheral register block.
Returns
True if CSEN conversion is in progress.

Definition at line 718 of file em_csen.h .

References _CSEN_STATUS_CSENBUSY_MASK , and CSEN_TypeDef::STATUS .

__STATIC_INLINE void CSEN_Start ( CSEN_TypeDef * csen )

Start scan sequence and/or single conversion.

Parameters
[in] csen Pointer to CSEN peripheral register block.

Definition at line 730 of file em_csen.h .

References CSEN_TypeDef::CMD , and CSEN_CMD_START .