LibDriver ADS1118
Loading...
Searching...
No Matches
ads1118 basic driver function

ads1118 basic driver modules More...

Collaboration diagram for ads1118 basic driver function:

Data Structures

struct  ads1118_handle_s
 ads1118 handle structure definition More...
struct  ads1118_info_s
 ads1118 information structure definition More...

Typedefs

typedef struct ads1118_handle_s ads1118_handle_t
 ads1118 handle structure definition
typedef struct ads1118_info_s ads1118_info_t
 ads1118 information structure definition

Enumerations

enum  ads1118_bool_t { ADS1118_BOOL_FALSE = 0x00 , ADS1118_BOOL_TRUE = 0x01 }
 ads1118 bool enumeration definition More...
enum  ads1118_range_t {
  ADS1118_RANGE_6P144V = 0x00 , ADS1118_RANGE_4P096V = 0x01 , ADS1118_RANGE_2P048V = 0x02 , ADS1118_RANGE_1P024V = 0x03 ,
  ADS1118_RANGE_0P512V = 0x04 , ADS1118_RANGE_0P256V = 0x05
}
 ads1118 range enumeration definition More...
enum  ads1118_rate_t {
  ADS1118_RATE_8SPS = 0x00 , ADS1118_RATE_16SPS = 0x01 , ADS1118_RATE_32SPS = 0x02 , ADS1118_RATE_64SPS = 0x03 ,
  ADS1118_RATE_128SPS = 0x04 , ADS1118_RATE_250SPS = 0x05 , ADS1118_RATE_475SPS = 0x06 , ADS1118_RATE_860SPS = 0x07
}
 ads1118 channel rate enumeration definition More...
enum  ads1118_channel_t {
  ADS1118_CHANNEL_AIN0_AIN1 = 0x00 , ADS1118_CHANNEL_AIN0_AIN3 = 0x01 , ADS1118_CHANNEL_AIN1_AIN3 = 0x02 , ADS1118_CHANNEL_AIN2_AIN3 = 0x03 ,
  ADS1118_CHANNEL_AIN0_GND = 0x04 , ADS1118_CHANNEL_AIN1_GND = 0x05 , ADS1118_CHANNEL_AIN2_GND = 0x06 , ADS1118_CHANNEL_AIN3_GND = 0x07
}
 ads1118 channel enumeration definition More...
enum  ads1118_mode_t { ADS1118_MODE_ADC = 0x00 , ADS1118_MODE_TEMPERATURE = 0x01 }
 ads1118 mode enumeration definition More...

Functions

uint8_t ads1118_info (ads1118_info_t *info)
 get chip's information
uint8_t ads1118_init (ads1118_handle_t *handle)
 initialize the chip
uint8_t ads1118_deinit (ads1118_handle_t *handle)
 close the chip
uint8_t ads1118_single_read (ads1118_handle_t *handle, int16_t *raw, float *v)
 read data from the chip once
uint8_t ads1118_continuous_read (ads1118_handle_t *handle, int16_t *raw, float *v)
 read data from the chip continuously
uint8_t ads1118_start_continuous_read (ads1118_handle_t *handle)
 start the chip reading
uint8_t ads1118_stop_continuous_read (ads1118_handle_t *handle)
 stop the chip reading
uint8_t ads1118_temperature_convert (ads1118_handle_t *handle, int16_t raw, float *deg)
 temperature convert
uint8_t ads1118_set_channel (ads1118_handle_t *handle, ads1118_channel_t channel)
 set the adc channel
uint8_t ads1118_get_channel (ads1118_handle_t *handle, ads1118_channel_t *channel)
 get the adc channel
uint8_t ads1118_set_range (ads1118_handle_t *handle, ads1118_range_t range)
 set the adc range
uint8_t ads1118_get_range (ads1118_handle_t *handle, ads1118_range_t *range)
 get the adc range
uint8_t ads1118_set_rate (ads1118_handle_t *handle, ads1118_rate_t rate)
 set the sample rate
uint8_t ads1118_get_rate (ads1118_handle_t *handle, ads1118_rate_t *rate)
 get the sample rate
uint8_t ads1118_set_mode (ads1118_handle_t *handle, ads1118_mode_t mode)
 set the chip mode
uint8_t ads1118_get_mode (ads1118_handle_t *handle, ads1118_mode_t *mode)
 get the chip mode
uint8_t ads1118_set_dout_pull_up (ads1118_handle_t *handle, ads1118_bool_t enable)
 enable or disable dout pull up
uint8_t ads1118_get_dout_pull_up (ads1118_handle_t *handle, ads1118_bool_t *enable)
 get dout pull up status

Detailed Description

ads1118 basic driver modules

Typedef Documentation

◆ ads1118_handle_t

ads1118 handle structure definition

◆ ads1118_info_t

ads1118 information structure definition

Enumeration Type Documentation

◆ ads1118_bool_t

ads1118 bool enumeration definition

Enumerator
ADS1118_BOOL_FALSE 

disable function

ADS1118_BOOL_TRUE 

enable function

Definition at line 62 of file driver_ads1118.h.

◆ ads1118_channel_t

ads1118 channel enumeration definition

Enumerator
ADS1118_CHANNEL_AIN0_AIN1 

AIN0 and AIN1 pins

ADS1118_CHANNEL_AIN0_AIN3 

AIN0 and AIN3 pins

ADS1118_CHANNEL_AIN1_AIN3 

AIN1 and AIN3 pins

ADS1118_CHANNEL_AIN2_AIN3 

AIN2 and AIN3 pins

ADS1118_CHANNEL_AIN0_GND 

AIN0 and GND pins

ADS1118_CHANNEL_AIN1_GND 

AIN1 and GND pins

ADS1118_CHANNEL_AIN2_GND 

AIN2 and GND pins

ADS1118_CHANNEL_AIN3_GND 

AIN3 and GND pins

Definition at line 99 of file driver_ads1118.h.

◆ ads1118_mode_t

ads1118 mode enumeration definition

Enumerator
ADS1118_MODE_ADC 

adc mode

ADS1118_MODE_TEMPERATURE 

temperature mode

Definition at line 114 of file driver_ads1118.h.

◆ ads1118_range_t

ads1118 range enumeration definition

Enumerator
ADS1118_RANGE_6P144V 

6.144V range

ADS1118_RANGE_4P096V 

4.096V range

ADS1118_RANGE_2P048V 

2.048V range

ADS1118_RANGE_1P024V 

1.024V range

ADS1118_RANGE_0P512V 

0.512V range

ADS1118_RANGE_0P256V 

0.256V range

Definition at line 71 of file driver_ads1118.h.

◆ ads1118_rate_t

ads1118 channel rate enumeration definition

Enumerator
ADS1118_RATE_8SPS 

8 sample per second

ADS1118_RATE_16SPS 

16 sample per second

ADS1118_RATE_32SPS 

32 sample per second

ADS1118_RATE_64SPS 

64 sample per second

ADS1118_RATE_128SPS 

128 sample per second

ADS1118_RATE_250SPS 

250 sample per second

ADS1118_RATE_475SPS 

475 sample per second

ADS1118_RATE_860SPS 

860 sample per second

Definition at line 84 of file driver_ads1118.h.

Function Documentation

◆ ads1118_continuous_read()

uint8_t ads1118_continuous_read ( ads1118_handle_t * handle,
int16_t * raw,
float * v )

read data from the chip continuously

Parameters
[in]*handlepointer to an ads1118 handle structure
[out]*rawpointer to a raw adc buffer
[out]*vpointer to a converted adc buffer
Returns
status code
  • 0 success
  • 1 continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
this function can be used only after run ads1118_start_continuous_read and can be stopped by ads1118_stop_continuous_read

Definition at line 819 of file driver_ads1118.c.

◆ ads1118_deinit()

uint8_t ads1118_deinit ( ads1118_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an ads1118 handle structure
Returns
status code
  • 0 success
  • 1 spi deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 power down failed
Note
none

Definition at line 199 of file driver_ads1118.c.

◆ ads1118_get_channel()

uint8_t ads1118_get_channel ( ads1118_handle_t * handle,
ads1118_channel_t * channel )

get the adc channel

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

Definition at line 299 of file driver_ads1118.c.

◆ ads1118_get_dout_pull_up()

uint8_t ads1118_get_dout_pull_up ( ads1118_handle_t * handle,
ads1118_bool_t * enable )

get dout pull up status

Parameters
[in]*handlepointer to an ads1118 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get dout pull up failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 635 of file driver_ads1118.c.

◆ ads1118_get_mode()

uint8_t ads1118_get_mode ( ads1118_handle_t * handle,
ads1118_mode_t * mode )

get the chip mode

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

Definition at line 551 of file driver_ads1118.c.

◆ ads1118_get_range()

uint8_t ads1118_get_range ( ads1118_handle_t * handle,
ads1118_range_t * range )

get the adc range

Parameters
[in]*handlepointer to an ads1118 handle structure
[out]*rangepointer to a voltage range buffer
Returns
status code
  • 0 success
  • 1 get range failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 383 of file driver_ads1118.c.

◆ ads1118_get_rate()

uint8_t ads1118_get_rate ( ads1118_handle_t * handle,
ads1118_rate_t * rate )

get the sample rate

Parameters
[in]*handlepointer to an ads1118 handle structure
[out]*ratepointer to an adc sample rate buffer
Returns
status code
  • 0 success
  • 1 get rate failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 467 of file driver_ads1118.c.

◆ ads1118_info()

uint8_t ads1118_info ( ads1118_info_t * info)

get chip's information

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

Definition at line 1037 of file driver_ads1118.c.

◆ ads1118_init()

uint8_t ads1118_init ( ads1118_handle_t * handle)

initialize the chip

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

Definition at line 142 of file driver_ads1118.c.

◆ ads1118_set_channel()

uint8_t ads1118_set_channel ( ads1118_handle_t * handle,
ads1118_channel_t channel )

set the adc channel

Parameters
[in]*handlepointer to an ads1118 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 252 of file driver_ads1118.c.

◆ ads1118_set_dout_pull_up()

uint8_t ads1118_set_dout_pull_up ( ads1118_handle_t * handle,
ads1118_bool_t enable )

enable or disable dout pull up

Parameters
[in]*handlepointer to an ads1118 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set dout pull up failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 588 of file driver_ads1118.c.

◆ ads1118_set_mode()

uint8_t ads1118_set_mode ( ads1118_handle_t * handle,
ads1118_mode_t mode )

set the chip mode

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

Definition at line 504 of file driver_ads1118.c.

◆ ads1118_set_range()

uint8_t ads1118_set_range ( ads1118_handle_t * handle,
ads1118_range_t range )

set the adc range

Parameters
[in]*handlepointer to an ads1118 handle structure
[in]rangeadc max voltage range
Returns
status code
  • 0 success
  • 1 set range failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 336 of file driver_ads1118.c.

◆ ads1118_set_rate()

uint8_t ads1118_set_rate ( ads1118_handle_t * handle,
ads1118_rate_t rate )

set the sample rate

Parameters
[in]*handlepointer to an ads1118 handle structure
[in]rateadc sample rate
Returns
status code
  • 0 success
  • 1 set rate failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 420 of file driver_ads1118.c.

◆ ads1118_single_read()

uint8_t ads1118_single_read ( ads1118_handle_t * handle,
int16_t * raw,
float * v )

read data from the chip once

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

Definition at line 673 of file driver_ads1118.c.

◆ ads1118_start_continuous_read()

uint8_t ads1118_start_continuous_read ( ads1118_handle_t * handle)

start the chip reading

Parameters
[in]*handlepointer to an ads1118 handle structure
Returns
status code
  • 0 success
  • 1 start continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 893 of file driver_ads1118.c.

◆ ads1118_stop_continuous_read()

uint8_t ads1118_stop_continuous_read ( ads1118_handle_t * handle)

stop the chip reading

Parameters
[in]*handlepointer to an ads1118 handle structure
Returns
status code
  • 0 success
  • 1 stop continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 936 of file driver_ads1118.c.

◆ ads1118_temperature_convert()

uint8_t ads1118_temperature_convert ( ads1118_handle_t * handle,
int16_t raw,
float * deg )

temperature convert

Parameters
[in]*handlepointer to an ads1118 handle structure
[in]rawadc raw data
[out]*degpointer to a deg buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 981 of file driver_ads1118.c.