Fixed remainders and resistance units
authorTom Knot <tomasknot@gmail.com>
Wed, 4 Jul 2018 13:20:24 +0000 (15:20 +0200)
committerTom Knot <tomasknot@gmail.com>
Wed, 4 Jul 2018 13:20:24 +0000 (15:20 +0200)
modules/unipi/src/unipi_iio.c
modules/unipi/src/unipi_spi.c
version.txt

index d82a72926b3be7dccca21d838389685ad7b88ed8..901708c7a0c9c32ef12c53865db0bfefe58e8a00 100644 (file)
@@ -64,7 +64,7 @@ int neuronspi_iio_stm_ao_read_raw(struct iio_dev *indio_dev, struct iio_chan_spe
        case 3: {
                if (ch->type == IIO_RESISTANCE) {
                        neuronspi_spi_iio_stm_ao_read_resistance(indio_dev, ch, val, val2, mask);
-                       return IIO_VAL_INT;
+                       return IIO_VAL_FRACTIONAL;
                } else {
                        return -EINVAL;
                }
index 11b8c1279f3eced99241f8da58e6466a73c78b6a..478eb6612873684a5c604122a4d74238b0cddbe1 100644 (file)
@@ -610,6 +610,7 @@ void neuronspi_spi_iio_stm_ao_set_voltage(struct iio_dev *indio_dev, struct iio_
        u32 stm_v_err = 0;
        u32 stm_v_off = 0;
        u64 stm_true_val = val;
+       u64 stm_true_val_fraction = val2;
        u64 stm_true_ref = 0;
        regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_int, &stm_v_int_ref);
        regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_inp, &stm_v_inp_ref);
@@ -617,7 +618,7 @@ void neuronspi_spi_iio_stm_ao_set_voltage(struct iio_dev *indio_dev, struct iio_
        regmap_read(n_spi->reg_map, n_spi->regstart_table->stm_ao_vol_off, &stm_v_off);
        stm_true_ref = ((u64)stm_v_int_ref) * (99000 + stm_v_err) * 1000;
        stm_v_inp_ref = stm_v_inp_ref * 10000;
-       stm_true_val = ((stm_true_val * 10000) - stm_v_off) * 4095;
+       stm_true_val = ((stm_true_val * 10000) + (stm_true_val_fraction / 100) - stm_v_off) * 4095;
        do_div(stm_true_ref, stm_v_inp_ref);
        stm_v_inp_ref = stm_true_ref;
        do_div(stm_true_val, stm_v_inp_ref);
@@ -636,15 +637,15 @@ void neuronspi_spi_iio_stm_ao_set_current(struct iio_dev *indio_dev, struct iio_
        u32 stm_i_err = 0;
        u32 stm_i_off = 0;
        u64 stm_true_val = val;
+       u64 stm_true_val_fraction = val2;
        u64 stm_true_ref = 0;
        regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_int, &stm_v_int_ref);
        regmap_read(n_spi->reg_map, n_spi->regstart_table->vref_inp, &stm_v_inp_ref);
        regmap_read(n_spi->reg_map, n_spi->regstart_table->stm_ao_curr_err, &stm_i_err);
        regmap_read(n_spi->reg_map, n_spi->regstart_table->stm_ao_curr_off, &stm_i_off);
-       printk(KERN_INFO "NEURONSPI: Val2: %d\n", val2);
        stm_true_ref = ((u64)stm_v_int_ref) * (330000 + stm_i_err) * 100;
        stm_v_inp_ref = stm_v_inp_ref * 1000;
-       stm_true_val = ((stm_true_val * 10000) - stm_i_off) * 4095;
+       stm_true_val = (((stm_true_val * 10000) + (stm_true_val_fraction / 100)) - stm_i_off) * 4095;
        do_div(stm_true_ref, stm_v_inp_ref);
        stm_v_inp_ref = stm_true_ref;
        do_div(stm_true_val, stm_v_inp_ref);
index e962b57551ba39fb8e91cba486f159ecd0c55f68..c28bd162d455de3f9092cce3ff25f6ce4530c071 100644 (file)
@@ -1 +1 @@
-Repository:neuron-kernel ActiveBranch:[uart_timeout] PrecedingRelease:v.0.12 PrecedingRevision:83(ad90589) LatestCommit:Wed Jul 4 15:15:04 CEST 2018
+Repository:neuron-kernel ActiveBranch:[uart_timeout] PrecedingRelease:v.0.12 PrecedingRevision:84(3027140) LatestCommit:Wed Jul 4 15:20:25 CEST 2018