![]() |
no-OS
|
Header file of AD7156 Driver. More...
Classes | |
| struct | ad7156_dev |
| struct | ad7156_init_param |
Functions | |
| void | ad7156_get_register_value (struct ad7156_dev *dev, uint8_t *p_read_data, uint8_t register_address, uint8_t bytes_number) |
| Performs a burst read of a specified number of registers. | |
| void | ad7156_set_register_value (struct ad7156_dev *dev, uint16_t register_value, uint8_t register_address, uint8_t bytes_number) |
| Writes data into one or two registers. | |
| int8_t | ad7156_init (struct ad7156_dev **device, struct ad7156_init_param init_param) |
| Initializes the communication peripheral and the initial Values for AD7156 Board. | |
| int32_t | ad7156_remove (struct ad7156_dev *dev) |
| Free the resources allocated by ad7156_init(). | |
| void | ad7156_reset (struct ad7156_dev *dev) |
| Resets the device. | |
| void | ad7156_set_power_mode (struct ad7156_dev *dev, uint8_t pwr_mode) |
| Sets the converter mode of operation. | |
| void | ad7156_channel_state (struct ad7156_dev *dev, uint8_t channel, uint8_t enable_conv) |
| Enables or disables conversion on the selected channel. | |
| void | ad7156_set_range (struct ad7156_dev *dev, uint32_t channel, uint8_t range) |
| Sets the input range of the specified channel. | |
| float | ad7156_get_range (struct ad7156_dev *dev, uint32_t channel) |
| Reads the range bits from the device and returns the range in pF. | |
| void | ad7156_set_threshold_mode (struct ad7156_dev *dev, uint8_t thr_mode, uint8_t thr_fixed) |
| Selects the threshold mode of operation. | |
| void | ad7156_set_threshold (struct ad7156_dev *dev, uint8_t channel, float p_fthr) |
| Writes to the threshold register when threshold fixed mode is enabled. | |
| void | ad7156_set_sensitivity (struct ad7156_dev *dev, uint8_t channel, float p_fsensitivity) |
| Writes a value(pF) to the sensitivity register. This functions should be used when adaptive threshold mode is selected. | |
| uint16_t | ad7156_read_channel_data (struct ad7156_dev *dev, uint8_t channel) |
| Reads a 12-bit sample from the selected channel. | |
| uint16_t | ad7156_wait_read_channel_data (struct ad7156_dev *dev, uint8_t channel) |
| Waits for a finished CDC conversion and reads a 12-bit sample from the selected channel. | |
| float | ad7156_read_channel_capacitance (struct ad7156_dev *dev, uint8_t channel) |
| Reads a sample the selected channel and converts the data to picofarads(pF). | |
| float | ad7156_wait_read_channel_capacitance (struct ad7156_dev *dev, uint8_t channel) |
| Waits for a finished CDC conversion the selected channel, reads a sample and converts the data to picofarads(pF). | |
Header file of AD7156 Driver.
Copyright 2013(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define AD7156_ADAPTIVE_THRESHOLD 0 |
| #define AD7156_ADDRESS 0x48 |
< AD7156 slave address AD7156 registers
| #define AD7156_CDC_RANGE_0_5_PF 1 |
| #define AD7156_CDC_RANGE_1_PF 2 |
| #define AD7156_CDC_RANGE_2_PF 0 |
| #define AD7156_CDC_RANGE_4_PF 3 |
AD7156_REG_CONFIG definition
| #define AD7156_CH1_CAPDAC_DAC_AUTO1 (1 << 6) |
| #define AD7156_CH1_CAPDAC_DAC_EN1 (1 << 7) |
| #define AD7156_CH1_CAPDAC_DAC_VAL1 | ( | x | ) |
AD7156_REG_CH2_CAPDAC
| #define AD7156_CH1_SETUP_HYST1 (1 << 4) |
| #define AD7156_CH1_SETUP_RANGE | ( | x | ) |
| #define AD7156_CH1_SETUP_THR1 | ( | x | ) |
AD7156_REG_CH2_SETUP definition
| #define AD7156_CH2_CAPDAC_DAC_AUTO2 (1 << 6) |
| #define AD7156_CH2_CAPDAC_DAC_EN2 (1 << 7) |
| #define AD7156_CH2_CAPDAC_DAC_VAL2 | ( | x | ) |
Chip identification code
| #define AD7156_CH2_SETUP_HYST2 (1 << 4) |
| #define AD7156_CH2_SETUP_RANGE | ( | x | ) |
| #define AD7156_CH2_SETUP_THR2 | ( | x | ) |
AD7156_CH1_SETUP_RANGE(x) and AD7156_CH2_SETUP_RANGE(x) options
| #define AD7156_CHANNEL1 1 |
| #define AD7156_CHANNEL2 2 |
| #define AD7156_CONFIG_EN_CH1 (1 << 4) |
| #define AD7156_CONFIG_EN_CH2 (1 << 3) |
| #define AD7156_CONFIG_MD | ( | x | ) |
AD7156_CONFIG_THR_FIXED options
| #define AD7156_CONFIG_THR_FIXED (1 << 7) |
| #define AD7156_CONFIG_THR_MD | ( | x | ) |
| #define AD7156_CONV_MODE_CONT_CONV 1 |
| #define AD7156_CONV_MODE_IDLE 0 |
| #define AD7156_CONV_MODE_PWR_DWN 3 |
AD7156_REG_PWR_DWN_TMR definition
| #define AD7156_CONV_MODE_SINGLE_CONV 2 |
| #define AD7156_DEFAULT_ID 0x88 |
AD7156 Reset Command
| #define AD7156_FIXED_THRESHOLD 1 |
AD7156_CONFIG_THR_MD(x) options
| #define AD7156_PWR_DWN_TMR_TIMEOUT | ( | x | ) |
AD7156_REG_CH1_CAPDAC
| #define AD7156_REG_CH1_AVG_H 0x05 |
| #define AD7156_REG_CH1_AVG_L 0x06 |
| #define AD7156_REG_CH1_CAPDAC 0x11 |
| #define AD7156_REG_CH1_DATA_H 0x01 |
| #define AD7156_REG_CH1_DATA_L 0x02 |
| #define AD7156_REG_CH1_SENS_THRSH_H 0x09 |
| #define AD7156_REG_CH1_SETUP 0x0B |
| #define AD7156_REG_CH1_TMO_THRSH_L 0x0A |
| #define AD7156_REG_CH2_AVG_H 0x07 |
| #define AD7156_REG_CH2_AVG_L 0x08 |
| #define AD7156_REG_CH2_CAPDAC 0x12 |
| #define AD7156_REG_CH2_DATA_H 0x03 |
| #define AD7156_REG_CH2_DATA_L 0x04 |
| #define AD7156_REG_CH2_SENS_THRSH_H 0x0C |
| #define AD7156_REG_CH2_SETUP 0x0E |
| #define AD7156_REG_CH2_TMO_THRSH_L 0x0D |
| #define AD7156_REG_CHIP_ID 0x17 |
AD7156_REG_STATUS definition
| #define AD7156_REG_CONFIG 0x0F |
| #define AD7156_REG_PWR_DWN_TMR 0x10 |
| #define AD7156_REG_SERIAL_N0 0x16 |
| #define AD7156_REG_SERIAL_N1 0x15 |
| #define AD7156_REG_SERIAL_N2 0x14 |
| #define AD7156_REG_SERIAL_N3 0x13 |
| #define AD7156_REG_STATUS 0x00 |
| #define AD7156_RESET_CMD 0xBF |
AD7156 Channels
| #define AD7156_STATUS_C1_C2 (1 << 2) |
| #define AD7156_STATUS_DAC_STEP1 (1 << 4) |
| #define AD7156_STATUS_DAC_STEP2 (1 << 6) |
| #define AD7156_STATUS_OUT1 (1 << 3) |
| #define AD7156_STATUS_OUT2 (1 << 5) |
| #define AD7156_STATUS_PWR_DWN (1 << 7) |
| #define AD7156_STATUS_RDY1 (1 << 0) |
AD7156_REG_CH1_SETUP definition
| #define AD7156_STATUS_RDY2 (1 << 1) |
| #define AD7156_THR_MODE_IN_WINDOW 2 |
| #define AD7156_THR_MODE_NEGATIVE 0 |
| #define AD7156_THR_MODE_OU_WINDOW 3 |
AD7156_CONFIG_MD(x) options
| #define AD7156_THR_MODE_POSITIVE 1 |
| void ad7156_channel_state | ( | struct ad7156_dev * | dev, |
| uint8_t | channel, | ||
| uint8_t | enable_conv ) |
Enables or disables conversion on the selected channel.
Sets the input range of the specified channel.
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| enable_conv | - The state of channel activity. Example: 0 - disable conversion on selected channel. 1 - enable conversion on selected channel. |
| float ad7156_get_range | ( | struct ad7156_dev * | dev, |
| uint32_t | channel ) |
Reads the range bits from the device and returns the range in pF.
Selects the threshold mode of operation.
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| void ad7156_get_register_value | ( | struct ad7156_dev * | dev, |
| uint8_t * | p_read_data, | ||
| uint8_t | register_address, | ||
| uint8_t | bytes_number ) |
Performs a burst read of a specified number of registers.
Writes data into one or two registers..
| dev | - The device structure. |
| p_read_data | - The read values are stored in this buffer. |
| register_address | - The start address of the burst read. |
| bytes_number | - Number of bytes to read. |
| int8_t ad7156_init | ( | struct ad7156_dev ** | device, |
| struct ad7156_init_param | init_param ) |
Initializes the communication peripheral and the initial Values for AD7156 Board.
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
| float ad7156_read_channel_capacitance | ( | struct ad7156_dev * | dev, |
| uint8_t | channel ) |
Reads a sample the selected channel and converts the data to picofarads(pF).
Waits for a finished CDC conversion the selected channel, reads a sample and converts the data to picofarads(pF).
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| uint16_t ad7156_read_channel_data | ( | struct ad7156_dev * | dev, |
| uint8_t | channel ) |
Reads a 12-bit sample from the selected channel.
Waits for a finished CDC conversion and reads a 12-bit sample from the selected channel.
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| int32_t ad7156_remove | ( | struct ad7156_dev * | dev | ) |
Free the resources allocated by ad7156_init().
Free the resources allocated by ad7156_init(). Resets the device.
| dev | - The device structure. |
| void ad7156_reset | ( | struct ad7156_dev * | dev | ) |
Resets the device.
Sets the converter mode of operation.
| dev | - The device structure. |
| void ad7156_set_power_mode | ( | struct ad7156_dev * | dev, |
| uint8_t | pwr_mode ) |
Sets the converter mode of operation.
Enables or disables conversion on the selected channel.
| dev | - The device structure. |
| pwr_mode | - Mode of operation option. Example: AD7156_CONV_MODE_IDLE - Idle AD7156_CONV_MODE_CONT_CONV - Continuous conversion AD7156_CONV_MODE_SINGLE_CONV - Single conversion AD7156_CONV_MODE_PWR_DWN - Power-down |
| void ad7156_set_range | ( | struct ad7156_dev * | dev, |
| uint32_t | channel, | ||
| uint8_t | range ) |
Sets the input range of the specified channel.
Reads the range bits from the device and returns the range in pF.
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| range | - Input range option. Example: AD7156_CDC_RANGE_2_PF - 2pF input range. AD7156_CDC_RANGE_0_5_PF - 0.5pF input range. AD7156_CDC_RANGE_1_PF - 1pF input range. AD7156_CDC_RANGE_4_PF - 4pF input range. |
| void ad7156_set_register_value | ( | struct ad7156_dev * | dev, |
| uint16_t | register_value, | ||
| uint8_t | register_address, | ||
| uint8_t | bytes_number ) |
Writes data into one or two registers.
Initializes the communication peripheral and checks if the device is present.
| dev | - The device structure. |
| register_value | - Data value to write. |
| register_address | - Address of the register. |
| bytes_number | - Number of bytes. Accepted values: 0 - 1. |
| void ad7156_set_sensitivity | ( | struct ad7156_dev * | dev, |
| uint8_t | channel, | ||
| float | p_fsensitivity ) |
Writes a value(pF) to the sensitivity register. This functions should be used when adaptive threshold mode is selected.
Reads a 12-bit sample from the selected channel
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| p_fsensitivity | - The sensitivity value in picofarads(pF). |
| void ad7156_set_threshold | ( | struct ad7156_dev * | dev, |
| uint8_t | channel, | ||
| float | p_fthr ) |
Writes to the threshold register when threshold fixed mode is enabled.
Writes a value(pF) to the sensitivity register. This functions should be used when adaptive threshold mode is selected.
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| p_fthr | - The threshold value in picofarads(pF). The value must not be out of the selected input range. |
| void ad7156_set_threshold_mode | ( | struct ad7156_dev * | dev, |
| uint8_t | thr_mode, | ||
| uint8_t | thr_fixed ) |
Selects the threshold mode of operation.
Writes to the threshold register when threshold fixed mode is enabled.
| dev | - The device structure. |
| thr_mode | - Output comparator mode. Example: AD7156_THR_MODE_NEGATIVE AD7156_THR_MODE_POSITIVE AD7156_THR_MODE_IN_WINDOW AD7156_THR_MODE_OU_WINDOW |
| thr_fixed | - Selects the threshold mode. Example: AD7156_ADAPTIVE_THRESHOLD AD7156_FIXED_THRESHOLD |
| float ad7156_wait_read_channel_capacitance | ( | struct ad7156_dev * | dev, |
| uint8_t | channel ) |
Waits for a finished CDC conversion the selected channel, reads a sample and converts the data to picofarads(pF).
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |
| uint16_t ad7156_wait_read_channel_data | ( | struct ad7156_dev * | dev, |
| uint8_t | channel ) |
Waits for a finished CDC conversion and reads a 12-bit sample from the selected channel.
Reads a sample the selected channel and converts the data to picofarads(pF).
| dev | - The device structure. |
| channel | - Channel option. Example: AD7156_CHANNEL1 AD7156_CHANNEL2 |