1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/ads101x: eliminate casts

A helper variable is added, and now all type casts are not needed anymore.
This commit is contained in:
Kees Bakker 2019-01-03 22:35:44 +01:00
parent b77c802f9b
commit 9e8b1edbf9

View File

@ -33,18 +33,19 @@
static int read_adc(const void *dev, phydat_t *res)
{
const ads101x_t *mydev = dev;
/* Change the mux channel */
ads101x_set_mux_gain((const ads101x_t *)dev,
((ads101x_t *)dev)->params.mux_gain);
ads101x_set_mux_gain(mydev, mydev->params.mux_gain);
/* Read raw value */
if (ads101x_read_raw((const ads101x_t *)dev, res->val) < 0) {
if (ads101x_read_raw(mydev, res->val) < 0) {
return ECANCELED;
}
/* Special case for 2.048V */
/* (this is the fixed FSR of ADS1013 and ADS1113) */
if ((((ads101x_t *)dev)->params.mux_gain & ADS101X_PGA_MASK)
if ((mydev->params.mux_gain & ADS101X_PGA_MASK)
== ADS101X_PGA_FSR_2V048) {
/* LSB == 62.5uV to LSB == 100uV */