Loading...
Searching...
No Matches
gp8xxx.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Bas Stottelaar <basstottelaar@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
38
39#include "periph/i2c.h"
40
41#include "gp8xxx_info.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
54#if MODULE_GP8503 || MODULE_GP8512 || MODULE_GP8403 || MODULE_GP8413 || \
55 MODULE_GP8211S
56# define GP8XXX_HAS_VDAC 1
57#endif
58#if MODULE_GP8302
59# define GP8XXX_HAS_IDAC 1
60#endif
61
70
81
85typedef struct {
87 uint8_t address;
88#if GP8XXX_HAS_VDAC || DOXYGEN
90#endif /* GP8XXX_HAS_VDAC || DOXYGEN */
93
97typedef struct {
98 char *name;
99 uint8_t dev;
102
106typedef struct {
109#if GP8XXX_HAS_IDAC || DOXYGEN
112#endif /* GP8XXX_HAS_IDAC || DOXYGEN */
113} gp8xxx_t;
114
125
137int gp8xxx_init(gp8xxx_t *dev, const gp8xxx_params_t *params);
138
150int gp8xxx_set_dac(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t value);
151
152#if GP8XXX_HAS_VDAC || DOXYGEN
163
175int gp8xxx_set_voltage(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t voltage);
176#endif /* GP8XXX_HAS_VDAC || DOXYGEN */
177
178#if GP8XXX_HAS_IDAC || DOXYGEN
193void gp8xxx_set_current_calibration(gp8xxx_t *dev, uint16_t calibration_4ma,
194 uint16_t calibration_20ma);
195
207int gp8xxx_set_current(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t current);
208#endif /* GP8XXX_HAS_IDAC || DOXYGEN */
209
210#ifdef __cplusplus
211}
212#endif
213
Definitions of the Guestgood GP8xxx I2C DACs.
gp8xxx_output_range_t
Output range values.
Definition gp8xxx.h:74
gp8xxx_channel_t
Compile time macros to enable/disable features.
Definition gp8xxx.h:65
int gp8xxx_set_voltage_range(gp8xxx_t *dev, gp8xxx_output_range_t value)
Set the output range.
void gp8xxx_set_current_calibration(gp8xxx_t *dev, uint16_t calibration_4ma, uint16_t calibration_20ma)
Set the current calibration values.
int gp8xxx_init(gp8xxx_t *dev, const gp8xxx_params_t *params)
Initialize the given device.
int gp8xxx_set_dac(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t value)
Set the DAC value.
int gp8xxx_set_current(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t current)
Set the current.
int gp8xxx_set_voltage(gp8xxx_t *dev, gp8xxx_channel_t channel, uint16_t voltage)
Set the voltage.
@ GP8XXX_OUTPUT_RANGE_25_MA
0-25 mA output range
Definition gp8xxx.h:79
@ GP8XXX_OUTPUT_RANGE_VCC
0-VCC V output range (VCC fixed to 3V3)
Definition gp8xxx.h:76
@ GP8XXX_OUTPUT_RANGE_2_5V
0-2.5 V output range
Definition gp8xxx.h:75
@ GP8XXX_OUTPUT_RANGE_5V
0-5 V output range
Definition gp8xxx.h:77
@ GP8XXX_OUTPUT_RANGE_10V
0-10 V output range
Definition gp8xxx.h:78
@ GP8XXX_CHANNEL_0
Channel 0.
Definition gp8xxx.h:66
@ GP8XXX_CHANNEL_ALL
All channels.
Definition gp8xxx.h:68
@ GP8XXX_CHANNEL_1
Channel 1.
Definition gp8xxx.h:67
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:135
Low-level I2C peripheral driver interface definition.
Struct to record GP8xxx actuator information.
Device initialization parameters.
Definition gp8xxx.h:85
gp8xxx_output_range_t range
default output range
Definition gp8xxx.h:89
const gp8xxx_info_t * info
device information
Definition gp8xxx.h:91
uint8_t address
converter address
Definition gp8xxx.h:87
i2c_t i2c_dev
I2C bus the converter is connected to.
Definition gp8xxx.h:86
SAUL device initialization parameters.
Definition gp8xxx.h:97
gp8xxx_channel_t channel
channel of the device
Definition gp8xxx.h:100
char * name
name of the device and channel
Definition gp8xxx.h:98
uint8_t dev
device index
Definition gp8xxx.h:99
SAUL device descriptor for the driver.
Definition gp8xxx.h:121
gp8xxx_channel_t channel
channel of the device
Definition gp8xxx.h:123
gp8xxx_t * dev
device descriptor
Definition gp8xxx.h:122
Device descriptor for the driver.
Definition gp8xxx.h:106
uint16_t calibration_20ma
calibration value for 20 mA
Definition gp8xxx.h:111
uint16_t calibration_4ma
calibration value for 4 mA
Definition gp8xxx.h:110
gp8xxx_params_t params
device parameters
Definition gp8xxx.h:107
gp8xxx_output_range_t range
current output range
Definition gp8xxx.h:108