Midnight Sun Firmware
Loading...
Searching...
No Matches
ads1115.h
1#pragma once
2
3/************************************************************************************************
4 * @file ads1115.h
5 *
6 * @brief ADS1115 driver header file
7 *
8 * @date 2025-07-30
9 * @author Midnight Sun Team
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdint.h>
14
15/* Inter-component Headers */
16#include "gpio.h"
17#include "i2c.h"
18
19/* Intra-component Headers */
20#include "status.h"
21
22/* Standard Library Headers */
23
33#define ALRT_EVENT 0U
34
38#define ADS1115_I2C_PORT I2C_PORT_1
39
43typedef enum {
49
53typedef enum {
59
63typedef enum {
69
73typedef struct {
78
90
101
112StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, int16_t *reading);
113
125StatusCode ads1115_read_converted(ADS1115_Config *config, ADS1115_Channel channel, float *reading);
126
StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, int16_t *reading)
Reads the raw ADC value from the specified channel.
Definition: ads1115.c:72
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.
Definition: ads1115.c:21
ADS1115_Address
I2C Address selection based on ADDR pin connection.
Definition: ads1115.h:43
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.
Definition: ads1115.c:79
StatusCode ads1115_select_channel(ADS1115_Config *config, ADS1115_Channel channel)
Selects the active ADC channel on the ADS1115.
Definition: ads1115.c:50
ADS1115_Channel
ADS1115 single-ended input channels.
Definition: ads1115.h:53
ADS1115_Reg
Register map for the ADS1115.
Definition: ads1115.h:63
@ ADS1115_ADDR_SDA
Definition: ads1115.h:46
@ ADS1115_ADDR_SCL
Definition: ads1115.h:47
@ ADS1115_ADDR_GND
Definition: ads1115.h:44
@ ADS1115_ADDR_VDD
Definition: ads1115.h:45
@ ADS1115_CHANNEL_3
Definition: ads1115.h:57
@ ADS1115_CHANNEL_2
Definition: ads1115.h:56
@ ADS1115_CHANNEL_1
Definition: ads1115.h:55
@ ADS1115_CHANNEL_0
Definition: ads1115.h:54
@ ADS1115_REG_CONVERSION
Definition: ads1115.h:64
@ ADS1115_REG_CONFIG
Definition: ads1115.h:65
@ ADS1115_REG_HI_THRESH
Definition: ads1115.h:67
@ ADS1115_REG_LO_THRESH
Definition: ads1115.h:66
uint8_t I2CAddress
I2C address type.
Definition: i2c.h:34
I2CPort
I2C Port selection.
Definition: i2c.h:37
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Configuration structure for the ADS1115 driver.
Definition: ads1115.h:73
GpioAddress * ready_pin
Definition: ads1115.h:76
I2CPort i2c_port
Definition: ads1115.h:74
I2CAddress i2c_addr
Definition: ads1115.h:75
Port and pin data.
Definition: gpio.h:112