PSoC-FDC1004Q
PSoC FDC1004Q Library
|
Header file for the FDC1004Q driver. More...
Go to the source code of this file.
Functions | |
uint8_t | FDC_Start (void) |
Start the FDC1004Q. More... | |
void | FDC_Stop (void) |
Stop communication with the FDC1004Q. | |
uint8_t | FDC_Reset (void) |
Perform a software reset of the sensor. More... | |
uint8_t | FDC_IsDeviceConnected (void) |
Check if device is connected on the I2C bus. More... | |
uint8_t | FDC_SetSampleRate (uint8_t sampleRate) |
Set up sample rate for continuous measurements. More... | |
uint8_t | FDC_ReadSampleRate (uint8_t *sampleRate) |
Read current sample rate. More... | |
uint8_t | FDC_ReadOffsetCalibration (uint8_t channel, float *offset) |
Read channel offset calibration register as float value. More... | |
uint8_t | FDC_ReadRawOffsetCalibration (uint8_t channel, int16_t *offset) |
Read channel offset calibration register as Q5.11 format. More... | |
uint8_t | FDC_SetOffsetCalibration (uint8_t channel, float offset) |
Set channel offset calibration register in float format. More... | |
uint8_t | FDC_SetRawOffsetCalibration (uint8_t channel, int16_t offset) |
Set channel offset calibration register in raw format. More... | |
uint8_t | FDC_ReadGainCalibration (uint8_t channel, float *gain) |
Read gain calibration register in float format. More... | |
uint8_t | FDC_ReadRawGainCalibration (uint8_t channel, uint16_t *gain) |
Read gain calibration register in fixed point Q2.14 formta. More... | |
uint8_t | FDC_SetGainCalibration (uint8_t channel, float gain) |
Set gain calibration register. More... | |
uint8_t | FDC_SetRawGainCalibration (uint8_t channel, uint16_t gain) |
Set gain calibration register in Q2.14 format. More... | |
uint8_t | FDC_InitMeasurement (uint8_t channel) |
Init measurement for given channel. More... | |
uint8_t | FDC_StopMeasurement (uint8_t channel) |
Stop measurement for given channel. More... | |
uint8_t | FDC_IsMeasurementDone (uint8_t channel, uint8_t *done) |
Check if measurement for a given channel is complete. More... | |
uint8_t | FDC_EnableRepeatMeasurement (uint8_t channel_flags) |
Enable repeated measurement. More... | |
uint8_t | FDC_DisableRepeatMeasurement (void) |
Disable repated measurement. More... | |
uint8_t | FDC_ConfigureMeasurementInput (uint8_t meas_channel, uint8_t pos_channel, uint8_t neg_channel, uint8_t capdac) |
Configure measurement input settings. More... | |
uint8_t | FDC_ConfigureMeasurement (uint8_t meas_channel, uint8_t pos_channel, uint8_t neg_channel, uint8_t capdac, int16_t offset, uint16_t gain) |
Configure measurement settings. More... | |
uint8_t | FDC_ReadRawCapdacSetting (uint8_t channel, uint8_t *capdac) |
Read current capdac setting. More... | |
uint8_t | FDC_ReadCapdacSetting (uint8_t channel, float *capdac) |
Read current capdac setting in float format. More... | |
uint8_t | FDC_ReadPositiveChannelSetting (uint8_t channel, uint8_t *input) |
Read current positive input channel setting. More... | |
uint8_t | FDC_ReadNegativeChannelSetting (uint8_t channel, uint8_t *input) |
Read current negative input channel setting. More... | |
uint8_t | FDC_ReadRawMeasurement (uint8_t channel, uint32_t *capacitance) |
Read capacitance measurement in raw format. More... | |
uint8_t | FDC_ReadMeasurement (uint8_t channel, double *capacitance) |
Read capacitance measurement in double format. More... | |
double | FDC_ConvertRawMeasurement (uint32_t capacitance) |
Convert raw capacitance measurement in double format. More... | |
uint8_t | FDC_HasNewData (uint8_t *done) |
Check if new measurement data are available to be read. More... | |
uint8_t | FDC_ReadManufacturerId (uint16_t *id) |
Read the manufacturer ID from the sensor. More... | |
uint8_t | FDC_ReadDeviceId (uint16_t *id) |
Read the device ID from the sensor. More... | |
uint8_t | FDC_ReadRegister (uint8_t reg_addr, uint8_t *data) |
Read a register from the FDC1004Q. More... | |
uint8_t | FDC_WriteRegister (uint8_t reg_addr, uint8_t *data) |
Write a register to the FDC1004Q. More... | |
Header file for the FDC1004Q driver.
This file contains function declarations and type definitions for the FDC1004Q driver.
Definition in file FDC1004Q.h.
uint8_t FDC_ConfigureMeasurement | ( | uint8_t | meas_channel, |
uint8_t | pos_channel, | ||
uint8_t | neg_channel, | ||
uint8_t | capdac, | ||
int16_t | offset, | ||
uint16_t | gain | ||
) |
Configure measurement settings.
This function allows to configure the settings for a given channel of the measurement.
meas_channel | the measurement channel to be configured. |
pos_channel | the positive input channel to capacitance digital converter. |
neg_channel | the negative input channel to capacitance digital converter. |
capdac | value of CAPDAC, that is the capacitance offset (this value is multiplied by 3.125 pF). |
offset | value of capacitance offset. |
gain | value of capacitance gain. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if error in the settings. |
Definition at line 400 of file FDC1004Q.c.
uint8_t FDC_ConfigureMeasurementInput | ( | uint8_t | meas_channel, |
uint8_t | pos_channel, | ||
uint8_t | neg_channel, | ||
uint8_t | capdac | ||
) |
Configure measurement input settings.
This function allows to configure the input settings for a given channel of the measurement.
meas_channel | the measurement channel to be configured. |
pos_channel | the positive input channel to capacitance digital converter. |
neg_channel | the negative input channel to capacitance digital converter. |
capdac | value of CAPDAC, that is the capacitance offset (this value is multiplied by 3.125 pF). |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if error in the settings. |
Definition at line 364 of file FDC1004Q.c.
double FDC_ConvertRawMeasurement | ( | uint32_t | capacitance | ) |
Convert raw capacitance measurement in double format.
This function converts a raw measurement in dobule format. CAPDAC value is not added to the measurement, so it is necessary to add it after the conversion is completed.
capacitance | the raw capacitance value |
Definition at line 470 of file FDC1004Q.c.
uint8_t FDC_DisableRepeatMeasurement | ( | void | ) |
Disable repated measurement.
This function disables repeated measurements.
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 349 of file FDC1004Q.c.
uint8_t FDC_EnableRepeatMeasurement | ( | uint8_t | channel_flags | ) |
Enable repeated measurement.
This function enables repeated measurements for a single channel or for the set of channels.
channel_flags | the channels for which to enable repeated measurements. It is possible to OR together the following values: |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 321 of file FDC1004Q.c.
uint8_t FDC_HasNewData | ( | uint8_t * | done | ) |
Check if new measurement data are available to be read.
This function checks whether new data are available in the measurement registers to be read.
FDC_OK | if no error occurred |
FDC_COMM_ERR | if communication error occurred. |
Definition at line 547 of file FDC1004Q.c.
uint8_t FDC_InitMeasurement | ( | uint8_t | channel | ) |
Init measurement for given channel.
This function inits the capacitance measurement for a given channel.
channel | the channel for which the measurement must be started. Possible values are: |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
FDC_CONF_ERR | if channel value not correct |
Definition at line 272 of file FDC1004Q.c.
uint8_t FDC_IsDeviceConnected | ( | void | ) |
Check if device is connected on the I2C bus.
This function sends a write request on the I2C bus to check it it is acknowledged by the sensor. If the sensor acknowledges it, then it means that it is connected.
FDC_OK | if device was found on I2C bus. |
FDC_DEV_NOT_FOUND | if device was not found on I2C bus. |
Definition at line 73 of file FDC1004Q.c.
uint8_t FDC_IsMeasurementDone | ( | uint8_t | channel, |
uint8_t * | done | ||
) |
Check if measurement for a given channel is complete.
This function check if the capacitance measurement for a given channel is complete.
[in] | channel | the channel for which the measurement must be started. |
[out] | done | pointer to variable where the result of the check will be stored. |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
FDC_CONF_ERR | if channel value not correct |
Definition at line 307 of file FDC1004Q.c.
uint8_t FDC_ReadCapdacSetting | ( | uint8_t | channel, |
float * | capdac | ||
) |
Read current capdac setting in float format.
This function reads the current value of capdac set in the register. The value returned is in float format.
[in] | channel | the channel for which the capdac setting must be retrieved. Possible values are: |
[out] | capdac | pointer to variable where the capdac value will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 497 of file FDC1004Q.c.
uint8_t FDC_ReadDeviceId | ( | uint16_t * | id | ) |
Read the device ID from the sensor.
This function reads the device ID from the sensor, so that the device can be distinguished from other sensors on the same I2C bus.
id | the manufacturer id read from the sensor |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 580 of file FDC1004Q.c.
uint8_t FDC_ReadGainCalibration | ( | uint8_t | channel, |
float * | gain | ||
) |
Read gain calibration register in float format.
This function reads the current gain calibration value in the register for the channel passed in as parameter to the function. A detailed description of the gain calibration register can be found at FDC1004Q_GAIN_CAL_CIN1.
[in] | channel | the channel from which to read the calibration gain. Possible values are: |
[out] | gain | pointer to variable where the gain will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if channel value not correct. |
Definition at line 240 of file FDC1004Q.c.
uint8_t FDC_ReadManufacturerId | ( | uint16_t * | id | ) |
Read the manufacturer ID from the sensor.
This function reads the manufacturer ID from the sensor, so that the device can be distinguished from other sensors on the same I2C bus.
id | the manufacturer id read from the sensor |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 566 of file FDC1004Q.c.
uint8_t FDC_ReadMeasurement | ( | uint8_t | channel, |
double * | capacitance | ||
) |
Read capacitance measurement in double format.
This function reads the content of the measurement registers, converting it and adding the offset specified by the capdac setting.
[in] | channel | the channel for which the measurement must be read. Possible values are: |
[out] | capacitance | pointer to variable where the result will be stored. |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 439 of file FDC1004Q.c.
uint8_t FDC_ReadNegativeChannelSetting | ( | uint8_t | channel, |
uint8_t * | input | ||
) |
Read current negative input channel setting.
This function reads the current value configured as negative input channel for the measurement channel of interest.
[in] | channel | the channel for which the setting must be retrieved. Possible values are: |
[out] | input | pointer to variable where the negative input channel value will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 530 of file FDC1004Q.c.
uint8_t FDC_ReadOffsetCalibration | ( | uint8_t | channel, |
float * | offset | ||
) |
Read channel offset calibration register as float value.
This function reads the current offset calibration set in the register for the channel passed in as parameter to the function. A detailed description of the offset calibration register can be found at FDC1004Q_OFFSET_CAL_CIN1. This function converts the stored value in float format.
[in] | channel | the channel from which to read the calibration offset. Possible values are: |
[out] | offset | pointer to variable where the value of the offset will be stored |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
FDC_CONF_ERR | if wrong value for channel. |
Definition at line 184 of file FDC1004Q.c.
uint8_t FDC_ReadPositiveChannelSetting | ( | uint8_t | channel, |
uint8_t * | input | ||
) |
Read current positive input channel setting.
This function reads the current value configured as positive input channel for the measurement channel of interest.
[in] | channel | the channel for which the setting must be retrieved. Possible values are: |
[out] | input | pointer to variable where the positive input channel value will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 513 of file FDC1004Q.c.
uint8_t FDC_ReadRawCapdacSetting | ( | uint8_t | channel, |
uint8_t * | capdac | ||
) |
Read current capdac setting.
This function reads the current value of capdac set in the configuration register. The value returned is in raw format, without multiplication by a factor of 3.125.
[in] | channel | the channel for which the capdac setting must be retrieved. Possible values are: |
[out] | capdac | pointer to variable where the capdvac value will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 481 of file FDC1004Q.c.
uint8_t FDC_ReadRawGainCalibration | ( | uint8_t | channel, |
uint16_t * | gain | ||
) |
Read gain calibration register in fixed point Q2.14 formta.
This function reads the current gain calibration value in the register for the channel passed in as parameter to the function and return the value in raw format. A detailed description of the gain calibration register can be found at FDC1004Q_GAIN_CAL_CIN1.
[in] | channel | the channel from which to read the calibration gain. Possible values are: |
[out] | gain | pointer to variable where the gain will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if channel value not correct. |
Definition at line 254 of file FDC1004Q.c.
uint8_t FDC_ReadRawMeasurement | ( | uint8_t | channel, |
uint32_t * | capacitance | ||
) |
Read capacitance measurement in raw format.
This function reads the content of the measurement registers, without doing any conversion of the result or adding the capacitance offset to the read value.
[in] | channel | the channel for which the measurement must be read. Possible values are: |
[out] | capacitance | pointer to variable where the result will be stored. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if channel value not correct. |
Definition at line 420 of file FDC1004Q.c.
uint8_t FDC_ReadRawOffsetCalibration | ( | uint8_t | channel, |
int16_t * | offset | ||
) |
Read channel offset calibration register as Q5.11 format.
This function reads the current offset calibration set in the register for the channel passed in as parameter to the function. A detailed description of the offset calibration register can be found at FDC1004Q_OFFSET_CAL_CIN1.
[in] | channel | the channel from which to read the calibration offset Possible values are: |
[out] | offset | pointer to variable where the value of the offset will be stored in Q5.11 format |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
FDC_CONF_ERR | if wrong value for channel. |
Definition at line 202 of file FDC1004Q.c.
uint8_t FDC_ReadRegister | ( | uint8_t | reg_addr, |
uint8_t * | data | ||
) |
Read a register from the FDC1004Q.
This function reads the content of a 16-bit register and return its value.
[in] | reg_addr | the address of the register to be read. |
[out] | data | 16-bit to be written. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 597 of file FDC1004Q.c.
uint8_t FDC_ReadSampleRate | ( | uint8_t * | sampleRate | ) |
Read current sample rate.
This function reads the current sample rate configured for the FDC1004Q to be used in case continuous measurements is set up.
[out] | sampleRate | pointer to variable storing sample rate |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
Definition at line 144 of file FDC1004Q.c.
uint8_t FDC_Reset | ( | void | ) |
Perform a software reset of the sensor.
This function performs a software reset of the sensor by setting the RST bit in the FDC1004Q_FDC_CONF to 1.
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_DEV_NOT_FOUND | if device was not found on I2C bus. |
Definition at line 95 of file FDC1004Q.c.
uint8_t FDC_SetGainCalibration | ( | uint8_t | channel, |
float | gain | ||
) |
Set gain calibration register.
This function sets the gain calibration value in the register for the channel passed in as parameter to the function with the value in float format. A detailed description of the gain calibration register can be found at FDC1004Q_GAIN_CAL_CIN1.
channel | the channel from which to read the calibration gain. Possible values are: |
gain | value to be set as gain in float format. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if channel value not correct or gain value too high. |
Definition at line 216 of file FDC1004Q.c.
uint8_t FDC_SetOffsetCalibration | ( | uint8_t | channel, |
float | offset | ||
) |
Set channel offset calibration register in float format.
This function sets the offset calibration in the register for the channel passed in as parameter to the function. A detailed description of the offset calibration register can be found at FDC1004Q_OFFSET_CAL_CIN1.
channel | the channel for which to set the calibration offset. Possible values are: |
offset | value to be set as capacitance offset. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if offset value is not between limits or channel not correct. |
Definition at line 156 of file FDC1004Q.c.
uint8_t FDC_SetRawGainCalibration | ( | uint8_t | channel, |
uint16_t | gain | ||
) |
Set gain calibration register in Q2.14 format.
This function sets the gain calibration value in the register for the channel passed in as parameter to the function with the value in raw format. A detailed description of the gain calibration register can be found at FDC1004Q_GAIN_CAL_CIN1.
channel | the channel for which to set the calibration gain. Possible values are: |
gain | value to be set as gain in Q2.14 format. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if channel value not correct or gain value too high. |
Definition at line 228 of file FDC1004Q.c.
uint8_t FDC_SetRawOffsetCalibration | ( | uint8_t | channel, |
int16_t | offset | ||
) |
Set channel offset calibration register in raw format.
This function sets the offset calibration in the register for the channel passed in as parameter to the function. A detailed description of the offset calibration register can be found at FDC1004Q_OFFSET_CAL_CIN1.
channel | the channel for which to set the calibration offset. Possible values are: |
offset | value to be set as capacitance offset. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if offset value is not between limits or channel not correct. |
Definition at line 172 of file FDC1004Q.c.
uint8_t FDC_SetSampleRate | ( | uint8_t | sampleRate | ) |
Set up sample rate for continuous measurements.
This function sets up the sample rate of the FDC1004Q to be used in case continuous measurements is set up.
[in] | sampleRate | the desired sample rate. Possible values: |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
FDC_CONF_ERR | if sample rate value is not among possible values. |
Definition at line 125 of file FDC1004Q.c.
uint8_t FDC_Start | ( | void | ) |
Start the FDC1004Q.
This function starts the underlying I2C peripheral that needs to be used for communication purposes. It also checks if the device is present on the I2C bus.
FDC_OK | initialization successful and device present on bus. |
FDC_DEV_NOT_FOUND | device not present on the bus. |
Definition at line 58 of file FDC1004Q.c.
uint8_t FDC_StopMeasurement | ( | uint8_t | channel | ) |
Stop measurement for given channel.
This function stops the capacitance measurement for a given channel.
channel | the channel for which the measurement must be stopped. |
FDC_OK | if everything ok |
FDC_COMM_ERR | if error occurred during communication |
FDC_CONF_ERR | if channel value not correct |
Definition at line 290 of file FDC1004Q.c.
uint8_t FDC_WriteRegister | ( | uint8_t | reg_addr, |
uint8_t * | data | ||
) |
Write a register to the FDC1004Q.
This function writes a 16-bit register.
[in] | reg_addr | the address of the register to be written. |
[in] | data | the data to be written to the register. |
FDC_OK | if everything ok. |
FDC_COMM_ERR | if error occurred during communication. |
Definition at line 611 of file FDC1004Q.c.