ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
ads1219.c File Reference

Soil Power Sensor ADS12 library. More...

#include "ads1219.h"
#include <libtock-sync/services/alarm.h>
#include <libtock/peripherals/i2c_master.h>
#include <libtock/tock.h>
#include "../proto/sensor.h"

Go to the source code of this file.

Data Structures

union  ConfigReg
 

Enumerations

enum  ads1219_cmd_t {
  cmd_reset = 0x06 , cmd_start = 0x08 , cmd_powerdown = 0x02 , cmd_rdata = 0x10 ,
  cmd_rreg = 0x20 , cmd_wreg = 0x40
}
 

Functions

void power_on (void)
 GPIO port for adc data ready line.
 
void power_off (void)
 Turn off power to analog circuit.
 
int measure (uint32_t *meas)
 Measure from the adc.
 
int configure (const ConfigReg reg_data)
 This function reconfigures the ADS1219 based on the parameter reg_data.
 
int ads1219_reset (void)
 This function starts up the ADS1219.
 
int ads1219_voltage_raw (uint32_t *voltage)
 
int ads1219_voltage (double *voltage)
 This function reads the current ADC voltage value.
 
int ads1219_current_raw (uint32_t *current)
 
int ads1219_current (double *current)
 This function reads the current ADC ampere value.
 
uint8_t ads1219_sensor_voltage (uint8_t *data, Metadata meta, uint32_t idx)
 Sensor measure functions.
 
uint8_t ads1219_sensor_current (uint8_t *data, Metadata meta, uint32_t idx)
 

Detailed Description

Soil Power Sensor ADS12 library.

Author
Stephen Taylor
Date
11/27/2023

This file provides a function to read from the ADS1219.

This file was copied and modified from the ENTS libraries.

TODO (jmadden173): Add support for data ready pin TODO (jmadden173): Improve lib with big bang for regs TODO (jmadden173): Add offset calibration at startup

Definition in file ads1219.c.

Enumeration Type Documentation

◆ ads1219_cmd_t

i2c address

Enumerator
cmd_reset 

Reset the device

cmd_start 

Start or restart conversion

cmd_powerdown 

Enter power-down mode

cmd_rdata 

Read data

cmd_rreg 

Write to register

cmd_wreg 

Read from register

Definition at line 35 of file ads1219.c.

Function Documentation

◆ configure()

int configure ( const ConfigReg  reg_data)

This function reconfigures the ADS1219 based on the parameter reg_data.

Parameters
reg_data
Returns
int

Definition at line 142 of file ads1219.c.

References ADS1219_CONFIGURE, ADS1219_SUCCESS, cmd_wreg, and ConfigReg::value.

Referenced by ads1219_current_raw(), and ads1219_voltage_raw().

◆ measure()

int measure ( uint32_t *  meas)

Measure from the adc.

Parameters
mwasRaw measurement
Returns
Raw measurement from adc

Definition at line 231 of file ads1219.c.

References ADS1219_CONVERSION, ADS1219_MEASURE, ADS1219_SUCCESS, cmd_rdata, cmd_start, power_off(), and power_on().

Referenced by ads1219_current_raw(), and ads1219_voltage_raw().

◆ power_off()

void power_off ( void  )

Turn off power to analog circuit.

See also
data_ready_pin

Definition at line 226 of file ads1219.c.

Referenced by measure().

◆ power_on()

void power_on ( void  )

GPIO port for adc data ready line.

See also
data_ready_pin

GPIO pin for adc data ready line

Turn on power to analog circuit

Has a blocking wait of 1 mS to account for the startup time of OpAmps. This should be an order of magnitude greater than the startup or turn-on time of the opamps used in the circuit.

MAX9944 - N/A INA296 - 20 uS THS4532 - 420 nS

See also
data_ready_pin

Definition at line 219 of file ads1219.c.

Referenced by measure().