Loading...
Searching...
No Matches
ph_oem.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 University of Applied Sciences Emden / Leer
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
50#ifndef PH_OEM_H
51#define PH_OEM_H
52
53#ifdef __cplusplus
54extern "C"
55{
56#endif
57
58#include "periph/i2c.h"
59#include "periph/gpio.h"
60
74
78typedef enum {
82
98
107
118
122typedef void (*ph_oem_interrupt_pin_cb_t)(void *);
123
132
144int ph_oem_init(ph_oem_t *dev, const ph_oem_params_t *params);
145
165int ph_oem_set_i2c_address(ph_oem_t *dev, uint8_t addr);
166
194 void *arg);
195
210
222
238
254
265
288int ph_oem_set_calibration(const ph_oem_t *dev, uint16_t calibration_value,
290
304int ph_oem_read_calibration_state(const ph_oem_t *dev, uint16_t *calibration_state);
305
325 uint16_t temperature_compensation);
326
341 uint16_t *temperature_compensation);
342
355int ph_oem_read_ph(const ph_oem_t *dev, uint16_t *ph_value);
356
357#ifdef __cplusplus
358}
359#endif
360
361#endif /* PH_OEM_H */
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
int ph_oem_enable_interrupt(ph_oem_t *dev, ph_oem_interrupt_pin_cb_t cb, void *arg)
Enable the pH OEM interrupt pin if ph_oem_params_t::interrupt_pin is defined.
int ph_oem_read_ph(const ph_oem_t *dev, uint16_t *ph_value)
Reads the PH_OEM_REG_PH_READING_BASE register to get the current pH reading.
int ph_oem_reset_interrupt_pin(const ph_oem_t *dev)
The interrupt pin will not auto reset on option PH_OEM_IRQ_RISING and PH_OEM_IRQ_FALLING after interr...
int ph_oem_set_calibration(const ph_oem_t *dev, uint16_t calibration_value, ph_oem_calibration_option_t option)
Sets the PH_OEM_REG_CALIBRATION_BASE register to the calibration_value which the pH OEM sensor will b...
void(* ph_oem_interrupt_pin_cb_t)(void *)
pH OEM interrupt pin callback
Definition ph_oem.h:122
int ph_oem_read_compensation(const ph_oem_t *dev, uint16_t *temperature_compensation)
Reads the PH_OEM_REG_TEMP_CONFIRMATION_BASE register to verify the temperature compensation value tha...
int ph_oem_set_led_state(const ph_oem_t *dev, ph_oem_led_state_t state)
Set the LED state of the pH OEM sensor by writing to the PH_OEM_REG_LED register.
struct ph_oem_params ph_oem_params_t
pH OEM sensor params
int ph_oem_start_new_reading(const ph_oem_t *dev)
Starts a new reading by setting the device state to PH_OEM_TAKE_READINGS.
int ph_oem_set_device_state(const ph_oem_t *dev, ph_oem_device_state_t state)
Sets the device state (active/hibernate) of the pH OEM sensor by writing to the PH_OEM_REG_HIBERNATE ...
ph_oem_irq_option_t
Interrupt pin option values.
Definition ph_oem.h:93
int ph_oem_read_calibration_state(const ph_oem_t *dev, uint16_t *calibration_state)
Read the PH_OEM_REG_CALIBRATION_CONFIRM register.
int ph_oem_set_i2c_address(ph_oem_t *dev, uint8_t addr)
Sets a new address to the pH OEM device by unlocking the PH_OEM_REG_UNLOCK register and writing a new...
int ph_oem_set_compensation(const ph_oem_t *dev, uint16_t temperature_compensation)
Sets the PH_OEM_REG_TEMP_COMPENSATION_BASE register to the temperature_compensation value which the p...
ph_oem_named_returns_t
Named return values.
Definition ph_oem.h:64
ph_oem_led_state_t
LED state values.
Definition ph_oem.h:78
ph_oem_device_state_t
Device state values.
Definition ph_oem.h:86
int ph_oem_init(ph_oem_t *dev, const ph_oem_params_t *params)
Initialize a pH OEM sensor.
int ph_oem_clear_calibration(const ph_oem_t *dev)
Clears all calibrations previously done.
struct ph_oem ph_oem_t
pH OEM device descriptor
ph_oem_calibration_option_t
Calibration option values.
Definition ph_oem.h:102
@ PH_OEM_IRQ_FALLING
Pin low on new reading (manually reset)
Definition ph_oem.h:95
@ PH_OEM_IRQ_BOTH
Invert state on new reading (automatically reset)
Definition ph_oem.h:96
@ PH_OEM_IRQ_RISING
Pin high on new reading (manually reset)
Definition ph_oem.h:94
@ PH_OEM_GPIO_INIT_ERR
Error while initializing GPIO PIN.
Definition ph_oem.h:71
@ PH_OEM_INTERRUPT_GPIO_UNDEF
Interrupt pin is GPIO_UNDEF.
Definition ph_oem.h:70
@ PH_OEM_WRITE_ERR
Writing to device failed.
Definition ph_oem.h:68
@ PH_OEM_NOT_PH
Not an Atlas Scientific pH OEM device.
Definition ph_oem.h:69
@ PH_OEM_READ_ERR
Reading to device failed.
Definition ph_oem.h:67
@ PH_OEM_TEMP_OUT_OF_RANGE
Temperature is out of range.
Definition ph_oem.h:72
@ PH_OEM_NODEV
No device found on the bus.
Definition ph_oem.h:66
@ PH_OEM_OK
Everything was fine.
Definition ph_oem.h:65
@ PH_OEM_LED_OFF
LED off state.
Definition ph_oem.h:80
@ PH_OEM_LED_ON
LED on state.
Definition ph_oem.h:79
@ PH_OEM_STOP_READINGS
Device hibernate state.
Definition ph_oem.h:88
@ PH_OEM_TAKE_READINGS
Device active state.
Definition ph_oem.h:87
@ PH_OEM_CALIBRATE_LOW_POINT
Low point calibration option.
Definition ph_oem.h:103
@ PH_OEM_CALIBRATE_HIGH_POINT
High point calibration option.
Definition ph_oem.h:105
@ PH_OEM_CALIBRATE_MID_POINT
Mid point calibration option.
Definition ph_oem.h:104
Low-level I2C peripheral driver interface definition.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:82
pH OEM sensor params
Definition ph_oem.h:111
uint8_t addr
the slave address of the sensor on the I2C bus
Definition ph_oem.h:113
gpio_mode_t gpio_mode
gpio mode of the interrupt pin
Definition ph_oem.h:115
ph_oem_irq_option_t irq_option
behavior of the interrupt pin, disabled by default
Definition ph_oem.h:116
i2c_t i2c
I2C device the sensor is connected to.
Definition ph_oem.h:112
gpio_t interrupt_pin
interrupt pin (GPIO_UNDEF if not defined)
Definition ph_oem.h:114
pH OEM device descriptor
Definition ph_oem.h:127
void * arg
interrupt pin callback param
Definition ph_oem.h:130
ph_oem_params_t params
device driver configuration
Definition ph_oem.h:128
ph_oem_interrupt_pin_cb_t cb
interrupt pin callback
Definition ph_oem.h:129