Loading...
Searching...
No Matches
ph_oem.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 University of Applied Sciences Emden / Leer
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
48
49#ifdef __cplusplus
50extern "C"
51{
52#endif
53
54#include "periph/i2c.h"
55#include "periph/gpio.h"
56
70
74typedef enum {
78
86
94
103
114
118typedef void (*ph_oem_interrupt_pin_cb_t)(void *);
119
128
139int ph_oem_init(ph_oem_t *dev, const ph_oem_params_t *params);
140
160int ph_oem_set_i2c_address(ph_oem_t *dev, uint8_t addr);
161
189 void *arg);
190
205
217
233
249
260
283int ph_oem_set_calibration(const ph_oem_t *dev, uint16_t calibration_value,
285
299int ph_oem_read_calibration_state(const ph_oem_t *dev, uint16_t *calibration_state);
300
320 uint16_t temperature_compensation);
321
336 uint16_t *temperature_compensation);
337
350int ph_oem_read_ph(const ph_oem_t *dev, uint16_t *ph_value);
351
352#ifdef __cplusplus
353}
354#endif
355
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:96
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
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:118
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:89
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:60
ph_oem_led_state_t
LED state values.
Definition ph_oem.h:74
ph_oem_device_state_t
Device state values.
Definition ph_oem.h:82
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:98
@ PH_OEM_IRQ_FALLING
Pin low on new reading (manually reset)
Definition ph_oem.h:91
@ PH_OEM_IRQ_BOTH
Invert state on new reading (automatically reset)
Definition ph_oem.h:92
@ PH_OEM_IRQ_RISING
Pin high on new reading (manually reset)
Definition ph_oem.h:90
@ PH_OEM_GPIO_INIT_ERR
Error while initializing GPIO PIN.
Definition ph_oem.h:67
@ PH_OEM_INTERRUPT_GPIO_UNDEF
Interrupt pin is GPIO_UNDEF.
Definition ph_oem.h:66
@ PH_OEM_WRITE_ERR
Writing to device failed.
Definition ph_oem.h:64
@ PH_OEM_NOT_PH
Not an Atlas Scientific pH OEM device.
Definition ph_oem.h:65
@ PH_OEM_READ_ERR
Reading to device failed.
Definition ph_oem.h:63
@ PH_OEM_TEMP_OUT_OF_RANGE
Temperature is out of range.
Definition ph_oem.h:68
@ PH_OEM_NODEV
No device found on the bus.
Definition ph_oem.h:62
@ PH_OEM_OK
Everything was fine.
Definition ph_oem.h:61
@ PH_OEM_LED_OFF
LED off state.
Definition ph_oem.h:76
@ PH_OEM_LED_ON
LED on state.
Definition ph_oem.h:75
@ PH_OEM_STOP_READINGS
Device hibernate state.
Definition ph_oem.h:84
@ PH_OEM_TAKE_READINGS
Device active state.
Definition ph_oem.h:83
@ PH_OEM_CALIBRATE_LOW_POINT
Low point calibration option.
Definition ph_oem.h:99
@ PH_OEM_CALIBRATE_HIGH_POINT
High point calibration option.
Definition ph_oem.h:101
@ PH_OEM_CALIBRATE_MID_POINT
Mid point calibration option.
Definition ph_oem.h:100
Low-level I2C peripheral driver interface definition.
pH OEM sensor params
Definition ph_oem.h:107
uint8_t addr
the slave address of the sensor on the I2C bus
Definition ph_oem.h:109
gpio_mode_t gpio_mode
gpio mode of the interrupt pin
Definition ph_oem.h:111
ph_oem_irq_option_t irq_option
behavior of the interrupt pin, disabled by default
Definition ph_oem.h:112
i2c_t i2c
I2C device the sensor is connected to.
Definition ph_oem.h:108
gpio_t interrupt_pin
interrupt pin (GPIO_UNDEF if not defined)
Definition ph_oem.h:110
pH OEM device descriptor
Definition ph_oem.h:123
void * arg
interrupt pin callback param
Definition ph_oem.h:126
ph_oem_params_t params
device driver configuration
Definition ph_oem.h:124
ph_oem_interrupt_pin_cb_t cb
interrupt pin callback
Definition ph_oem.h:125