/* Temperature threshold error, we don't handle this yet */ if (event == 0) return;
chan = xadc_event_to_channel(indio_dev, event);
if (chan->type == IIO_TEMP) { /* * The temperature channel only supports over-temperature * events.
*/
iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(chan->type, chan->channel,
IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
iio_get_time_ns(indio_dev));
} else { /* * For other channels we don't know whether it is a upper or * lower threshold event. Userspace will have to check the * channel value if it wants to know.
*/
iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(chan->type, chan->channel,
IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER),
iio_get_time_ns(indio_dev));
}
}
staticunsignedint xadc_get_alarm_mask(conststruct iio_chan_spec *chan)
{ if (chan->type == IIO_TEMP) return XADC_ALARM_OT_MASK; switch (chan->channel) { case 0: return XADC_ALARM_VCCINT_MASK; case 1: return XADC_ALARM_VCCAUX_MASK; case 2: return XADC_ALARM_VCCBRAM_MASK; case 3: return XADC_ALARM_VCCPINT_MASK; case 4: return XADC_ALARM_VCCPAUX_MASK; case 5: return XADC_ALARM_VCCODDR_MASK; default: /* We will never get here */ return 0;
}
}
int xadc_write_event_value(struct iio_dev *indio_dev, conststruct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, enum iio_event_info info, int val, int val2)
{ unsignedint offset = xadc_get_threshold_offset(chan, dir); struct xadc *xadc = iio_priv(indio_dev); int ret = 0;
/* MSB aligned */
val <<= 16 - chan->scan_type.realbits;
if (val < 0 || val > 0xffff) return -EINVAL;
mutex_lock(&xadc->mutex);
switch (info) { case IIO_EV_INFO_VALUE:
xadc->threshold[offset] = val; break; case IIO_EV_INFO_HYSTERESIS:
xadc->temp_hysteresis = val; break; default:
mutex_unlock(&xadc->mutex); return -EINVAL;
}
if (chan->type == IIO_TEMP) { /* * According to the datasheet we need to set the lower 4 bits to * 0x3, otherwise 125 degree celsius will be used as the * threshold.
*/
val |= 0x3;
/* * Since we store the hysteresis as relative (to the threshold) * value, but the hardware expects an absolute value we need to * recalculate this value whenever the hysteresis or the * threshold changes.
*/ if (xadc->threshold[offset] < xadc->temp_hysteresis)
xadc->threshold[offset + 4] = 0; else
xadc->threshold[offset + 4] = xadc->threshold[offset] -
xadc->temp_hysteresis;
ret = _xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(offset + 4),
xadc->threshold[offset + 4]); if (ret) goto out_unlock;
}
if (info == IIO_EV_INFO_VALUE)
ret = _xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(offset), val);
out_unlock:
mutex_unlock(&xadc->mutex);
return ret;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.