Midnight Sun Firmware
Loading...
Searching...
No Matches
ADS1115

ADS1115 ADC driver. More...

Classes

struct  ADS1115_Config
 Configuration structure for the ADS1115 driver. More...
 

Macros

#define ALRT_EVENT   0U
 Alert event ID used for soft interrupt handling.
 
#define ADS1115_I2C_PORT   I2C_PORT_1
 Default I2C port used by the ADS1115.
 

Enumerations

enum  ADS1115_Address { ADS1115_ADDR_GND = 0x48U , ADS1115_ADDR_VDD = 0x49U , ADS1115_ADDR_SDA = 0x4AU , ADS1115_ADDR_SCL = 0x4BU }
 I2C Address selection based on ADDR pin connection. More...
 
enum  ADS1115_Channel { ADS1115_CHANNEL_0 = 0 , ADS1115_CHANNEL_1 , ADS1115_CHANNEL_2 , ADS1115_CHANNEL_3 }
 ADS1115 single-ended input channels. More...
 
enum  ADS1115_Reg { ADS1115_REG_CONVERSION = 0x00 , ADS1115_REG_CONFIG , ADS1115_REG_LO_THRESH , ADS1115_REG_HI_THRESH }
 Register map for the ADS1115. More...
 

Functions

StatusCode ads1115_init (ADS1115_Config *config, ADS1115_Address i2c_addr, GpioAddress *ready_pin)
 Initializes the ADS1115 on the I2C bus with an optional ALERT/RDY pin. More...
 
StatusCode ads1115_select_channel (ADS1115_Config *config, ADS1115_Channel channel)
 Selects the active ADC channel on the ADS1115. More...
 
StatusCode ads1115_read_raw (ADS1115_Config *config, ADS1115_Channel channel, int16_t *reading)
 Reads the raw ADC value from the specified channel. More...
 
StatusCode ads1115_read_converted (ADS1115_Config *config, ADS1115_Channel channel, float *reading)
 Reads and converts the ADC value from the specified channel into a voltage. More...
 

Detailed Description

ADS1115 ADC driver.

Enumeration Type Documentation

◆ ADS1115_Address

I2C Address selection based on ADDR pin connection.

Enumerator
ADS1115_ADDR_GND 

ADDR pin connected to GND

ADS1115_ADDR_VDD 

ADDR pin connected to VDD

ADS1115_ADDR_SDA 

ADDR pin connected to SDA

ADS1115_ADDR_SCL 

ADDR pin connected to SCL

◆ ADS1115_Channel

ADS1115 single-ended input channels.

Enumerator
ADS1115_CHANNEL_0 

Input channel AIN0

ADS1115_CHANNEL_1 

Input channel AIN1

ADS1115_CHANNEL_2 

Input channel AIN2

ADS1115_CHANNEL_3 

Input channel AIN3

◆ ADS1115_Reg

Register map for the ADS1115.

Enumerator
ADS1115_REG_CONVERSION 

Conversion result register

ADS1115_REG_CONFIG 

Configuration register

ADS1115_REG_LO_THRESH 

Low threshold register for comparator

ADS1115_REG_HI_THRESH 

High threshold register for comparator

Function Documentation

◆ ads1115_init()

StatusCode ads1115_init ( ADS1115_Config config,
ADS1115_Address  i2c_addr,
GpioAddress ready_pin 
)

Initializes the ADS1115 on the I2C bus with an optional ALERT/RDY pin.

Parameters
configPointer to the ADS1115_Config to populate
i2c_addrI2C address of the device
ready_pinPointer to GPIO address of the ALERT/RDY pin (can be NULL)
Returns
STATUS_CODE_OK if initialization succeeds STATUS_CODE_INVALID_ARGS if config or address is invalid STATUS_CODE_INTERNAL_ERROR on I2C failure

◆ ads1115_read_converted()

StatusCode ads1115_read_converted ( ADS1115_Config config,
ADS1115_Channel  channel,
float *  reading 
)

Reads and converts the ADC value from the specified channel into a voltage.

Conversion depends on the ADS1115's internal reference and configuration.

Parameters
configPointer to the ADS1115 configuration
channelInput channel to read from
readingPointer to store the converted voltage (in volts)
Returns
STATUS_CODE_OK if successful STATUS_CODE_INVALID_ARGS if any parameter is invalid STATUS_CODE_INTERNAL_ERROR on I2C failure

◆ ads1115_read_raw()

StatusCode ads1115_read_raw ( ADS1115_Config config,
ADS1115_Channel  channel,
int16_t *  reading 
)

Reads the raw ADC value from the specified channel.

Parameters
configPointer to the ADS1115 configuration
channelInput channel to read from
readingPointer to store the raw 16-bit ADC result
Returns
STATUS_CODE_OK if successful STATUS_CODE_INVALID_ARGS if any parameter is invalid STATUS_CODE_INTERNAL_ERROR on I2C failure

◆ ads1115_select_channel()

StatusCode ads1115_select_channel ( ADS1115_Config config,
ADS1115_Channel  channel 
)

Selects the active ADC channel on the ADS1115.

Reconfigures the ADC for single-ended input on the selected channel.

Parameters
configPointer to the ADS1115 configuration
channelInput channel to read from (AIN0–AIN3)
Returns
STATUS_CODE_OK if successful STATUS_CODE_INVALID_ARGS if channel or config is invalid