Sensor Application Programming Interfaces (APIs)

Last modified by Microchip on 2026/03/26 09:20

MTOUCH_Sensor_Initialize

enum mtouch_sensor_error MTOUCH_Sensor_Initialize(enum mtouch_sensor_names sensor)

Description: This Application Programming Interface (API) enables, calibrates, and resets the sensor when it is called. 

Parameter:

Type Description
enum mtouch_sensor_namesEnumerator for the configured sensor names

Return: 

Type Description
enum mtouch_sensor_errorEnumerator containing the list of errors with respect to sensor

MTOUCH_Sensor_Scan_Initialize

void MTOUCH_Sensor_Scan_Initialize(void)

Description: This function initializes the Analog-to-Digital Converter (ADC) and pin module for guard/Tx.

Parameter: None

Return: None

MTOUCH_Sensor_InitializeAll

void MTOUCH_Sensor_InitializeAll(void)

Description: This function initializes all the sensors configured.

Parameter: None

Return: None

MTOUCH_Sensor_SetSampledCallback

void MTOUCH_Sensor_SetSampledCallback(void (*callback)(enum mtouch_sensor_names sensor))

Description: This function sets the callback function of sampling completion. The parameter of this callback function is the name (index) of the sensor, which just finishes its sampling.

 

MTOUCH_Sensor_SampleAll

bool MTOUCH_Sensor_SampleAll(void)

Description: This function checks whether sampling is completed for all the configured sensors and returns 0/ false. 

Parameter: None

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_isSamplingComplete

bool MTOUCH_Sensor_isSamplingComplete(void)

Description: For each sensor, this API checks whether sampling is completed or not.

Parameter: None

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_postAcquisitionProcess

void MTOUCH_Sensor_postAcquisitionProcess(void)

Description: This function updates the raw sample value of all the sensors.

Parameter: None

Return: None

MTOUCH_Sensor_ADCC_Initialize

void MTOUCH_Sensor_ADCC_Initialize(void)

Description: This function initializes the Analog-to-Digital Converter with Computation (ADCC).

Parameter: None

Return: None

ADCC_ThresholdISR_mTouch

void ADCC_ThresholdISR_mTouch(void)

Description: This interrupt service routine clears the ADC threshold Interrupt flag and then starts the sensor service.

Parameter: None

Return: None

MTOUCH_Sensor_isSampling

bool MTOUCH_Sensor_isSampling(void)

Description: This function returns the sampling flag value.

Parameter: None

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_isAnySensorActive

bool MTOUCH_Sensor_isAnySensorActive(void)

Description: This function checks if any sensor is active or not.

Parameter: None

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_isActive

bool MTOUCH_Sensor_isActive(enum mtouch_sensor_names sensor)

Description: This function returns whether the specified sensor is currently active.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_wasSampled

bool MTOUCH_Sensor_wasSampled(enum mtouch_sensor_names sensor) 

Description: This function checks whether the particular sensor is sampled or not.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_isCalibrated

bool MTOUCH_Sensor_isCalibrated(enum mtouch_sensor_names sensor)

Description: This function checks whether the sensor is calibrated or not.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_isEnabled

bool MTOUCH_Sensor_isEnabled(enum mtouch_sensor_names sensor)

Description: This function checks whether the sensor is enabled or not.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
boolReturns 0 or 1

MTOUCH_Sensor_Sampled_ResetAll

void MTOUCH_Sensor_Sampled_ResetAll(void)

Description: This function resets the sampled status of all configured sensors that have been sampled.

Parameter: None

Return: None

MTOUCH_Sensor_Disable

void MTOUCH_Sensor_Disable(enum mtouch_sensor_names sensor)

Description: This function disables the specified sensor.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: None

MTOUCH_Sensor_Enable

void MTOUCH_Sensor_Enable(enum mtouch_sensor_names sensor)

Description: This function enables the sensor.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: None

MTOUCH_Sensor_Calibrate

void MTOUCH_Sensor_Calibrate(enum mtouch_sensor_names sensor)

Description: This function calibrates the specified sensors.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: None

MTOUCH_Sensor_RawSample_Get

mtouch_sensor_sample_t MTOUCH_Sensor_RawSample_Get(enum mtouch_sensor_names name)

Description: This function returns the oversampled sensor reading from the ADC. This is used by the higher-level module, like button and proximity sensor modules. It is also useful if you want to implement their own high-level decoding, such as humidity sensor, liquid level sensor, etc.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
mtouch_sensor_sample_tRange between 0 and 65535

MTOUCH_Sensor_CVDSample_Get

mtouch_sensor_sample_t MTOUCH_Sensor_CVDSample_Get(enum mtouch_sensor_names name)

Description: This function returns the Charge Voltage Discharge (CVD) sample value.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
mtouch_sensor_sample_tRange between 0 and 65535

MTOUCH_Sensor_AdditionalCap_Get

uint8_t MTOUCH_Sensor_AdditionalCap_Get(enum mtouch_sensor_names name) 

Description: This function returns the additional capacitance value.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
uint8_tRange between 0 and 255

MTOUCH_Sensor_AcquisitionTime_Get

uint8_t MTOUCH_Sensor_AcquisitionTime_Get(enum mtouch_sensor_names name) 

Description: This function returns the acquisition time of the specified sensor considering the delay.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
uint8_tRange between 0 and 255

MTOUCH_Sensor_PreChargeTime_Get

uint8_t MTOUCH_Sensor_PreChargeTime_Get(enum mtouch_sensor_names name) 

Description: This function returns the pre-charge time of the specified sensor.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
uint8_tRange between 0 and 255

MTOUCH_Sensor_Oversampling_Get

uint8_t MTOUCH_Sensor_Oversampling_Get(enum mtouch_sensor_names name) 

Description: This function returns the oversampling value of the specified sensor.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
uint8_tRange between 0 and 255

MTOUCH_Sensor_Oversampling_Set

void MTOUCH_Sensor_Oversampling_Set(enum mtouch_sensor_names name, uint8_t value ) 

Description: Oversampling of the specified sensor can be set manually using this API.

Parameter:

Type Description
enum mtouch_sensor_names sensorEnumerator for the configured sensor names

Return: 

Type Description
uint8_tRange between 0 and 255

Back to Top