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
54 extern "C"
55 {
56 #endif
57 
58 #include "periph/i2c.h"
59 #include "periph/gpio.h"
60 
64 typedef enum {
65  PH_OEM_OK = 0,
66  PH_OEM_NODEV = -1,
74 
78 typedef enum {
79  PH_OEM_LED_ON = 0x01,
80  PH_OEM_LED_OFF = 0x00,
82 
86 typedef enum {
93 typedef enum {
96  PH_OEM_IRQ_BOTH = 0x08,
98 
102 typedef enum {
107 
111 typedef struct ph_oem_params {
113  uint8_t addr;
114  gpio_t interrupt_pin;
118 
122 typedef void (*ph_oem_interrupt_pin_cb_t)(void *);
123 
127 typedef struct ph_oem {
130  void *arg;
131 } ph_oem_t;
132 
144 int ph_oem_init(ph_oem_t *dev, const ph_oem_params_t *params);
145 
165 int ph_oem_set_i2c_address(ph_oem_t *dev, uint8_t addr);
166 
194  void *arg);
195 
209 int ph_oem_reset_interrupt_pin(const ph_oem_t *dev);
210 
221 int ph_oem_set_led_state(const ph_oem_t *dev, ph_oem_led_state_t state);
222 
238 
253 int ph_oem_start_new_reading(const ph_oem_t *dev);
254 
264 int ph_oem_clear_calibration(const ph_oem_t *dev);
265 
288 int ph_oem_set_calibration(const ph_oem_t *dev, uint16_t calibration_value,
290 
304 int ph_oem_read_calibration_state(const ph_oem_t *dev, uint16_t *calibration_state);
305 
324 int ph_oem_set_compensation(const ph_oem_t *dev,
325  uint16_t temperature_compensation);
326 
340 int ph_oem_read_compensation(const ph_oem_t *dev,
341  uint16_t *temperature_compensation);
342 
355 int 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 */
362 
Everything was fine.
Definition: ph_oem.h:65
int ph_oem_init(ph_oem_t *dev, const ph_oem_params_t *params)
Initialize a pH OEM sensor.
ph_oem_device_state_t
Device state values.
Definition: ph_oem.h:86
i2c_t i2c
I2C device the sensor is connected to.
Definition: ph_oem.h:112
Interrupt pin is GPIO_UNDEF.
Definition: ph_oem.h:70
Error while initializing GPIO PIN.
Definition: ph_oem.h:71
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_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 ...
Device active state.
Definition: ph_oem.h:87
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...
Low-level GPIO peripheral driver interface definitions.
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...
ph_oem_irq_option_t irq_option
behavior of the interrupt pin, disabled by default
Definition: ph_oem.h:116
ph_oem_calibration_option_t
Calibration option values.
Definition: ph_oem.h:102
Device hibernate state.
Definition: ph_oem.h:88
High point calibration option.
Definition: ph_oem.h:105
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
ph_oem_irq_option_t
Interrupt pin option values.
Definition: ph_oem.h:93
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. ...
Temperature is out of range.
Definition: ph_oem.h:72
Pin low on new reading (manually reset)
Definition: ph_oem.h:95
gpio_t interrupt_pin
interrupt pin (GPIO_UNDEF if not defined)
Definition: ph_oem.h:114
Writing to device failed.
Definition: ph_oem.h:68
Not an Atlas Scientific pH OEM device.
Definition: ph_oem.h:69
Reading to device failed.
Definition: ph_oem.h:67
Mid point calibration option.
Definition: ph_oem.h:104
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_read_calibration_state(const ph_oem_t *dev, uint16_t *calibration_state)
Read the PH_OEM_REG_CALIBRATION_CONFIRM register.
gpio_mode_t gpio_mode
gpio mode of the interrupt pin
Definition: ph_oem.h:115
void * arg
interrupt pin callback param
Definition: ph_oem.h:130
int ph_oem_clear_calibration(const ph_oem_t *dev)
Clears all calibrations previously done.
ph_oem_interrupt_pin_cb_t cb
interrupt pin callback
Definition: ph_oem.h:129
Invert state on new reading (automatically reset)
Definition: ph_oem.h:96
struct ph_oem ph_oem_t
pH OEM device descriptor
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.
void(* ph_oem_interrupt_pin_cb_t)(void *)
pH OEM interrupt pin callback
Definition: ph_oem.h:122
ph_oem_led_state_t
LED state values.
Definition: ph_oem.h:78
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...
struct ph_oem_params ph_oem_params_t
pH OEM sensor params
Low point calibration option.
Definition: ph_oem.h:103
gpio_mode_t
Available pin modes.
Definition: gpio.h:113
ph_oem_params_t params
device driver configuration
Definition: ph_oem.h:128
ph_oem_named_returns_t
Named return values.
Definition: ph_oem.h:64
No device found on the bus.
Definition: ph_oem.h:66
pH OEM device descriptor
Definition: ph_oem.h:127
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...
LED on state.
Definition: ph_oem.h:79
Pin high on new reading (manually reset)
Definition: ph_oem.h:94
pH OEM sensor params
Definition: ph_oem.h:111
LED off state.
Definition: ph_oem.h:80
uint8_t addr
the slave address of the sensor on the I2C bus
Definition: ph_oem.h:113
Low-level I2C peripheral driver interface definition.