X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fdmm%2Ffs9922.c;h=51d3c654dbc7aa7ed9e7efcc2949397699c4f404;hb=0d4405ce5e9373d2dcd90a9188b79d79eaafae5d;hp=fced8f593ae59fc3ef798790a99376be395691e7;hpb=649a4cd672e5ea14707c4591dd0426fdd87ddd5a;p=libsigrok.git diff --git a/hardware/common/dmm/fs9922.c b/hardware/common/dmm/fs9922.c index fced8f59..51d3c654 100644 --- a/hardware/common/dmm/fs9922.c +++ b/hardware/common/dmm/fs9922.c @@ -29,14 +29,14 @@ #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with driver-specific prefix string. */ -#define DRIVER_LOG_DOMAIN "fs9922: " -#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) -#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) -#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) -#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) -#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) -#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) +/* Message logging helpers with subsystem-specific prefix string. */ +#define LOG_PREFIX "fs9922: " +#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) +#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args) +#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args) +#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args) +#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) +#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) static gboolean flags_valid(const struct fs9922_info *info) { @@ -194,7 +194,7 @@ static void parse_flags(const uint8_t *buf, struct fs9922_info *info) info->is_beep = (buf[9] & (1 << 3)) != 0; info->is_diode = (buf[9] & (1 << 2)) != 0; info->is_percent = (buf[9] & (1 << 1)) != 0; - info->is_z4 = (buf[8] & (1 << 0)) != 0; /* User symbol 4 */ + info->is_z4 = (buf[9] & (1 << 0)) != 0; /* User symbol 4 */ /* Byte 10 */ info->is_volt = (buf[10] & (1 << 7)) != 0; @@ -279,7 +279,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval, if (info->is_beep) { analog->mq = SR_MQ_CONTINUITY; analog->unit = SR_UNIT_BOOLEAN; - *floatval = (*floatval < 0.0) ? 0.0 : 1.0; + *floatval = (*floatval == INFINITY) ? 0.0 : 1.0; } if (info->is_percent) { analog->mq = SR_MQ_DUTY_CYCLE; @@ -293,6 +293,8 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval, analog->mqflags |= SR_MQFLAG_DC; if (info->is_auto) analog->mqflags |= SR_MQFLAG_AUTORANGE; + if (info->is_diode) + analog->mqflags |= SR_MQFLAG_DIODE; if (info->is_hold) analog->mqflags |= SR_MQFLAG_HOLD; if (info->is_max) @@ -373,3 +375,17 @@ SR_PRIV int sr_fs9922_parse(const uint8_t *buf, float *floatval, return SR_OK; } + +SR_PRIV void sr_fs9922_z1_diode(struct sr_datafeed_analog *analog, void *info) +{ + struct fs9922_info *info_local; + + info_local = (struct fs9922_info *)info; + + /* User-defined z1 flag means "diode mode". */ + if (info_local->is_z1) { + analog->mq = SR_MQ_VOLTAGE; + analog->unit = SR_UNIT_VOLT; + analog->mqflags |= SR_MQFLAG_DIODE; + } +}