Skip to content

Conversation

@basilfx
Copy link
Member

@basilfx basilfx commented Feb 2, 2025

Contribution description

This adds support for the Guestgood GP8xxx I2C voltage and current DACs. The following variations are supported.

  • GP8503: 2-channel 12-bit VDAC with 0-2.5/VCC V output range
  • GP8512: 1-channel 15-bit VDAC with 0-2.5/VCC V output range
  • GP8211S: 1-channel 15-bit VDAC with 0-5/10 V output range
  • GP8403: 2-channel 12-bit VDAC with 0-5/10 V output range
  • GP8413: 2-channel 15-bit VDAC with 0-5/10 V output range
  • GP8302: 1-channel 12-bit IDAC with 0-25 mA output range

Although Guestgood is Chinese and doesn't offer English datasheets, small and well-documented development boards are produced by DFRobot, which are distributed by several known distributors such as Mouser and Digikey.

The 0-10V VDACs had my particular interest, because several home automation appliances can be controlled using 0-10V signals. These single-chip solutions are very ideal for this purpose.

SAUL was extended to support voltage and current actuators.

Testing procedure

A test application is provided in tests/drivers/gp8xxx. By default, it will select the GP8403, but additional actuators can be specified using USEMODULE. I tested the GP8403 and GP8302 only, but the others will probably work out of the box (my driver is largely based on DFRobot's Arduino version).

SAUL integration can be tested with examples/basic/saul. Note that when using this application, the arguments are parsed as Volts or Amperes. Unfortunately, the SAUL shell does not support fractional numbers, so testing the full range is not really possible for the 0-25 mA IDAC.

I have created three videos to show the driver in action:

My test setup:

Issues/PRs references

None

@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer labels Feb 2, 2025
@basilfx basilfx force-pushed the driver-gp8xxx branch 3 times, most recently from 8643628 to c59968c Compare February 2, 2025 21:18
@github-actions github-actions bot added the Area: tools Area: Supplementary tools label Feb 2, 2025
@basilfx basilfx marked this pull request as ready for review February 2, 2025 21:37
@basilfx basilfx added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 4, 2025
@riot-ci
Copy link

riot-ci commented Feb 4, 2025

Murdock results

✔️ PASSED

47a53e8 tests/drivers/saul_drivers: enable gp8403 and 8302

Success Failures Total Runtime
11000 0 11001 09m:22s

Artifacts

@basilfx basilfx force-pushed the driver-gp8xxx branch 2 times, most recently from b5824f6 to c13315e Compare January 5, 2026 22:41
@basilfx
Copy link
Member Author

basilfx commented Jan 5, 2026

I took the liberty of rebasing this PR and adapt it to meet the conventions since last push.

Tested this once more using the SLSTK3401A with the GP8302 + GP8403 combination.

{
assert(dev->params.info->type == GP8XXX_INFO_TYPE_VDAC);

/* only the 5 V/10 V models have a customizable range */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to return an error when the range wasn't actually set because the device doesn't support it? -ENOSUP for example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided that wrong use would fall in the use of programming errors, and that an assert would be sufficient alternative to another return value or making it type safer.

Comment on lines 8408 to 8427
warning: Member GP8211S_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8211S_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8211S_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8302_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8302_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8302_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8403_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8403_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8403_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8413_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8413_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8413_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8503_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8503_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8503_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8512_INFO_CHANNELS (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8512_INFO_RANGE (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8512_INFO_RESOLUTION (macro definition) of file gp8xxx_info.h is not documented.
warning: Member GP8XXX_REG_CHANNEL (macro definition) of file gp8xxx_constants.h is not documented.
warning: Member GP8XXX_REG_OUTPUT (macro definition) of file gp8xxx_constants.h is not documented.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much prefer if you instead documented the macros.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented them, so this commit will be removed.

Comment on lines +31 to +34
ifneq (,$(filter gp8xxx,$(DRIVERS)))
USEMODULE += gp8403
USEMODULE += gp8302
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this also work when selecting gp8512 module in the test application?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this by only selecting gp8512 AND including gp8512, which compiled fine.

@basilfx
Copy link
Member Author

basilfx commented Jan 6, 2026

Thanks @crasbe, I will take care of the comments tonight (hopefully).

@github-actions github-actions bot removed the Area: tools Area: Supplementary tools label Jan 6, 2026
@basilfx basilfx force-pushed the driver-gp8xxx branch 2 times, most recently from 1f60595 to 9a4f7cc Compare January 6, 2026 22:41
@basilfx
Copy link
Member Author

basilfx commented Jan 6, 2026

@crasbe I have addressed all comments. I commented on the ones still unresolved, to check if you agree.

Did another round of testing with the SLSTK3401a (as in the videos) and it still works.

@basilfx
Copy link
Member Author

basilfx commented Jan 12, 2026

@crasbe anything I need to address, or can I squash?

Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some super small nitpicks, you can squash the changes directly I think.

@crasbe crasbe enabled auto-merge January 13, 2026 14:11
@crasbe crasbe added this pull request to the merge queue Jan 13, 2026
@crasbe crasbe removed this pull request from the merge queue due to a manual request Jan 13, 2026
@crasbe
Copy link
Contributor

crasbe commented Jan 13, 2026

The test needs a Makefile.ci file to exclude devices that don't have enough memory, I'll run make generate-Makefile.ci locally and post the results here shortly.

@crasbe
Copy link
Contributor

crasbe commented Jan 13, 2026

Here you go:

BOARD_INSUFFICIENT_MEMORY := \
    atmega8 \
    nucleo-l011k4 \
    #

To add support for voltage and current DACs, add additional SAUL
actuators.
The Guestgood GP8xxx I2C DACs are easy-to-use voltage and current
DACs with standardized output ranges. All supported variants have
very similar I2C protocol.

This commit adds support for a generic driver (gp8xxx) and uses a
information structure to record capabilities. Multiple driver
instances can work simultaneously on the same I2C bus.

SAUL support is also added.
These two drivers ensure that a VDAC and IDAC capabilities are included.
@basilfx
Copy link
Member Author

basilfx commented Jan 13, 2026

Thanks. I took the liberty to immediately squash that into the commit for the test application.

@crasbe crasbe enabled auto-merge January 13, 2026 15:38
@crasbe crasbe added this pull request to the merge queue Jan 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2026
@crasbe crasbe added this pull request to the merge queue Jan 13, 2026
Merged via the queue into RIOT-OS:master with commit aab9636 Jan 13, 2026
25 checks passed
@basilfx basilfx deleted the driver-gp8xxx branch January 13, 2026 22:14
@basilfx
Copy link
Member Author

basilfx commented Jan 13, 2026

Thank you @crasbe for the review and help to get this merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: doc Area: Documentation Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants