]> sigrok.org Git - libsigrok.git/commitdiff
fs9721: Factor out common code from serial-dmm.
authorUwe Hermann <redacted>
Wed, 1 May 2013 00:10:56 +0000 (02:10 +0200)
committerUwe Hermann <redacted>
Wed, 1 May 2013 00:16:55 +0000 (02:16 +0200)
These functions are FS9721 specific (and DMM specific), and can be used
from various drivers (e.g. serial-dmm or uni-t-dmm or possibly others).

hardware/common/dmm/fs9721.c
hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.c
hardware/uni-t-dmm/api.c
libsigrok-internal.h

index a914add8f414a26db59e90adb38d031d9519fd96..17a03a62647faf068dc577e91b2306b6fffd2868 100644 (file)
@@ -369,7 +369,7 @@ SR_PRIV int sr_fs9721_parse(const uint8_t *buf, float *floatval,
        return SR_OK;
 }
 
-SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *analog, void *info)
+SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info)
 {
        struct fs9721_info *info_local;
 
@@ -381,3 +381,48 @@ SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *a
                analog->unit = SR_UNIT_CELSIUS;
        }
 }
+
+SR_PRIV void sr_fs9721_01_temp_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (C). */
+       if (info_local->is_c2c1_01) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
+
+SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
+       if (info_local->is_c2c1_10) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
+
+SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *info)
+{
+       struct fs9721_info *info_local;
+
+       info_local = (struct fs9721_info *)info;
+
+       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (F). */
+       if (info_local->is_c2c1_01) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_FAHRENHEIT;
+       }
+
+       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
+       if (info_local->is_c2c1_10) {
+               analog->mq = SR_MQ_TEMPERATURE;
+               analog->unit = SR_UNIT_CELSIUS;
+       }
+}
index c0eeba04cc9b5e6c7123ecac0ac52c25b42d7293..e950c303b15cda52b0bb6368901fedc9091cc608 100644 (file)
@@ -63,14 +63,14 @@ SR_PRIV struct dmm_info dmms[] = {
                "Digitek", "DT4000ZC", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               dmm_details_dt4000zc,
+               sr_fs9721_10_temp_c,
                &digitek_dt4000zc_driver_info, receive_data_DIGITEK_DT4000ZC,
        },
        {
                "TekPower", "TP4000ZC", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               dmm_details_tp4000zc,
+               sr_fs9721_10_temp_c,
                &tekpower_tp4000zc_driver_info, receive_data_TEKPOWER_TP4000ZC,
        },
        {
@@ -98,7 +98,7 @@ SR_PRIV struct dmm_info dmms[] = {
                "V&A", "VA18B", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               dmm_details_va18b,
+               sr_fs9721_01_temp_c,
                &va_va18b_driver_info, receive_data_VA_VA18B,
        },
        {
@@ -119,7 +119,7 @@ SR_PRIV struct dmm_info dmms[] = {
                "PCE", "PCE-DM32", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               dmm_details_pce_dm32,
+               sr_fs9721_01_10_temp_f_c,
                &pce_pce_dm32_driver_info, receive_data_PCE_PCE_DM32,
        },
        {
@@ -155,7 +155,7 @@ SR_PRIV struct dmm_info dmms[] = {
                "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
                2400, FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               sr_fs9721_details_c2c1_00_temp_celsius,
+               sr_fs9721_00_temp_c,
                &voltcraft_vc840_ser_driver_info,
                receive_data_VOLTCRAFT_VC840_SER,
        },
index 6e69758667922cf17129f376571988348f8b940b..a21d2472a9cbd19228ca0989e07dfa5e65d141ea 100644 (file)
@@ -35,56 +35,6 @@ static void log_dmm_packet(const uint8_t *buf)
               buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]);
 }
 
-SR_PRIV void dmm_details_dt4000zc(struct sr_datafeed_analog *analog, void *info)
-{
-       dmm_details_tp4000zc(analog, info); /* Same as TP4000ZC. */
-}
-
-SR_PRIV void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info)
-{
-       struct fs9721_info *info_local;
-
-       info_local = (struct fs9721_info *)info;
-
-       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
-       if (info_local->is_c2c1_10) {
-               analog->mq = SR_MQ_TEMPERATURE;
-               analog->unit = SR_UNIT_CELSIUS;
-       }
-}
-
-SR_PRIV void dmm_details_va18b(struct sr_datafeed_analog *analog, void *info)
-{
-       struct fs9721_info *info_local;
-
-       info_local = (struct fs9721_info *)info;
-
-       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (C). */
-       if (info_local->is_c2c1_01) {
-               analog->mq = SR_MQ_TEMPERATURE;
-               analog->unit = SR_UNIT_CELSIUS;
-       }
-}
-
-SR_PRIV void dmm_details_pce_dm32(struct sr_datafeed_analog *analog, void *info)
-{
-       struct fs9721_info *info_local;
-
-       info_local = (struct fs9721_info *)info;
-
-       /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature (F). */
-       if (info_local->is_c2c1_01) {
-               analog->mq = SR_MQ_TEMPERATURE;
-               analog->unit = SR_UNIT_FAHRENHEIT;
-       }
-
-       /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */
-       if (info_local->is_c2c1_10) {
-               analog->mq = SR_MQ_TEMPERATURE;
-               analog->unit = SR_UNIT_CELSIUS;
-       }
-}
-
 static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
                          int dmm, void *info)
 {
index 1e8a621ccc59cf6b9ce51d909196ee15334c497b..4e8fe349fdaf9238231e96707d7e7288fcc5a406 100644 (file)
@@ -68,7 +68,7 @@ SR_PRIV struct dmm_info udmms[] = {
                "Voltcraft", "VC-840", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
-               sr_fs9721_details_c2c1_00_temp_celsius,
+               sr_fs9721_00_temp_c,
                &voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840,
        },
 };
index 4396cc1590be97d25afa7469ab97cca06e145300..57005cd2d04fa1b39bb622ca4bc32d5d33f42ee5 100644 (file)
@@ -228,7 +228,10 @@ struct fs9721_info {
 SR_PRIV gboolean sr_fs9721_packet_valid(const uint8_t *buf);
 SR_PRIV int sr_fs9721_parse(const uint8_t *buf, float *floatval,
                            struct sr_datafeed_analog *analog, void *info);
-SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void sr_fs9721_01_temp_c(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *info);
 
 /*--- hardware/common/dmm/metex14.c -----------------------------------------*/