1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

drivers/saul: use const qualifier for data to write

This makes life easier when calling e.g. `saul_reg_write()` with data
stored in flash.

As now the signatures for reading and writing differ (in that `const`
qualifier only), `saul_notsup()` is split into `saul_write_notsup()`
and `saul_read_notsup()`. However, one is implemented as a symbol alias
of the other, so that ROM consumption remains unchanged.
This commit is contained in:
Marian Buschsieweke 2022-05-02 21:31:03 +02:00
parent dc7bc9f854
commit 16f859dafd
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94
81 changed files with 161 additions and 147 deletions

View File

@ -35,7 +35,7 @@ static int _read(const void *dev, phydat_t *res)
const saul_driver_t efm32_coretemp_saul_driver = {
.read = _read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -63,6 +63,6 @@ const saul_reg_info_t nrf_temperature_saul_info = {
const saul_driver_t nrf_temperature_saul_driver = {
.read = _read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -78,18 +78,18 @@ static int _read_volt(const void *dev, phydat_t *res)
const saul_driver_t ad7746_saul_driver_cap = {
.read = _read_cap,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CAPACITANCE,
};
const saul_driver_t ad7746_saul_driver_temp = {
.read = _read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t ad7746_saul_driver_volt = {
.read = _read_volt,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_VOLTAGE
};

View File

@ -38,6 +38,6 @@ static int read_adc(const void *dev, phydat_t *res)
const saul_driver_t adcxx1c_saul_driver = {
.read = read_adc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ANALOG,
};

View File

@ -66,6 +66,6 @@ static int read_adc(const void *dev, phydat_t *res)
const saul_driver_t ads101x_saul_driver = {
.read = read_adc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ANALOG,
};

View File

@ -32,6 +32,6 @@ static int read_acc(const void *dev, phydat_t *res)
const saul_driver_t adxl345_saul_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};

View File

@ -68,20 +68,20 @@ static int read_rgb(const void *dev, phydat_t *res)
const saul_driver_t apds99xx_saul_prx_driver = {
.read = read_prx,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PROXIMITY,
};
const saul_driver_t apds99xx_saul_als_driver = {
.read = read_als,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT,
};
#if MODULE_APDS9900 || MODULE_APDS9901 || MODULE_APDS9930
const saul_driver_t apds99xx_saul_lux_driver = {
.read = read_lux,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT,
};
#endif
@ -89,7 +89,7 @@ const saul_driver_t apds99xx_saul_lux_driver = {
#if MODULE_APDS9950 || MODULE_APDS9960
const saul_driver_t apds99xx_saul_rgb_driver = {
.read = read_rgb,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT,
};
#endif

View File

@ -187,24 +187,24 @@ static int read_gas(const void *dev, phydat_t *data)
const saul_driver_t bme680_saul_driver_temperature = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t bme680_saul_driver_pressure = {
.read = read_press,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS
};
const saul_driver_t bme680_saul_driver_humidity = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM
};
const saul_driver_t bme680_saul_driver_gas = {
.read = read_gas,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GAS
};

View File

@ -42,12 +42,12 @@ static int read_pressure(const void *dev, phydat_t *res)
const saul_driver_t bmp180_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t bmp180_pressure_saul_driver = {
.read = read_pressure,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS
};

View File

@ -60,18 +60,18 @@ static int read_gyro(const void *dev, phydat_t *res)
const saul_driver_t bmx055_magnetometer_saul_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};
const saul_driver_t bmx055_accelerometer_saul_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};
const saul_driver_t bmx055_gyroscope_saul_driver = {
.read = read_gyro,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};

View File

@ -57,20 +57,20 @@ static int read_relative_humidity(const void *dev, phydat_t *res)
const saul_driver_t bmx280_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t bmx280_pressure_saul_driver = {
.read = read_pressure,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS,
};
#if defined(MODULE_BME280_SPI) || defined(MODULE_BME280_I2C)
const saul_driver_t bme280_relative_humidity_saul_driver = {
.read = read_relative_humidity,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};
#endif

View File

@ -66,12 +66,12 @@ static int read_eco2(const void *dev, phydat_t *res)
const saul_driver_t ccs811_saul_driver_eco2 = {
.read = read_eco2,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CO2
};
const saul_driver_t ccs811_saul_driver_tvoc = {
.read = read_tvoc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TVOC
};

View File

@ -53,12 +53,12 @@ static int read_hum(const void *dev, phydat_t *res)
const saul_driver_t dht_temp_saul_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t dht_hum_saul_driver = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM
};

View File

@ -37,6 +37,6 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t ds18_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -39,6 +39,6 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t ds75lx_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -61,12 +61,12 @@ static int read_acc(const void *dev, phydat_t *res)
const saul_driver_t fxos8700_saul_mag_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};
const saul_driver_t fxos8700_saul_acc_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};

View File

@ -41,6 +41,6 @@ static int _read(const void *dev, phydat_t *res)
const saul_driver_t gp2y10xx_saul_driver = {
.read = _read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM,
};

View File

@ -24,7 +24,7 @@
#include "saul.h"
#include "grove_ledbar.h"
static int set_ledbar(const void *dev, phydat_t *res)
static int set_ledbar(const void *dev, const phydat_t *res)
{
uint8_t lvl = (uint8_t)res->val[0];
grove_ledbar_set((grove_ledbar_t *)dev, lvl);
@ -32,7 +32,7 @@ static int set_ledbar(const void *dev, phydat_t *res)
}
const saul_driver_t grove_ledbar_saul_driver = {
.read = saul_notsup,
.read = saul_read_notsup,
.write = set_ledbar,
.type = SAUL_ACT_LED_RGB,
};

View File

@ -51,12 +51,12 @@ static int read_hum(const void *dev, phydat_t *res)
const saul_driver_t hdc1000_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t hdc1000_saul_hum_driver = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};

View File

@ -138,38 +138,38 @@ static int read_nc_pm_10(const void *_dev, phydat_t *data)
const saul_driver_t hm330x_saul_driver_mc_pm_1 = {
.read = read_mc_pm_1,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};
const saul_driver_t hm330x_saul_driver_mc_pm_2p5 = {
.read = read_mc_pm_2p5,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};
const saul_driver_t hm330x_saul_driver_mc_pm_10 = {
.read = read_mc_pm_10,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};
#if IS_USED(MODULE_HM3302)
const saul_driver_t hm330x_saul_driver_nc_pm_1 = {
.read = read_nc_pm_1,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COUNT
};
const saul_driver_t hm330x_saul_driver_nc_pm_2p5 = {
.read = read_nc_pm_2p5,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COUNT
};
const saul_driver_t hm330x_saul_driver_nc_pm_10 = {
.read = read_nc_pm_10,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COUNT
};
#endif

View File

@ -35,6 +35,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t hmc5883l_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -45,12 +45,12 @@ static int read_pressure(const void *dev, phydat_t *res)
const saul_driver_t hsc_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t hsc_pressure_saul_driver = {
.read = read_pressure,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS
};

View File

@ -47,12 +47,12 @@ static int read_hum(const void *dev, phydat_t *res)
const saul_driver_t hts221_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t hts221_saul_hum_driver = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};

View File

@ -69,18 +69,18 @@ static int read_voltage(const void *_dev, phydat_t *res)
const saul_driver_t ina2xx_saul_current_driver = {
.read = read_current,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CURRENT
};
const saul_driver_t ina2xx_saul_power_driver = {
.read = read_power,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_POWER
};
const saul_driver_t ina2xx_saul_voltage_driver = {
.read = read_voltage,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_VOLTAGE
};

View File

@ -96,7 +96,7 @@ static int read_shunt_voltage_sum(const void *dev, phydat_t *res)
return 1;
}
static int configure_channel(const void *dev, phydat_t *data)
static int configure_channel(const void *dev, const phydat_t *data)
{
ina3221_ch_t ch = (data->val[0] ? INA3221_CH1 : 0) |
(data->val[1] ? INA3221_CH2 : 0) |
@ -107,7 +107,7 @@ static int configure_channel(const void *dev, phydat_t *data)
return INA3221_NUM_CH;
}
static int configure_channel_sum(const void *dev, phydat_t *data)
static int configure_channel_sum(const void *dev, const phydat_t *data)
{
ina3221_ch_t ch = (data->val[0] ? INA3221_CH1 : 0) |
(data->val[1] ? INA3221_CH2 : 0) |

View File

@ -275,7 +275,7 @@ typedef int(*saul_read_t)(const void *dev, phydat_t *res);
* @return -ENOTSUP if the device does not support this operation
* @return -ECANCELED on other errors
*/
typedef int(*saul_write_t)(const void *dev, phydat_t *data);
typedef int(*saul_write_t)(const void *dev, const phydat_t *data);
/**
* @brief Definition of the RIOT actuator/sensor interface
@ -297,9 +297,18 @@ typedef struct {
void saul_init_devs(void);
/**
* @brief Default not supported function
* @brief Fallback function when write is not supported
*
* @details Returns `-NOTSUP` without evaluating arguments.
*/
int saul_notsup(const void *dev, phydat_t *dat);
int saul_write_notsup(const void *dev, const phydat_t *dat);
/**
* @brief Fallback function when read is not supported
*
* @details Returns `-NOTSUP` without evaluating arguments.
*/
int saul_read_notsup(const void *dev, phydat_t *dat);
/**
* @brief Helper function converts a class ID to a string

View File

@ -38,6 +38,6 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t io1_xplained_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -35,6 +35,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t isl29020_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT,
};

View File

@ -48,12 +48,12 @@ static int read_temp(const void *dev, phydat_t *res)
const saul_driver_t itg320x_saul_gyro_driver = {
.read = read_gyro,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};
const saul_driver_t itg320x_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -36,6 +36,6 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t jc42_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -33,6 +33,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t l3g4200d_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};

View File

@ -37,6 +37,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t l3gxxxx_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};

View File

@ -44,12 +44,12 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t lis2dh12_saul_driver = {
.read = read_accelerometer,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};
const saul_driver_t lis2dh12_saul_temp_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -46,6 +46,6 @@ static int read_acc(const void *dev, phydat_t *res)
const saul_driver_t lis3dh_saul_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};

View File

@ -36,6 +36,6 @@ static int read_mag(const void *dev, phydat_t *res)
const saul_driver_t lis3mdl_saul_mag_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -36,6 +36,6 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t lm75_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};

View File

@ -50,12 +50,12 @@ static int read_temp(const void *dev, phydat_t *res)
const saul_driver_t lpsxxx_saul_pres_driver = {
.read = read_pres,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS,
};
const saul_driver_t lpsxxx_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -70,12 +70,12 @@ static int read_mag(const void *dev, phydat_t *res)
const saul_driver_t lsm303dlhc_saul_acc_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};
const saul_driver_t lsm303dlhc_saul_mag_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -62,18 +62,18 @@ static int read_temp(const void *dev, phydat_t *res)
const saul_driver_t lsm6dsl_saul_acc_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};
const saul_driver_t lsm6dsl_saul_gyro_driver = {
.read = read_gyro,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};
const saul_driver_t lsm6dsl_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -56,12 +56,12 @@ static int read_current(const void *dev, phydat_t *res)
const saul_driver_t ltc4150_saul_charge_driver = {
.read = read_charge,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CHARGE
};
const saul_driver_t ltc4150_saul_current_driver = {
.read = read_current,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CURRENT
};

View File

@ -36,6 +36,6 @@ static int read_mag(const void *dev, phydat_t *res)
const saul_driver_t mag3110_saul_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -21,7 +21,7 @@
extern mcp47xx_t mcp47xx_devs[];
static int set(const void *dev, phydat_t *data)
static int set(const void *dev, const phydat_t *data)
{
const mcp47xx_saul_dac_params_t *p = (const mcp47xx_saul_dac_params_t *)dev;
mcp47xx_dac_set(&mcp47xx_devs[p->dev], p->channel, (uint16_t)data->val[0]);

View File

@ -37,6 +37,6 @@ static int read_ppm(const void *dev, phydat_t *res)
const saul_driver_t mhz19_ppm_saul_driver = {
.read = read_ppm,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CO2
};

View File

@ -36,6 +36,6 @@ static int read_acc(const void *dev, phydat_t *res)
const saul_driver_t mma7660_saul_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};

View File

@ -37,6 +37,6 @@ static int read_acc(const void *dev, phydat_t *res)
const saul_driver_t mma8x5x_saul_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};

View File

@ -59,12 +59,12 @@ static int read_temperature(const void *dev, phydat_t *res)
const saul_driver_t mpl3115a2_pressure_saul_driver = {
.read = read_pressure,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS,
};
const saul_driver_t mpl3115a2_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -66,18 +66,18 @@ static int read_mag(const void *dev, phydat_t *res)
const saul_driver_t mpu9x50_saul_acc_driver = {
.read = read_acc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ACCEL,
};
const saul_driver_t mpu9x50_saul_gyro_driver = {
.read = read_gyro,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_GYRO,
};
const saul_driver_t mpu9x50_saul_mag_driver = {
.read = read_mag,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -43,6 +43,6 @@ static int read_lux(const void *dev, phydat_t *res)
const saul_driver_t opt3001_saul_driver = {
.read = read_lux,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT,
};

View File

@ -21,7 +21,7 @@
extern pca9685_t pca9685_devs[];
static int set(const void *dev, phydat_t *data)
static int set(const void *dev, const phydat_t *data)
{
const pca9685_saul_pwm_params_t *p = (const pca9685_saul_pwm_params_t *)dev;
pca9685_pwm_set(&pca9685_devs[p->dev], p->channel, (uint16_t)data->val[0]);
@ -29,7 +29,7 @@ static int set(const void *dev, phydat_t *data)
}
const saul_driver_t pca9685_pwm_saul_driver = {
.read = saul_notsup,
.read = saul_read_notsup,
.write = set,
.type = SAUL_ACT_SERVO
};

View File

@ -33,7 +33,7 @@ static int read(const void *dev, phydat_t *res)
return 1;
}
static int write(const void *dev, phydat_t *state)
static int write(const void *dev, const phydat_t *state)
{
const pcf857x_saul_gpio_params_t *p = (const pcf857x_saul_gpio_params_t *)dev;
int inverted = (p->gpio.flags & SAUL_GPIO_INVERTED);
@ -51,7 +51,7 @@ const saul_driver_t pcf857x_gpio_out_saul_driver = {
const saul_driver_t pcf857x_gpio_in_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_BTN
};
#endif /* MODULE_SAUL_GPIO */

View File

@ -52,7 +52,7 @@ static int read_ph(const void *dev, phydat_t *res)
/* Sets the temperature compensation for taking accurate pH readings.
* Valid temperature range is 1 - 20000 (0.01 °C to 200.0 °C) */
static int set_temp_compensation(const void *dev, phydat_t *res)
static int set_temp_compensation(const void *dev, const phydat_t *res)
{
const ph_oem_t *mydev = dev;

View File

@ -38,6 +38,6 @@ static int read_occup(const void *dev, phydat_t *res) {
const saul_driver_t pir_saul_occup_driver = {
.read = read_occup,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_OCCUP,
};

View File

@ -33,7 +33,7 @@ static int read_pulse_counter(const void *dev, phydat_t *res)
return 1;
}
static int write_pulse_counter(const void *dev, phydat_t *data)
static int write_pulse_counter(const void *dev, const phydat_t *data)
{
/* Using non-const dev !! */
pulse_counter_t *mydev = (pulse_counter_t *)dev;

View File

@ -36,6 +36,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t qmc5883l_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_MAG,
};

View File

@ -37,6 +37,6 @@ static int read_adc(const void *dev, phydat_t *res)
const saul_driver_t adc_saul_driver = {
.read = read_adc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_ANALOG,
};

View File

@ -37,7 +37,7 @@ static int read(const void *dev, phydat_t *res)
return 1;
}
static int write(const void *dev, phydat_t *state)
static int write(const void *dev, const phydat_t *state)
{
const saul_gpio_params_t *p = (const saul_gpio_params_t *)dev;
int inverted = (p->flags & SAUL_GPIO_INVERTED);
@ -55,6 +55,6 @@ const saul_driver_t gpio_out_saul_driver = {
const saul_driver_t gpio_in_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_BTN
};

View File

@ -43,7 +43,7 @@ static int _read_voltage(const void *dev, phydat_t *res)
static saul_driver_t nrf_vddh_saul_driver = {
.read = _read_voltage,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_VOLTAGE,
};

View File

@ -74,7 +74,7 @@ static inline void setchan(const saul_pwm_channel_t *chan, uint16_t value)
(chan->flags & SAUL_PWM_INVERTED) ? saul_pwm_resolution - value : value);
}
static int write_dimmer(const void *dev, phydat_t *state)
static int write_dimmer(const void *dev, const phydat_t *state)
{
const saul_pwm_dimmer_params_t *p = dev;
@ -94,12 +94,12 @@ static int write_dimmer(const void *dev, phydat_t *state)
}
const saul_driver_t dimmer_saul_driver = {
.read = saul_notsup,
.read = saul_read_notsup,
.write = write_dimmer,
.type = SAUL_ACT_DIMMER
};
static int write_rgb(const void *dev, phydat_t *state)
static int write_rgb(const void *dev, const phydat_t *state)
{
const saul_pwm_rgb_params_t *p = dev;
@ -123,7 +123,7 @@ static int write_rgb(const void *dev, phydat_t *state)
}
const saul_driver_t rgb_saul_driver = {
.read = saul_notsup,
.read = saul_read_notsup,
.write = write_rgb,
.type = SAUL_ACT_LED_RGB
};

View File

@ -22,9 +22,14 @@
#include "saul.h"
int saul_notsup(const void *dev, phydat_t *dat)
int saul_write_notsup(const void *dev, const phydat_t *dat)
{
(void)dev;
(void)dat;
return -ENOTSUP;
}
/* No need to consume ROM for a second implementation, just create an
* alias symbol to saul_write_notsup */
__attribute__((alias("saul_write_notsup")))
int saul_read_notsup(const void *dev, phydat_t *dat);

View File

@ -86,18 +86,18 @@ static int _hum_read(const void *dev, phydat_t *res)
const saul_driver_t scd30_co2_saul_driver = {
.read = _co2_read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CO2,
};
const saul_driver_t scd30_temp_saul_driver = {
.read = _temp_read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t scd30_hum_saul_driver = {
.read = _hum_read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};

View File

@ -49,12 +49,12 @@ static int read_differential_pressure(const void *dev, phydat_t *res)
const saul_driver_t sdp3x_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t sdp3x_differential_pressure_saul_driver = {
.read = read_differential_pressure,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PRESS,
};

View File

@ -40,6 +40,6 @@ static int _read(const void *dev, phydat_t *res)
const saul_driver_t sds011_saul_driver = {
.read = _read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};

View File

@ -38,6 +38,6 @@ static int read_temp(const void *dev, phydat_t *res)
const saul_driver_t seesaw_soil_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};

View File

@ -54,12 +54,12 @@ static int _read_eco2(const void *dev, phydat_t *res)
const saul_driver_t sgp30_saul_driver_eco2 = {
.read = _read_eco2,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_CO2
};
const saul_driver_t sgp30_saul_driver_tvoc = {
.read = _read_tvoc,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TVOC
};

View File

@ -77,12 +77,12 @@ static int read_hum(const void *dev, phydat_t *res)
const saul_driver_t sht1x_saul_temp_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t sht1x_saul_hum_driver = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM
};

View File

@ -42,12 +42,12 @@ static int read_relative_humidity(const void *dev, phydat_t *res)
const saul_driver_t sht2x_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t sht2x_relative_humidity_saul_driver = {
.read = read_relative_humidity,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};

View File

@ -110,12 +110,12 @@ static int read_hum(const void *dev, phydat_t *data)
const saul_driver_t sht3x_saul_driver_temperature = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
const saul_driver_t sht3x_saul_driver_humidity = {
.read = read_hum,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM
};

View File

@ -45,12 +45,12 @@ static int read_relative_humidity(const void *dev, phydat_t *res)
const saul_driver_t shtcx_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t shtcx_relative_humidity_saul_driver = {
.read = read_relative_humidity,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM,
};

View File

@ -90,18 +90,18 @@ static int read_white(const void *dev, phydat_t *res)
const saul_driver_t si1133_uv_saul_driver = {
.read = read_uv,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_UV
};
const saul_driver_t si1133_ir_saul_driver = {
.read = read_ir,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};
const saul_driver_t si1133_visible_saul_driver = {
.read = read_white,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};

View File

@ -64,24 +64,24 @@ static int read_distance(const void *dev, phydat_t *res)
const saul_driver_t si114x_uv_saul_driver = {
.read = read_uv,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_UV
};
const saul_driver_t si114x_ir_saul_driver = {
.read = read_ir,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};
const saul_driver_t si114x_visible_saul_driver = {
.read = read_visible,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};
const saul_driver_t si114x_distance_saul_driver = {
.read = read_distance,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_DISTANCE
};

View File

@ -44,14 +44,14 @@ static int read_relative_humidity(const void *dev, phydat_t *res)
const saul_driver_t si70xx_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_TEMP
};
#if SI70XX_HAS_HUMIDITY_SENSOR
const saul_driver_t si70xx_relative_humidity_saul_driver = {
.read = read_relative_humidity,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_HUM
};
#endif /* SI70XX_HAS_HUMIDITY_SENSOR */

View File

@ -53,12 +53,12 @@ static int read_mc_pm_10(const void *_dev, phydat_t *data)
const saul_driver_t sm_pwm_01c_saul_driver_mc_pm_10 = {
.read = read_mc_pm_10,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM,
};
const saul_driver_t sm_pwm_01c_saul_driver_mc_pm_2p5 = {
.read = read_mc_pm_2p5,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM,
};

View File

@ -156,30 +156,30 @@ static int read_ps(const void *dev, phydat_t *data)
const saul_driver_t sps30_saul_driver_mc_pm_1_2p5_4 = {
.read = read_mc_pm_1_2p5_4,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};
const saul_driver_t sps30_saul_driver_mc_pm_10 = {
.read = read_mc_pm_10,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PM
};
const saul_driver_t sps30_saul_driver_nc_pm_0p5_1_2p5 = {
.read = read_nc_pm_0p5_1_2p5,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COUNT
};
const saul_driver_t sps30_saul_driver_nc_pm_4_10 = {
.read = read_nc_pm_4_10,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COUNT
};
const saul_driver_t sps30_saul_driver_ps = {
.read = read_ps,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_SIZE
};

View File

@ -40,6 +40,6 @@ static int read(const void *dev, phydat_t *res)
const saul_driver_t tcs37727_saul_driver = {
.read = read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_COLOR,
};

View File

@ -44,6 +44,6 @@ static int read_temp(const void *dev, phydat_t *res)
const saul_driver_t tmp00x_saul_driver = {
.read = read_temp,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_OBJTEMP,
};

View File

@ -32,6 +32,6 @@ static int read_illuminance(const void *dev, phydat_t *res)
const saul_driver_t tsl2561_illuminance_saul_driver = {
.read = read_illuminance,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};

View File

@ -35,6 +35,6 @@ static int _read(const void *dev, phydat_t *data)
const saul_driver_t tsl4531x_saul_driver = {
.read = _read,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};

View File

@ -47,12 +47,12 @@ static int read_illuminance(const void *dev, phydat_t *res)
const saul_driver_t vcnl40x0_proximity_saul_driver = {
.read = read_proximity,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_PROXIMITY
};
const saul_driver_t vcnl40x0_illuminance_saul_driver = {
.read = read_illuminance,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_LIGHT
};

View File

@ -33,6 +33,6 @@ static int read_uv(const void *dev, phydat_t *res)
const saul_driver_t veml6070_uv_saul_driver = {
.read = read_uv,
.write = saul_notsup,
.write = saul_write_notsup,
.type = SAUL_SENSE_UV
};

View File

@ -134,7 +134,7 @@ int saul_reg_read(saul_reg_t *dev, phydat_t *res);
* @return -ENOTSUP if read operation is not supported by the device
* @return -ECANCELED on device errors
*/
int saul_reg_write(saul_reg_t *dev, phydat_t *data);
int saul_reg_write(saul_reg_t *dev, const phydat_t *data);
#ifdef __cplusplus
}

View File

@ -110,7 +110,7 @@ int saul_reg_read(saul_reg_t *dev, phydat_t *res)
return dev->driver->read(dev->dev, res);
}
int saul_reg_write(saul_reg_t *dev, phydat_t *data)
int saul_reg_write(saul_reg_t *dev, const phydat_t *data)
{
if (dev == NULL) {
return -ENODEV;