LibDriver PCF8591
Loading...
Searching...
No Matches
pcf8591 base driver function

pcf8591 base driver modules More...

Collaboration diagram for pcf8591 base driver function:

Data Structures

struct  pcf8591_handle_s
 pcf8591 handle structure definition More...
struct  pcf8591_info_s
 pcf8591 information structure definition More...

Typedefs

typedef struct pcf8591_handle_s pcf8591_handle_t
 pcf8591 handle structure definition
typedef struct pcf8591_info_s pcf8591_info_t
 pcf8591 information structure definition

Enumerations

enum  pcf8591_address_t {
  PCF8591_ADDRESS_A000 = 0 , PCF8591_ADDRESS_A001 = 1 , PCF8591_ADDRESS_A010 = 2 , PCF8591_ADDRESS_A011 = 3 ,
  PCF8591_ADDRESS_A100 = 4 , PCF8591_ADDRESS_A101 = 5 , PCF8591_ADDRESS_A110 = 6 , PCF8591_ADDRESS_A111 = 7
}
 pcf8591 address enumeration definition More...
enum  pcf8591_bool_t { PCF8591_BOOL_FALSE = 0x00 , PCF8591_BOOL_TRUE = 0x01 }
 pcf8591 bool enumeration definition More...
enum  pcf8591_channel_t { PCF8591_CHANNEL_0 = 0x00 , PCF8591_CHANNEL_1 = 0x01 , PCF8591_CHANNEL_2 = 0x02 , PCF8591_CHANNEL_3 = 0x03 }
 pcf8591 channel definition More...
enum  pcf8591_mode_t { PCF8591_MODE_AIN0123_GND = 0x00 , PCF8591_MODE_AIN012_AIN3 = 0x01 , PCF8591_MODE_AIN0_GND_AND_AIN1_GND_AND_AIN2_AIN3 = 0x02 , PCF8591_MODE_AIN0_AIN1_AND_ANI2_AIN3 = 0x03 }
 pcf8591 mode definition More...

Functions

uint8_t pcf8591_info (pcf8591_info_t *info)
 get chip's information
uint8_t pcf8591_set_addr_pin (pcf8591_handle_t *handle, pcf8591_address_t addr_pin)
 set the address pin
uint8_t pcf8591_get_addr_pin (pcf8591_handle_t *handle, pcf8591_address_t *addr_pin)
 get the address pin
uint8_t pcf8591_init (pcf8591_handle_t *handle)
 initialize the chip
uint8_t pcf8591_deinit (pcf8591_handle_t *handle)
 close the chip
uint8_t pcf8591_read (pcf8591_handle_t *handle, int16_t *raw, float *adc)
 read data from the chip
uint8_t pcf8591_multiple_read (pcf8591_handle_t *handle, int16_t *raw, float *adc, uint8_t *len)
 read the multiple channel data from the chip
uint8_t pcf8591_write (pcf8591_handle_t *handle, uint8_t data)
 write to the dac
uint8_t pcf8591_dac_convert_to_register (pcf8591_handle_t *handle, float dac, uint8_t *reg)
 convert a dac value to a register raw data
uint8_t pcf8591_set_reference_voltage (pcf8591_handle_t *handle, float ref_voltage)
 set the adc reference voltage
uint8_t pcf8591_get_reference_voltage (pcf8591_handle_t *handle, float *ref_voltage)
 get the adc reference voltage
uint8_t pcf8591_set_channel (pcf8591_handle_t *handle, pcf8591_channel_t channel)
 set the adc channel
uint8_t pcf8591_get_channel (pcf8591_handle_t *handle, pcf8591_channel_t *channel)
 get the adc channel
uint8_t pcf8591_set_mode (pcf8591_handle_t *handle, pcf8591_mode_t mode)
 set the adc mode
uint8_t pcf8591_get_mode (pcf8591_handle_t *handle, pcf8591_mode_t *mode)
 get the adc mode
uint8_t pcf8591_set_auto_increment (pcf8591_handle_t *handle, pcf8591_bool_t enable)
 set the adc auto increment read mode
uint8_t pcf8591_get_auto_increment (pcf8591_handle_t *handle, pcf8591_bool_t *enable)
 get the adc auto increment read mode

Detailed Description

pcf8591 base driver modules

Typedef Documentation

◆ pcf8591_handle_t

pcf8591 handle structure definition

◆ pcf8591_info_t

pcf8591 information structure definition

Enumeration Type Documentation

◆ pcf8591_address_t

pcf8591 address enumeration definition

Enumerator
PCF8591_ADDRESS_A000 

A2A1A0 000

PCF8591_ADDRESS_A001 

A2A1A0 001

PCF8591_ADDRESS_A010 

A2A1A0 010

PCF8591_ADDRESS_A011 

A2A1A0 011

PCF8591_ADDRESS_A100 

A2A1A0 100

PCF8591_ADDRESS_A101 

A2A1A0 101

PCF8591_ADDRESS_A110 

A2A1A0 110

PCF8591_ADDRESS_A111 

A2A1A0 111

Definition at line 63 of file driver_pcf8591.h.

◆ pcf8591_bool_t

pcf8591 bool enumeration definition

Enumerator
PCF8591_BOOL_FALSE 

disable function

PCF8591_BOOL_TRUE 

enable function

Definition at line 78 of file driver_pcf8591.h.

◆ pcf8591_channel_t

pcf8591 channel definition

Enumerator
PCF8591_CHANNEL_0 

channel 0

PCF8591_CHANNEL_1 

channel 1

PCF8591_CHANNEL_2 

channel 2

PCF8591_CHANNEL_3 

channel 3

Definition at line 87 of file driver_pcf8591.h.

◆ pcf8591_mode_t

pcf8591 mode definition

Enumerator
PCF8591_MODE_AIN0123_GND 

AIN0-GND AIN1-GND AIN2-GND AIN3-GND

PCF8591_MODE_AIN012_AIN3 

AIN0-AIN3 AIN1-AIN3 AIN2-AIN3

PCF8591_MODE_AIN0_GND_AND_AIN1_GND_AND_AIN2_AIN3 

AIN0-GND AIN1-GND AIN2-AIN3

PCF8591_MODE_AIN0_AIN1_AND_ANI2_AIN3 

AIN0-AIN1 AIN2-AIN3

Definition at line 98 of file driver_pcf8591.h.

Function Documentation

◆ pcf8591_dac_convert_to_register()

uint8_t pcf8591_dac_convert_to_register ( pcf8591_handle_t * handle,
float dac,
uint8_t * reg )

convert a dac value to a register raw data

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]dacconverted dac value
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 511 of file driver_pcf8591.c.

◆ pcf8591_deinit()

uint8_t pcf8591_deinit ( pcf8591_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a pcf8591 handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 425 of file driver_pcf8591.c.

◆ pcf8591_get_addr_pin()

uint8_t pcf8591_get_addr_pin ( pcf8591_handle_t * handle,
pcf8591_address_t * addr_pin )

get the address pin

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*addr_pinpointer to a chip address pins buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 83 of file driver_pcf8591.c.

◆ pcf8591_get_auto_increment()

uint8_t pcf8591_get_auto_increment ( pcf8591_handle_t * handle,
pcf8591_bool_t * enable )

get the adc auto increment read mode

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 285 of file driver_pcf8591.c.

◆ pcf8591_get_channel()

uint8_t pcf8591_get_channel ( pcf8591_handle_t * handle,
pcf8591_channel_t * channel )

get the adc channel

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*channelpointer to an adc channel buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 145 of file driver_pcf8591.c.

◆ pcf8591_get_mode()

uint8_t pcf8591_get_mode ( pcf8591_handle_t * handle,
pcf8591_mode_t * mode )

get the adc mode

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*modepointer to an adc mode buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 211 of file driver_pcf8591.c.

◆ pcf8591_get_reference_voltage()

uint8_t pcf8591_get_reference_voltage ( pcf8591_handle_t * handle,
float * ref_voltage )

get the adc reference voltage

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*ref_voltagepointer to an adc reference voltage buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 337 of file driver_pcf8591.c.

◆ pcf8591_info()

uint8_t pcf8591_info ( pcf8591_info_t * info)

get chip's information

Parameters
[out]*infopointer to a pcf8591 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 949 of file driver_pcf8591.c.

◆ pcf8591_init()

uint8_t pcf8591_init ( pcf8591_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a pcf8591 handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 363 of file driver_pcf8591.c.

◆ pcf8591_multiple_read()

uint8_t pcf8591_multiple_read ( pcf8591_handle_t * handle,
int16_t * raw,
float * adc,
uint8_t * len )

read the multiple channel data from the chip

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*rawpointer to a raw adc buffer
[out]*adcpointer to a converted adc buffer
[in,out]*lenpointer to an adc length buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
len means max length of raw and adc input buffer and return the read length of raw and adc

Definition at line 736 of file driver_pcf8591.c.

◆ pcf8591_read()

uint8_t pcf8591_read ( pcf8591_handle_t * handle,
int16_t * raw,
float * adc )

read data from the chip

Parameters
[in]*handlepointer to a pcf8591 handle structure
[out]*rawpointer to a raw adc buffer
[out]*adcpointer to a converted adc buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 539 of file driver_pcf8591.c.

◆ pcf8591_set_addr_pin()

uint8_t pcf8591_set_addr_pin ( pcf8591_handle_t * handle,
pcf8591_address_t addr_pin )

set the address pin

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]addr_pinchip address pins
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 61 of file driver_pcf8591.c.

◆ pcf8591_set_auto_increment()

uint8_t pcf8591_set_auto_increment ( pcf8591_handle_t * handle,
pcf8591_bool_t enable )

set the adc auto increment read mode

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set auto increment failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 238 of file driver_pcf8591.c.

◆ pcf8591_set_channel()

uint8_t pcf8591_set_channel ( pcf8591_handle_t * handle,
pcf8591_channel_t channel )

set the adc channel

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]channeladc channel
Returns
status code
  • 0 success
  • 1 set channel failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 106 of file driver_pcf8591.c.

◆ pcf8591_set_mode()

uint8_t pcf8591_set_mode ( pcf8591_handle_t * handle,
pcf8591_mode_t mode )

set the adc mode

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]modeadc mode
Returns
status code
  • 0 success
  • 1 set mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 172 of file driver_pcf8591.c.

◆ pcf8591_set_reference_voltage()

uint8_t pcf8591_set_reference_voltage ( pcf8591_handle_t * handle,
float ref_voltage )

set the adc reference voltage

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]ref_voltageadc reference voltage
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 311 of file driver_pcf8591.c.

◆ pcf8591_write()

uint8_t pcf8591_write ( pcf8591_handle_t * handle,
uint8_t data )

write to the dac

Parameters
[in]*handlepointer to a pcf8591 handle structure
[in]datadac value
Returns
status code
  • 0 success
  • 1 write dac value failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 471 of file driver_pcf8591.c.