From a42a9add2ac33cc050265313f4631b56251d5d30 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:14:53 -0500 Subject: [PATCH 01/17] Updated icb_strings.c to use stdint.h --- mcaApp/CanberraSrc/icb_strings.c | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_strings.c b/mcaApp/CanberraSrc/icb_strings.c index 80d1fcf6..42774ddf 100644 --- a/mcaApp/CanberraSrc/icb_strings.c +++ b/mcaApp/CanberraSrc/icb_strings.c @@ -1,7 +1,7 @@ #include #include #include -#include "ndtypes.h" +#include #define OK 0 @@ -17,17 +17,17 @@ * * "status" is the status of the operation. Any errors have been signaled. * -* "str" (CHAR *) the destination zero terminated string. +* "str" (int8_t *) the destination zero terminated string. * * "dsc" (struct dsc$descriptor *) is the source descriptor * -* "str" (LONG) is the max length of the string. +* "str" (int32_t) is the max length of the string. * *******************************************************************************/ -int icb_dsc2str (CHAR *str, - CHAR *dsc, - LONG max_len) +int icb_dsc2str (int8_t *str, + int8_t *dsc, + int32_t max_len) { /* @@ -55,12 +55,12 @@ int icb_dsc2str (CHAR *str, * * "dsc" (struct dsc$descriptor *) is the destination descriptor * -* "str" (CHAR *) the source zero terminated string. +* "str" (int8_t *) the source zero terminated string. * *******************************************************************************/ -int icb_str2dsc (CHAR *dsc, - CHAR *str) +int icb_str2dsc (int8_t *dsc, + int8_t *str) { /* @@ -94,19 +94,19 @@ int icb_str2dsc (CHAR *dsc, * * "status" is the status of the operation. != 0 if strings are the same * -* "s1" (CHAR *) string 1 +* "s1" (int8_t *) string 1 * -* "s2" (CHAR *) string 2 +* "s2" (int8_t *) string 2 * * "len" (int) Length of strings to compare * *******************************************************************************/ -int StrNCmp (CHAR *s1, - CHAR *s2, +int StrNCmp (int8_t *s1, + int8_t *s2, int len) { - LONG i; + int32_t i; if (strlen(s1) < len) len = strlen(s1); if (strlen(s2) < len) len = strlen(s2); @@ -128,19 +128,19 @@ int StrNCmp (CHAR *s1, * * "status" is the status of the operation. * -* "dst" (CHAR *) destination string +* "dst" (int8_t *) destination string * -* "src" (CHAR *) source string +* "src" (int8_t *) source string * * "len" (int) Maximum length * *******************************************************************************/ -int StrUpCase (CHAR *dst, - CHAR *src, +int StrUpCase (int8_t *dst, + int8_t *src, int len) { - LONG i; + int32_t i; if (strlen(src) < len) len = strlen(src); strncpy(dst, src, len); @@ -163,9 +163,9 @@ int StrUpCase (CHAR *dst, * * "status" is the status of the operation. * -* "dst" (CHAR *) destination string +* "dst" (int8_t *) destination string * -* "src" (CHAR *) source string +* "src" (int8_t *) source string * * "len" (int) Maximum length * @@ -173,12 +173,12 @@ int StrUpCase (CHAR *dst, * *******************************************************************************/ -int StrTrim (CHAR *dst, - CHAR *src, +int StrTrim (int8_t *dst, + int8_t *src, int len, int *trim_len) { - LONG i; + int32_t i; if (strlen(src) < len) len = strlen(src); *trim_len = 0; From bd2572cc6207fa4c407ea3c6faba3d581cc6bd64 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:16:44 -0500 Subject: [PATCH 02/17] icb_user_subs.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_user_subs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_user_subs.c b/mcaApp/CanberraSrc/icb_user_subs.c index 24a37c3e..8a7167e1 100644 --- a/mcaApp/CanberraSrc/icb_user_subs.c +++ b/mcaApp/CanberraSrc/icb_user_subs.c @@ -10,7 +10,6 @@ #include #include -#include "ndtypes.h" #include "nmc_sys_defs.h" #include "mcamsgdef.h" #include "icb_user_subs.h" From 485cbfb631fbb152e0da66cd2256463c16d7f637 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:18:25 -0500 Subject: [PATCH 03/17] icb_show_modules.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_show_modules.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_show_modules.c b/mcaApp/CanberraSrc/icb_show_modules.c index 1fcc3a59..ba2eaa32 100644 --- a/mcaApp/CanberraSrc/icb_show_modules.c +++ b/mcaApp/CanberraSrc/icb_show_modules.c @@ -12,7 +12,6 @@ #define ICB_DEFINE_NAMES 1 #include -#include "ndtypes.h" #include "icb_sys_defs.h" #include "icb_bus_defs.h" #include "nmc_sys_defs.h" From 1dfdf210cc76bce06be1f27de83cc0536566dadd Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:18:56 -0500 Subject: [PATCH 04/17] icb_read_regs.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_read_regs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_read_regs.c b/mcaApp/CanberraSrc/icb_read_regs.c index db2a24ce..3d3f3d3d 100644 --- a/mcaApp/CanberraSrc/icb_read_regs.c +++ b/mcaApp/CanberraSrc/icb_read_regs.c @@ -1,5 +1,4 @@ #include -#include "ndtypes.h" #include "icb_sys_defs.h" #include "campardef.h" From c757d33047253b06cddc354d80e905a4b0c1bfa6 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:35:09 -0500 Subject: [PATCH 05/17] Updated icb_handler_subs.c to use stdint.h --- mcaApp/CanberraSrc/icb_handler_subs.c | 658 +++++++++++++------------- 1 file changed, 329 insertions(+), 329 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_handler_subs.c b/mcaApp/CanberraSrc/icb_handler_subs.c index 83464415..72088850 100644 --- a/mcaApp/CanberraSrc/icb_handler_subs.c +++ b/mcaApp/CanberraSrc/icb_handler_subs.c @@ -77,7 +77,7 @@ #include #include #include -#include "ndtypes.h" +#include #include "icb_sys_defs.h" #include "icb_bus_defs.h" #include "nmc_sys_defs.h" @@ -94,18 +94,18 @@ extern struct nmc_module_info_struct *nmc_module_info; /* pointer to networked m /* the setting the ASTF_CCERR flag. */ /*-------------------------------------------------------*/ -LONG hvps_ccerr_vbits = CAM_M_HVPSVF_VOLT | CAM_M_HVPSVF_OVLE | +int32_t hvps_ccerr_vbits = CAM_M_HVPSVF_VOLT | CAM_M_HVPSVF_OVLE | CAM_M_HVPSVF_INHLE | CAM_M_HVPSVF_LVINH | CAM_M_HVPSVF_STAT; -LONG adc_ccerr_vbits = CAM_M_ADCVF_RANGE | CAM_M_ADCVF_OFFSET | +int32_t adc_ccerr_vbits = CAM_M_ADCVF_RANGE | CAM_M_ADCVF_OFFSET | CAM_M_ADCVF_ACQMODE | CAM_M_ADCVF_CNVGAIN | CAM_M_ADCVF_LLD | CAM_M_ADCVF_ULD | CAM_M_ADCVF_ZERO | CAM_M_ADCVF_ANTIC | CAM_M_ADCVF_LATEC | CAM_M_ADCVF_DELPK | CAM_M_ADCVF_NONOV | CAM_M_ADCVF_LTCPUR; -LONG amp_ccerr_vbits = CAM_M_AMPVF_PRAMPT | CAM_M_AMPVF_HWGAIN1 | +int32_t amp_ccerr_vbits = CAM_M_AMPVF_PRAMPT | CAM_M_AMPVF_HWGAIN1 | CAM_M_AMPVF_HWGAIN3 | CAM_M_AMPVF_SHAPEM | CAM_M_AMPVF_BLRTYPE | CAM_M_AMPVF_DTCTYPE | CAM_M_AMPVF_DIFF | CAM_M_AMPVF_NEGPOL | @@ -159,7 +159,7 @@ static ICB_PARAM_LIST hvps_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static LONG hvps_flag_bits[] = { +static int32_t hvps_flag_bits[] = { CAM_M_HVPSF_OVLE, CAM_M_HVPSF_INHLE, CAM_M_HVPSF_LVINH, @@ -183,7 +183,7 @@ static LONG hvps_flag_bits[] = { /* "ICB 9645",*/ /* 0};*/ -/*static LONG hvps_types_int[] = {*/ +/*static int32_t hvps_types_int[] = {*/ /* ICB_K_MTYPE_CI9641,*/ /* 2000 Volt supply */ /* ICB_K_MTYPE_CI9645,*/ /* 6000 Volt supply */ /* 0};*/ /* End of list */ @@ -225,7 +225,7 @@ static ICB_PARAM_LIST adc_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static LONG adc_flag_bits[] = { +static int32_t adc_flag_bits[] = { CAM_M_ADCF_ANTIC, CAM_M_ADCF_LATEC, CAM_M_ADCF_DELPK, @@ -244,7 +244,7 @@ static LONG adc_flag_bits[] = { /* "ICB 9635",*/ /* 0};*/ -/*static LONG adc_types_int[] = {*/ +/*static int32_t adc_types_int[] = {*/ /* ICB_K_MTYPE_CI9633,*/ /* 16K chan ADC */ /* ICB_K_MTYPE_CI9635,*/ /* 8K chan ADC */ /* 0};*/ /* End of list */ @@ -290,7 +290,7 @@ static ICB_PARAM_LIST amp_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static LONG amp_flag_bits[] = { +static int32_t amp_flag_bits[] = { CAM_M_AMPF_DIFF, CAM_M_AMPF_NEGPOL, CAM_M_AMPF_COMPINH, @@ -311,7 +311,7 @@ static LONG amp_flag_bits[] = { /* "ICB 9615",*/ /* 0};*/ -/*static LONG amp_types_int[] = {*/ +/*static int32_t amp_types_int[] = {*/ /* ICB_K_MTYPE_CI9615,*/ /* Standard Amp */ /* 0};*/ /* End of list */ @@ -322,8 +322,8 @@ static LONG amp_flag_bits[] = { /*------------------------------------------------*/ static struct { - REAL real_val; - LONG dac_val; + float real_val; + int32_t dac_val; } amp_hwgain1_tbl[] = {{500.0, 0x0F}, {250.0, 0x0D}, {100.0, 0x0B}, @@ -333,7 +333,7 @@ static struct { { 5.0, 0x01}, { 2.5, 0x00}}; -static REAL amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; +static float amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; /******************************************************************************* @@ -353,7 +353,7 @@ static REAL amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; /* hvps_flag_list, NULL};*/ -/*static LONG (*icb_hdlr_summary[])() = {icb_adc_hdlr,*/ +/*static int32_t (*icb_hdlr_summary[])() = {icb_adc_hdlr,*/ /* icb_amp_hdlr,*/ /* icb_hvps_hdlr, NULL};*/ @@ -363,7 +363,7 @@ static REAL amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; * (rather than the cache) during a read operation. */ -static LONG icb_req_read_plist[] = {CAM_L_HVPSFPOL, +static int32_t icb_req_read_plist[] = {CAM_L_HVPSFPOL, CAM_L_HVPSFOV, CAM_L_HVPSFINH, CAM_L_HVPSFSTAT, @@ -402,17 +402,17 @@ static LONG icb_req_read_plist[] = {CAM_L_HVPSFPOL, * *******************************************************************************/ -LONG icb_hvps_hdlr (LONG index, +int32_t icb_hvps_hdlr (int32_t index, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG s; + int32_t s; ICB_CCNIM_HVPS *hvps; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - LONG reset; - LONG present; + int32_t reset; + int32_t present; /* * First make sure that the module exists and is the correct type. @@ -506,17 +506,17 @@ LONG icb_hvps_hdlr (LONG index, * *******************************************************************************/ -LONG icb_adc_hdlr (LONG index, +int32_t icb_adc_hdlr (int32_t index, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG s; + int32_t s; ICB_CCNIM_ADC *adc; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - LONG reset; - LONG present; + int32_t reset; + int32_t present; /* * First make sure that the module exists and is the correct type. @@ -606,17 +606,17 @@ LONG icb_adc_hdlr (LONG index, * *******************************************************************************/ -LONG icb_amp_hdlr (LONG index, +int32_t icb_amp_hdlr (int32_t index, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG s; + int32_t s; ICB_CCNIM_AMP *amp; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - LONG reset; - LONG present; + int32_t reset; + int32_t present; /* * First make sure that the module exists and is the correct type. @@ -706,18 +706,18 @@ LONG icb_amp_hdlr (LONG index, * *******************************************************************************/ -int icb_validate_module (LONG index, +int icb_validate_module (int32_t index, ICB_PARAM_LIST *params, - LONG *present, - LONG *reset, - LONG flags) + int32_t *present, + int32_t *reset, + int32_t flags) { - LONG i, j; - LONG s; + int32_t i, j; + int32_t s; ICB_MODULE_INFO *entry; - UCHAR register_list[16]; - LONG do_read; + uint8_t register_list[16]; + int32_t do_read; ICB_CCNIM_ANY *ccany; /* @@ -827,11 +827,11 @@ int icb_validate_module (LONG index, * *******************************************************************************/ -int icb_init_ccnim_cache (LONG index, - LONG flags) +int icb_init_ccnim_cache (int32_t index, + int32_t flags) { - LONG i, j; + int32_t i, j; ICB_MODULE_INFO *entry; ICB_CCNIM_ANY *ccany; ICB_PARAM_LIST *plist=NULL, *flist=NULL; @@ -923,8 +923,8 @@ int icb_init_ccnim_cache (LONG index, ICB_PARAM_LIST *icb_build_cached_plist (ICB_CCNIM_ANY *ccany) { - LONG i, j; - LONG pcount = 0; + int32_t i, j; + int32_t pcount = 0; ICB_PARAM_LIST *plist; /* @@ -982,7 +982,7 @@ int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, ICB_PARAM_LIST *params) { - LONG i, j; + int32_t i, j; /* * For each parameter, find it's entry (if any) in the cached parameter @@ -1022,21 +1022,21 @@ int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, * *******************************************************************************/ -LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, +int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG i; - LONG s=OK; - LONG index; - ULONG fbits; + int32_t i; + int32_t s=OK; + int32_t index; + uint32_t fbits; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - LONG *flag_vals; - UCHAR reg_val; - LONG local_flags; - REAL level; + int32_t *flag_vals; + uint8_t reg_val; + int32_t local_flags; + float level; ICB_PARAM_LIST *params_start; /* @@ -1069,7 +1069,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Make sure the new value is valid */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->voltage = *((REAL *) params->value); + hvps->voltage = *((float *) params->value); if (hvps->voltage > hvps->voltlim) hvps->voltage = hvps->voltlim; @@ -1113,7 +1113,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Make sure the new value is valid */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->voltlim = *((REAL *) params->value); + hvps->voltlim = *((float *) params->value); if (hvps->voltlim > hvps->abs_voltlim) hvps->voltlim = hvps->abs_voltlim; @@ -1127,11 +1127,11 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (hvps_flag_list)); - flag_vals = (LONG *) malloc (sizeof (hvps_flag_bits)); + flag_vals = (int32_t *) malloc (sizeof (hvps_flag_bits)); memcpy (flag_list, hvps_flag_list, sizeof (hvps_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((LONG *) params->value); + fbits = *((int32_t *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((hvps_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -1153,7 +1153,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the overload latch enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.ovle = *((LONG *) params->value); + hvps->flags.bit.ovle = *((int32_t *) params->value); if (!entry) break; if (hvps->flags.bit.ovle) @@ -1173,7 +1173,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the inhibit latch enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.inhle = *((LONG *) params->value); + hvps->flags.bit.inhle = *((int32_t *) params->value); if (!entry) break; if (hvps->flags.bit.inhle) @@ -1193,7 +1193,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the 12V level inhibit enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.lvinh = *((LONG *) params->value); + hvps->flags.bit.lvinh = *((int32_t *) params->value); if (!entry) break; if (hvps->flags.bit.lvinh) @@ -1211,7 +1211,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.pol = *((LONG *) params->value); + hvps->flags.bit.pol = *((int32_t *) params->value); break; /*------------------------------*/ @@ -1221,7 +1221,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the On/Off bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.stat = *((LONG *) params->value); + hvps->flags.bit.stat = *((int32_t *) params->value); if (!entry) break; /* If module is being turned off, terminate the ramp process */ @@ -1277,7 +1277,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*-----------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - if (*((LONG *) params->value) == 0) break; + if (*((int32_t *) params->value) == 0) break; /* Reset the HVPS */ @@ -1291,7 +1291,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*-----------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.fastramp = *((LONG *) params->value); + hvps->flags.bit.fastramp = *((int32_t *) params->value); break; /*------------------------------*/ @@ -1299,7 +1299,7 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.atten = *((LONG *) params->value); + hvps->flags.bit.atten = *((int32_t *) params->value); if (!entry) break; if (hvps->flags.bit.atten) @@ -1359,14 +1359,14 @@ LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, +int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG i; - ULONG reg; - LONG index; + int32_t i; + uint32_t reg; + int32_t index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -1397,7 +1397,7 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, case CAM_F_VOLTAGE: /* Voltage */ /*------------------------------*/ - *((REAL *) params->value) = hvps->voltage; + *((float *) params->value) = hvps->voltage; break; /*------------------------------*/ @@ -1405,35 +1405,35 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ - *((REAL *) params->value) = hvps->voltlim; + *((float *) params->value) = hvps->voltlim; break; /*------------------------------*/ case CAM_L_HVPSFLAGS: /* Flags field */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.lword; + *((uint32_t *) params->value) = hvps->flags.lword; break; /*------------------------------*/ case CAM_L_HVPSFOVLE: /* Overload latch enable */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.ovle; + *((uint32_t *) params->value) = hvps->flags.bit.ovle; break; /*------------------------------*/ case CAM_L_HVPSFINHLE: /* Inhibit latch enable */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.inhle; + *((uint32_t *) params->value) = hvps->flags.bit.inhle; break; /*------------------------------*/ case CAM_L_HVPSFLVINH: /* 5v/12v inhibit */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.lvinh; + *((uint32_t *) params->value) = hvps->flags.bit.lvinh; break; /*------------------------------*/ @@ -1441,12 +1441,12 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (!entry) { - *((ULONG *) params->value) = hvps->flags.bit.pol; + *((uint32_t *) params->value) = hvps->flags.bit.pol; break; } - reg = ((ULONG) entry->registers[1]); - *((ULONG *) params->value) = i = ((reg & HVPS_M_R3_POLARITY_NEG) != 0); + reg = ((uint32_t) entry->registers[1]); + *((uint32_t *) params->value) = i = ((reg & HVPS_M_R3_POLARITY_NEG) != 0); if (i != hvps->flags.bit.pol) { hvps->flags.bit.pol = i; @@ -1459,10 +1459,10 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (entry) { - reg = ((ULONG) entry->registers[1]); + reg = ((uint32_t) entry->registers[1]); hvps->flags.bit.inh = ((reg & HVPS_M_R3_INHIBIT) == 0); } - *((ULONG *) params->value) = hvps->flags.bit.inh; + *((uint32_t *) params->value) = hvps->flags.bit.inh; break; /*------------------------------*/ @@ -1470,10 +1470,10 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (entry) { - reg = ((ULONG) entry->registers[1]); + reg = ((uint32_t) entry->registers[1]); hvps->flags.bit.ov = ((reg & HVPS_M_R3_OVERLOAD) == 0); } - *((ULONG *) params->value) = hvps->flags.bit.ov; + *((uint32_t *) params->value) = hvps->flags.bit.ov; break; /*------------------------------*/ @@ -1484,35 +1484,35 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, reg = entry->registers[0]; hvps->flags.bit.stat = ((reg & HVPS_M_R2_STATUS_ON) != 0); } - *((ULONG *) params->value) = hvps->flags.bit.stat; + *((uint32_t *) params->value) = hvps->flags.bit.stat; break; /*------------------------------*/ case CAM_L_HVPSFONLINE: /* Module on-line */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.online; + *((uint32_t *) params->value) = hvps->flags.bit.online; break; /*------------------------------*/ case CAM_L_HVPSFATTEN: /* Module requires attention */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.atten; + *((uint32_t *) params->value) = hvps->flags.bit.atten; break; /*-----------------------------*/ case CAM_L_HVPSFASTRAMP: /* Fast Ramp Flag */ /*-----------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.fastramp; + *((uint32_t *) params->value) = hvps->flags.bit.fastramp; break; /*-----------------------------*/ case CAM_L_HVPSFBUSY: /* Ramp in progress flag */ /*-----------------------------*/ - *((ULONG *) params->value) = hvps->flags.bit.busy; + *((uint32_t *) params->value) = hvps->flags.bit.busy; break; /*======================================================*/ @@ -1523,56 +1523,56 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, case CAM_L_HVPSVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.lword; + *((uint32_t *) params->value) = hvps->vflags.lword; break; /*------------------------------*/ case CAM_L_HVPSVFID: /* VF: Module ID */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.id; + *((uint32_t *) params->value) = hvps->vflags.bit.id; break; /*------------------------------*/ case CAM_L_HVPSVFVOLT: /* VF: Voltage */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.volt; + *((uint32_t *) params->value) = hvps->vflags.bit.volt; break; /*------------------------------*/ case CAM_L_HVPSVFOVLE: /* VF: Overload latch */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.ovle; + *((uint32_t *) params->value) = hvps->vflags.bit.ovle; break; /*------------------------------*/ case CAM_L_HVPSVFINHLE: /* VF: Inhibit latch */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.inhle; + *((uint32_t *) params->value) = hvps->vflags.bit.inhle; break; /*------------------------------*/ case CAM_L_HVPSVFLVINH: /* VF: 5v/12v inhibit */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.lvinh; + *((uint32_t *) params->value) = hvps->vflags.bit.lvinh; break; /*------------------------------*/ case CAM_L_HVPSVFPOL: /* VF: Output polarity */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.id; + *((uint32_t *) params->value) = hvps->vflags.bit.id; break; /*------------------------------*/ case CAM_L_HVPSVFSTAT: /* VF: Status (on/off) */ /*------------------------------*/ - *((ULONG *) params->value) = hvps->vflags.bit.stat; + *((uint32_t *) params->value) = hvps->vflags.bit.stat; break; /*------------------------------*/ @@ -1612,21 +1612,21 @@ LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (UBYTE *) The list of ICB registers. This should be NULL +* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL * when ICB_HVPS_VERIFY() is called from the outside. * *******************************************************************************/ -LONG icb_hvps_verify (ICB_CCNIM_HVPS *hvps, +int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - LONG flags, - UBYTE *reg_list) + int32_t flags, + uint8_t *reg_list) { - LONG s; - UBYTE registers[14]; - UBYTE lreg; - UBYTE mreg; + int32_t s; + uint8_t registers[14]; + uint8_t lreg; + uint8_t mreg; ICB_MODULE_INFO *entry; /* @@ -1748,7 +1748,7 @@ LONG icb_hvps_verify (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -LONG icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) +int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) /* This routine runs as an AST on VMS systems. This means it runs as @@ -1757,9 +1757,9 @@ LONG icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) could simply make this routine run as a separate vxWorks task. */ { - LONG s = OK; /* Assume true status */ - REAL hvps_diff; - REAL level; + int32_t s = OK; /* Assume true status */ + float hvps_diff; + float level; double delay = 5.0; /* Delta time of 5 seconds */ /* @@ -1830,8 +1830,8 @@ while (1) { * *******************************************************************************/ -LONG icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, - REAL voltage, +int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, + float voltage, LONG flags) { @@ -1893,12 +1893,12 @@ LONG icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -LONG icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, - REAL *voltage, - LONG flags) +int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, + float *voltage, + int32_t flags) { - ULONG dac; - REAL hvps_step; + uint32_t dac; + float hvps_step; ICB_MODULE_INFO *entry; /* @@ -1928,7 +1928,7 @@ LONG icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, } else { dac = ((entry->registers[2] >> 6) & 0x0003); dac |= ((entry->registers[3] << 2) & 0x03FC); - *voltage = (REAL) dac * hvps_step; + *voltage = (float) dac * hvps_step; } return OK; @@ -1956,13 +1956,13 @@ LONG icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -LONG icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, - LONG state, - LONG flags) +int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, + int32_t state, + int32_t flags) { - LONG s; - LONG index; + int32_t s; + int32_t index; ICB_MODULE_INFO *entry; /* @@ -2014,22 +2014,22 @@ LONG icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -LONG icb_adc_write (ICB_CCNIM_ADC *adc, +int32_t icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG i; - LONG s=OK; - ULONG dac; - ULONG fbits; - LONG load_dac = FALSE; - LONG index; + int32_t i; + int32_t s=OK; + uint32_t dac; + uint32_t fbits; + int32_t load_dac = FALSE; + int32_t index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - LONG *flag_vals; - UCHAR reg_val; - LONG local_flags; + int32_t *flag_vals; + uint8_t reg_val; + int32_t local_flags; ICB_PARAM_LIST *params_start; /* @@ -2062,7 +2062,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert range in channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->range = *((LONG *) params->value); + adc->range = *((int32_t *) params->value); if (!entry) break; dac = icb_adc_encode_chns (adc->range) << 4; @@ -2081,7 +2081,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert offset in channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->offset = *((LONG *) params->value); + adc->offset = *((int32_t *) params->value); if (!entry) break; dac = ~(adc->offset >> 7); @@ -2119,7 +2119,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert cnvgain channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->cnvgain = *((LONG *) params->value); + adc->cnvgain = *((int32_t *) params->value); if (!entry) break; dac = icb_adc_encode_chns (adc->cnvgain); @@ -2138,7 +2138,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Make sure LLD value is reasonable */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->lld = *((REAL *) params->value); + adc->lld = *((float *) params->value); if (adc->lld < 0.0) adc->lld = 0.0; if (adc->lld > 110.0) adc->lld = 110.0; @@ -2162,7 +2162,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Make sure ULD value is reasonable */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->uld = *((REAL *) params->value); + adc->uld = *((float *) params->value); if (adc->uld < 0.0) adc->uld = 0.0; if (adc->uld > 110.0) adc->uld = 110.0; @@ -2186,7 +2186,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Make sure Zero value is reasonable */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->zero = *((REAL *) params->value); + adc->zero = *((float *) params->value); if (adc->zero < -5.0) adc->zero = -5.0; if (adc->zero > 5.0) adc->zero = 5.0; @@ -2210,11 +2210,11 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (adc_flag_list)); - flag_vals = (LONG *) malloc (sizeof (adc_flag_bits)); + flag_vals = (int32_t *) malloc (sizeof (adc_flag_bits)); memcpy (flag_list, adc_flag_list, sizeof (adc_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((LONG *) params->value); + fbits = *((int32_t *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((adc_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -2236,7 +2236,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the anticoincidence mode bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.antic = *((LONG *) params->value); + adc->flags.bit.antic = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.antic) @@ -2256,7 +2256,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the late coincidence mode bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.latec = *((LONG *) params->value); + adc->flags.bit.latec = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.latec) @@ -2276,7 +2276,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the delayed peak detect bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.delpk = *((LONG *) params->value); + adc->flags.bit.delpk = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.delpk) @@ -2296,7 +2296,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the non-overlap transfer bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.nonov = *((LONG *) params->value); + adc->flags.bit.nonov = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.nonov) @@ -2316,7 +2316,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the LTC/PUR EOC bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.ltcpur = *((LONG *) params->value); + adc->flags.bit.ltcpur = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.ltcpur) @@ -2334,7 +2334,7 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.atten = *((LONG *) params->value); + adc->flags.bit.atten = *((int32_t *) params->value); if (!entry) break; if (adc->flags.bit.atten) @@ -2404,12 +2404,12 @@ LONG icb_adc_write (ICB_CCNIM_ADC *adc, * *******************************************************************************/ -LONG icb_adc_read (ICB_CCNIM_ADC *adc, +int32_t icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG index; + int32_t index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -2439,14 +2439,14 @@ LONG icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_ADCRANGE: /* Range */ /*------------------------------*/ - *((LONG *) params->value) = adc->range; + *((int32_t *) params->value) = adc->range; break; /*------------------------------*/ case CAM_L_ADCOFFSET: /* Offset */ /*------------------------------*/ - *((LONG *) params->value) = adc->offset; + *((int32_t *) params->value) = adc->offset; break; /*------------------------------*/ @@ -2460,84 +2460,84 @@ LONG icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_CNVGAIN: /* Conversion Gain */ /*------------------------------*/ - *((LONG *) params->value) = adc->cnvgain; + *((int32_t *) params->value) = adc->cnvgain; break; /*------------------------------*/ case CAM_F_LLD: /* Lower level discriminator */ /*------------------------------*/ - *((REAL *) params->value) = adc->lld; + *((float *) params->value) = adc->lld; break; /*------------------------------*/ case CAM_F_ULD: /* Upper level discriminator */ /*------------------------------*/ - *((REAL *) params->value) = adc->uld; + *((float *) params->value) = adc->uld; break; /*------------------------------*/ case CAM_F_ZERO: /* Zero */ /*------------------------------*/ - *((REAL *) params->value) = adc->zero; + *((float *) params->value) = adc->zero; break; /*------------------------------*/ case CAM_L_ADCFLAGS: /* ADC Mode flags */ /*------------------------------*/ - *((ULONG *) params->value) = adc->flags.lword; + *((uint32_t *) params->value) = adc->flags.lword; continue; /*------------------------------*/ case CAM_L_ADCFANTIC: /* Anti-coincidence mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->flags.bit.antic; + *((int32_t *) params->value) = adc->flags.bit.antic; break; /*------------------------------*/ case CAM_L_ADCFLATEC: /* Late (vs early) coinc mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->flags.bit.latec; + *((int32_t *) params->value) = adc->flags.bit.latec; break; /*------------------------------*/ case CAM_L_ADCFDELPK: /* Delayed (vs auto) peak detect*/ /*------------------------------*/ - *((LONG *) params->value) = adc->flags.bit.delpk; + *((int32_t *) params->value) = adc->flags.bit.delpk; break; /*------------------------------*/ case CAM_L_ADCFNONOV: /* Non-overlap transfer mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->flags.bit.nonov; + *((int32_t *) params->value) = adc->flags.bit.nonov; break; /*------------------------------*/ case CAM_L_ADCFLTCPUR: /* LTC/PUR Output signal */ /*------------------------------*/ - *((LONG *) params->value) = adc->flags.bit.ltcpur; + *((int32_t *) params->value) = adc->flags.bit.ltcpur; break; /*------------------------------*/ case CAM_L_ADCFONLINE: /* Module on-line */ /*------------------------------*/ - *((ULONG *) params->value) = adc->flags.bit.online; + *((uint32_t *) params->value) = adc->flags.bit.online; break; /*------------------------------*/ case CAM_L_ADCFATTEN: /* Module requires attention */ /*------------------------------*/ - *((ULONG *) params->value) = adc->flags.bit.atten; + *((uint32_t *) params->value) = adc->flags.bit.atten; break; /*======================================================*/ @@ -2548,98 +2548,98 @@ LONG icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_ADCVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((ULONG *) params->value) = adc->vflags.lword; + *((uint32_t *) params->value) = adc->vflags.lword; break; /*------------------------------*/ case CAM_L_ADCVFID: /* VF: Module ID */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.id; + *((int32_t *) params->value) = adc->vflags.bit.id; break; /*------------------------------*/ case CAM_L_ADCVFRANGE: /* VF: Range */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.range; + *((int32_t *) params->value) = adc->vflags.bit.range; break; /*------------------------------*/ case CAM_L_ADCVFOFFSET: /* VF: Offset */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.offset; + *((int32_t *) params->value) = adc->vflags.bit.offset; break; /*------------------------------*/ case CAM_L_ADCVFACQMODE:/* VF: Acquisition Mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.acqmode; + *((int32_t *) params->value) = adc->vflags.bit.acqmode; break; /*------------------------------*/ case CAM_L_ADCVFCNVGAIN:/* VF: Conversion Gain */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.cnvgain; + *((int32_t *) params->value) = adc->vflags.bit.cnvgain; break; /*------------------------------*/ case CAM_L_ADCVFLLD: /* VF: Lower level discriminator*/ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.lld; + *((int32_t *) params->value) = adc->vflags.bit.lld; break; /*------------------------------*/ case CAM_L_ADCVFULD: /* VF: Upper level discriminator*/ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.uld; + *((int32_t *) params->value) = adc->vflags.bit.uld; break; /*------------------------------*/ case CAM_L_ADCVFZERO: /* VF: Zero */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.zero; + *((int32_t *) params->value) = adc->vflags.bit.zero; break; /*------------------------------*/ case CAM_L_ADCVFANTIC: /* VF: Anti-coinc. mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.antic; + *((int32_t *) params->value) = adc->vflags.bit.antic; break; /*------------------------------*/ case CAM_L_ADCVFLATEC: /* VF: Late coinc mode */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.latec; + *((int32_t *) params->value) = adc->vflags.bit.latec; break; /*------------------------------*/ case CAM_L_ADCVFDELPK: /* VF: Delayed peak detect */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.delpk; + *((int32_t *) params->value) = adc->vflags.bit.delpk; break; /*------------------------------*/ case CAM_L_ADCVFNONOV: /* VF: Non-overlap transfer */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.nonov; + *((int32_t *) params->value) = adc->vflags.bit.nonov; break; /*------------------------------*/ case CAM_L_ADCVFLTCPUR: /* VF: LTC/PUR Output */ /*------------------------------*/ - *((LONG *) params->value) = adc->vflags.bit.ltcpur; + *((int32_t *) params->value) = adc->vflags.bit.ltcpur; break; /*------------------------------*/ @@ -2680,21 +2680,21 @@ LONG icb_adc_read (ICB_CCNIM_ADC *adc, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (UBYTE *) The list of ICB registers. This should be NULL +* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL * when ICB_ADC_VERIFY() is called from the outside. * *******************************************************************************/ -LONG icb_adc_verify (ICB_CCNIM_ADC *adc, +int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - LONG flags, - UBYTE *reg_list) + int32_t flags, + uint8_t *reg_list) { - LONG s; - UBYTE registers[14]; - UBYTE lreg; - UBYTE mreg; + int32_t s; + uint8_t registers[14]; + uint8_t lreg; + uint8_t mreg; ICB_MODULE_INFO *entry; /* @@ -2874,20 +2874,20 @@ LONG icb_adc_verify (ICB_CCNIM_ADC *adc, * *******************************************************************************/ -LONG icb_amp_write (ICB_CCNIM_AMP *amp, +int32_t icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG i; - LONG s=OK; - ULONG dac; - ULONG fbits; - LONG index; + int32_t i; + int32_t s=OK; + uint32_t dac; + uint32_t fbits; + int32_t index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - LONG *flag_vals; - LONG local_flags; + int32_t *flag_vals; + int32_t local_flags; ICB_PARAM_LIST *params_start; /* @@ -2943,7 +2943,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, if ((flags & ICB_M_HDLR_INITIALIZE) != 0) break; - amp->gain = *((REAL *) params->value); + amp->gain = *((float *) params->value); s = icb_amp_vgain_to_hwgain (amp, flags); break; @@ -2954,7 +2954,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Convert floating course gain into a DAC value */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->hwgain1 = *((REAL *) params->value); + amp->hwgain1 = *((float *) params->value); for (i = 0; amp_hwgain1_tbl[i].real_val != 0.0; i++) if (amp->hwgain1 >= amp_hwgain1_tbl[i].real_val) break; @@ -2976,7 +2976,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* to be done here in a switch statement. */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->hwgain2 = *((REAL *) params->value); + amp->hwgain2 = *((float *) params->value); if (amp->hwgain2 < 1.0) amp->hwgain2 = 1.0; if (amp->hwgain2 > 3.0) amp->hwgain2 = 3.0; amp->gain = amp->hwgain1 * amp->hwgain2 * amp->hwgain3; @@ -2992,7 +2992,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Convert floating super find gain into a DAC value */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->hwgain3 = *((REAL *) params->value); + amp->hwgain3 = *((float *) params->value); if (amp->hwgain3 < 0.998) amp->hwgain3 = 0.998; if (amp->hwgain3 > 1.002) amp->hwgain3 = 1.002; amp->gain = amp->hwgain1 * amp->hwgain2 * amp->hwgain3; @@ -3031,7 +3031,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->pz = *((LONG *) params->value); + amp->pz = *((int32_t *) params->value); if (!entry) break; /* Store the pole zero in the module */ @@ -3084,7 +3084,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->tc = *((REAL *) params->value); + amp->tc = *((float *) params->value); break; /*------------------------------*/ @@ -3094,11 +3094,11 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (amp_flag_list)); - flag_vals = (LONG *) malloc (sizeof (amp_flag_bits)); + flag_vals = (int32_t *) malloc (sizeof (amp_flag_bits)); memcpy (flag_list, amp_flag_list, sizeof (amp_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((LONG *) params->value); + fbits = *((int32_t *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((amp_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -3120,7 +3120,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the differential input bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.diff = *((LONG *) params->value); + amp->flags.bit.diff = *((int32_t *) params->value); if (!entry) break; if (amp->flags.bit.diff) @@ -3140,7 +3140,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the input polarity bit (1=negative) */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.negpol = *((LONG *) params->value); + amp->flags.bit.negpol = *((int32_t *) params->value); if (!entry) break; if (amp->flags.bit.negpol) @@ -3160,7 +3160,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the inhibit polarity bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.compinh = *((LONG *) params->value); + amp->flags.bit.compinh = *((int32_t *) params->value); if (!entry) break; if (amp->flags.bit.compinh) @@ -3180,7 +3180,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the pileup reject bit (1=negative) */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.purej = *((LONG *) params->value); + amp->flags.bit.purej = *((int32_t *) params->value); if (!entry) break; if (amp->flags.bit.purej) @@ -3198,7 +3198,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) != 0) break; - if (*((LONG *) params->value) == 0) break; + if (*((int32_t *) params->value) == 0) break; /* Performing an automatic pole zero in the AMP is too */ /* complicated to be done here in a switch statement. */ @@ -3212,7 +3212,7 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.atten = *((LONG *) params->value); + amp->flags.bit.atten = *((int32_t *) params->value); if (!entry) break; if (amp->flags.bit.atten) @@ -3273,14 +3273,14 @@ LONG icb_amp_write (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -LONG icb_amp_read (ICB_CCNIM_AMP *amp, +int32_t icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - LONG flags) + int32_t flags) { - LONG i; - ULONG reg; - LONG index; + int32_t i; + uint32_t reg; + int32_t index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -3317,28 +3317,28 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_F_AMPGAIN: /* Virtual Amplifier Gain */ /*------------------------------*/ - *((REAL *) params->value) = amp->gain; + *((float *) params->value) = amp->gain; break; /*------------------------------*/ case CAM_F_AMPHWGAIN1: /* Course GAIN */ /*------------------------------*/ - *((REAL *) params->value) = amp->hwgain1; + *((float *) params->value) = amp->hwgain1; break; /*------------------------------*/ case CAM_F_AMPHWGAIN2: /* Fine Gain */ /*------------------------------*/ - *((REAL *) params->value) = amp->hwgain2; + *((float *) params->value) = amp->hwgain2; break; /*------------------------------*/ case CAM_F_AMPHWGAIN3: /* Super Fine Gain */ /*------------------------------*/ - *((REAL *) params->value) = amp->hwgain3; + *((float *) params->value) = amp->hwgain3; break; /*------------------------------*/ @@ -3352,7 +3352,7 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPPZ: /* Amplifier pole zero */ /*------------------------------*/ - *((LONG *) params->value) = amp->pz; + *((int32_t *) params->value) = amp->pz; break; /*------------------------------*/ @@ -3374,7 +3374,7 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, /*------------------------------*/ if (!entry) { - *((REAL *) params->value) = amp->tc; + *((float *) params->value) = amp->tc; break; } @@ -3382,10 +3382,10 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, /* Logic 0 indicates the setting. Bit 0 ==> 0.5 */ /* Bit 5 ==> 12 us */ - reg = ((ULONG) entry->registers[5]); + reg = ((uint32_t) entry->registers[5]); for (i = 0; i < 6; i++, reg >>= 1) if ((reg & 1) == 0) break; - *((REAL *) params->value) = amp_shape_time[i]; + *((float *) params->value) = amp_shape_time[i]; if (amp->tc != amp_shape_time[i]) { amp->vflags.bit.tc = TRUE; @@ -3397,77 +3397,77 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPFLAGS: /* Amplifier Mode flags */ /*------------------------------*/ - *((ULONG *) params->value) = amp->flags.lword; + *((uint32_t *) params->value) = amp->flags.lword; continue; /*--------------------------------*/ case CAM_L_AMPFDIFF: /* Differential (vs normal) input */ /*--------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.diff; + *((uint32_t *) params->value) = amp->flags.bit.diff; break; /*---------------------------------*/ case CAM_L_AMPFNEGPOL: /* Negative (vs positive) polarity */ /*---------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.negpol; + *((uint32_t *) params->value) = amp->flags.bit.negpol; break; /*------------------------------*/ case CAM_L_AMPFCOMPINH: /* Complement inhibit polarity */ /*------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.compinh; + *((uint32_t *) params->value) = amp->flags.bit.compinh; break; /*--------------------------------*/ case CAM_L_AMPFPUREJ: /* Pileup reject (enable/disable) */ /*--------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.purej; + *((uint32_t *) params->value) = amp->flags.bit.purej; break; /*------------------------------*/ case CAM_L_AMPFONLINE: /* Module on-line */ /*------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.online; + *((uint32_t *) params->value) = amp->flags.bit.online; break; /*-------------------------------*/ case CAM_L_AMPFMOTRBUSY: /* Motor Busy */ /*-------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.motrbusy; + *((uint32_t *) params->value) = amp->flags.bit.motrbusy; break; /*--------------------------------*/ case CAM_L_AMPFPZBUSY: /* Pole Zero Busy */ /*--------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.pzbusy; + *((uint32_t *) params->value) = amp->flags.bit.pzbusy; break; /*------------------------------*/ case CAM_L_AMPFATTEN: /* Module requires attention */ /*------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.atten; + *((uint32_t *) params->value) = amp->flags.bit.atten; break; /*--------------------------------*/ case CAM_L_AMPFPZFAIL: /* Pole Zero Failed */ /*--------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.pzfail; + *((uint32_t *) params->value) = amp->flags.bit.pzfail; break; /*--------------------------------*/ case CAM_L_AMPFMOTRFAIL:/* Fine Gain Motor Failed */ /*--------------------------------*/ - *((ULONG *) params->value) = amp->flags.bit.motrfail; + *((uint32_t *) params->value) = amp->flags.bit.motrfail; break; /*======================================================*/ @@ -3478,105 +3478,105 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((ULONG *) params->value) = amp->vflags.lword; + *((uint32_t *) params->value) = amp->vflags.lword; break; /*------------------------------*/ case CAM_L_AMPVFID: /* VF: Module ID */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.id; + *((int32_t *) params->value) = amp->vflags.bit.id; break; /*------------------------------*/ case CAM_L_AMPVFPRAMPT: /* VF: Preamplifier type */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.prampt; + *((int32_t *) params->value) = amp->vflags.bit.prampt; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN1:/* VF: Course GAIN */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.hwgain1; + *((int32_t *) params->value) = amp->vflags.bit.hwgain1; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN2:/* VF: Fine Gain */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.hwgain2; + *((int32_t *) params->value) = amp->vflags.bit.hwgain2; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN3:/* VF: Super Fine Gain */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.hwgain3; + *((int32_t *) params->value) = amp->vflags.bit.hwgain3; break; /*------------------------------*/ case CAM_L_AMPVFSHAPEM: /* VF: Amplifier shaping mode */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.shapem; + *((int32_t *) params->value) = amp->vflags.bit.shapem; break; /*------------------------------*/ case CAM_L_AMPVFPZ: /* VF: Amplifier pole zero */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.pz; + *((int32_t *) params->value) = amp->vflags.bit.pz; break; /*------------------------------*/ case CAM_L_AMPVFBLRTYPE:/* VF: Base-line restore */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.blrtype; + *((int32_t *) params->value) = amp->vflags.bit.blrtype; break; /*------------------------------*/ case CAM_L_AMPVFDTCTYPE:/* VF: Dead-time control */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.dtctype; + *((int32_t *) params->value) = amp->vflags.bit.dtctype; break; /*------------------------------*/ case CAM_L_AMPVFTC: /* VF: Amplifier time constant */ /*------------------------------*/ - *((LONG *) params->value) = amp->vflags.bit.tc; + *((int32_t *) params->value) = amp->vflags.bit.tc; break; /*-------------------------------*/ case CAM_L_AMPVFDIFF: /* VF: Differential input */ /*-------------------------------*/ - *((ULONG *) params->value) = amp->vflags.bit.diff; + *((uint32_t *) params->value) = amp->vflags.bit.diff; break; /*------------------------------*/ case CAM_L_AMPVFNEGPOL: /* VF: Negative polarity */ /*------------------------------*/ - *((ULONG *) params->value) = amp->vflags.bit.negpol; + *((uint32_t *) params->value) = amp->vflags.bit.negpol; break; /*------------------------------*/ case CAM_L_AMPVFCOMPINH:/* VF: Comp. inhibit polarity */ /*------------------------------*/ - *((ULONG *) params->value) = amp->vflags.bit.compinh; + *((uint32_t *) params->value) = amp->vflags.bit.compinh; break; /*------------------------------*/ case CAM_L_AMPVFPUREJ: /* VF: Pileup reject */ /*------------------------------*/ - *((ULONG *) params->value) = amp->vflags.bit.purej; + *((uint32_t *) params->value) = amp->vflags.bit.purej; break; /*------------------------------*/ @@ -3615,22 +3615,22 @@ LONG icb_amp_read (ICB_CCNIM_AMP *amp, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (UBYTE *) The list of ICB registers. This should be NULL +* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL * when ICB_AMP_VERIFY() is called from the outside. * *******************************************************************************/ -LONG icb_amp_verify (ICB_CCNIM_AMP *amp, +int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - LONG flags, - UBYTE *reg_list) + int32_t flags, + uint8_t *reg_list) { - LONG i; - LONG s; - UBYTE registers[14]; - UBYTE lreg; - UBYTE mreg; + int32_t i; + int32_t s; + uint8_t registers[14]; + uint8_t lreg; + uint8_t mreg; ICB_MODULE_INFO *entry; /* @@ -3828,15 +3828,15 @@ LONG icb_amp_verify (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -LONG icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, - LONG flags) +int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, + int32_t flags) { - LONG i; /* Loop counter */ - REAL vg; /* Intermediate virtual gain */ - static REAL cg; /* Computed course gain */ - static REAL fg; /* Computed fine gain */ - static REAL sfg; /* Computed super fine gain */ + int32_t i; /* Loop counter */ + float vg; /* Intermediate virtual gain */ + static float cg; /* Computed course gain */ + static float fg; /* Computed fine gain */ + static float sfg; /* Computed super fine gain */ ICB_PARAM_LIST plist[] = {{CAM_F_AMPHWGAIN1, 0, &cg}, {CAM_F_AMPHWGAIN2, 0, &fg}, @@ -3863,8 +3863,8 @@ LONG icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, * Adjust the fine gain so that it has only 3 digits right of the decimal. */ i = (fg *= 1000.0); - if ((fg - ((REAL) i)) >= 0.5) i++; /* Round up if necessary */ - fg = ((REAL) i) / 1000.0; + if ((fg - ((float) i)) >= 0.5) i++; /* Round up if necessary */ + fg = ((float) i) / 1000.0; /* * Use this adjusted fine gain to compute the super fine gain. Make @@ -3879,8 +3879,8 @@ LONG icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, * Adjust the super gain so that it has only 4 digits right of the decimal. */ i = (sfg *= 10000.0); - if ((sfg - ((REAL) i)) >= 0.5) i++; /* Round up if necessary */ - sfg = ((REAL) i) / 10000.0; + if ((sfg - ((float) i)) >= 0.5) i++; /* Round up if necessary */ + sfg = ((float) i) / 10000.0; /* * Set the hardware gains @@ -3906,7 +3906,7 @@ LONG icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -LONG icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) +int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -3916,9 +3916,9 @@ LONG icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) */ { - LONG s; - LONG nvpos; - ULONG pos; + int32_t s; + int32_t nvpos; + uint32_t pos; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -3997,12 +3997,12 @@ while (1) { * *******************************************************************************/ -LONG icb_amp_complete_position (ICB_CCNIM_AMP *amp) +int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp) { - LONG s; - UBYTE temp[4]; - ULONG pos; + int32_t s; + uint8_t temp[4]; + uint32_t pos; ICB_MODULE_INFO *entry; /* @@ -4063,7 +4063,7 @@ LONG icb_amp_complete_position (ICB_CCNIM_AMP *amp) * *******************************************************************************/ -LONG icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) +int32_t icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -4073,9 +4073,9 @@ LONG icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) */ { - LONG s; - ULONG pos; - UBYTE temp[4]; + int32_t s; + uint32_t pos; + uint8_t temp[4]; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4146,8 +4146,8 @@ while (1) { int icb_amp_home_motor (ICB_CCNIM_AMP *amp) { - LONG s; - UBYTE temp[4]; + int32_t s; + uint8_t temp[4]; ICB_MODULE_INFO *entry; /* @@ -4199,7 +4199,7 @@ int icb_amp_home_motor (ICB_CCNIM_AMP *amp) * *******************************************************************************/ -LONG icb_amp_test_home (ICB_CCNIM_AMP *amp) +int32_t icb_amp_test_home (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -4209,8 +4209,8 @@ LONG icb_amp_test_home (ICB_CCNIM_AMP *amp) */ { - LONG s; - UBYTE temp[4]; + int32_t s; + uint8_t temp[4]; ICB_MODULE_INFO *entry; double dt_qsec= .25; @@ -4268,11 +4268,11 @@ while (1) { * *******************************************************************************/ -ULONG icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) +uint32_t icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) { - LONG pos; + int32_t pos; /* * Make sure the fine gain value is reasonable before computing the @@ -4309,15 +4309,15 @@ ULONG icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) int icb_amp_get_nvram_motor_pos (index, nvpos, flags) -LONG index; -LONG *nvpos; -LONG flags; +int32_t index; +int32_t *nvpos; +int32_t flags; { - LONG s; - LONG i; - ULONG nibble; - UCHAR reg_val; + int32_t s; + int32_t i; + uint32_t nibble; + uint8_t reg_val; /* * Map the second page of NVRAM. @@ -4333,7 +4333,7 @@ LONG flags; *nvpos = 0; nibble = 0; for (i = 2; i >= 0; i--) { - s = icb_read_nvram (index, i, (LONG *) &nibble); + s = icb_read_nvram (index, i, (int32_t *) &nibble); if (s != OK) return s; *nvpos = (*nvpos * 16) | nibble; } @@ -4372,16 +4372,16 @@ LONG flags; int icb_amp_put_nvram_motor_pos (index, nvpos, flags) -LONG index; -LONG nvpos; -LONG flags; +int32_t index; +int32_t nvpos; +int32_t flags; { - LONG s; - LONG i; - UCHAR reg_val; + int32_t s; + int32_t i; + uint8_t reg_val; CHAR nibble; - ULONG temp; + uint32_t temp; struct icb_module_info_struct *entry; /* @@ -4446,13 +4446,13 @@ LONG flags; int icb_amp_put_motor_pos (index, pos, flags) -LONG index; -LONG pos; -LONG flags; +int32_t index; +int32_t pos; +int32_t flags; { - LONG s; - UBYTE temp[4]; + int32_t s; + uint8_t temp[4]; ICB_MODULE_INFO *entry; double wait_time = 0.1; /* for taskDelay */ @@ -4528,11 +4528,11 @@ LONG flags; * *******************************************************************************/ -LONG icb_amp_start_pz (ICB_CCNIM_AMP *amp) +int32_t icb_amp_start_pz (ICB_CCNIM_AMP *amp) { - LONG s=OK; - UCHAR reg_val; + int32_t s=OK; + uint8_t reg_val; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4602,11 +4602,11 @@ while(1) { * *******************************************************************************/ -LONG icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp) +int32_t icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp) { - LONG s; - UBYTE temp[4]; + int32_t s; + uint8_t temp[4]; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4667,10 +4667,10 @@ while (1) { * *******************************************************************************/ -LONG icb_amp_write_pz (ICB_CCNIM_AMP *amp) +int32_t icb_amp_write_pz (ICB_CCNIM_AMP *amp) { - LONG s; + int32_t s; ICB_MODULE_INFO *entry; /* @@ -4726,11 +4726,11 @@ LONG icb_amp_write_pz (ICB_CCNIM_AMP *amp) int icb_adc_encode_chns (chns) -ULONG chns; +uint32_t chns; { - LONG i; - ULONG mask; + int32_t i; + uint32_t mask; /* * Find the first set bit. @@ -4773,14 +4773,14 @@ ULONG chns; *******************************************************************************/ int icb_write_csr (ICB_CCNIM_ANY *ccnim, - LONG perm_bits, - LONG temp_bits, - LONG mask) + int32_t perm_bits, + int32_t temp_bits, + int32_t mask) { - LONG s; - UCHAR csr; - UCHAR register_list[16]; + int32_t s; + uint8_t csr; + uint8_t register_list[16]; ICB_MODULE_INFO *entry; /* @@ -4836,12 +4836,12 @@ int icb_write_csr (ICB_CCNIM_ANY *ccnim, int icb_monitor_modules () { - LONG i; + int32_t i; ICB_MODULE_INFO *entry; - static REAL tc; - static LONG tc_verify; - static LONG inhibit; - static LONG overload; + static float tc; + static int32_t tc_verify; + static int32_t inhibit; + static int32_t overload; static ICB_PARAM_LIST amp_plist[] = {{CAM_F_AMPTC, 0, &tc}, {CAM_L_AMPVFTC, 0, &tc_verify}, {0, 0, 0}}; From b692bcb6409796f8f4b4df8a3cb3f9de1c10e2ac Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:35:55 -0500 Subject: [PATCH 06/17] icb_get_module_status.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_get_module_status.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_get_module_status.c b/mcaApp/CanberraSrc/icb_get_module_status.c index 8ed1df51..eecb48da 100644 --- a/mcaApp/CanberraSrc/icb_get_module_status.c +++ b/mcaApp/CanberraSrc/icb_get_module_status.c @@ -31,7 +31,7 @@ *******************************************************************************/ #include -#include "ndtypes.h" + #include "icb_sys_defs.h" #include "nmc_sys_defs.h" From 8b6d610bb23facf0de9c4372ea356bdad8ee1a3c Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:36:37 -0500 Subject: [PATCH 07/17] icb_crmpsc.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_crmpsc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_crmpsc.c b/mcaApp/CanberraSrc/icb_crmpsc.c index 49feb93e..9e8df19f 100644 --- a/mcaApp/CanberraSrc/icb_crmpsc.c +++ b/mcaApp/CanberraSrc/icb_crmpsc.c @@ -1,6 +1,5 @@ #include #include -#include "ndtypes.h" #include "icb_sys_defs.h" #include "nmc_sys_defs.h" From d2a8552c39ff10a96c97a90ca83c1657e2d09c6c Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:37:36 -0500 Subject: [PATCH 08/17] icb_control_subs.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_control_subs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_control_subs.c b/mcaApp/CanberraSrc/icb_control_subs.c index 3d20fc99..154bc8b0 100644 --- a/mcaApp/CanberraSrc/icb_control_subs.c +++ b/mcaApp/CanberraSrc/icb_control_subs.c @@ -54,7 +54,6 @@ #include #include #include -#include "ndtypes.h" #include "icb_sys_defs.h" #include "icb_bus_defs.h" #include "nmc_sys_defs.h" From 030853cfbb272f41c09d54ecd783d00e07397487 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:38:15 -0500 Subject: [PATCH 09/17] icb_control_subs2.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/icb_control_subs2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_control_subs2.c b/mcaApp/CanberraSrc/icb_control_subs2.c index c65c8555..25705981 100644 --- a/mcaApp/CanberraSrc/icb_control_subs2.c +++ b/mcaApp/CanberraSrc/icb_control_subs2.c @@ -37,7 +37,6 @@ #include #include #include -#include "ndtypes.h" #include "icb_sys_defs.h" #include "icb_bus_defs.h" #include "nmc_sys_defs.h" From fa9c479d3012c36cc51ea8c12892e22fabfc00d5 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:39:19 -0500 Subject: [PATCH 10/17] drvIcbAsyn.c doesn't use anything from ndtypes.h --- mcaApp/CanberraSrc/drvIcbAsyn.c | 3189 +++++++++++++++---------------- 1 file changed, 1594 insertions(+), 1595 deletions(-) diff --git a/mcaApp/CanberraSrc/drvIcbAsyn.c b/mcaApp/CanberraSrc/drvIcbAsyn.c index d8696939..e6264e6a 100644 --- a/mcaApp/CanberraSrc/drvIcbAsyn.c +++ b/mcaApp/CanberraSrc/drvIcbAsyn.c @@ -1,1595 +1,1594 @@ -/* drvIcbAsyn.c - - Author: Mark Rivers - Date: 23-June-2004 Modified from icbMpfServer.cc - - This module is an asyn driver which is called from from asyn generic - device support and commmunicates with the following Canberra ICB modules: - 9633/9635 ADC - 9615 Amplifier - 9641/9621 HVPS - TCA - 9660 DSP - -*/ - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "drvIcbAsyn.h" -#include "icbDsp.h" - -#include "ndtypes.h" -#include "nmc_sys_defs.h" -#include "icb_user_subs.h" -#include "icb_sys_defs.h" -#include "icb_bus_defs.h" -#include "campardef.h" -#include - -typedef struct { - int command; - char *commandString; -} icbCommandStruct; - -static icbCommandStruct icbAdcCommands[MAX_ICB_ADC_COMMANDS] = { - {icbAdcGain, "GAIN"}, - {icbAdcRange, "RANGE"}, - {icbAdcOffset, "OFFSET"}, - {icbAdcLld, "LLD"}, - {icbAdcUld, "ULD"}, - {icbAdcZero, "ZERO"}, - {icbAdcGmod, "GATE_MODE"}, - {icbAdcCmod, "COINCIDENCE_MODE"}, - {icbAdcPmod, "PEAK_MODE"}, - {icbAdcAmod, "ACQUISITION_MODE"}, - {icbAdcTmod, "TRANSFER_MODE"}, - {icbAdcZeroRbv, "ZERO_READBACK"} -}; - -static icbCommandStruct icbAmpCommands[MAX_ICB_AMP_COMMANDS] = { - {icbAmpCgain, "COARSE_GAIN"}, - {icbAmpFgain, "FINE_GAIN"}, - {icbAmpSfgain, "SUPERFINE_GAIN"}, - {icbAmpInpp, "INPUT_POLARITY"}, - {icbAmpInhp, "INHIBIT_POLARITY"}, - {icbAmpDmod, "DIFFERENTIAL_MODE"}, - {icbAmpSmod, "SHAPING_MODE"}, - {icbAmpPtyp, "PREAMP_TYPE"}, - {icbAmpPurmod, "PUR_MODE"}, - {icbAmpBlmod, "BASELINE_MODE"}, - {icbAmpDtmod, "DEADTIME_MODE"}, - {icbAmpAutoPz, "START_PZ"}, - {icbAmpPz, "REQUESTED_PZ"}, - {icbAmpShaping, "SHAPING"}, - {icbAmpPzRbv, "PZ_READBACK"} -}; - -static icbCommandStruct icbHvpsCommands[MAX_ICB_HVPS_COMMANDS] = { - {icbHvpsVolt, "VOLT"}, - {icbHvpsVlim, "LIMIT"}, - {icbHvpsInhl, "INHIBIT_LEVEL"}, - {icbHvpsLati, "LATCH_INHIBIT"}, - {icbHvpsLato, "LATCH_OVERLOAD"}, - {icbHvpsReset, "RESET"}, - {icbHvpsStatus, "STATUS"}, - {icbHvpsFramp, "FAST_RAMP"}, - {icbHvpsVpol, "POLARITY"}, - {icbHvpsInh, "INHIBIT"}, - {icbHvpsOvl, "OVERLOAD"}, - {icbHvpsStatRbv, "STATUS_READBACK"}, - {icbHvpsBusy, "BUSY"}, - {icbHvpsVoltRbv, "VOLT_READBACK"} -}; - -static icbCommandStruct icbTcaCommands[MAX_ICB_TCA_COMMANDS] = { - {icbTcaPolarity, "POLARITY"}, - {icbTcaThresh, "THRESHOLD"}, - {icbTcaScaEn, "SCA_ENABLE"}, - {icbTcaGate1, "GATE1"}, - {icbTcaGate2, "GATE2"}, - {icbTcaGate3, "GATE3"}, - {icbTcaSelect, "TCA_SELECT"}, - {icbTcaPurEn, "PUR_ENABLE"}, - {icbTcaPur1, "PUR1"}, - {icbTcaPur2, "PUR2"}, - {icbTcaPur3, "PUR3"}, - {icbTcaPurAmp, "PUR_AMP"}, - {icbTcaLow1, "LOW1"}, - {icbTcaHi1, "HI1"}, - {icbTcaLow2, "LOW2"}, - {icbTcaHi2, "HI2"}, - {icbTcaLow3, "LOW3"}, - {icbTcaHi3, "HI3"}, - {icbTcaStatus, "STATUS"} -}; - -#define MAX_ICB_DSP_COMMANDS 75 -static icbCommandStruct icbDspCommands[MAX_ICB_DSP_COMMANDS] = { - {ID_AMP_CGAIN, "AMP_CGAIN"}, - {ID_AMP_FGAIN, "AMP_FGAIN"}, - {ID_AMP_SFGAIN, "AMP_SFGAIN"}, - {ID_ADC_CGAIN, "ADC_CGAIN"}, - {ID_ADC_CRANGE, "ADC_CRANGE"}, - {ID_ADC_OFFS, "ADC_OFFS"}, - {ID_ADC_TYPE, "ADC_TYPE"}, - {ID_ADC_LLD, "ADC_LLD"}, - {ID_ADC_ZERO, "ADC_ZERO"}, - {ID_FILTER_RT, "FILTER_RT"}, - {ID_FILTER_FT, "FILTER_FT"}, - {ID_FILTER_MDEX, "FILTER_MDEX"}, - {ID_FILTER_MFACT, "FILTER_MFACT"}, - {ID_FILTER_BLRM, "FILTER_BLRM"}, - {ID_FILTER_PZM, "FILTER_PZM"}, - {ID_FILTER_PZ, "FILTER_PZ"}, - {ID_FILTER_THR, "FILTER_THR"}, - {ID_FILTER_FRQ, "FILTER_FRQ"}, - {ID_STABLZ_GCOR, "STABLZ_GCOR"}, - {ID_STABLZ_ZCOR, "STABLZ_ZCOR"}, - {ID_STABLZ_GMOD, "STABLZ_GMOD"}, - {ID_STABLZ_ZMOD, "STABLZ_ZMOD"}, - {ID_STABLZ_GDIV, "STABLZ_GDIV"}, - {ID_STABLZ_ZDIV, "STABLZ_ZDIV"}, - {ID_STABLZ_GSPAC, "STABLZ_GSPAC"}, - {ID_STABLZ_ZSPAC, "STABLZ_ZSPAC"}, - {ID_STABLZ_GWIN, "STABLZ_GWIN"}, - {ID_STABLZ_ZWIN, "STABLZ_ZWIN"}, - {ID_STABLZ_GCENT, "STABLZ_GCENT"}, - {ID_STABLZ_ZCENT, "STABLZ_ZCENT"}, - {ID_STABLZ_GRAT, "STABLZ_GRAT"}, - {ID_STABLZ_ZRAT, "STABLZ_ZRAT"}, - {ID_STABLZ_RESET, "STABLZ_RESET"}, - {ID_STABLZ_GAIN, "STABLZ_GAIN"}, - {ID_STABLZ_ZERO, "STABLZ_ZERO"}, - {ID_MISC_FDM, "MISC_FDM"}, - {ID_MISC_FD, "MISC_FD"}, - {ID_MISC_INPP, "MISC_INPP"}, - {ID_MISC_INHP, "MISC_INHP"}, - {ID_MISC_PURM, "MISC_PURM"}, - {ID_MISC_GATM, "MISC_GATM"}, - {ID_MISC_OUTM, "MISC_OUTM"}, - {ID_MISC_GD, "MISC_GD"}, - {ID_MISC_TINH, "MISC_TINH"}, - {ID_MISC_LTRIM, "MISC_LTRIM"}, - {ID_MISC_BBRN, "MISC_BBRN"}, - {ID_INFO_TDAC, "INFO_TDAC"}, - {ID_INFO_THRP, "INFO_THRP"}, - {ID_INFO_THRI, "INFO_THRI"}, - {ID_INFO_PZ, "INFO_PZ"}, - {ID_INFO_BDC, "INFO_BDC"}, - {ID_STATUS_FLGS, "STATUS_FLGS"}, - {ID_SYSOP_CMD, "SYSOP_CMD"}, - {ID_SYSOP_RDATL, "SYSOP_RDATL"}, - {ID_SYSOP_RDATH, "SYSOP_RDATH"}, - {ID_SYSOP_LCD, "SYSOP_LCD"}, - {ID_SYSOP_DAC, "SYSOP_DAC"}, - {ID_START_PZ, "START_PZ"}, - {ID_START_BDC, "START_BDC"}, - {ID_CLEAR_ERRORS, "CLEAR_ERRORS"}, - {ID_STABLZ_GOVR, "STABLZ_GOVR"}, - {ID_STABLZ_GOVF, "STABLZ_GOVF"}, - {ID_STABLZ_ZOVR, "STABLZ_ZOVR"}, - {ID_STABLZ_ZOVF, "STABLZ_ZOVF"}, - {ID_INFO_PZAER, "INFO_PZAER"}, - {ID_INFO_BDCAER, "INFO_BDCAER"}, - {ID_STATUS_PZBSY, "STATUS_PZBSY"}, - {ID_STATUS_BDBSY, "STATUS_BDBSY"}, - {ID_STATUS_MINT, "STATUS_MINT"}, - {ID_STATUS_DGBSY, "STATUS_DGBSY"}, - {ID_STATUS_MERR, "STATUS_MERR"}, - {ID_INFO_DT, "INFO_DT"}, - {ID_INFO_ICR, "INFO_ICR"}, - {ID_INFO_DSPRATE, "INFO_DSPRATE"}, - {ID_INFO_MCARATE, "INFO_MCARATE"} -}; - -#define LLD 0 -#define ULD 0x20 -#define SCA_1 0 -#define SCA_2 0x40 -#define SCA_3 0x80 - -typedef struct { - int module; - int icbAddress; - int polarity; - int threshold; - int sca_enable; - int gate1; - int gate2; - int gate3; - int select; - int pur_enable; - int pur1; - int pur2; - int pur3; - int pur_amp; - float lld[3]; - float uld[3]; -} icbTcaModule; - -typedef struct { - int module; - int icbAddress; - int defined; - int stablz_gmod; - int stablz_zmod; - int info_pz; - int info_bdc; - int info_thri; - int status_flgs; -} icbDspModule; - - -typedef enum { - icbUndefined, - icbNotFound, - icbFound -} icbModuleStatus; - -typedef struct { - char address[80]; - icbModuleStatus defined; - int index; - /* Note, we put these structures in for all modules, regardless of type. - * Small extra memory, but simpler than using pointers and allocation */ - icbTcaModule tca; - icbDspModule dsp; -} icbModule; - -typedef struct { - char *portName; - icbModuleType icbModuleType; - icbModule icbModule; - asynInterface common; - asynInterface int32; - asynInterface float64; - asynInterface drvUser; -} drvIcbAsynPvt; - - -/* These functions are in the public interfaces */ -static asynStatus int32Write( void *drvPvt, asynUser *pasynUser, - epicsInt32 value); -static asynStatus int32Read( void *drvPvt, asynUser *pasynUser, - epicsInt32 *value); -static asynStatus getBounds( void *drvPvt, asynUser *pasynUser, - epicsInt32 *low, epicsInt32 *high); -static asynStatus float64Write( void *drvPvt, asynUser *pasynUser, - epicsFloat64 value); -static asynStatus float64Read( void *drvPvt, asynUser *pasynUser, - epicsFloat64 *value); -static asynStatus drvUserCreate( void *drvPvt, asynUser *pasynUser, - const char *drvInfo, - const char **pptypeName, size_t *psize); -static asynStatus drvUserGetType( void *drvPvt, asynUser *pasynUser, - const char **pptypeName, size_t *psize); -static asynStatus drvUserDestroy( void *drvPvt, asynUser *pasynUser); -static void icbReport( void *drvPvt, FILE *fp, int details); -static asynStatus icbConnect( void *drvPvt, asynUser *pasynUser); -static asynStatus icbDisconnect( void *drvPvt, asynUser *pasynUser); - -/* These functions are private, not in any interface */ -static asynStatus icbRead(void *drvPvt, asynUser *pasynUser, int icbCommand, - int *ivalue, double *dvalue); -static asynStatus icbReadAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue); -static asynStatus icbReadAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue); -static asynStatus icbReadHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue); -static asynStatus icbReadTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue); -static asynStatus icbReadDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue); -static asynStatus icbWrite(void *drvPvt, asynUser *pasynUser, int icbCommand, - int ivalue, double dvalue); -static asynStatus icbWriteAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue); -static asynStatus icbWriteAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue); -static asynStatus icbWriteHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue); -static asynStatus icbWriteTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue); -static asynStatus icbWriteDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue); -static int writeAdc(icbModule *m, long command, char c, void *addr); -static int writeAmp(icbModule *m, long command, char c, void *addr); -static int writeHvps(icbModule *m, long command, char c, void *addr); -static int readAdc(icbModule *m, long command, char c, void *addr); -static int readAmp(icbModule *m, long command, char c, void *addr); -static int readHvps(icbModule *m, long command, char c, void *addr); -static int tcaWriteReg2(icbTcaModule *m); -static int tcaWriteReg6(icbTcaModule *m); -static int tcaWriteDiscrim(icbTcaModule *m, double percent, int discrim_spec); -static int sendDsp(int module, int icbAddress, int command, - unsigned short data); -static int readDsp(int module, int icbAddress, int command, - unsigned short *data); -static unsigned short dspDoubleToShort(double dval, double dmin, double dmax, - unsigned short imin, - unsigned short imax); -static double dspShortToDouble(unsigned short ival, double dmin, double dmax, - unsigned short imin, unsigned short imax); -static double dspUnpackThroughput(unsigned short ival); - -static asynStatus verifyModule(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - icbModule **m); - -/* asynCommon interface */ -static struct asynCommon icbCommon = { - icbReport, - icbConnect, - icbDisconnect -}; - -/* asynInt32 interface */ -static asynInt32 icbInt32 = { - int32Write, - int32Read, - getBounds, - NULL, - NULL -}; - -/* asynFloat64 interface */ -static asynFloat64 icbFloat64 = { - float64Write, - float64Read, - NULL, - NULL -}; - -/* asynDrvUser interface */ -static asynDrvUser icbDrvUser = { - drvUserCreate, - drvUserGetType, - drvUserDestroy -}; - - -int icbConfig(const char *portName, int enetAddress, int icbAddress, - icbModuleType icbModuleType) -{ - int status; - drvIcbAsynPvt *pPvt; - icbModule *m; - unsigned char csr; - - pPvt = callocMustSucceed(1, sizeof(drvIcbAsynPvt), "icbSetup"); - pPvt->portName = epicsStrDup(portName); - pPvt->icbModuleType = icbModuleType; - m = &pPvt->icbModule; - pPvt->common.interfaceType = asynCommonType; - pPvt->common.pinterface = (void *)&icbCommon; - pPvt->common.drvPvt = pPvt; - pPvt->int32.interfaceType = asynInt32Type; - pPvt->int32.pinterface = (void *)&icbInt32; - pPvt->int32.drvPvt = pPvt; - pPvt->float64.interfaceType = asynFloat64Type; - pPvt->float64.pinterface = (void *)&icbFloat64; - pPvt->float64.drvPvt = pPvt; - pPvt->drvUser.interfaceType = asynDrvUserType; - pPvt->drvUser.pinterface = (void *)&icbDrvUser; - pPvt->drvUser.drvPvt = pPvt; - status = pasynManager->registerPort(pPvt->portName, - ASYN_CANBLOCK, /* Not MULTIDEVICE */ - 1, /* autoconnect */ - 0, /* medium priority */ - 0); /* default stack size */ - if (status != asynSuccess) { - errlogPrintf("icbConfig ERROR: Can't register common\n"); - return -1; - } - status = pasynManager->registerInterface(pPvt->portName,&pPvt->common); - if (status != asynSuccess) { - errlogPrintf("icbConfig ERROR: Can't register common.\n"); - return -1; - } - status = pasynInt32Base->initialize(pPvt->portName,&pPvt->int32); - if (status != asynSuccess) { - errlogPrintf("icbConfig ERROR: Can't register int32\n"); - return -1; - } - - status = pasynFloat64Base->initialize(pPvt->portName,&pPvt->float64); - if (status != asynSuccess) { - errlogPrintf("icbConfig ERROR: Can't register float64\n"); - return -1; - } - - status = pasynManager->registerInterface(pPvt->portName,&pPvt->drvUser); - if (status != asynSuccess) { - errlogPrintf("icbConfig ERROR: Can't register drvUser\n"); - return -1; - } - - /* Initialize the ICB software in case this has not been done */ - status=icb_initialize(); - if (status != 0) return(-1); - - m->defined = icbNotFound; - sprintf(m->address, "NI%X:%X", enetAddress, icbAddress); - - /* This part is different for different module types */ - switch (pPvt->icbModuleType) { - case icbAdcType: - case icbAmpType: - case icbHvpsType: - status = icb_findmod_by_address(m->address, &m->index); - if (status != 0) { - errlogPrintf("icbConfig: Error looking up ICB module %s\n", - m->address); - return(-1); - } - break; - case icbTcaType: - if (parse_ICB_address(m->address, &m->tca.module, - &m->tca.icbAddress) != OK) { - errlogPrintf("icbConfig: failed to initialize this address: %s\n", - m->address); - return(-1); - } - /* Initialize the module. Can't turn on green light on this module, - * that is controlled by TCA select bit. Clear the reset bit. */ - csr = ICB_M_CTRL_CLEAR_RESET; - write_icb(m->tca.module, m->tca.icbAddress, 0, 1, &csr); - break; - case icbDspType: - if (parse_ICB_address(m->address, &m->dsp.module, - &m->dsp.icbAddress) != OK) { - errlogPrintf("icbConfig: failed to initialize this address: %s\n", - m->address); - return(-1); - } - /* Initialize the module (turn on green light) */ - csr = ICB_M_CTRL_LED_GREEN; - write_icb(m->dsp.module, m->dsp.icbAddress, 0, 1, &csr); - break; - default: - errlogPrintf("icbConfig: unknown module type %d\n", pPvt->icbModuleType); - return(-1); - } - m->defined = icbFound; - return(0); -} - - - -static asynStatus getBounds(void *drvPvt, asynUser *pasynUser, - epicsInt32 *low, epicsInt32 *high) -{ - /* This function should not be called, since no device support - * should be using LINEAR conversion */ - *low = 0; - *high = 65535; - return(0); -} - -static asynStatus int32Write(void *drvPvt, asynUser *pasynUser, - epicsInt32 value) -{ - int icbCommand=pasynUser->reason; - - return(icbWrite(drvPvt, pasynUser, icbCommand, value, 0.)); -} - -static asynStatus float64Write(void *drvPvt, asynUser *pasynUser, - epicsFloat64 value) -{ - int icbCommand=pasynUser->reason; - - return(icbWrite(drvPvt, pasynUser, icbCommand, 0, value)); -} - -static asynStatus icbWrite(void *drvPvt, asynUser *pasynUser, int icbCommand, - int ivalue, double dvalue) -{ - drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; - icbModule *module; - int status; - - status = verifyModule(pPvt, pasynUser, &module); - if (status != asynSuccess) return(status); - - switch (pPvt->icbModuleType) { - case icbAdcType: - status=icbWriteAdc(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbAmpType: - status=icbWriteAmp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbHvpsType: - status=icbWriteHvps(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbTcaType: - status=icbWriteTca(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbDspType: - status=icbWriteDsp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - } - return(status); -} - - -static asynStatus icbWriteAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue) -{ - int status; - char str[80]; - float fvalue=dvalue; - - switch (icbCommand) { - case icbAdcGain: /* We set both the ADC gain if either changes */ - case icbAdcRange: - status = writeAdc(module, CAM_L_CNVGAIN, 0, &ivalue); - status = writeAdc(module, CAM_L_ADCRANGE, 0, &ivalue); - break; - case icbAdcOffset: - ivalue = (int) dvalue; - status = writeAdc(module, CAM_L_ADCOFFSET, 0, &ivalue); - break; - case icbAdcLld: - status = writeAdc(module, CAM_F_LLD, 0, &fvalue); - break; - case icbAdcUld: - status = writeAdc(module, CAM_F_ULD, 0, &fvalue); - break; - case icbAdcZero: - status = writeAdc(module, CAM_F_ZERO, 0, &fvalue); - break; - case icbAdcGmod: - status = writeAdc(module, CAM_L_ADCFANTIC, 0, &ivalue); - break; - case icbAdcCmod: - status = writeAdc(module, CAM_L_ADCFLATEC, 0, &ivalue); - break; - case icbAdcPmod: - status = writeAdc(module, CAM_L_ADCFDELPK, 0, &ivalue); - break; - case icbAdcAmod: - if (ivalue) strcpy(str, "SVA"); - else strcpy(str, "PHA"); - status = writeAdc(module, CAM_T_ADCACQMODE, 'S', &str); - break; - case icbAdcTmod: - status = writeAdc(module, CAM_L_ADCFNONOV, 0, &ivalue); - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbWrite unknown ADC command=%d", - icbCommand); - status = asynError; - } - return(status); -} - - -static asynStatus icbWriteAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue) -{ - int status; - char str[80]; - float fvalue=dvalue; - - switch (icbCommand) { - case icbAmpCgain: - fvalue = (float)ivalue; - /* The value 2.5 will be sent as 2, since MBBO only does integers */ - if (fvalue == 2.0) fvalue = 2.5; - status = writeAmp(module, CAM_F_AMPHWGAIN1, 0, &fvalue); - break; - case icbAmpFgain: - status = writeAmp(module, CAM_F_AMPHWGAIN2, 0, &fvalue); - break; - case icbAmpSfgain: - status = writeAmp(module, CAM_F_AMPHWGAIN3, 0, &fvalue); - break; - case icbAmpInpp: - status = writeAmp(module, CAM_L_AMPFNEGPOL, 0, &ivalue); - break; - case icbAmpInhp: - status = writeAmp(module, CAM_L_AMPFCOMPINH, 0, &ivalue); - break; - case icbAmpDmod: - status = writeAmp(module, CAM_L_AMPFDIFF, 0, &ivalue); - break; - case icbAmpSmod: - if (ivalue) strcpy(str, "TRIANGLE"); - else strcpy(str, "GAUSSIAN"); - status = writeAmp(module, CAM_T_AMPSHAPEMODE, 'S', &str); - break; - case icbAmpPtyp: - if (ivalue) strcpy(str, "TRP"); - else strcpy(str, "RC"); - status = writeAmp(module, CAM_T_PRAMPTYPE, 'S', &str); - break; - case icbAmpPurmod: - status = writeAmp(module, CAM_L_AMPFPUREJ, 0, &ivalue); - break; - case icbAmpBlmod: - if (ivalue) strcpy(str, "ASYM"); - else strcpy(str, "SYM"); - status = writeAmp(module, CAM_T_AMPBLRTYPE, 'S', &str); - break; - case icbAmpDtmod: - if (ivalue) strcpy(str, "LFC"); - else strcpy(str, "Norm"); - status = writeAmp(module, CAM_T_AMPDTCTYPE, 'S', &str); - break; - case icbAmpPz: - ivalue = (int) fvalue; - status = writeAmp(module, CAM_L_AMPPZ, 0, &ivalue); - break; - case icbAmpAutoPz: - status = writeAmp(module, CAM_L_AMPFPZSTART, 0, &ivalue); - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbWrite unknown AMP command=%d", - icbCommand); - status = asynError; - } - return(status); -} - - -static asynStatus icbWriteHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue) -{ - int status; - float fvalue=dvalue; - - switch (icbCommand) { - case icbHvpsVolt: - status = writeHvps(module, CAM_F_VOLTAGE, 0, &fvalue); - break; - case icbHvpsVlim: - status = writeHvps(module, CAM_F_HVPSVOLTLIM, 0, &fvalue); - break; - case icbHvpsInhl: - status = writeHvps(module, CAM_L_HVPSFLVINH, 0, &ivalue); - break; - case icbHvpsLati: - status = writeHvps(module, CAM_L_HVPSFINHLE, 0, &ivalue); - break; - case icbHvpsLato: - status = writeHvps(module, CAM_L_HVPSFOVLE, 0, &ivalue); - break; - case icbHvpsStatus: - status = writeHvps(module, CAM_L_HVPSFSTAT, 0, &ivalue); - break; - case icbHvpsReset: - status = writeHvps(module, CAM_L_HVPSFOVINRES, 0, &ivalue); - break; - case icbHvpsFramp: - status = writeHvps(module, CAM_L_HVPSFASTRAMP, 0, &ivalue); - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbWrite unknown HVPS command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -static asynStatus icbWriteTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue) -{ - int status=asynSuccess; - float fvalue=dvalue; - icbTcaModule *tca = &module->tca; - - switch (icbCommand) { - case icbTcaPolarity: - tca->polarity = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaThresh: - tca->threshold = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaScaEn: - tca->sca_enable = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaGate1: - tca->gate1 = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaGate2: - tca->gate2 = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaGate3: - tca->gate3 = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaSelect: - tca->select = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaPurEn: - tca->pur_enable = ivalue; - tcaWriteReg2(tca); - break; - case icbTcaPur1: - tca->pur1 = ivalue; - tcaWriteReg6(tca); - break; - case icbTcaPur2: - tca->pur2 = ivalue; - tcaWriteReg6(tca); - break; - case icbTcaPur3: - tca->pur3 = ivalue; - tcaWriteReg6(tca); - break; - case icbTcaPurAmp: - tca->pur_amp = ivalue; - tcaWriteReg6(tca); - break; - case icbTcaLow1: - /* It appears that it is necessary to write the ULD whenever the - * LLD changes. We write both when either changes. */ - tca->lld[0] = fvalue; - tcaWriteDiscrim(tca, tca->lld[0], SCA_1 | LLD); - tcaWriteDiscrim(tca, tca->uld[0], SCA_1 | ULD); - break; - case icbTcaHi1: - tca->uld[0] = fvalue; - tcaWriteDiscrim(tca,tca->lld[0], SCA_1 | LLD); - tcaWriteDiscrim(tca, tca->uld[0], SCA_1 | ULD); - break; - case icbTcaLow2: - tca->lld[1] = fvalue; - tcaWriteDiscrim(tca, tca->lld[1], SCA_2 | LLD); - tcaWriteDiscrim(tca, tca->uld[1], SCA_2 | ULD); - break; - case icbTcaHi2: - tca->uld[1] = fvalue; - tcaWriteDiscrim(tca, tca->lld[1], SCA_2 | LLD); - tcaWriteDiscrim(tca, tca->uld[1], SCA_2 | ULD); - break; - case icbTcaLow3: - tca->lld[2] = fvalue; - tcaWriteDiscrim(tca, tca->lld[2], SCA_3 | LLD); - tcaWriteDiscrim(tca, tca->uld[2], SCA_3 | ULD); - break; - case icbTcaHi3: - tca->uld[2] = fvalue; - tcaWriteDiscrim(tca, tca->lld[2], SCA_3 | LLD); - tcaWriteDiscrim(tca, tca->uld[2], SCA_3 | ULD); - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbWrite unknown TCA command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -static asynStatus icbWriteDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int ivalue, double dvalue) -{ - int status=asynSuccess; - icbDspModule *dsp = &module->dsp; - unsigned short svalue=ivalue; - int sendCommand=1; - - switch (icbCommand) { - /* These are the ao records, double values */ - /* Convert from double value to output value (unsigned short) */ - case ID_AMP_FGAIN: - svalue = dspDoubleToShort(dvalue, 0.4, 1.6, 1024, 4095); - break; - case ID_AMP_SFGAIN: - svalue = dspDoubleToShort(dvalue, 0.0, 0.03, 0, 4095); - break; - case ID_ADC_OFFS: - svalue = dspDoubleToShort(dvalue, 0.0, 16128., 0, 126); - break; - case ID_ADC_LLD: - svalue = dspDoubleToShort(dvalue, 0.0, 100., 0, 32767); - break; - case ID_ADC_ZERO: - svalue = dspDoubleToShort(dvalue, -3.125, 3.125, 0, 6250); - break; - case ID_FILTER_RT: - svalue = dspDoubleToShort(dvalue, 0.4, 28.0, 4, 280); - break; - case ID_FILTER_FT: - svalue = dspDoubleToShort(dvalue, 0.0, 3.0, 0, 30); - break; - case ID_FILTER_MFACT: - svalue = dspDoubleToShort(dvalue, 0.0, 32767, 0, 32767); - break; - case ID_FILTER_PZ: - svalue = dspDoubleToShort(dvalue, 0.0, 4095., 0, 4095); - break; - case ID_FILTER_THR: - svalue = dspDoubleToShort(dvalue, 0.0, 32767., 0, 32767); - break; - case ID_STABLZ_GSPAC: - svalue = dspDoubleToShort(dvalue, 2.0, 512., 2, 512); - break; - case ID_STABLZ_ZSPAC: - svalue = dspDoubleToShort(dvalue, 2.0, 512., 2, 512); - break; - case ID_STABLZ_GWIN: - svalue = dspDoubleToShort(dvalue, 1.0, 128., 1, 128); - break; - case ID_STABLZ_ZWIN: - svalue = dspDoubleToShort(dvalue, 1.0, 128., 1, 128); - break; - case ID_STABLZ_GCENT: - svalue = dspDoubleToShort(dvalue, 10.0, 16376., 10, 16376); - break; - case ID_STABLZ_ZCENT: - svalue = dspDoubleToShort(dvalue, 10.0, 16376., 10, 16376); - break; - case ID_STABLZ_GRAT: - svalue = dspDoubleToShort(dvalue, .01, 100., 1, 10000); - break; - case ID_STABLZ_ZRAT: - svalue = dspDoubleToShort(dvalue, .01, 100., 1, 10000); - break; - case ID_MISC_FD: - svalue = dspDoubleToShort(dvalue, 0.0, 100., 0, 1000); - break; - case ID_MISC_LTRIM: - svalue = dspDoubleToShort(dvalue, 0.0, 1000., 0, 1000); - break; - - /* These are the mbbo records, integer values */ - /* First we deal with the special cases */ - case ID_ADC_CGAIN: /* We set both the ADC gain and range */ - status = sendDsp(dsp->module, dsp->icbAddress, ID_ADC_CRANGE, svalue); - break; - case ID_START_PZ: /* Start auto pole-zero if value is non-zero */ - if (svalue != 0) - status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 8); - sendCommand = 0; - break; - case ID_START_BDC: /* Start auto BDC if value is non-zero */ - if (svalue != 0) - status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 9); - sendCommand = 0; - break; - case ID_INFO_THRI: /* Remember throughput index */ - dsp->info_thri = svalue; - break; - case ID_CLEAR_ERRORS: /* Clear errors, abort auto-PZ/BDC if value */ - /* is non-zero */ - if (svalue != 0) - status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 0); - sendCommand = 0; - break; - /* For all of the following commands just send svalue */ - case ID_AMP_CGAIN: - case ID_FILTER_BLRM: - case ID_FILTER_PZM: - case ID_MISC_INPP: - case ID_MISC_INHP: - case ID_MISC_PURM: - case ID_MISC_GATM: - case ID_MISC_OUTM: - case ID_MISC_FDM: - case ID_MISC_BBRN: - case ID_MISC_GD: - case ID_ADC_TYPE: - case ID_STABLZ_GMOD: - case ID_STABLZ_ZMOD: - case ID_STABLZ_GCOR: - case ID_STABLZ_RESET: - case ID_STABLZ_ZCOR: - case ID_ADC_CRANGE: - case ID_STABLZ_GDIV: - case ID_STABLZ_ZDIV: - case ID_FILTER_FRQ: - case ID_INFO_TDAC: - case ID_FILTER_MDEX: - case ID_MISC_TINH: - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbWrite unknown DSP command=%d", - icbCommand); - status = asynError; - sendCommand = 0; - break; - } - if (sendCommand) { - status = sendDsp(dsp->module, dsp->icbAddress, icbCommand, svalue); - } - return(status); -} - - - -static asynStatus int32Read(void *drvPvt, asynUser *pasynUser, - epicsInt32 *value) -{ - int icbCommand=pasynUser->reason; - - return(icbRead(drvPvt, pasynUser, icbCommand, value, NULL)); -} - -static asynStatus float64Read(void *drvPvt, asynUser *pasynUser, - epicsFloat64 *value) -{ - int icbCommand=pasynUser->reason; - - return(icbRead(drvPvt, pasynUser, icbCommand, NULL, value)); -} - -static asynStatus icbRead(void *drvPvt, asynUser *pasynUser, int icbCommand, - int *ivalue, double *dvalue) -{ - drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; - icbModule *module; - int status; - - status = verifyModule(pPvt, pasynUser, &module); - if (status != asynSuccess) return(status); - - switch (pPvt->icbModuleType) { - case icbAdcType: - status=icbReadAdc(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbAmpType: - status=icbReadAmp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbHvpsType: - status=icbReadHvps(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbTcaType: - status=icbReadTca(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - case icbDspType: - status=icbReadDsp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); - break; - } - return(status); -} - -static asynStatus icbReadAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue) -{ - float fvalue=0.; - int status; - - switch (icbCommand) { - case icbAdcZeroRbv: - status = readAdc(module, CAM_F_ZERO, 0, &fvalue); - *dvalue = fvalue; - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbRead, unknown ADC command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - -static asynStatus icbReadAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue) -{ - float fvalue=0.; - int status; - - switch (icbCommand) { - case icbAmpShaping: - status = readAmp(module, CAM_F_AMPTC, 0, &fvalue); - *dvalue = fvalue; - break; - case icbAmpPzRbv: - status = readAmp(module, CAM_L_AMPPZ, 0, ivalue); - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbRead, unknown AMP command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -static asynStatus icbReadHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue) -{ - float fvalue=0.; - int status; - - switch (icbCommand) { - case icbHvpsVpol: - status = readHvps(module, CAM_L_HVPSFPOL, 0, ivalue); - break; - case icbHvpsInh: - status = readHvps(module, CAM_L_HVPSFINH, 0, ivalue); - break; - case icbHvpsOvl: - status = readHvps(module, CAM_L_HVPSFOV, 0, ivalue); - break; - case icbHvpsStatRbv: - status = readHvps(module, CAM_L_HVPSFSTAT, 0, ivalue); - break; - case icbHvpsBusy: - status = readHvps(module, CAM_L_HVPSFBUSY, 0, ivalue); - break; - case icbHvpsVoltRbv: - status = readHvps(module, CAM_F_VOLTAGE, 0, &fvalue); - *dvalue = fvalue; - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbRead, unknown HVPS command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -static asynStatus icbReadTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue) -{ - icbTcaModule *tca = &module->tca; - unsigned char reg; - int status; - - switch (icbCommand) { - case icbTcaStatus: - /* Read status of module */ - status = read_icb(tca->module, tca->icbAddress, 0, 1, ®); - /* It seems like "status" should tell us if the module can - * communicate but it does not, it returns OK even for non-existant - * modules. Look for data = 0xff instead */ - if (reg == 0xff) { /* Can't communicate */ - *ivalue = 3; - status = ERROR; - } else if (reg & 0x8) /* module has been reset */ - *ivalue = 2; - else if (reg & 0x10) /* module failed self test */ - *ivalue = 1; - else /* module must be ok */ - *ivalue = 0; - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbRead, unknown TCA command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -static asynStatus icbReadDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - int icbCommand, icbModule *module, - int *ivalue, double *dvalue) -{ - icbDspModule *dsp = &module->dsp; - unsigned short svalue; - int status=asynSuccess; - - switch (icbCommand) { - /* These are the mbbi records, return value in *ivalue */ - case ID_STABLZ_GMOD: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - /* Store value for use by other commands */ - dsp->stablz_gmod = svalue; - *ivalue = svalue & 0x3; - break; - case ID_STABLZ_GOVR: - /* Use cached value of GMOD */ - if (dsp->stablz_gmod & 0x80) *ivalue=1; else *ivalue=0; - break; - case ID_STABLZ_GOVF: - /* Use cached value of GMOD */ - if (dsp->stablz_gmod & 0x40) *ivalue=1; else *ivalue=0; - break; - case ID_STABLZ_ZMOD: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - /* Store value for use by other commands */ - dsp->stablz_gmod = svalue; - *ivalue = svalue & 0x3; - break; - case ID_STABLZ_ZOVR: - /* Use cached value of GMOD */ - if (dsp->stablz_zmod & 0x80) *ivalue=1; else *ivalue=0; - break; - case ID_STABLZ_ZOVF: - /* Use cached value of GMOD */ - if (dsp->stablz_zmod & 0x40) *ivalue=1; else *ivalue=0; - break; - case ID_INFO_PZAER: - *ivalue = ((dsp->info_pz & 0x7000) >> 12); - break; - case ID_INFO_BDCAER: - *ivalue = ((dsp->info_bdc & 0x7000) >> 12); - break; - case ID_STATUS_PZBSY: - *ivalue = (dsp->status_flgs & 0x1) != 0; - break; - case ID_STATUS_BDBSY: - *ivalue = (dsp->status_flgs & 0x2) != 0; - break; - case ID_STATUS_MINT: - *ivalue = (dsp->status_flgs & 0x4) != 0; - break; - case ID_STATUS_DGBSY: - *ivalue = (dsp->status_flgs & 0x8) != 0; - break; - case ID_STATUS_MERR: - *ivalue = (dsp->status_flgs & 0x10) != 0; - break; - - /* These are the ao records, return value in *dvalue*/ - case ID_STATUS_FLGS: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - /* Store value for use by other commands */ - dsp->status_flgs = svalue; - *dvalue = svalue; - break; - case ID_INFO_PZ: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - /* Store value for use by other commands */ - dsp->info_pz = svalue; - /* Return actual pole zero */ - svalue = svalue & 0xfff; - *dvalue = dspShortToDouble(svalue, 0.0, 4095., 0, 4095); - break; - case ID_FILTER_PZ: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - *dvalue = dspShortToDouble(svalue, 0.0, 4095., 0, 4095); - break; - case ID_INFO_BDC: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - /* Store value for use by other commands */ - dsp->info_bdc = svalue; - /* Return actual flat top */ - svalue = svalue & 0x3f; - *dvalue = dspShortToDouble(svalue, 0.0, 3.0, 0, 30); - break; - case ID_FILTER_FT: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - *dvalue = dspShortToDouble(svalue, 0.0, 3.0, 0, 30); - break; - case ID_STABLZ_GAIN: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - *dvalue = svalue; - break; - case ID_STABLZ_ZERO: - status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); - *dvalue = svalue; - break; - case ID_INFO_THRP: - status = readDsp(dsp->module, dsp->icbAddress, ID_INFO_THRP, &svalue); - *dvalue = dspUnpackThroughput(svalue); - /* Need to do special case of DT divide by 10. */ - if (dsp->info_thri == 0) *dvalue = *dvalue / 10.; - break; - default: - epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, - "icbRead, unknown DSP command=%d", - icbCommand); - status = asynError; - break; - } - return(status); -} - - -/* asynDrvUser routines */ -static asynStatus drvUserCreate(void *drvPvt, asynUser *pasynUser, - const char *drvInfo, - const char **pptypeName, size_t *psize) -{ - drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; - int i; - int maxCommands=0; - icbCommandStruct *pcommands=NULL; - char *pstring; - - switch (pPvt->icbModuleType) { - case icbAdcType: - maxCommands = MAX_ICB_ADC_COMMANDS; - pcommands = icbAdcCommands; - break; - case icbAmpType: - maxCommands = MAX_ICB_AMP_COMMANDS; - pcommands = icbAmpCommands; - break; - case icbHvpsType: - maxCommands = MAX_ICB_HVPS_COMMANDS; - pcommands = icbHvpsCommands; - break; - case icbTcaType: - maxCommands = MAX_ICB_TCA_COMMANDS; - pcommands = icbTcaCommands; - break; - case icbDspType: - maxCommands = MAX_ICB_DSP_COMMANDS; - pcommands = icbDspCommands; - break; - } - - for (i=0; ireason = pcommands[i].command; - if (pptypeName) *pptypeName = epicsStrDup(pstring); - if (psize) *psize = sizeof(pcommands[i].command); - asynPrint(pasynUser, ASYN_TRACE_FLOW, - "drvIcbAsyn:drvUserCreate::drvUserCreate, command=%s\n", pstring); - return(asynSuccess); - } - } - asynPrint(pasynUser, ASYN_TRACE_ERROR, - "drvIcbAsyn::drvUserCreate, unknown command=%s\n", drvInfo); - return(asynError); -} - -static asynStatus drvUserGetType(void *drvPvt, asynUser *pasynUser, - const char **pptypeName, size_t *psize) -{ - int command = pasynUser->reason; - - *pptypeName = epicsStrDup("icbCommands"); - *psize = sizeof(command); - return(asynSuccess); -} - -static asynStatus drvUserDestroy(void *drvPvt, asynUser *pasynUser) -{ - return(asynSuccess); -} - - -/* asynCommon routines */ - -/* Report parameters */ -static void icbReport(void *drvPvt, FILE *fp, int details) -{ - drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; - icbModule *module; - - assert(pPvt); - fprintf(fp, "ICB port %s:\n", pPvt->portName); - if (details >= 1) { - module = &pPvt->icbModule; - if (module->defined == icbFound) - fprintf(fp, " module address: %s OK\n", module->address); - else if (module->defined == icbNotFound) - fprintf(fp, " module address: %s NOT FOUND\n", module->address); - } -} - -/* Connect */ -static asynStatus icbConnect(void *drvPvt, asynUser *pasynUser) -{ - pasynManager->exceptionConnect(pasynUser); - return(asynSuccess); -} - -/* Disconnect */ -static asynStatus icbDisconnect(void *drvPvt, asynUser *pasynUser) -{ - pasynManager->exceptionDisconnect(pasynUser); - return(asynSuccess); -} - - -static asynStatus verifyModule(drvIcbAsynPvt *pPvt, asynUser *pasynUser, - icbModule **m) -{ - *m = &pPvt->icbModule; - if ((*m)->defined != icbFound) { - asynPrint(pasynUser, ASYN_TRACE_ERROR, - "drvIcbAsyn::verifyModule module not defined or not found\n"); - return(asynError); - } - return(asynSuccess); -} - - -static int writeAdc(icbModule *m, long command, char c, void *addr) -{ - ICB_PARAM_LIST icb_write_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - return(icb_adc_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); -} - -static int writeAmp(icbModule *m, long command, char c, void *addr) -{ - ICB_PARAM_LIST icb_write_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - return(icb_amp_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); -} - -static int writeHvps(icbModule *m, long command, char c, void *addr) -{ - ICB_PARAM_LIST icb_write_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - return(icb_hvps_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); -} - - -/* We need a way to determine if the module is communicating. icb_xxx_hdlr does - * not always return an error condition if the module is not available. Read the - * CSR and test it for the value 0xff, which is what it has if it is not on the ICB. */ -static int readAdc(icbModule *m, long command, char c, void *addr) -{ - int s; - unsigned char csr; - ICB_PARAM_LIST icb_read_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - s = icb_adc_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); - if (s != OK) return(s); - icb_input(m->index, 0, 1, &csr); - if (csr == 0xff) return(ERROR); - else return(OK); -} - -static int readAmp(icbModule *m, long command, char c, void *addr) -{ - int s; - unsigned char csr; - ICB_PARAM_LIST icb_read_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - s = icb_amp_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); - if (s != OK) return(s); - icb_input(m->index, 0, 1, &csr); - if (csr == 0xff) return(ERROR); - else return(OK); -} - -static int readHvps(icbModule *m, long command, char c, void *addr) -{ - int s; - unsigned char csr; - ICB_PARAM_LIST icb_read_list[] = { - {command, c, addr}, /* Parameter */ - {0, 0, 0}}; /* End of list */ - s = icb_hvps_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); - if (s != OK) return(s); - icb_input(m->index, 0, 1, &csr); - if (csr == 0xff) return(ERROR); - else return(OK); -} - - -static int tcaWriteReg2(icbTcaModule *m) -{ - unsigned char reg; - - /* build up register 2 */ - reg = 0; - if (m->select) reg |= 0x80; - if (m->gate3) reg |= 0x40; - if (m->gate2) reg |= 0x20; - if (m->gate1) reg |= 0x10; - if (m->sca_enable) reg |= 0x08; - if (m->threshold) reg |= 0x04; - if (m->pur_enable) reg |= 0x02; - if (m->polarity) reg |= 0x01; - return(write_icb(m->module, m->icbAddress, 2, 1, ®)); -} - -static int tcaWriteReg6(icbTcaModule *m) -{ - unsigned char reg; - - /* build up register 6 */ - reg = 0; - if (m->pur_amp) reg |= 0x08; - if (m->pur3) reg |= 0x04; - if (m->pur2) reg |= 0x02; - if (m->pur1) reg |= 0x01; - return(write_icb(m->module, m->icbAddress, 6, 1, ®)); -} - -static int tcaWriteDiscrim(icbTcaModule *m, double percent, int discrim_spec) -{ - ULONG dac; - unsigned char registers[2]; - - if (percent < 0.0) percent = 0.0; - if (percent > 100.) percent = 100.; - - /* Convert to 12 bit DAC value & load into regs for write */ - dac = (int) (percent * 40.95); - registers[0] = dac & 0xff; - registers[1] = ((dac & 0xff00) >> 8) | discrim_spec; - - /* Send new value to the ICB module */ - return(write_icb(m->module, m->icbAddress, 3, 2, ®isters[0])); -} - - -static int sendDsp(int module, int icbAddress, int command, unsigned short data) -{ - unsigned char registers[4]; - unsigned char r6; - int i; - - registers[0] = 0; /* Not a read command, use only table 0 for now */ - registers[1] = command; /* Parameter opcode */ - registers[2] = (data & 0x0000ff00) >> 8; /* MSB of data */ - registers[3] = data & 0x000000ff; /* LSB of data */ - write_icb(module, icbAddress, 2, 4, registers); - /* The following delay seems to be necessary or writes will sometimes - * timeout below */ - epicsThreadSleep(DELAY_9660); - - /* Read register 6 back. Return error flag on error. Wait for WDONE to be - * set */ - for (i=0; i dmax) d = dmax; - ival = (unsigned short) (imin + (imax-imin) * (d - dmin) / - (dmax - dmin) + 0.5); - return(ival); -} - -static double dspShortToDouble(unsigned short ival, double dmin, double dmax, - unsigned short imin, unsigned short imax) -{ - double dval; - unsigned short i=ival; - - if (i < imin) i = imin; - if (i > imax) i = imax; - dval = dmin + (dmax-dmin) * (i - imin) / (imax - imin); - return(dval); -} - -static double dspUnpackThroughput(unsigned short ival) -{ - int exponent; - double mantissa; - - exponent = (ival & 0xE000) >> 13; - mantissa = (ival & 0x1FFF); - return(mantissa * (2 << exponent)); -} - - -/* iocsh functions */ - -static const iocshArg icbConfigArg0 = { "Port name",iocshArgString}; -static const iocshArg icbConfigArg1 = { "Ethernet address",iocshArgInt}; -static const iocshArg icbConfigArg2 = { "ICB address",iocshArgInt}; -static const iocshArg icbConfigArg3 = { "ICB module type",iocshArgInt}; -static const iocshArg * const icbConfigArgs[4] = {&icbConfigArg0, - &icbConfigArg1, - &icbConfigArg2, - &icbConfigArg3}; -static const iocshFuncDef icbConfigFuncDef = {"icbConfig",4,icbConfigArgs}; -static void icbConfigCallFunc(const iocshArgBuf *args) -{ - icbConfig(args[0].sval, args[1].ival, - args[2].ival, args[3].ival); -} - -void icbAsynRegister(void) -{ - iocshRegister(&icbConfigFuncDef,icbConfigCallFunc); -} - -epicsExportRegistrar(icbAsynRegister); +/* drvIcbAsyn.c + + Author: Mark Rivers + Date: 23-June-2004 Modified from icbMpfServer.cc + + This module is an asyn driver which is called from from asyn generic + device support and commmunicates with the following Canberra ICB modules: + 9633/9635 ADC + 9615 Amplifier + 9641/9621 HVPS + TCA + 9660 DSP + +*/ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "drvIcbAsyn.h" +#include "icbDsp.h" + +#include "nmc_sys_defs.h" +#include "icb_user_subs.h" +#include "icb_sys_defs.h" +#include "icb_bus_defs.h" +#include "campardef.h" +#include + +typedef struct { + int command; + char *commandString; +} icbCommandStruct; + +static icbCommandStruct icbAdcCommands[MAX_ICB_ADC_COMMANDS] = { + {icbAdcGain, "GAIN"}, + {icbAdcRange, "RANGE"}, + {icbAdcOffset, "OFFSET"}, + {icbAdcLld, "LLD"}, + {icbAdcUld, "ULD"}, + {icbAdcZero, "ZERO"}, + {icbAdcGmod, "GATE_MODE"}, + {icbAdcCmod, "COINCIDENCE_MODE"}, + {icbAdcPmod, "PEAK_MODE"}, + {icbAdcAmod, "ACQUISITION_MODE"}, + {icbAdcTmod, "TRANSFER_MODE"}, + {icbAdcZeroRbv, "ZERO_READBACK"} +}; + +static icbCommandStruct icbAmpCommands[MAX_ICB_AMP_COMMANDS] = { + {icbAmpCgain, "COARSE_GAIN"}, + {icbAmpFgain, "FINE_GAIN"}, + {icbAmpSfgain, "SUPERFINE_GAIN"}, + {icbAmpInpp, "INPUT_POLARITY"}, + {icbAmpInhp, "INHIBIT_POLARITY"}, + {icbAmpDmod, "DIFFERENTIAL_MODE"}, + {icbAmpSmod, "SHAPING_MODE"}, + {icbAmpPtyp, "PREAMP_TYPE"}, + {icbAmpPurmod, "PUR_MODE"}, + {icbAmpBlmod, "BASELINE_MODE"}, + {icbAmpDtmod, "DEADTIME_MODE"}, + {icbAmpAutoPz, "START_PZ"}, + {icbAmpPz, "REQUESTED_PZ"}, + {icbAmpShaping, "SHAPING"}, + {icbAmpPzRbv, "PZ_READBACK"} +}; + +static icbCommandStruct icbHvpsCommands[MAX_ICB_HVPS_COMMANDS] = { + {icbHvpsVolt, "VOLT"}, + {icbHvpsVlim, "LIMIT"}, + {icbHvpsInhl, "INHIBIT_LEVEL"}, + {icbHvpsLati, "LATCH_INHIBIT"}, + {icbHvpsLato, "LATCH_OVERLOAD"}, + {icbHvpsReset, "RESET"}, + {icbHvpsStatus, "STATUS"}, + {icbHvpsFramp, "FAST_RAMP"}, + {icbHvpsVpol, "POLARITY"}, + {icbHvpsInh, "INHIBIT"}, + {icbHvpsOvl, "OVERLOAD"}, + {icbHvpsStatRbv, "STATUS_READBACK"}, + {icbHvpsBusy, "BUSY"}, + {icbHvpsVoltRbv, "VOLT_READBACK"} +}; + +static icbCommandStruct icbTcaCommands[MAX_ICB_TCA_COMMANDS] = { + {icbTcaPolarity, "POLARITY"}, + {icbTcaThresh, "THRESHOLD"}, + {icbTcaScaEn, "SCA_ENABLE"}, + {icbTcaGate1, "GATE1"}, + {icbTcaGate2, "GATE2"}, + {icbTcaGate3, "GATE3"}, + {icbTcaSelect, "TCA_SELECT"}, + {icbTcaPurEn, "PUR_ENABLE"}, + {icbTcaPur1, "PUR1"}, + {icbTcaPur2, "PUR2"}, + {icbTcaPur3, "PUR3"}, + {icbTcaPurAmp, "PUR_AMP"}, + {icbTcaLow1, "LOW1"}, + {icbTcaHi1, "HI1"}, + {icbTcaLow2, "LOW2"}, + {icbTcaHi2, "HI2"}, + {icbTcaLow3, "LOW3"}, + {icbTcaHi3, "HI3"}, + {icbTcaStatus, "STATUS"} +}; + +#define MAX_ICB_DSP_COMMANDS 75 +static icbCommandStruct icbDspCommands[MAX_ICB_DSP_COMMANDS] = { + {ID_AMP_CGAIN, "AMP_CGAIN"}, + {ID_AMP_FGAIN, "AMP_FGAIN"}, + {ID_AMP_SFGAIN, "AMP_SFGAIN"}, + {ID_ADC_CGAIN, "ADC_CGAIN"}, + {ID_ADC_CRANGE, "ADC_CRANGE"}, + {ID_ADC_OFFS, "ADC_OFFS"}, + {ID_ADC_TYPE, "ADC_TYPE"}, + {ID_ADC_LLD, "ADC_LLD"}, + {ID_ADC_ZERO, "ADC_ZERO"}, + {ID_FILTER_RT, "FILTER_RT"}, + {ID_FILTER_FT, "FILTER_FT"}, + {ID_FILTER_MDEX, "FILTER_MDEX"}, + {ID_FILTER_MFACT, "FILTER_MFACT"}, + {ID_FILTER_BLRM, "FILTER_BLRM"}, + {ID_FILTER_PZM, "FILTER_PZM"}, + {ID_FILTER_PZ, "FILTER_PZ"}, + {ID_FILTER_THR, "FILTER_THR"}, + {ID_FILTER_FRQ, "FILTER_FRQ"}, + {ID_STABLZ_GCOR, "STABLZ_GCOR"}, + {ID_STABLZ_ZCOR, "STABLZ_ZCOR"}, + {ID_STABLZ_GMOD, "STABLZ_GMOD"}, + {ID_STABLZ_ZMOD, "STABLZ_ZMOD"}, + {ID_STABLZ_GDIV, "STABLZ_GDIV"}, + {ID_STABLZ_ZDIV, "STABLZ_ZDIV"}, + {ID_STABLZ_GSPAC, "STABLZ_GSPAC"}, + {ID_STABLZ_ZSPAC, "STABLZ_ZSPAC"}, + {ID_STABLZ_GWIN, "STABLZ_GWIN"}, + {ID_STABLZ_ZWIN, "STABLZ_ZWIN"}, + {ID_STABLZ_GCENT, "STABLZ_GCENT"}, + {ID_STABLZ_ZCENT, "STABLZ_ZCENT"}, + {ID_STABLZ_GRAT, "STABLZ_GRAT"}, + {ID_STABLZ_ZRAT, "STABLZ_ZRAT"}, + {ID_STABLZ_RESET, "STABLZ_RESET"}, + {ID_STABLZ_GAIN, "STABLZ_GAIN"}, + {ID_STABLZ_ZERO, "STABLZ_ZERO"}, + {ID_MISC_FDM, "MISC_FDM"}, + {ID_MISC_FD, "MISC_FD"}, + {ID_MISC_INPP, "MISC_INPP"}, + {ID_MISC_INHP, "MISC_INHP"}, + {ID_MISC_PURM, "MISC_PURM"}, + {ID_MISC_GATM, "MISC_GATM"}, + {ID_MISC_OUTM, "MISC_OUTM"}, + {ID_MISC_GD, "MISC_GD"}, + {ID_MISC_TINH, "MISC_TINH"}, + {ID_MISC_LTRIM, "MISC_LTRIM"}, + {ID_MISC_BBRN, "MISC_BBRN"}, + {ID_INFO_TDAC, "INFO_TDAC"}, + {ID_INFO_THRP, "INFO_THRP"}, + {ID_INFO_THRI, "INFO_THRI"}, + {ID_INFO_PZ, "INFO_PZ"}, + {ID_INFO_BDC, "INFO_BDC"}, + {ID_STATUS_FLGS, "STATUS_FLGS"}, + {ID_SYSOP_CMD, "SYSOP_CMD"}, + {ID_SYSOP_RDATL, "SYSOP_RDATL"}, + {ID_SYSOP_RDATH, "SYSOP_RDATH"}, + {ID_SYSOP_LCD, "SYSOP_LCD"}, + {ID_SYSOP_DAC, "SYSOP_DAC"}, + {ID_START_PZ, "START_PZ"}, + {ID_START_BDC, "START_BDC"}, + {ID_CLEAR_ERRORS, "CLEAR_ERRORS"}, + {ID_STABLZ_GOVR, "STABLZ_GOVR"}, + {ID_STABLZ_GOVF, "STABLZ_GOVF"}, + {ID_STABLZ_ZOVR, "STABLZ_ZOVR"}, + {ID_STABLZ_ZOVF, "STABLZ_ZOVF"}, + {ID_INFO_PZAER, "INFO_PZAER"}, + {ID_INFO_BDCAER, "INFO_BDCAER"}, + {ID_STATUS_PZBSY, "STATUS_PZBSY"}, + {ID_STATUS_BDBSY, "STATUS_BDBSY"}, + {ID_STATUS_MINT, "STATUS_MINT"}, + {ID_STATUS_DGBSY, "STATUS_DGBSY"}, + {ID_STATUS_MERR, "STATUS_MERR"}, + {ID_INFO_DT, "INFO_DT"}, + {ID_INFO_ICR, "INFO_ICR"}, + {ID_INFO_DSPRATE, "INFO_DSPRATE"}, + {ID_INFO_MCARATE, "INFO_MCARATE"} +}; + +#define LLD 0 +#define ULD 0x20 +#define SCA_1 0 +#define SCA_2 0x40 +#define SCA_3 0x80 + +typedef struct { + int module; + int icbAddress; + int polarity; + int threshold; + int sca_enable; + int gate1; + int gate2; + int gate3; + int select; + int pur_enable; + int pur1; + int pur2; + int pur3; + int pur_amp; + float lld[3]; + float uld[3]; +} icbTcaModule; + +typedef struct { + int module; + int icbAddress; + int defined; + int stablz_gmod; + int stablz_zmod; + int info_pz; + int info_bdc; + int info_thri; + int status_flgs; +} icbDspModule; + + +typedef enum { + icbUndefined, + icbNotFound, + icbFound +} icbModuleStatus; + +typedef struct { + char address[80]; + icbModuleStatus defined; + int index; + /* Note, we put these structures in for all modules, regardless of type. + * Small extra memory, but simpler than using pointers and allocation */ + icbTcaModule tca; + icbDspModule dsp; +} icbModule; + +typedef struct { + char *portName; + icbModuleType icbModuleType; + icbModule icbModule; + asynInterface common; + asynInterface int32; + asynInterface float64; + asynInterface drvUser; +} drvIcbAsynPvt; + + +/* These functions are in the public interfaces */ +static asynStatus int32Write( void *drvPvt, asynUser *pasynUser, + epicsInt32 value); +static asynStatus int32Read( void *drvPvt, asynUser *pasynUser, + epicsInt32 *value); +static asynStatus getBounds( void *drvPvt, asynUser *pasynUser, + epicsInt32 *low, epicsInt32 *high); +static asynStatus float64Write( void *drvPvt, asynUser *pasynUser, + epicsFloat64 value); +static asynStatus float64Read( void *drvPvt, asynUser *pasynUser, + epicsFloat64 *value); +static asynStatus drvUserCreate( void *drvPvt, asynUser *pasynUser, + const char *drvInfo, + const char **pptypeName, size_t *psize); +static asynStatus drvUserGetType( void *drvPvt, asynUser *pasynUser, + const char **pptypeName, size_t *psize); +static asynStatus drvUserDestroy( void *drvPvt, asynUser *pasynUser); +static void icbReport( void *drvPvt, FILE *fp, int details); +static asynStatus icbConnect( void *drvPvt, asynUser *pasynUser); +static asynStatus icbDisconnect( void *drvPvt, asynUser *pasynUser); + +/* These functions are private, not in any interface */ +static asynStatus icbRead(void *drvPvt, asynUser *pasynUser, int icbCommand, + int *ivalue, double *dvalue); +static asynStatus icbReadAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue); +static asynStatus icbReadAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue); +static asynStatus icbReadHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue); +static asynStatus icbReadTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue); +static asynStatus icbReadDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue); +static asynStatus icbWrite(void *drvPvt, asynUser *pasynUser, int icbCommand, + int ivalue, double dvalue); +static asynStatus icbWriteAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue); +static asynStatus icbWriteAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue); +static asynStatus icbWriteHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue); +static asynStatus icbWriteTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue); +static asynStatus icbWriteDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue); +static int writeAdc(icbModule *m, long command, char c, void *addr); +static int writeAmp(icbModule *m, long command, char c, void *addr); +static int writeHvps(icbModule *m, long command, char c, void *addr); +static int readAdc(icbModule *m, long command, char c, void *addr); +static int readAmp(icbModule *m, long command, char c, void *addr); +static int readHvps(icbModule *m, long command, char c, void *addr); +static int tcaWriteReg2(icbTcaModule *m); +static int tcaWriteReg6(icbTcaModule *m); +static int tcaWriteDiscrim(icbTcaModule *m, double percent, int discrim_spec); +static int sendDsp(int module, int icbAddress, int command, + unsigned short data); +static int readDsp(int module, int icbAddress, int command, + unsigned short *data); +static unsigned short dspDoubleToShort(double dval, double dmin, double dmax, + unsigned short imin, + unsigned short imax); +static double dspShortToDouble(unsigned short ival, double dmin, double dmax, + unsigned short imin, unsigned short imax); +static double dspUnpackThroughput(unsigned short ival); + +static asynStatus verifyModule(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + icbModule **m); + +/* asynCommon interface */ +static struct asynCommon icbCommon = { + icbReport, + icbConnect, + icbDisconnect +}; + +/* asynInt32 interface */ +static asynInt32 icbInt32 = { + int32Write, + int32Read, + getBounds, + NULL, + NULL +}; + +/* asynFloat64 interface */ +static asynFloat64 icbFloat64 = { + float64Write, + float64Read, + NULL, + NULL +}; + +/* asynDrvUser interface */ +static asynDrvUser icbDrvUser = { + drvUserCreate, + drvUserGetType, + drvUserDestroy +}; + + +int icbConfig(const char *portName, int enetAddress, int icbAddress, + icbModuleType icbModuleType) +{ + int status; + drvIcbAsynPvt *pPvt; + icbModule *m; + unsigned char csr; + + pPvt = callocMustSucceed(1, sizeof(drvIcbAsynPvt), "icbSetup"); + pPvt->portName = epicsStrDup(portName); + pPvt->icbModuleType = icbModuleType; + m = &pPvt->icbModule; + pPvt->common.interfaceType = asynCommonType; + pPvt->common.pinterface = (void *)&icbCommon; + pPvt->common.drvPvt = pPvt; + pPvt->int32.interfaceType = asynInt32Type; + pPvt->int32.pinterface = (void *)&icbInt32; + pPvt->int32.drvPvt = pPvt; + pPvt->float64.interfaceType = asynFloat64Type; + pPvt->float64.pinterface = (void *)&icbFloat64; + pPvt->float64.drvPvt = pPvt; + pPvt->drvUser.interfaceType = asynDrvUserType; + pPvt->drvUser.pinterface = (void *)&icbDrvUser; + pPvt->drvUser.drvPvt = pPvt; + status = pasynManager->registerPort(pPvt->portName, + ASYN_CANBLOCK, /* Not MULTIDEVICE */ + 1, /* autoconnect */ + 0, /* medium priority */ + 0); /* default stack size */ + if (status != asynSuccess) { + errlogPrintf("icbConfig ERROR: Can't register common\n"); + return -1; + } + status = pasynManager->registerInterface(pPvt->portName,&pPvt->common); + if (status != asynSuccess) { + errlogPrintf("icbConfig ERROR: Can't register common.\n"); + return -1; + } + status = pasynInt32Base->initialize(pPvt->portName,&pPvt->int32); + if (status != asynSuccess) { + errlogPrintf("icbConfig ERROR: Can't register int32\n"); + return -1; + } + + status = pasynFloat64Base->initialize(pPvt->portName,&pPvt->float64); + if (status != asynSuccess) { + errlogPrintf("icbConfig ERROR: Can't register float64\n"); + return -1; + } + + status = pasynManager->registerInterface(pPvt->portName,&pPvt->drvUser); + if (status != asynSuccess) { + errlogPrintf("icbConfig ERROR: Can't register drvUser\n"); + return -1; + } + + /* Initialize the ICB software in case this has not been done */ + status=icb_initialize(); + if (status != 0) return(-1); + + m->defined = icbNotFound; + sprintf(m->address, "NI%X:%X", enetAddress, icbAddress); + + /* This part is different for different module types */ + switch (pPvt->icbModuleType) { + case icbAdcType: + case icbAmpType: + case icbHvpsType: + status = icb_findmod_by_address(m->address, &m->index); + if (status != 0) { + errlogPrintf("icbConfig: Error looking up ICB module %s\n", + m->address); + return(-1); + } + break; + case icbTcaType: + if (parse_ICB_address(m->address, &m->tca.module, + &m->tca.icbAddress) != OK) { + errlogPrintf("icbConfig: failed to initialize this address: %s\n", + m->address); + return(-1); + } + /* Initialize the module. Can't turn on green light on this module, + * that is controlled by TCA select bit. Clear the reset bit. */ + csr = ICB_M_CTRL_CLEAR_RESET; + write_icb(m->tca.module, m->tca.icbAddress, 0, 1, &csr); + break; + case icbDspType: + if (parse_ICB_address(m->address, &m->dsp.module, + &m->dsp.icbAddress) != OK) { + errlogPrintf("icbConfig: failed to initialize this address: %s\n", + m->address); + return(-1); + } + /* Initialize the module (turn on green light) */ + csr = ICB_M_CTRL_LED_GREEN; + write_icb(m->dsp.module, m->dsp.icbAddress, 0, 1, &csr); + break; + default: + errlogPrintf("icbConfig: unknown module type %d\n", pPvt->icbModuleType); + return(-1); + } + m->defined = icbFound; + return(0); +} + + + +static asynStatus getBounds(void *drvPvt, asynUser *pasynUser, + epicsInt32 *low, epicsInt32 *high) +{ + /* This function should not be called, since no device support + * should be using LINEAR conversion */ + *low = 0; + *high = 65535; + return(0); +} + +static asynStatus int32Write(void *drvPvt, asynUser *pasynUser, + epicsInt32 value) +{ + int icbCommand=pasynUser->reason; + + return(icbWrite(drvPvt, pasynUser, icbCommand, value, 0.)); +} + +static asynStatus float64Write(void *drvPvt, asynUser *pasynUser, + epicsFloat64 value) +{ + int icbCommand=pasynUser->reason; + + return(icbWrite(drvPvt, pasynUser, icbCommand, 0, value)); +} + +static asynStatus icbWrite(void *drvPvt, asynUser *pasynUser, int icbCommand, + int ivalue, double dvalue) +{ + drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; + icbModule *module; + int status; + + status = verifyModule(pPvt, pasynUser, &module); + if (status != asynSuccess) return(status); + + switch (pPvt->icbModuleType) { + case icbAdcType: + status=icbWriteAdc(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbAmpType: + status=icbWriteAmp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbHvpsType: + status=icbWriteHvps(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbTcaType: + status=icbWriteTca(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbDspType: + status=icbWriteDsp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + } + return(status); +} + + +static asynStatus icbWriteAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue) +{ + int status; + char str[80]; + float fvalue=dvalue; + + switch (icbCommand) { + case icbAdcGain: /* We set both the ADC gain if either changes */ + case icbAdcRange: + status = writeAdc(module, CAM_L_CNVGAIN, 0, &ivalue); + status = writeAdc(module, CAM_L_ADCRANGE, 0, &ivalue); + break; + case icbAdcOffset: + ivalue = (int) dvalue; + status = writeAdc(module, CAM_L_ADCOFFSET, 0, &ivalue); + break; + case icbAdcLld: + status = writeAdc(module, CAM_F_LLD, 0, &fvalue); + break; + case icbAdcUld: + status = writeAdc(module, CAM_F_ULD, 0, &fvalue); + break; + case icbAdcZero: + status = writeAdc(module, CAM_F_ZERO, 0, &fvalue); + break; + case icbAdcGmod: + status = writeAdc(module, CAM_L_ADCFANTIC, 0, &ivalue); + break; + case icbAdcCmod: + status = writeAdc(module, CAM_L_ADCFLATEC, 0, &ivalue); + break; + case icbAdcPmod: + status = writeAdc(module, CAM_L_ADCFDELPK, 0, &ivalue); + break; + case icbAdcAmod: + if (ivalue) strcpy(str, "SVA"); + else strcpy(str, "PHA"); + status = writeAdc(module, CAM_T_ADCACQMODE, 'S', &str); + break; + case icbAdcTmod: + status = writeAdc(module, CAM_L_ADCFNONOV, 0, &ivalue); + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbWrite unknown ADC command=%d", + icbCommand); + status = asynError; + } + return(status); +} + + +static asynStatus icbWriteAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue) +{ + int status; + char str[80]; + float fvalue=dvalue; + + switch (icbCommand) { + case icbAmpCgain: + fvalue = (float)ivalue; + /* The value 2.5 will be sent as 2, since MBBO only does integers */ + if (fvalue == 2.0) fvalue = 2.5; + status = writeAmp(module, CAM_F_AMPHWGAIN1, 0, &fvalue); + break; + case icbAmpFgain: + status = writeAmp(module, CAM_F_AMPHWGAIN2, 0, &fvalue); + break; + case icbAmpSfgain: + status = writeAmp(module, CAM_F_AMPHWGAIN3, 0, &fvalue); + break; + case icbAmpInpp: + status = writeAmp(module, CAM_L_AMPFNEGPOL, 0, &ivalue); + break; + case icbAmpInhp: + status = writeAmp(module, CAM_L_AMPFCOMPINH, 0, &ivalue); + break; + case icbAmpDmod: + status = writeAmp(module, CAM_L_AMPFDIFF, 0, &ivalue); + break; + case icbAmpSmod: + if (ivalue) strcpy(str, "TRIANGLE"); + else strcpy(str, "GAUSSIAN"); + status = writeAmp(module, CAM_T_AMPSHAPEMODE, 'S', &str); + break; + case icbAmpPtyp: + if (ivalue) strcpy(str, "TRP"); + else strcpy(str, "RC"); + status = writeAmp(module, CAM_T_PRAMPTYPE, 'S', &str); + break; + case icbAmpPurmod: + status = writeAmp(module, CAM_L_AMPFPUREJ, 0, &ivalue); + break; + case icbAmpBlmod: + if (ivalue) strcpy(str, "ASYM"); + else strcpy(str, "SYM"); + status = writeAmp(module, CAM_T_AMPBLRTYPE, 'S', &str); + break; + case icbAmpDtmod: + if (ivalue) strcpy(str, "LFC"); + else strcpy(str, "Norm"); + status = writeAmp(module, CAM_T_AMPDTCTYPE, 'S', &str); + break; + case icbAmpPz: + ivalue = (int) fvalue; + status = writeAmp(module, CAM_L_AMPPZ, 0, &ivalue); + break; + case icbAmpAutoPz: + status = writeAmp(module, CAM_L_AMPFPZSTART, 0, &ivalue); + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbWrite unknown AMP command=%d", + icbCommand); + status = asynError; + } + return(status); +} + + +static asynStatus icbWriteHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue) +{ + int status; + float fvalue=dvalue; + + switch (icbCommand) { + case icbHvpsVolt: + status = writeHvps(module, CAM_F_VOLTAGE, 0, &fvalue); + break; + case icbHvpsVlim: + status = writeHvps(module, CAM_F_HVPSVOLTLIM, 0, &fvalue); + break; + case icbHvpsInhl: + status = writeHvps(module, CAM_L_HVPSFLVINH, 0, &ivalue); + break; + case icbHvpsLati: + status = writeHvps(module, CAM_L_HVPSFINHLE, 0, &ivalue); + break; + case icbHvpsLato: + status = writeHvps(module, CAM_L_HVPSFOVLE, 0, &ivalue); + break; + case icbHvpsStatus: + status = writeHvps(module, CAM_L_HVPSFSTAT, 0, &ivalue); + break; + case icbHvpsReset: + status = writeHvps(module, CAM_L_HVPSFOVINRES, 0, &ivalue); + break; + case icbHvpsFramp: + status = writeHvps(module, CAM_L_HVPSFASTRAMP, 0, &ivalue); + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbWrite unknown HVPS command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +static asynStatus icbWriteTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue) +{ + int status=asynSuccess; + float fvalue=dvalue; + icbTcaModule *tca = &module->tca; + + switch (icbCommand) { + case icbTcaPolarity: + tca->polarity = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaThresh: + tca->threshold = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaScaEn: + tca->sca_enable = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaGate1: + tca->gate1 = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaGate2: + tca->gate2 = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaGate3: + tca->gate3 = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaSelect: + tca->select = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaPurEn: + tca->pur_enable = ivalue; + tcaWriteReg2(tca); + break; + case icbTcaPur1: + tca->pur1 = ivalue; + tcaWriteReg6(tca); + break; + case icbTcaPur2: + tca->pur2 = ivalue; + tcaWriteReg6(tca); + break; + case icbTcaPur3: + tca->pur3 = ivalue; + tcaWriteReg6(tca); + break; + case icbTcaPurAmp: + tca->pur_amp = ivalue; + tcaWriteReg6(tca); + break; + case icbTcaLow1: + /* It appears that it is necessary to write the ULD whenever the + * LLD changes. We write both when either changes. */ + tca->lld[0] = fvalue; + tcaWriteDiscrim(tca, tca->lld[0], SCA_1 | LLD); + tcaWriteDiscrim(tca, tca->uld[0], SCA_1 | ULD); + break; + case icbTcaHi1: + tca->uld[0] = fvalue; + tcaWriteDiscrim(tca,tca->lld[0], SCA_1 | LLD); + tcaWriteDiscrim(tca, tca->uld[0], SCA_1 | ULD); + break; + case icbTcaLow2: + tca->lld[1] = fvalue; + tcaWriteDiscrim(tca, tca->lld[1], SCA_2 | LLD); + tcaWriteDiscrim(tca, tca->uld[1], SCA_2 | ULD); + break; + case icbTcaHi2: + tca->uld[1] = fvalue; + tcaWriteDiscrim(tca, tca->lld[1], SCA_2 | LLD); + tcaWriteDiscrim(tca, tca->uld[1], SCA_2 | ULD); + break; + case icbTcaLow3: + tca->lld[2] = fvalue; + tcaWriteDiscrim(tca, tca->lld[2], SCA_3 | LLD); + tcaWriteDiscrim(tca, tca->uld[2], SCA_3 | ULD); + break; + case icbTcaHi3: + tca->uld[2] = fvalue; + tcaWriteDiscrim(tca, tca->lld[2], SCA_3 | LLD); + tcaWriteDiscrim(tca, tca->uld[2], SCA_3 | ULD); + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbWrite unknown TCA command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +static asynStatus icbWriteDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int ivalue, double dvalue) +{ + int status=asynSuccess; + icbDspModule *dsp = &module->dsp; + unsigned short svalue=ivalue; + int sendCommand=1; + + switch (icbCommand) { + /* These are the ao records, double values */ + /* Convert from double value to output value (unsigned short) */ + case ID_AMP_FGAIN: + svalue = dspDoubleToShort(dvalue, 0.4, 1.6, 1024, 4095); + break; + case ID_AMP_SFGAIN: + svalue = dspDoubleToShort(dvalue, 0.0, 0.03, 0, 4095); + break; + case ID_ADC_OFFS: + svalue = dspDoubleToShort(dvalue, 0.0, 16128., 0, 126); + break; + case ID_ADC_LLD: + svalue = dspDoubleToShort(dvalue, 0.0, 100., 0, 32767); + break; + case ID_ADC_ZERO: + svalue = dspDoubleToShort(dvalue, -3.125, 3.125, 0, 6250); + break; + case ID_FILTER_RT: + svalue = dspDoubleToShort(dvalue, 0.4, 28.0, 4, 280); + break; + case ID_FILTER_FT: + svalue = dspDoubleToShort(dvalue, 0.0, 3.0, 0, 30); + break; + case ID_FILTER_MFACT: + svalue = dspDoubleToShort(dvalue, 0.0, 32767, 0, 32767); + break; + case ID_FILTER_PZ: + svalue = dspDoubleToShort(dvalue, 0.0, 4095., 0, 4095); + break; + case ID_FILTER_THR: + svalue = dspDoubleToShort(dvalue, 0.0, 32767., 0, 32767); + break; + case ID_STABLZ_GSPAC: + svalue = dspDoubleToShort(dvalue, 2.0, 512., 2, 512); + break; + case ID_STABLZ_ZSPAC: + svalue = dspDoubleToShort(dvalue, 2.0, 512., 2, 512); + break; + case ID_STABLZ_GWIN: + svalue = dspDoubleToShort(dvalue, 1.0, 128., 1, 128); + break; + case ID_STABLZ_ZWIN: + svalue = dspDoubleToShort(dvalue, 1.0, 128., 1, 128); + break; + case ID_STABLZ_GCENT: + svalue = dspDoubleToShort(dvalue, 10.0, 16376., 10, 16376); + break; + case ID_STABLZ_ZCENT: + svalue = dspDoubleToShort(dvalue, 10.0, 16376., 10, 16376); + break; + case ID_STABLZ_GRAT: + svalue = dspDoubleToShort(dvalue, .01, 100., 1, 10000); + break; + case ID_STABLZ_ZRAT: + svalue = dspDoubleToShort(dvalue, .01, 100., 1, 10000); + break; + case ID_MISC_FD: + svalue = dspDoubleToShort(dvalue, 0.0, 100., 0, 1000); + break; + case ID_MISC_LTRIM: + svalue = dspDoubleToShort(dvalue, 0.0, 1000., 0, 1000); + break; + + /* These are the mbbo records, integer values */ + /* First we deal with the special cases */ + case ID_ADC_CGAIN: /* We set both the ADC gain and range */ + status = sendDsp(dsp->module, dsp->icbAddress, ID_ADC_CRANGE, svalue); + break; + case ID_START_PZ: /* Start auto pole-zero if value is non-zero */ + if (svalue != 0) + status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 8); + sendCommand = 0; + break; + case ID_START_BDC: /* Start auto BDC if value is non-zero */ + if (svalue != 0) + status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 9); + sendCommand = 0; + break; + case ID_INFO_THRI: /* Remember throughput index */ + dsp->info_thri = svalue; + break; + case ID_CLEAR_ERRORS: /* Clear errors, abort auto-PZ/BDC if value */ + /* is non-zero */ + if (svalue != 0) + status = sendDsp(dsp->module, dsp->icbAddress, ID_SYSOP_CMD, 0); + sendCommand = 0; + break; + /* For all of the following commands just send svalue */ + case ID_AMP_CGAIN: + case ID_FILTER_BLRM: + case ID_FILTER_PZM: + case ID_MISC_INPP: + case ID_MISC_INHP: + case ID_MISC_PURM: + case ID_MISC_GATM: + case ID_MISC_OUTM: + case ID_MISC_FDM: + case ID_MISC_BBRN: + case ID_MISC_GD: + case ID_ADC_TYPE: + case ID_STABLZ_GMOD: + case ID_STABLZ_ZMOD: + case ID_STABLZ_GCOR: + case ID_STABLZ_RESET: + case ID_STABLZ_ZCOR: + case ID_ADC_CRANGE: + case ID_STABLZ_GDIV: + case ID_STABLZ_ZDIV: + case ID_FILTER_FRQ: + case ID_INFO_TDAC: + case ID_FILTER_MDEX: + case ID_MISC_TINH: + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbWrite unknown DSP command=%d", + icbCommand); + status = asynError; + sendCommand = 0; + break; + } + if (sendCommand) { + status = sendDsp(dsp->module, dsp->icbAddress, icbCommand, svalue); + } + return(status); +} + + + +static asynStatus int32Read(void *drvPvt, asynUser *pasynUser, + epicsInt32 *value) +{ + int icbCommand=pasynUser->reason; + + return(icbRead(drvPvt, pasynUser, icbCommand, value, NULL)); +} + +static asynStatus float64Read(void *drvPvt, asynUser *pasynUser, + epicsFloat64 *value) +{ + int icbCommand=pasynUser->reason; + + return(icbRead(drvPvt, pasynUser, icbCommand, NULL, value)); +} + +static asynStatus icbRead(void *drvPvt, asynUser *pasynUser, int icbCommand, + int *ivalue, double *dvalue) +{ + drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; + icbModule *module; + int status; + + status = verifyModule(pPvt, pasynUser, &module); + if (status != asynSuccess) return(status); + + switch (pPvt->icbModuleType) { + case icbAdcType: + status=icbReadAdc(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbAmpType: + status=icbReadAmp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbHvpsType: + status=icbReadHvps(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbTcaType: + status=icbReadTca(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + case icbDspType: + status=icbReadDsp(pPvt, pasynUser, icbCommand, module, ivalue, dvalue); + break; + } + return(status); +} + +static asynStatus icbReadAdc(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue) +{ + float fvalue=0.; + int status; + + switch (icbCommand) { + case icbAdcZeroRbv: + status = readAdc(module, CAM_F_ZERO, 0, &fvalue); + *dvalue = fvalue; + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbRead, unknown ADC command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + +static asynStatus icbReadAmp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue) +{ + float fvalue=0.; + int status; + + switch (icbCommand) { + case icbAmpShaping: + status = readAmp(module, CAM_F_AMPTC, 0, &fvalue); + *dvalue = fvalue; + break; + case icbAmpPzRbv: + status = readAmp(module, CAM_L_AMPPZ, 0, ivalue); + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbRead, unknown AMP command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +static asynStatus icbReadHvps(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue) +{ + float fvalue=0.; + int status; + + switch (icbCommand) { + case icbHvpsVpol: + status = readHvps(module, CAM_L_HVPSFPOL, 0, ivalue); + break; + case icbHvpsInh: + status = readHvps(module, CAM_L_HVPSFINH, 0, ivalue); + break; + case icbHvpsOvl: + status = readHvps(module, CAM_L_HVPSFOV, 0, ivalue); + break; + case icbHvpsStatRbv: + status = readHvps(module, CAM_L_HVPSFSTAT, 0, ivalue); + break; + case icbHvpsBusy: + status = readHvps(module, CAM_L_HVPSFBUSY, 0, ivalue); + break; + case icbHvpsVoltRbv: + status = readHvps(module, CAM_F_VOLTAGE, 0, &fvalue); + *dvalue = fvalue; + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbRead, unknown HVPS command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +static asynStatus icbReadTca(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue) +{ + icbTcaModule *tca = &module->tca; + unsigned char reg; + int status; + + switch (icbCommand) { + case icbTcaStatus: + /* Read status of module */ + status = read_icb(tca->module, tca->icbAddress, 0, 1, ®); + /* It seems like "status" should tell us if the module can + * communicate but it does not, it returns OK even for non-existant + * modules. Look for data = 0xff instead */ + if (reg == 0xff) { /* Can't communicate */ + *ivalue = 3; + status = ERROR; + } else if (reg & 0x8) /* module has been reset */ + *ivalue = 2; + else if (reg & 0x10) /* module failed self test */ + *ivalue = 1; + else /* module must be ok */ + *ivalue = 0; + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbRead, unknown TCA command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +static asynStatus icbReadDsp(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + int icbCommand, icbModule *module, + int *ivalue, double *dvalue) +{ + icbDspModule *dsp = &module->dsp; + unsigned short svalue; + int status=asynSuccess; + + switch (icbCommand) { + /* These are the mbbi records, return value in *ivalue */ + case ID_STABLZ_GMOD: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + /* Store value for use by other commands */ + dsp->stablz_gmod = svalue; + *ivalue = svalue & 0x3; + break; + case ID_STABLZ_GOVR: + /* Use cached value of GMOD */ + if (dsp->stablz_gmod & 0x80) *ivalue=1; else *ivalue=0; + break; + case ID_STABLZ_GOVF: + /* Use cached value of GMOD */ + if (dsp->stablz_gmod & 0x40) *ivalue=1; else *ivalue=0; + break; + case ID_STABLZ_ZMOD: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + /* Store value for use by other commands */ + dsp->stablz_gmod = svalue; + *ivalue = svalue & 0x3; + break; + case ID_STABLZ_ZOVR: + /* Use cached value of GMOD */ + if (dsp->stablz_zmod & 0x80) *ivalue=1; else *ivalue=0; + break; + case ID_STABLZ_ZOVF: + /* Use cached value of GMOD */ + if (dsp->stablz_zmod & 0x40) *ivalue=1; else *ivalue=0; + break; + case ID_INFO_PZAER: + *ivalue = ((dsp->info_pz & 0x7000) >> 12); + break; + case ID_INFO_BDCAER: + *ivalue = ((dsp->info_bdc & 0x7000) >> 12); + break; + case ID_STATUS_PZBSY: + *ivalue = (dsp->status_flgs & 0x1) != 0; + break; + case ID_STATUS_BDBSY: + *ivalue = (dsp->status_flgs & 0x2) != 0; + break; + case ID_STATUS_MINT: + *ivalue = (dsp->status_flgs & 0x4) != 0; + break; + case ID_STATUS_DGBSY: + *ivalue = (dsp->status_flgs & 0x8) != 0; + break; + case ID_STATUS_MERR: + *ivalue = (dsp->status_flgs & 0x10) != 0; + break; + + /* These are the ao records, return value in *dvalue*/ + case ID_STATUS_FLGS: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + /* Store value for use by other commands */ + dsp->status_flgs = svalue; + *dvalue = svalue; + break; + case ID_INFO_PZ: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + /* Store value for use by other commands */ + dsp->info_pz = svalue; + /* Return actual pole zero */ + svalue = svalue & 0xfff; + *dvalue = dspShortToDouble(svalue, 0.0, 4095., 0, 4095); + break; + case ID_FILTER_PZ: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + *dvalue = dspShortToDouble(svalue, 0.0, 4095., 0, 4095); + break; + case ID_INFO_BDC: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + /* Store value for use by other commands */ + dsp->info_bdc = svalue; + /* Return actual flat top */ + svalue = svalue & 0x3f; + *dvalue = dspShortToDouble(svalue, 0.0, 3.0, 0, 30); + break; + case ID_FILTER_FT: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + *dvalue = dspShortToDouble(svalue, 0.0, 3.0, 0, 30); + break; + case ID_STABLZ_GAIN: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + *dvalue = svalue; + break; + case ID_STABLZ_ZERO: + status = readDsp(dsp->module, dsp->icbAddress, icbCommand, &svalue); + *dvalue = svalue; + break; + case ID_INFO_THRP: + status = readDsp(dsp->module, dsp->icbAddress, ID_INFO_THRP, &svalue); + *dvalue = dspUnpackThroughput(svalue); + /* Need to do special case of DT divide by 10. */ + if (dsp->info_thri == 0) *dvalue = *dvalue / 10.; + break; + default: + epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, + "icbRead, unknown DSP command=%d", + icbCommand); + status = asynError; + break; + } + return(status); +} + + +/* asynDrvUser routines */ +static asynStatus drvUserCreate(void *drvPvt, asynUser *pasynUser, + const char *drvInfo, + const char **pptypeName, size_t *psize) +{ + drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; + int i; + int maxCommands=0; + icbCommandStruct *pcommands=NULL; + char *pstring; + + switch (pPvt->icbModuleType) { + case icbAdcType: + maxCommands = MAX_ICB_ADC_COMMANDS; + pcommands = icbAdcCommands; + break; + case icbAmpType: + maxCommands = MAX_ICB_AMP_COMMANDS; + pcommands = icbAmpCommands; + break; + case icbHvpsType: + maxCommands = MAX_ICB_HVPS_COMMANDS; + pcommands = icbHvpsCommands; + break; + case icbTcaType: + maxCommands = MAX_ICB_TCA_COMMANDS; + pcommands = icbTcaCommands; + break; + case icbDspType: + maxCommands = MAX_ICB_DSP_COMMANDS; + pcommands = icbDspCommands; + break; + } + + for (i=0; ireason = pcommands[i].command; + if (pptypeName) *pptypeName = epicsStrDup(pstring); + if (psize) *psize = sizeof(pcommands[i].command); + asynPrint(pasynUser, ASYN_TRACE_FLOW, + "drvIcbAsyn:drvUserCreate::drvUserCreate, command=%s\n", pstring); + return(asynSuccess); + } + } + asynPrint(pasynUser, ASYN_TRACE_ERROR, + "drvIcbAsyn::drvUserCreate, unknown command=%s\n", drvInfo); + return(asynError); +} + +static asynStatus drvUserGetType(void *drvPvt, asynUser *pasynUser, + const char **pptypeName, size_t *psize) +{ + int command = pasynUser->reason; + + *pptypeName = epicsStrDup("icbCommands"); + *psize = sizeof(command); + return(asynSuccess); +} + +static asynStatus drvUserDestroy(void *drvPvt, asynUser *pasynUser) +{ + return(asynSuccess); +} + + +/* asynCommon routines */ + +/* Report parameters */ +static void icbReport(void *drvPvt, FILE *fp, int details) +{ + drvIcbAsynPvt *pPvt = (drvIcbAsynPvt *)drvPvt; + icbModule *module; + + assert(pPvt); + fprintf(fp, "ICB port %s:\n", pPvt->portName); + if (details >= 1) { + module = &pPvt->icbModule; + if (module->defined == icbFound) + fprintf(fp, " module address: %s OK\n", module->address); + else if (module->defined == icbNotFound) + fprintf(fp, " module address: %s NOT FOUND\n", module->address); + } +} + +/* Connect */ +static asynStatus icbConnect(void *drvPvt, asynUser *pasynUser) +{ + pasynManager->exceptionConnect(pasynUser); + return(asynSuccess); +} + +/* Disconnect */ +static asynStatus icbDisconnect(void *drvPvt, asynUser *pasynUser) +{ + pasynManager->exceptionDisconnect(pasynUser); + return(asynSuccess); +} + + +static asynStatus verifyModule(drvIcbAsynPvt *pPvt, asynUser *pasynUser, + icbModule **m) +{ + *m = &pPvt->icbModule; + if ((*m)->defined != icbFound) { + asynPrint(pasynUser, ASYN_TRACE_ERROR, + "drvIcbAsyn::verifyModule module not defined or not found\n"); + return(asynError); + } + return(asynSuccess); +} + + +static int writeAdc(icbModule *m, long command, char c, void *addr) +{ + ICB_PARAM_LIST icb_write_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + return(icb_adc_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); +} + +static int writeAmp(icbModule *m, long command, char c, void *addr) +{ + ICB_PARAM_LIST icb_write_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + return(icb_amp_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); +} + +static int writeHvps(icbModule *m, long command, char c, void *addr) +{ + ICB_PARAM_LIST icb_write_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + return(icb_hvps_hdlr(m->index, icb_write_list, ICB_M_HDLR_WRITE)); +} + + +/* We need a way to determine if the module is communicating. icb_xxx_hdlr does + * not always return an error condition if the module is not available. Read the + * CSR and test it for the value 0xff, which is what it has if it is not on the ICB. */ +static int readAdc(icbModule *m, long command, char c, void *addr) +{ + int s; + unsigned char csr; + ICB_PARAM_LIST icb_read_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + s = icb_adc_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); + if (s != OK) return(s); + icb_input(m->index, 0, 1, &csr); + if (csr == 0xff) return(ERROR); + else return(OK); +} + +static int readAmp(icbModule *m, long command, char c, void *addr) +{ + int s; + unsigned char csr; + ICB_PARAM_LIST icb_read_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + s = icb_amp_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); + if (s != OK) return(s); + icb_input(m->index, 0, 1, &csr); + if (csr == 0xff) return(ERROR); + else return(OK); +} + +static int readHvps(icbModule *m, long command, char c, void *addr) +{ + int s; + unsigned char csr; + ICB_PARAM_LIST icb_read_list[] = { + {command, c, addr}, /* Parameter */ + {0, 0, 0}}; /* End of list */ + s = icb_hvps_hdlr(m->index, icb_read_list, ICB_M_HDLR_READ); + if (s != OK) return(s); + icb_input(m->index, 0, 1, &csr); + if (csr == 0xff) return(ERROR); + else return(OK); +} + + +static int tcaWriteReg2(icbTcaModule *m) +{ + unsigned char reg; + + /* build up register 2 */ + reg = 0; + if (m->select) reg |= 0x80; + if (m->gate3) reg |= 0x40; + if (m->gate2) reg |= 0x20; + if (m->gate1) reg |= 0x10; + if (m->sca_enable) reg |= 0x08; + if (m->threshold) reg |= 0x04; + if (m->pur_enable) reg |= 0x02; + if (m->polarity) reg |= 0x01; + return(write_icb(m->module, m->icbAddress, 2, 1, ®)); +} + +static int tcaWriteReg6(icbTcaModule *m) +{ + unsigned char reg; + + /* build up register 6 */ + reg = 0; + if (m->pur_amp) reg |= 0x08; + if (m->pur3) reg |= 0x04; + if (m->pur2) reg |= 0x02; + if (m->pur1) reg |= 0x01; + return(write_icb(m->module, m->icbAddress, 6, 1, ®)); +} + +static int tcaWriteDiscrim(icbTcaModule *m, double percent, int discrim_spec) +{ + ULONG dac; + unsigned char registers[2]; + + if (percent < 0.0) percent = 0.0; + if (percent > 100.) percent = 100.; + + /* Convert to 12 bit DAC value & load into regs for write */ + dac = (int) (percent * 40.95); + registers[0] = dac & 0xff; + registers[1] = ((dac & 0xff00) >> 8) | discrim_spec; + + /* Send new value to the ICB module */ + return(write_icb(m->module, m->icbAddress, 3, 2, ®isters[0])); +} + + +static int sendDsp(int module, int icbAddress, int command, unsigned short data) +{ + unsigned char registers[4]; + unsigned char r6; + int i; + + registers[0] = 0; /* Not a read command, use only table 0 for now */ + registers[1] = command; /* Parameter opcode */ + registers[2] = (data & 0x0000ff00) >> 8; /* MSB of data */ + registers[3] = data & 0x000000ff; /* LSB of data */ + write_icb(module, icbAddress, 2, 4, registers); + /* The following delay seems to be necessary or writes will sometimes + * timeout below */ + epicsThreadSleep(DELAY_9660); + + /* Read register 6 back. Return error flag on error. Wait for WDONE to be + * set */ + for (i=0; i dmax) d = dmax; + ival = (unsigned short) (imin + (imax-imin) * (d - dmin) / + (dmax - dmin) + 0.5); + return(ival); +} + +static double dspShortToDouble(unsigned short ival, double dmin, double dmax, + unsigned short imin, unsigned short imax) +{ + double dval; + unsigned short i=ival; + + if (i < imin) i = imin; + if (i > imax) i = imax; + dval = dmin + (dmax-dmin) * (i - imin) / (imax - imin); + return(dval); +} + +static double dspUnpackThroughput(unsigned short ival) +{ + int exponent; + double mantissa; + + exponent = (ival & 0xE000) >> 13; + mantissa = (ival & 0x1FFF); + return(mantissa * (2 << exponent)); +} + + +/* iocsh functions */ + +static const iocshArg icbConfigArg0 = { "Port name",iocshArgString}; +static const iocshArg icbConfigArg1 = { "Ethernet address",iocshArgInt}; +static const iocshArg icbConfigArg2 = { "ICB address",iocshArgInt}; +static const iocshArg icbConfigArg3 = { "ICB module type",iocshArgInt}; +static const iocshArg * const icbConfigArgs[4] = {&icbConfigArg0, + &icbConfigArg1, + &icbConfigArg2, + &icbConfigArg3}; +static const iocshFuncDef icbConfigFuncDef = {"icbConfig",4,icbConfigArgs}; +static void icbConfigCallFunc(const iocshArgBuf *args) +{ + icbConfig(args[0].sval, args[1].ival, + args[2].ival, args[3].ival); +} + +void icbAsynRegister(void) +{ + iocshRegister(&icbConfigFuncDef,icbConfigCallFunc); +} + +epicsExportRegistrar(icbAsynRegister); From 9e76123a3501dbe94a80c8a02611aba2c02ed97b Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 13:53:21 -0500 Subject: [PATCH 11/17] Updated icb_sys_defs.h to use stdint.h --- mcaApp/CanberraSrc/icb_sys_defs.h | 176 +++++++++++++++--------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_sys_defs.h b/mcaApp/CanberraSrc/icb_sys_defs.h index a37f713a..4596f0cc 100644 --- a/mcaApp/CanberraSrc/icb_sys_defs.h +++ b/mcaApp/CanberraSrc/icb_sys_defs.h @@ -69,8 +69,8 @@ extern "C" { */ typedef struct { - LONG pcode; /* CAM parameter code */ - LONG cached_flag; /* Boolian */ + int32_t pcode; /* CAM parameter code */ + int32_t cached_flag; /* Boolian */ } ICB_CACHED_PARAM; @@ -85,9 +85,9 @@ extern "C" { typedef struct { - LONG icb_index; /* Module ICB database index */ + int32_t icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - CHAR extra_header[24]; /* Space for more header info */ + int8_t extra_header[24]; /* Space for more header info */ } ICB_CCNIM_ANY; @@ -139,30 +139,30 @@ extern "C" { typedef struct { - LONG icb_index; /* Module ICB database index */ + int32_t icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - CHAR extra_header[24]; /* Space for more header info */ + int8_t extra_header[24]; /* Space for more header info */ /*----------------------*/ /* ADC CAM values */ /*----------------------*/ - LONG range; /* ADC range */ - LONG offset; /* ADC offset */ - CHAR acqmode[12]; /* ADC acquisition mode (8 char)*/ - LONG cnvgain; /* ADC conversion gain */ - LONG abs_cnvlim; /* Absolute conv. gain limit */ - REAL lld; /* Lower level descriminator */ - REAL uld; /* Upper level descriminator */ - REAL zero; /* ADC zero */ - CHAR extra_values[32]; /* Space for more values */ + int32_t range; /* ADC range */ + int32_t offset; /* ADC offset */ + int8_t acqmode[12]; /* ADC acquisition mode (8 char)*/ + int32_t cnvgain; /* ADC conversion gain */ + int32_t abs_cnvlim; /* Absolute conv. gain limit */ + float lld; /* Lower level descriminator */ + float uld; /* Upper level descriminator */ + float zero; /* ADC zero */ + int8_t extra_values[32]; /* Space for more values */ /*--------------------------------*/ /* ADC CAM flags (CAM_L_ADCFLAGS) */ /*--------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_ADC_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -171,11 +171,11 @@ extern "C" { /*----------------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_ADC_VFLAGS bit; /* Individual flag bit struct */ } vflags; - LONG extra_flags[1]; /* Space for extra values */ + int32_t extra_flags[1]; /* Space for extra values */ } ICB_CCNIM_ADC; @@ -231,33 +231,33 @@ extern "C" { typedef struct { - LONG icb_index; /* Module ICB database index */ + int32_t icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - CHAR extra_header[24]; /* Space for more header info */ + int8_t extra_header[24]; /* Space for more header info */ /*----------------------*/ /* AMP CAM values */ /*----------------------*/ - CHAR pramptype[12]; /* Preamp type (RC,TRP) (8 char) */ - REAL gain; /* Virtual gain (hwg1 * hwg2 * hwg3) */ - REAL hwgain1; /* Course gain */ - REAL hwgain2; /* Fine gain */ - REAL hwgain3; /* Super fine gain */ - CHAR shapemode[12]; /* Shaping mode (8 char) */ - LONG pz; /* Pole zero */ - CHAR blrtype[12]; /* Base-line restore (SYM,ASYM) (8 char) */ - CHAR dtctype[12]; /* Dead-time control (Normal,LFC) (8 char) */ - REAL tc; /* AMP time constant (seconds) */ - LONG hwgain2_timer; /* Callback Timer id for fine gain */ - CHAR extra_values[32]; /* Space for more values */ + int8_t pramptype[12]; /* Preamp type (RC,TRP) (8 char) */ + float gain; /* Virtual gain (hwg1 * hwg2 * hwg3) */ + float hwgain1; /* Course gain */ + float hwgain2; /* Fine gain */ + float hwgain3; /* Super fine gain */ + int8_t shapemode[12]; /* Shaping mode (8 char) */ + int32_t pz; /* Pole zero */ + int8_t blrtype[12]; /* Base-line restore (SYM,ASYM) (8 char) */ + int8_t dtctype[12]; /* Dead-time control (Normal,LFC) (8 char) */ + float tc; /* AMP time constant (seconds) */ + int32_t hwgain2_timer; /* Callback Timer id for fine gain */ + int8_t extra_values[32]; /* Space for more values */ /*--------------------------------*/ /* AMP CAM flags (CAM_L_AMPFLAGS) */ /*--------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_AMP_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -266,11 +266,11 @@ extern "C" { /*----------------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_AMP_VFLAGS bit; /* Individual flag bit struct */ } vflags; - LONG extra_flags[1]; /* Space for more values */ + int32_t extra_flags[1]; /* Space for more values */ } ICB_CCNIM_AMP; @@ -320,29 +320,29 @@ extern "C" { typedef struct { - LONG icb_index; /* Module ICB database index */ + int32_t icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - CHAR extra_header[24]; /* Space for more header info */ + int8_t extra_header[24]; /* Space for more header info */ /*----------------------*/ /* HVPS CAM values */ /*----------------------*/ - REAL voltage; /* High voltage setting */ - REAL voltlim; /* Voltage limit */ - REAL abs_voltlim; /* Absolute limit for module */ - REAL current_level; /* Current voltage level */ + float voltage; /* High voltage setting */ + float voltlim; /* Voltage limit */ + float abs_voltlim; /* Absolute limit for module */ + float current_level; /* Current voltage level */ void *ramp_ast_id; /* Id of ramp function AST */ /* Non-zero indicates that a */ /* ramp is in progress */ - CHAR extra_values[24]; /* Space for more values */ + int8_t extra_values[24]; /* Space for more values */ /*----------------------------------*/ /* HVPS CAM flags (CAM_L_HVPSFLAGS) */ /*----------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_HVPS_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -351,11 +351,11 @@ extern "C" { /*------------------------------------------*/ union { - LONG lword; /* Standard flags field */ + int32_t lword; /* Standard flags field */ ICB_HVPS_VFLAGS bit;/* Individual flag bit struct */ } vflags; - LONG extra_flags[1]; /* Space for more values */ + int32_t extra_flags[1]; /* Space for more values */ } ICB_CCNIM_HVPS; @@ -366,8 +366,8 @@ extern "C" { typedef struct _ICB_PARAM_LIST { - LONG pcode; - LONG reserved; + int32_t pcode; + int32_t reserved; void *value; } ICB_PARAM_LIST; @@ -478,54 +478,54 @@ int icb_crmpsc(); int icb_get_module_state(int index); /* Functions in icb_handler_subs.c */ -LONG icb_hvps_hdlr (LONG index, ICB_PARAM_LIST *params, LONG flags); -LONG icb_adc_hdlr (LONG index, ICB_PARAM_LIST *params, LONG flags); -LONG icb_amp_hdlr (LONG index, ICB_PARAM_LIST *params, LONG flags); -int icb_validate_module (LONG index, ICB_PARAM_LIST *params, - LONG *present, LONG *reset, LONG flags); -int icb_init_ccnim_cache (LONG index, LONG flags); +int32_t icb_hvps_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_adc_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_amp_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); +int icb_validate_module (int32_t index, ICB_PARAM_LIST *params, + int32_t *present, int32_t *reset, int32_t flags); +int icb_init_ccnim_cache (int32_t index, int32_t flags); ICB_PARAM_LIST *icb_build_cached_plist (ICB_CCNIM_ANY *ccany); int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, ICB_PARAM_LIST *params); -LONG icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, LONG flags); -LONG icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, LONG flags); -LONG icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, LONG flags, +int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags, UBYTE *reg_list); -LONG icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps); -LONG icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, REAL voltage, LONG flags); -LONG icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, REAL *voltage, LONG flags); -LONG icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, LONG state, LONG flags); -LONG icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, LONG flags); -LONG icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, LONG flags); -LONG icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, LONG flags, +int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps); +int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, int32_t flags); +int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, float *voltage, int32_t flags); +int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, int32_t state, int32_t flags); +int32_t icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags, UBYTE *reg_list); -LONG icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, LONG flags); -LONG icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, LONG flags); -LONG icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, LONG flags, +int32_t icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); +int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags, UBYTE *reg_list); -LONG icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, LONG flags); -LONG icb_amp_write_gain2 (ICB_CCNIM_AMP *amp); -LONG icb_amp_complete_position (ICB_CCNIM_AMP *amp); -LONG icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp); -LONG icb_amp_home_motor (ICB_CCNIM_AMP *amp); -LONG icb_amp_test_home (ICB_CCNIM_AMP *amp); -ULONG icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp); -LONG icb_amp_get_nvram_motor_pos (LONG index, LONG *nvpos, LONG flags); -LONG icb_amp_put_nvram_motor_pos (LONG index, LONG nvpos, LONG flags); -LONG icb_amp_put_motor_pos (LONG index, LONG pos, LONG flags); -LONG icb_amp_start_pz (ICB_CCNIM_AMP *amp); -LONG icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp); -LONG icb_amp_write_pz (ICB_CCNIM_AMP *amp); -LONG icb_adc_encode_chns (ULONG chns); -LONG icb_write_csr (ICB_CCNIM_ANY *ccnim, LONG perm_bits, LONG temp_bits, - LONG mask); -LONG icb_monitor_modules (); +int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, int32_t flags); +int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp); +int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp); +int32_t icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp); +int32_t icb_amp_home_motor (ICB_CCNIM_AMP *amp); +int32_t icb_amp_test_home (ICB_CCNIM_AMP *amp); +uint32_t icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp); +int32_t icb_amp_get_nvram_motor_pos (int32_t index, int32_t *nvpos, int32_t flags); +int32_t icb_amp_put_nvram_motor_pos (int32_t index, int32_t nvpos, int32_t flags); +int32_t icb_amp_put_motor_pos (int32_t index, int32_t pos, int32_t flags); +int32_t icb_amp_start_pz (ICB_CCNIM_AMP *amp); +int32_t icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp); +int32_t icb_amp_write_pz (ICB_CCNIM_AMP *amp); +int32_t icb_adc_encode_chns (uint32_t chns); +int32_t icb_write_csr (ICB_CCNIM_ANY *ccnim, int32_t perm_bits, int32_t temp_bits, + int32_t mask); +int32_t icb_monitor_modules (); /* The following routines are in icb_strings.c */ -int icb_dsc2str (CHAR *str, CHAR *dsc, LONG max_len); -int icb_str2dsc (CHAR *dsc, CHAR *str); -int StrNCmp (CHAR *s1, CHAR *s2, int len); -int StrUpCase (CHAR *dst, CHAR *src, int len); -int StrTrim (CHAR *dst, CHAR *src, int len, int *trim_len); +int icb_dsc2str (int8_t *str, int8_t *dsc, int32_t max_len); +int icb_str2dsc (int8_t *dsc, int8_t *str); +int StrNCmp (int8_t *s1, int8_t *s2, int len); +int StrUpCase (int8_t *dst, int8_t *src, int len); +int StrTrim (int8_t *dst, int8_t *src, int len, int *trim_len); #ifdef __cplusplus } From 3ebd1f7485a5e0d4be218be25137b85c6ab38df3 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 14:07:02 -0500 Subject: [PATCH 12/17] Missed a few pieces --- mcaApp/CanberraSrc/icb_handler_subs.c | 6 +++--- mcaApp/CanberraSrc/icb_sys_defs.h | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_handler_subs.c b/mcaApp/CanberraSrc/icb_handler_subs.c index 72088850..bcced3e5 100644 --- a/mcaApp/CanberraSrc/icb_handler_subs.c +++ b/mcaApp/CanberraSrc/icb_handler_subs.c @@ -1832,11 +1832,11 @@ while (1) { int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, - LONG flags) + int32_t flags) { - LONG s; - LONG index; + int32_t s; + int32_t index; ICB_MODULE_INFO *entry; /* diff --git a/mcaApp/CanberraSrc/icb_sys_defs.h b/mcaApp/CanberraSrc/icb_sys_defs.h index 4596f0cc..4bdcec44 100644 --- a/mcaApp/CanberraSrc/icb_sys_defs.h +++ b/mcaApp/CanberraSrc/icb_sys_defs.h @@ -27,6 +27,8 @@ extern "C" { #endif +#include + #define ICB_K_MAX_MODULES 96 /* The number of entries in ICB_MODULE_INFO */ /* @@ -489,7 +491,7 @@ int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, ICB_PARAM_LIST *params); int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags, - UBYTE *reg_list); + uint8_t *reg_list); int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps); int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, int32_t flags); int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, float *voltage, int32_t flags); @@ -497,11 +499,11 @@ int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, int32_t state, int32_t flags); int32_t icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags, - UBYTE *reg_list); + uint8_t *reg_list); int32_t icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags, - UBYTE *reg_list); + uint8_t *reg_list); int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, int32_t flags); int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp); int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp); From 565de50adbeacfdb57c44dab45e23453aaae3092 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 22 Oct 2015 14:18:55 -0500 Subject: [PATCH 13/17] Missed an additional CHAR --- mcaApp/CanberraSrc/icb_handler_subs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_handler_subs.c b/mcaApp/CanberraSrc/icb_handler_subs.c index bcced3e5..17451b2b 100644 --- a/mcaApp/CanberraSrc/icb_handler_subs.c +++ b/mcaApp/CanberraSrc/icb_handler_subs.c @@ -4380,7 +4380,7 @@ int32_t flags; int32_t s; int32_t i; uint8_t reg_val; - CHAR nibble; + int8_t nibble; uint32_t temp; struct icb_module_info_struct *entry; From a4604ac19e9fd7e9f929ece8cbe6088273e9f75c Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Fri, 23 Oct 2015 16:28:56 -0500 Subject: [PATCH 14/17] Switched icb_handler_subs from stdint to epicstypes.h --- mcaApp/CanberraSrc/icb_handler_subs.c | 587 +++++++++++++------------- 1 file changed, 294 insertions(+), 293 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_handler_subs.c b/mcaApp/CanberraSrc/icb_handler_subs.c index 17451b2b..2c8580a7 100644 --- a/mcaApp/CanberraSrc/icb_handler_subs.c +++ b/mcaApp/CanberraSrc/icb_handler_subs.c @@ -77,7 +77,6 @@ #include #include #include -#include #include "icb_sys_defs.h" #include "icb_bus_defs.h" #include "nmc_sys_defs.h" @@ -85,6 +84,8 @@ #include "mcamsgdef.h" #include "campardef.h" +#include "epicsTypes.h" + extern ICB_MODULE_INFO *icb_module_info; /* pointer to ICB module info structure */ extern struct nmc_module_info_struct *nmc_module_info; /* pointer to networked module info */ @@ -94,18 +95,18 @@ extern struct nmc_module_info_struct *nmc_module_info; /* pointer to networked m /* the setting the ASTF_CCERR flag. */ /*-------------------------------------------------------*/ -int32_t hvps_ccerr_vbits = CAM_M_HVPSVF_VOLT | CAM_M_HVPSVF_OVLE | +epicsInt32 hvps_ccerr_vbits = CAM_M_HVPSVF_VOLT | CAM_M_HVPSVF_OVLE | CAM_M_HVPSVF_INHLE | CAM_M_HVPSVF_LVINH | CAM_M_HVPSVF_STAT; -int32_t adc_ccerr_vbits = CAM_M_ADCVF_RANGE | CAM_M_ADCVF_OFFSET | +epicsInt32 adc_ccerr_vbits = CAM_M_ADCVF_RANGE | CAM_M_ADCVF_OFFSET | CAM_M_ADCVF_ACQMODE | CAM_M_ADCVF_CNVGAIN | CAM_M_ADCVF_LLD | CAM_M_ADCVF_ULD | CAM_M_ADCVF_ZERO | CAM_M_ADCVF_ANTIC | CAM_M_ADCVF_LATEC | CAM_M_ADCVF_DELPK | CAM_M_ADCVF_NONOV | CAM_M_ADCVF_LTCPUR; -int32_t amp_ccerr_vbits = CAM_M_AMPVF_PRAMPT | CAM_M_AMPVF_HWGAIN1 | +epicsInt32 amp_ccerr_vbits = CAM_M_AMPVF_PRAMPT | CAM_M_AMPVF_HWGAIN1 | CAM_M_AMPVF_HWGAIN3 | CAM_M_AMPVF_SHAPEM | CAM_M_AMPVF_BLRTYPE | CAM_M_AMPVF_DTCTYPE | CAM_M_AMPVF_DIFF | CAM_M_AMPVF_NEGPOL | @@ -159,7 +160,7 @@ static ICB_PARAM_LIST hvps_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static int32_t hvps_flag_bits[] = { +static epicsInt32 hvps_flag_bits[] = { CAM_M_HVPSF_OVLE, CAM_M_HVPSF_INHLE, CAM_M_HVPSF_LVINH, @@ -183,7 +184,7 @@ static int32_t hvps_flag_bits[] = { /* "ICB 9645",*/ /* 0};*/ -/*static int32_t hvps_types_int[] = {*/ +/*static epicsInt32 hvps_types_int[] = {*/ /* ICB_K_MTYPE_CI9641,*/ /* 2000 Volt supply */ /* ICB_K_MTYPE_CI9645,*/ /* 6000 Volt supply */ /* 0};*/ /* End of list */ @@ -225,7 +226,7 @@ static ICB_PARAM_LIST adc_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static int32_t adc_flag_bits[] = { +static epicsInt32 adc_flag_bits[] = { CAM_M_ADCF_ANTIC, CAM_M_ADCF_LATEC, CAM_M_ADCF_DELPK, @@ -244,7 +245,7 @@ static int32_t adc_flag_bits[] = { /* "ICB 9635",*/ /* 0};*/ -/*static int32_t adc_types_int[] = {*/ +/*static epicsInt32 adc_types_int[] = {*/ /* ICB_K_MTYPE_CI9633,*/ /* 16K chan ADC */ /* ICB_K_MTYPE_CI9635,*/ /* 8K chan ADC */ /* 0};*/ /* End of list */ @@ -290,7 +291,7 @@ static ICB_PARAM_LIST amp_flag_list[] = { /* same order as the above parameter list. */ /*----------------------------------------------*/ -static int32_t amp_flag_bits[] = { +static epicsInt32 amp_flag_bits[] = { CAM_M_AMPF_DIFF, CAM_M_AMPF_NEGPOL, CAM_M_AMPF_COMPINH, @@ -311,7 +312,7 @@ static int32_t amp_flag_bits[] = { /* "ICB 9615",*/ /* 0};*/ -/*static int32_t amp_types_int[] = {*/ +/*static epicsInt32 amp_types_int[] = {*/ /* ICB_K_MTYPE_CI9615,*/ /* Standard Amp */ /* 0};*/ /* End of list */ @@ -323,7 +324,7 @@ static int32_t amp_flag_bits[] = { static struct { float real_val; - int32_t dac_val; + epicsInt32 dac_val; } amp_hwgain1_tbl[] = {{500.0, 0x0F}, {250.0, 0x0D}, {100.0, 0x0B}, @@ -353,7 +354,7 @@ static float amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; /* hvps_flag_list, NULL};*/ -/*static int32_t (*icb_hdlr_summary[])() = {icb_adc_hdlr,*/ +/*static epicsInt32 (*icb_hdlr_summary[])() = {icb_adc_hdlr,*/ /* icb_amp_hdlr,*/ /* icb_hvps_hdlr, NULL};*/ @@ -363,7 +364,7 @@ static float amp_shape_time[] = {0.5, 1.0, 2.0, 4.0, 6.0, 12.0, 0.0}; * (rather than the cache) during a read operation. */ -static int32_t icb_req_read_plist[] = {CAM_L_HVPSFPOL, +static epicsInt32 icb_req_read_plist[] = {CAM_L_HVPSFPOL, CAM_L_HVPSFOV, CAM_L_HVPSFINH, CAM_L_HVPSFSTAT, @@ -402,17 +403,17 @@ static int32_t icb_req_read_plist[] = {CAM_L_HVPSFPOL, * *******************************************************************************/ -int32_t icb_hvps_hdlr (int32_t index, +epicsInt32 icb_hvps_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t s; + epicsInt32 s; ICB_CCNIM_HVPS *hvps; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - int32_t reset; - int32_t present; + epicsInt32 reset; + epicsInt32 present; /* * First make sure that the module exists and is the correct type. @@ -506,17 +507,17 @@ int32_t icb_hvps_hdlr (int32_t index, * *******************************************************************************/ -int32_t icb_adc_hdlr (int32_t index, +epicsInt32 icb_adc_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t s; + epicsInt32 s; ICB_CCNIM_ADC *adc; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - int32_t reset; - int32_t present; + epicsInt32 reset; + epicsInt32 present; /* * First make sure that the module exists and is the correct type. @@ -606,17 +607,17 @@ int32_t icb_adc_hdlr (int32_t index, * *******************************************************************************/ -int32_t icb_amp_hdlr (int32_t index, +epicsInt32 icb_amp_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t s; + epicsInt32 s; ICB_CCNIM_AMP *amp; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *plist; - int32_t reset; - int32_t present; + epicsInt32 reset; + epicsInt32 present; /* * First make sure that the module exists and is the correct type. @@ -706,18 +707,18 @@ int32_t icb_amp_hdlr (int32_t index, * *******************************************************************************/ -int icb_validate_module (int32_t index, +int icb_validate_module (epicsInt32 index, ICB_PARAM_LIST *params, - int32_t *present, - int32_t *reset, - int32_t flags) + epicsInt32 *present, + epicsInt32 *reset, + epicsInt32 flags) { - int32_t i, j; - int32_t s; + epicsInt32 i, j; + epicsInt32 s; ICB_MODULE_INFO *entry; - uint8_t register_list[16]; - int32_t do_read; + epicsUInt8 register_list[16]; + epicsInt32 do_read; ICB_CCNIM_ANY *ccany; /* @@ -827,11 +828,11 @@ int icb_validate_module (int32_t index, * *******************************************************************************/ -int icb_init_ccnim_cache (int32_t index, - int32_t flags) +int icb_init_ccnim_cache (epicsInt32 index, + epicsInt32 flags) { - int32_t i, j; + epicsInt32 i, j; ICB_MODULE_INFO *entry; ICB_CCNIM_ANY *ccany; ICB_PARAM_LIST *plist=NULL, *flist=NULL; @@ -923,8 +924,8 @@ int icb_init_ccnim_cache (int32_t index, ICB_PARAM_LIST *icb_build_cached_plist (ICB_CCNIM_ANY *ccany) { - int32_t i, j; - int32_t pcount = 0; + epicsInt32 i, j; + epicsInt32 pcount = 0; ICB_PARAM_LIST *plist; /* @@ -982,7 +983,7 @@ int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, ICB_PARAM_LIST *params) { - int32_t i, j; + epicsInt32 i, j; /* * For each parameter, find it's entry (if any) in the cached parameter @@ -1022,20 +1023,20 @@ int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, * *******************************************************************************/ -int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, +epicsInt32 icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t i; - int32_t s=OK; - int32_t index; - uint32_t fbits; + epicsInt32 i; + epicsInt32 s=OK; + epicsInt32 index; + epicsUInt32 fbits; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - int32_t *flag_vals; - uint8_t reg_val; - int32_t local_flags; + epicsInt32 *flag_vals; + epicsUInt8 reg_val; + epicsInt32 local_flags; float level; ICB_PARAM_LIST *params_start; @@ -1127,11 +1128,11 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (hvps_flag_list)); - flag_vals = (int32_t *) malloc (sizeof (hvps_flag_bits)); + flag_vals = (epicsInt32 *) malloc (sizeof (hvps_flag_bits)); memcpy (flag_list, hvps_flag_list, sizeof (hvps_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((int32_t *) params->value); + fbits = *((epicsInt32 *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((hvps_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -1153,7 +1154,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the overload latch enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.ovle = *((int32_t *) params->value); + hvps->flags.bit.ovle = *((epicsInt32 *) params->value); if (!entry) break; if (hvps->flags.bit.ovle) @@ -1173,7 +1174,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the inhibit latch enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.inhle = *((int32_t *) params->value); + hvps->flags.bit.inhle = *((epicsInt32 *) params->value); if (!entry) break; if (hvps->flags.bit.inhle) @@ -1193,7 +1194,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the 12V level inhibit enable bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.lvinh = *((int32_t *) params->value); + hvps->flags.bit.lvinh = *((epicsInt32 *) params->value); if (!entry) break; if (hvps->flags.bit.lvinh) @@ -1211,7 +1212,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.pol = *((int32_t *) params->value); + hvps->flags.bit.pol = *((epicsInt32 *) params->value); break; /*------------------------------*/ @@ -1221,7 +1222,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /* Set or clear the On/Off bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.stat = *((int32_t *) params->value); + hvps->flags.bit.stat = *((epicsInt32 *) params->value); if (!entry) break; /* If module is being turned off, terminate the ramp process */ @@ -1277,7 +1278,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*-----------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - if (*((int32_t *) params->value) == 0) break; + if (*((epicsInt32 *) params->value) == 0) break; /* Reset the HVPS */ @@ -1291,7 +1292,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*-----------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.fastramp = *((int32_t *) params->value); + hvps->flags.bit.fastramp = *((epicsInt32 *) params->value); break; /*------------------------------*/ @@ -1299,7 +1300,7 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - hvps->flags.bit.atten = *((int32_t *) params->value); + hvps->flags.bit.atten = *((epicsInt32 *) params->value); if (!entry) break; if (hvps->flags.bit.atten) @@ -1359,14 +1360,14 @@ int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, +epicsInt32 icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t i; - uint32_t reg; - int32_t index; + epicsInt32 i; + epicsUInt32 reg; + epicsInt32 index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -1412,28 +1413,28 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, case CAM_L_HVPSFLAGS: /* Flags field */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.lword; + *((epicsUInt32 *) params->value) = hvps->flags.lword; break; /*------------------------------*/ case CAM_L_HVPSFOVLE: /* Overload latch enable */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.ovle; + *((epicsUInt32 *) params->value) = hvps->flags.bit.ovle; break; /*------------------------------*/ case CAM_L_HVPSFINHLE: /* Inhibit latch enable */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.inhle; + *((epicsUInt32 *) params->value) = hvps->flags.bit.inhle; break; /*------------------------------*/ case CAM_L_HVPSFLVINH: /* 5v/12v inhibit */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.lvinh; + *((epicsUInt32 *) params->value) = hvps->flags.bit.lvinh; break; /*------------------------------*/ @@ -1441,12 +1442,12 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (!entry) { - *((uint32_t *) params->value) = hvps->flags.bit.pol; + *((epicsUInt32 *) params->value) = hvps->flags.bit.pol; break; } - reg = ((uint32_t) entry->registers[1]); - *((uint32_t *) params->value) = i = ((reg & HVPS_M_R3_POLARITY_NEG) != 0); + reg = ((epicsUInt32) entry->registers[1]); + *((epicsUInt32 *) params->value) = i = ((reg & HVPS_M_R3_POLARITY_NEG) != 0); if (i != hvps->flags.bit.pol) { hvps->flags.bit.pol = i; @@ -1459,10 +1460,10 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (entry) { - reg = ((uint32_t) entry->registers[1]); + reg = ((epicsUInt32) entry->registers[1]); hvps->flags.bit.inh = ((reg & HVPS_M_R3_INHIBIT) == 0); } - *((uint32_t *) params->value) = hvps->flags.bit.inh; + *((epicsUInt32 *) params->value) = hvps->flags.bit.inh; break; /*------------------------------*/ @@ -1470,10 +1471,10 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, /*------------------------------*/ if (entry) { - reg = ((uint32_t) entry->registers[1]); + reg = ((epicsUInt32) entry->registers[1]); hvps->flags.bit.ov = ((reg & HVPS_M_R3_OVERLOAD) == 0); } - *((uint32_t *) params->value) = hvps->flags.bit.ov; + *((epicsUInt32 *) params->value) = hvps->flags.bit.ov; break; /*------------------------------*/ @@ -1484,35 +1485,35 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, reg = entry->registers[0]; hvps->flags.bit.stat = ((reg & HVPS_M_R2_STATUS_ON) != 0); } - *((uint32_t *) params->value) = hvps->flags.bit.stat; + *((epicsUInt32 *) params->value) = hvps->flags.bit.stat; break; /*------------------------------*/ case CAM_L_HVPSFONLINE: /* Module on-line */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.online; + *((epicsUInt32 *) params->value) = hvps->flags.bit.online; break; /*------------------------------*/ case CAM_L_HVPSFATTEN: /* Module requires attention */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.atten; + *((epicsUInt32 *) params->value) = hvps->flags.bit.atten; break; /*-----------------------------*/ case CAM_L_HVPSFASTRAMP: /* Fast Ramp Flag */ /*-----------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.fastramp; + *((epicsUInt32 *) params->value) = hvps->flags.bit.fastramp; break; /*-----------------------------*/ case CAM_L_HVPSFBUSY: /* Ramp in progress flag */ /*-----------------------------*/ - *((uint32_t *) params->value) = hvps->flags.bit.busy; + *((epicsUInt32 *) params->value) = hvps->flags.bit.busy; break; /*======================================================*/ @@ -1523,56 +1524,56 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, case CAM_L_HVPSVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.lword; + *((epicsUInt32 *) params->value) = hvps->vflags.lword; break; /*------------------------------*/ case CAM_L_HVPSVFID: /* VF: Module ID */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.id; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.id; break; /*------------------------------*/ case CAM_L_HVPSVFVOLT: /* VF: Voltage */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.volt; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.volt; break; /*------------------------------*/ case CAM_L_HVPSVFOVLE: /* VF: Overload latch */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.ovle; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.ovle; break; /*------------------------------*/ case CAM_L_HVPSVFINHLE: /* VF: Inhibit latch */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.inhle; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.inhle; break; /*------------------------------*/ case CAM_L_HVPSVFLVINH: /* VF: 5v/12v inhibit */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.lvinh; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.lvinh; break; /*------------------------------*/ case CAM_L_HVPSVFPOL: /* VF: Output polarity */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.id; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.id; break; /*------------------------------*/ case CAM_L_HVPSVFSTAT: /* VF: Status (on/off) */ /*------------------------------*/ - *((uint32_t *) params->value) = hvps->vflags.bit.stat; + *((epicsUInt32 *) params->value) = hvps->vflags.bit.stat; break; /*------------------------------*/ @@ -1612,21 +1613,21 @@ int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL +* "reg_list" (epicsUInt8 *) The list of ICB registers. This should be NULL * when ICB_HVPS_VERIFY() is called from the outside. * *******************************************************************************/ -int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, +epicsInt32 icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, - int32_t flags, - uint8_t *reg_list) + epicsInt32 flags, + epicsUInt8 *reg_list) { - int32_t s; - uint8_t registers[14]; - uint8_t lreg; - uint8_t mreg; + epicsInt32 s; + epicsUInt8 registers[14]; + epicsUInt8 lreg; + epicsUInt8 mreg; ICB_MODULE_INFO *entry; /* @@ -1748,7 +1749,7 @@ int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) +epicsInt32 icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) /* This routine runs as an AST on VMS systems. This means it runs as @@ -1757,7 +1758,7 @@ int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps) could simply make this routine run as a separate vxWorks task. */ { - int32_t s = OK; /* Assume true status */ + epicsInt32 s = OK; /* Assume true status */ float hvps_diff; float level; double delay = 5.0; /* Delta time of 5 seconds */ @@ -1830,13 +1831,13 @@ while (1) { * *******************************************************************************/ -int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, +epicsInt32 icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, - int32_t flags) + epicsInt32 flags) { - int32_t s; - int32_t index; + epicsInt32 s; + epicsInt32 index; ICB_MODULE_INFO *entry; /* @@ -1893,11 +1894,11 @@ int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, +epicsInt32 icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, float *voltage, - int32_t flags) + epicsInt32 flags) { - uint32_t dac; + epicsUInt32 dac; float hvps_step; ICB_MODULE_INFO *entry; @@ -1956,13 +1957,13 @@ int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, - int32_t state, - int32_t flags) +epicsInt32 icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, + epicsInt32 state, + epicsInt32 flags) { - int32_t s; - int32_t index; + epicsInt32 s; + epicsInt32 index; ICB_MODULE_INFO *entry; /* @@ -2014,22 +2015,22 @@ int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, * *******************************************************************************/ -int32_t icb_adc_write (ICB_CCNIM_ADC *adc, +epicsInt32 icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t i; - int32_t s=OK; - uint32_t dac; - uint32_t fbits; - int32_t load_dac = FALSE; - int32_t index; + epicsInt32 i; + epicsInt32 s=OK; + epicsUInt32 dac; + epicsUInt32 fbits; + epicsInt32 load_dac = FALSE; + epicsInt32 index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - int32_t *flag_vals; - uint8_t reg_val; - int32_t local_flags; + epicsInt32 *flag_vals; + epicsUInt8 reg_val; + epicsInt32 local_flags; ICB_PARAM_LIST *params_start; /* @@ -2062,7 +2063,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert range in channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->range = *((int32_t *) params->value); + adc->range = *((epicsInt32 *) params->value); if (!entry) break; dac = icb_adc_encode_chns (adc->range) << 4; @@ -2081,7 +2082,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert offset in channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->offset = *((int32_t *) params->value); + adc->offset = *((epicsInt32 *) params->value); if (!entry) break; dac = ~(adc->offset >> 7); @@ -2119,7 +2120,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Convert cnvgain channels to the format the module expects */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->cnvgain = *((int32_t *) params->value); + adc->cnvgain = *((epicsInt32 *) params->value); if (!entry) break; dac = icb_adc_encode_chns (adc->cnvgain); @@ -2210,11 +2211,11 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (adc_flag_list)); - flag_vals = (int32_t *) malloc (sizeof (adc_flag_bits)); + flag_vals = (epicsInt32 *) malloc (sizeof (adc_flag_bits)); memcpy (flag_list, adc_flag_list, sizeof (adc_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((int32_t *) params->value); + fbits = *((epicsInt32 *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((adc_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -2236,7 +2237,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the anticoincidence mode bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.antic = *((int32_t *) params->value); + adc->flags.bit.antic = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.antic) @@ -2256,7 +2257,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the late coincidence mode bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.latec = *((int32_t *) params->value); + adc->flags.bit.latec = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.latec) @@ -2276,7 +2277,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the delayed peak detect bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.delpk = *((int32_t *) params->value); + adc->flags.bit.delpk = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.delpk) @@ -2296,7 +2297,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the non-overlap transfer bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.nonov = *((int32_t *) params->value); + adc->flags.bit.nonov = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.nonov) @@ -2316,7 +2317,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /* Set / Clear the LTC/PUR EOC bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.ltcpur = *((int32_t *) params->value); + adc->flags.bit.ltcpur = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.ltcpur) @@ -2334,7 +2335,7 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - adc->flags.bit.atten = *((int32_t *) params->value); + adc->flags.bit.atten = *((epicsInt32 *) params->value); if (!entry) break; if (adc->flags.bit.atten) @@ -2404,12 +2405,12 @@ int32_t icb_adc_write (ICB_CCNIM_ADC *adc, * *******************************************************************************/ -int32_t icb_adc_read (ICB_CCNIM_ADC *adc, +epicsInt32 icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t index; + epicsInt32 index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -2439,14 +2440,14 @@ int32_t icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_ADCRANGE: /* Range */ /*------------------------------*/ - *((int32_t *) params->value) = adc->range; + *((epicsInt32 *) params->value) = adc->range; break; /*------------------------------*/ case CAM_L_ADCOFFSET: /* Offset */ /*------------------------------*/ - *((int32_t *) params->value) = adc->offset; + *((epicsInt32 *) params->value) = adc->offset; break; /*------------------------------*/ @@ -2460,7 +2461,7 @@ int32_t icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_CNVGAIN: /* Conversion Gain */ /*------------------------------*/ - *((int32_t *) params->value) = adc->cnvgain; + *((epicsInt32 *) params->value) = adc->cnvgain; break; /*------------------------------*/ @@ -2488,56 +2489,56 @@ int32_t icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_ADCFLAGS: /* ADC Mode flags */ /*------------------------------*/ - *((uint32_t *) params->value) = adc->flags.lword; + *((epicsUInt32 *) params->value) = adc->flags.lword; continue; /*------------------------------*/ case CAM_L_ADCFANTIC: /* Anti-coincidence mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->flags.bit.antic; + *((epicsInt32 *) params->value) = adc->flags.bit.antic; break; /*------------------------------*/ case CAM_L_ADCFLATEC: /* Late (vs early) coinc mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->flags.bit.latec; + *((epicsInt32 *) params->value) = adc->flags.bit.latec; break; /*------------------------------*/ case CAM_L_ADCFDELPK: /* Delayed (vs auto) peak detect*/ /*------------------------------*/ - *((int32_t *) params->value) = adc->flags.bit.delpk; + *((epicsInt32 *) params->value) = adc->flags.bit.delpk; break; /*------------------------------*/ case CAM_L_ADCFNONOV: /* Non-overlap transfer mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->flags.bit.nonov; + *((epicsInt32 *) params->value) = adc->flags.bit.nonov; break; /*------------------------------*/ case CAM_L_ADCFLTCPUR: /* LTC/PUR Output signal */ /*------------------------------*/ - *((int32_t *) params->value) = adc->flags.bit.ltcpur; + *((epicsInt32 *) params->value) = adc->flags.bit.ltcpur; break; /*------------------------------*/ case CAM_L_ADCFONLINE: /* Module on-line */ /*------------------------------*/ - *((uint32_t *) params->value) = adc->flags.bit.online; + *((epicsUInt32 *) params->value) = adc->flags.bit.online; break; /*------------------------------*/ case CAM_L_ADCFATTEN: /* Module requires attention */ /*------------------------------*/ - *((uint32_t *) params->value) = adc->flags.bit.atten; + *((epicsUInt32 *) params->value) = adc->flags.bit.atten; break; /*======================================================*/ @@ -2548,98 +2549,98 @@ int32_t icb_adc_read (ICB_CCNIM_ADC *adc, case CAM_L_ADCVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((uint32_t *) params->value) = adc->vflags.lword; + *((epicsUInt32 *) params->value) = adc->vflags.lword; break; /*------------------------------*/ case CAM_L_ADCVFID: /* VF: Module ID */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.id; + *((epicsInt32 *) params->value) = adc->vflags.bit.id; break; /*------------------------------*/ case CAM_L_ADCVFRANGE: /* VF: Range */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.range; + *((epicsInt32 *) params->value) = adc->vflags.bit.range; break; /*------------------------------*/ case CAM_L_ADCVFOFFSET: /* VF: Offset */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.offset; + *((epicsInt32 *) params->value) = adc->vflags.bit.offset; break; /*------------------------------*/ case CAM_L_ADCVFACQMODE:/* VF: Acquisition Mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.acqmode; + *((epicsInt32 *) params->value) = adc->vflags.bit.acqmode; break; /*------------------------------*/ case CAM_L_ADCVFCNVGAIN:/* VF: Conversion Gain */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.cnvgain; + *((epicsInt32 *) params->value) = adc->vflags.bit.cnvgain; break; /*------------------------------*/ case CAM_L_ADCVFLLD: /* VF: Lower level discriminator*/ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.lld; + *((epicsInt32 *) params->value) = adc->vflags.bit.lld; break; /*------------------------------*/ case CAM_L_ADCVFULD: /* VF: Upper level discriminator*/ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.uld; + *((epicsInt32 *) params->value) = adc->vflags.bit.uld; break; /*------------------------------*/ case CAM_L_ADCVFZERO: /* VF: Zero */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.zero; + *((epicsInt32 *) params->value) = adc->vflags.bit.zero; break; /*------------------------------*/ case CAM_L_ADCVFANTIC: /* VF: Anti-coinc. mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.antic; + *((epicsInt32 *) params->value) = adc->vflags.bit.antic; break; /*------------------------------*/ case CAM_L_ADCVFLATEC: /* VF: Late coinc mode */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.latec; + *((epicsInt32 *) params->value) = adc->vflags.bit.latec; break; /*------------------------------*/ case CAM_L_ADCVFDELPK: /* VF: Delayed peak detect */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.delpk; + *((epicsInt32 *) params->value) = adc->vflags.bit.delpk; break; /*------------------------------*/ case CAM_L_ADCVFNONOV: /* VF: Non-overlap transfer */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.nonov; + *((epicsInt32 *) params->value) = adc->vflags.bit.nonov; break; /*------------------------------*/ case CAM_L_ADCVFLTCPUR: /* VF: LTC/PUR Output */ /*------------------------------*/ - *((int32_t *) params->value) = adc->vflags.bit.ltcpur; + *((epicsInt32 *) params->value) = adc->vflags.bit.ltcpur; break; /*------------------------------*/ @@ -2680,21 +2681,21 @@ int32_t icb_adc_read (ICB_CCNIM_ADC *adc, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL +* "reg_list" (epicsUInt8 *) The list of ICB registers. This should be NULL * when ICB_ADC_VERIFY() is called from the outside. * *******************************************************************************/ -int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, +epicsInt32 icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, - int32_t flags, - uint8_t *reg_list) + epicsInt32 flags, + epicsUInt8 *reg_list) { - int32_t s; - uint8_t registers[14]; - uint8_t lreg; - uint8_t mreg; + epicsInt32 s; + epicsUInt8 registers[14]; + epicsUInt8 lreg; + epicsUInt8 mreg; ICB_MODULE_INFO *entry; /* @@ -2874,20 +2875,20 @@ int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, * *******************************************************************************/ -int32_t icb_amp_write (ICB_CCNIM_AMP *amp, +epicsInt32 icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t i; - int32_t s=OK; - uint32_t dac; - uint32_t fbits; - int32_t index; + epicsInt32 i; + epicsInt32 s=OK; + epicsUInt32 dac; + epicsUInt32 fbits; + epicsInt32 index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *flag_list; - int32_t *flag_vals; - int32_t local_flags; + epicsInt32 *flag_vals; + epicsInt32 local_flags; ICB_PARAM_LIST *params_start; /* @@ -3031,7 +3032,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->pz = *((int32_t *) params->value); + amp->pz = *((epicsInt32 *) params->value); if (!entry) break; /* Store the pole zero in the module */ @@ -3094,11 +3095,11 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /* Build a flag parameter list based on the flag bit settings */ flag_list = (ICB_PARAM_LIST *) malloc (sizeof (amp_flag_list)); - flag_vals = (int32_t *) malloc (sizeof (amp_flag_bits)); + flag_vals = (epicsInt32 *) malloc (sizeof (amp_flag_bits)); memcpy (flag_list, amp_flag_list, sizeof (amp_flag_list)); if ((flags & ICB_M_HDLR_INITIALIZE) == 0) { - fbits = *((int32_t *) params->value); + fbits = *((epicsInt32 *) params->value); for (i = 0; flag_list[i].pcode != 0; i++) { flag_vals[i] = ((amp_flag_bits[i] & fbits) != 0); flag_list[i].value = &flag_vals[i]; @@ -3120,7 +3121,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the differential input bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.diff = *((int32_t *) params->value); + amp->flags.bit.diff = *((epicsInt32 *) params->value); if (!entry) break; if (amp->flags.bit.diff) @@ -3140,7 +3141,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the input polarity bit (1=negative) */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.negpol = *((int32_t *) params->value); + amp->flags.bit.negpol = *((epicsInt32 *) params->value); if (!entry) break; if (amp->flags.bit.negpol) @@ -3160,7 +3161,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the inhibit polarity bit */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.compinh = *((int32_t *) params->value); + amp->flags.bit.compinh = *((epicsInt32 *) params->value); if (!entry) break; if (amp->flags.bit.compinh) @@ -3180,7 +3181,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /* Set or clear the pileup reject bit (1=negative) */ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.purej = *((int32_t *) params->value); + amp->flags.bit.purej = *((epicsInt32 *) params->value); if (!entry) break; if (amp->flags.bit.purej) @@ -3198,7 +3199,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) != 0) break; - if (*((int32_t *) params->value) == 0) break; + if (*((epicsInt32 *) params->value) == 0) break; /* Performing an automatic pole zero in the AMP is too */ /* complicated to be done here in a switch statement. */ @@ -3212,7 +3213,7 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, /*------------------------------*/ if ((flags & ICB_M_HDLR_INITIALIZE) == 0) - amp->flags.bit.atten = *((int32_t *) params->value); + amp->flags.bit.atten = *((epicsInt32 *) params->value); if (!entry) break; if (amp->flags.bit.atten) @@ -3273,14 +3274,14 @@ int32_t icb_amp_write (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -int32_t icb_amp_read (ICB_CCNIM_AMP *amp, +epicsInt32 icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - int32_t flags) + epicsInt32 flags) { - int32_t i; - uint32_t reg; - int32_t index; + epicsInt32 i; + epicsUInt32 reg; + epicsInt32 index; ICB_MODULE_INFO *entry; ICB_PARAM_LIST *params_start; @@ -3352,7 +3353,7 @@ int32_t icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPPZ: /* Amplifier pole zero */ /*------------------------------*/ - *((int32_t *) params->value) = amp->pz; + *((epicsInt32 *) params->value) = amp->pz; break; /*------------------------------*/ @@ -3382,7 +3383,7 @@ int32_t icb_amp_read (ICB_CCNIM_AMP *amp, /* Logic 0 indicates the setting. Bit 0 ==> 0.5 */ /* Bit 5 ==> 12 us */ - reg = ((uint32_t) entry->registers[5]); + reg = ((epicsUInt32) entry->registers[5]); for (i = 0; i < 6; i++, reg >>= 1) if ((reg & 1) == 0) break; *((float *) params->value) = amp_shape_time[i]; @@ -3397,77 +3398,77 @@ int32_t icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPFLAGS: /* Amplifier Mode flags */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->flags.lword; + *((epicsUInt32 *) params->value) = amp->flags.lword; continue; /*--------------------------------*/ case CAM_L_AMPFDIFF: /* Differential (vs normal) input */ /*--------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.diff; + *((epicsUInt32 *) params->value) = amp->flags.bit.diff; break; /*---------------------------------*/ case CAM_L_AMPFNEGPOL: /* Negative (vs positive) polarity */ /*---------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.negpol; + *((epicsUInt32 *) params->value) = amp->flags.bit.negpol; break; /*------------------------------*/ case CAM_L_AMPFCOMPINH: /* Complement inhibit polarity */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.compinh; + *((epicsUInt32 *) params->value) = amp->flags.bit.compinh; break; /*--------------------------------*/ case CAM_L_AMPFPUREJ: /* Pileup reject (enable/disable) */ /*--------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.purej; + *((epicsUInt32 *) params->value) = amp->flags.bit.purej; break; /*------------------------------*/ case CAM_L_AMPFONLINE: /* Module on-line */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.online; + *((epicsUInt32 *) params->value) = amp->flags.bit.online; break; /*-------------------------------*/ case CAM_L_AMPFMOTRBUSY: /* Motor Busy */ /*-------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.motrbusy; + *((epicsUInt32 *) params->value) = amp->flags.bit.motrbusy; break; /*--------------------------------*/ case CAM_L_AMPFPZBUSY: /* Pole Zero Busy */ /*--------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.pzbusy; + *((epicsUInt32 *) params->value) = amp->flags.bit.pzbusy; break; /*------------------------------*/ case CAM_L_AMPFATTEN: /* Module requires attention */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.atten; + *((epicsUInt32 *) params->value) = amp->flags.bit.atten; break; /*--------------------------------*/ case CAM_L_AMPFPZFAIL: /* Pole Zero Failed */ /*--------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.pzfail; + *((epicsUInt32 *) params->value) = amp->flags.bit.pzfail; break; /*--------------------------------*/ case CAM_L_AMPFMOTRFAIL:/* Fine Gain Motor Failed */ /*--------------------------------*/ - *((uint32_t *) params->value) = amp->flags.bit.motrfail; + *((epicsUInt32 *) params->value) = amp->flags.bit.motrfail; break; /*======================================================*/ @@ -3478,105 +3479,105 @@ int32_t icb_amp_read (ICB_CCNIM_AMP *amp, case CAM_L_AMPVFLAGS: /* Verify Flags field */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->vflags.lword; + *((epicsUInt32 *) params->value) = amp->vflags.lword; break; /*------------------------------*/ case CAM_L_AMPVFID: /* VF: Module ID */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.id; + *((epicsInt32 *) params->value) = amp->vflags.bit.id; break; /*------------------------------*/ case CAM_L_AMPVFPRAMPT: /* VF: Preamplifier type */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.prampt; + *((epicsInt32 *) params->value) = amp->vflags.bit.prampt; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN1:/* VF: Course GAIN */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.hwgain1; + *((epicsInt32 *) params->value) = amp->vflags.bit.hwgain1; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN2:/* VF: Fine Gain */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.hwgain2; + *((epicsInt32 *) params->value) = amp->vflags.bit.hwgain2; break; /*------------------------------*/ case CAM_L_AMPVFHWGAIN3:/* VF: Super Fine Gain */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.hwgain3; + *((epicsInt32 *) params->value) = amp->vflags.bit.hwgain3; break; /*------------------------------*/ case CAM_L_AMPVFSHAPEM: /* VF: Amplifier shaping mode */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.shapem; + *((epicsInt32 *) params->value) = amp->vflags.bit.shapem; break; /*------------------------------*/ case CAM_L_AMPVFPZ: /* VF: Amplifier pole zero */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.pz; + *((epicsInt32 *) params->value) = amp->vflags.bit.pz; break; /*------------------------------*/ case CAM_L_AMPVFBLRTYPE:/* VF: Base-line restore */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.blrtype; + *((epicsInt32 *) params->value) = amp->vflags.bit.blrtype; break; /*------------------------------*/ case CAM_L_AMPVFDTCTYPE:/* VF: Dead-time control */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.dtctype; + *((epicsInt32 *) params->value) = amp->vflags.bit.dtctype; break; /*------------------------------*/ case CAM_L_AMPVFTC: /* VF: Amplifier time constant */ /*------------------------------*/ - *((int32_t *) params->value) = amp->vflags.bit.tc; + *((epicsInt32 *) params->value) = amp->vflags.bit.tc; break; /*-------------------------------*/ case CAM_L_AMPVFDIFF: /* VF: Differential input */ /*-------------------------------*/ - *((uint32_t *) params->value) = amp->vflags.bit.diff; + *((epicsUInt32 *) params->value) = amp->vflags.bit.diff; break; /*------------------------------*/ case CAM_L_AMPVFNEGPOL: /* VF: Negative polarity */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->vflags.bit.negpol; + *((epicsUInt32 *) params->value) = amp->vflags.bit.negpol; break; /*------------------------------*/ case CAM_L_AMPVFCOMPINH:/* VF: Comp. inhibit polarity */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->vflags.bit.compinh; + *((epicsUInt32 *) params->value) = amp->vflags.bit.compinh; break; /*------------------------------*/ case CAM_L_AMPVFPUREJ: /* VF: Pileup reject */ /*------------------------------*/ - *((uint32_t *) params->value) = amp->vflags.bit.purej; + *((epicsUInt32 *) params->value) = amp->vflags.bit.purej; break; /*------------------------------*/ @@ -3615,22 +3616,22 @@ int32_t icb_amp_read (ICB_CCNIM_AMP *amp, * * "flags" (longword, by reference) is the reserved flags field * -* "reg_list" (uint8_t *) The list of ICB registers. This should be NULL +* "reg_list" (epicsUInt8 *) The list of ICB registers. This should be NULL * when ICB_AMP_VERIFY() is called from the outside. * *******************************************************************************/ -int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, +epicsInt32 icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, - int32_t flags, - uint8_t *reg_list) + epicsInt32 flags, + epicsUInt8 *reg_list) { - int32_t i; - int32_t s; - uint8_t registers[14]; - uint8_t lreg; - uint8_t mreg; + epicsInt32 i; + epicsInt32 s; + epicsUInt8 registers[14]; + epicsUInt8 lreg; + epicsUInt8 mreg; ICB_MODULE_INFO *entry; /* @@ -3828,11 +3829,11 @@ int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, - int32_t flags) +epicsInt32 icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, + epicsInt32 flags) { - int32_t i; /* Loop counter */ + epicsInt32 i; /* Loop counter */ float vg; /* Intermediate virtual gain */ static float cg; /* Computed course gain */ static float fg; /* Computed fine gain */ @@ -3906,7 +3907,7 @@ int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, * *******************************************************************************/ -int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -3916,9 +3917,9 @@ int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp) */ { - int32_t s; - int32_t nvpos; - uint32_t pos; + epicsInt32 s; + epicsInt32 nvpos; + epicsUInt32 pos; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -3997,12 +3998,12 @@ while (1) { * *******************************************************************************/ -int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_complete_position (ICB_CCNIM_AMP *amp) { - int32_t s; - uint8_t temp[4]; - uint32_t pos; + epicsInt32 s; + epicsUInt8 temp[4]; + epicsUInt32 pos; ICB_MODULE_INFO *entry; /* @@ -4063,7 +4064,7 @@ int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp) * *******************************************************************************/ -int32_t icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -4073,9 +4074,9 @@ int32_t icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp) */ { - int32_t s; - uint32_t pos; - uint8_t temp[4]; + epicsInt32 s; + epicsUInt32 pos; + epicsUInt8 temp[4]; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4146,8 +4147,8 @@ while (1) { int icb_amp_home_motor (ICB_CCNIM_AMP *amp) { - int32_t s; - uint8_t temp[4]; + epicsInt32 s; + epicsUInt8 temp[4]; ICB_MODULE_INFO *entry; /* @@ -4199,7 +4200,7 @@ int icb_amp_home_motor (ICB_CCNIM_AMP *amp) * *******************************************************************************/ -int32_t icb_amp_test_home (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_test_home (ICB_CCNIM_AMP *amp) /* This routine runs as an AST on VMS systems. This means it runs as a separate "thread". Under EPICS this routine presently runs inline @@ -4209,8 +4210,8 @@ int32_t icb_amp_test_home (ICB_CCNIM_AMP *amp) */ { - int32_t s; - uint8_t temp[4]; + epicsInt32 s; + epicsUInt8 temp[4]; ICB_MODULE_INFO *entry; double dt_qsec= .25; @@ -4268,11 +4269,11 @@ while (1) { * *******************************************************************************/ -uint32_t icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) +epicsUInt32 icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) { - int32_t pos; + epicsInt32 pos; /* * Make sure the fine gain value is reasonable before computing the @@ -4309,15 +4310,15 @@ uint32_t icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp) int icb_amp_get_nvram_motor_pos (index, nvpos, flags) -int32_t index; -int32_t *nvpos; -int32_t flags; +epicsInt32 index; +epicsInt32 *nvpos; +epicsInt32 flags; { - int32_t s; - int32_t i; - uint32_t nibble; - uint8_t reg_val; + epicsInt32 s; + epicsInt32 i; + epicsUInt32 nibble; + epicsUInt8 reg_val; /* * Map the second page of NVRAM. @@ -4333,7 +4334,7 @@ int32_t flags; *nvpos = 0; nibble = 0; for (i = 2; i >= 0; i--) { - s = icb_read_nvram (index, i, (int32_t *) &nibble); + s = icb_read_nvram (index, i, (epicsInt32 *) &nibble); if (s != OK) return s; *nvpos = (*nvpos * 16) | nibble; } @@ -4372,16 +4373,16 @@ int32_t flags; int icb_amp_put_nvram_motor_pos (index, nvpos, flags) -int32_t index; -int32_t nvpos; -int32_t flags; +epicsInt32 index; +epicsInt32 nvpos; +epicsInt32 flags; { - int32_t s; - int32_t i; - uint8_t reg_val; + epicsInt32 s; + epicsInt32 i; + epicsUInt8 reg_val; int8_t nibble; - uint32_t temp; + epicsUInt32 temp; struct icb_module_info_struct *entry; /* @@ -4446,13 +4447,13 @@ int32_t flags; int icb_amp_put_motor_pos (index, pos, flags) -int32_t index; -int32_t pos; -int32_t flags; +epicsInt32 index; +epicsInt32 pos; +epicsInt32 flags; { - int32_t s; - uint8_t temp[4]; + epicsInt32 s; + epicsUInt8 temp[4]; ICB_MODULE_INFO *entry; double wait_time = 0.1; /* for taskDelay */ @@ -4528,11 +4529,11 @@ int32_t flags; * *******************************************************************************/ -int32_t icb_amp_start_pz (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_start_pz (ICB_CCNIM_AMP *amp) { - int32_t s=OK; - uint8_t reg_val; + epicsInt32 s=OK; + epicsUInt8 reg_val; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4602,11 +4603,11 @@ while(1) { * *******************************************************************************/ -int32_t icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp) { - int32_t s; - uint8_t temp[4]; + epicsInt32 s; + epicsUInt8 temp[4]; ICB_MODULE_INFO *entry; double dt_qsec = 0.25; @@ -4667,10 +4668,10 @@ while (1) { * *******************************************************************************/ -int32_t icb_amp_write_pz (ICB_CCNIM_AMP *amp) +epicsInt32 icb_amp_write_pz (ICB_CCNIM_AMP *amp) { - int32_t s; + epicsInt32 s; ICB_MODULE_INFO *entry; /* @@ -4726,11 +4727,11 @@ int32_t icb_amp_write_pz (ICB_CCNIM_AMP *amp) int icb_adc_encode_chns (chns) -uint32_t chns; +epicsUInt32 chns; { - int32_t i; - uint32_t mask; + epicsInt32 i; + epicsUInt32 mask; /* * Find the first set bit. @@ -4773,14 +4774,14 @@ uint32_t chns; *******************************************************************************/ int icb_write_csr (ICB_CCNIM_ANY *ccnim, - int32_t perm_bits, - int32_t temp_bits, - int32_t mask) + epicsInt32 perm_bits, + epicsInt32 temp_bits, + epicsInt32 mask) { - int32_t s; - uint8_t csr; - uint8_t register_list[16]; + epicsInt32 s; + epicsUInt8 csr; + epicsUInt8 register_list[16]; ICB_MODULE_INFO *entry; /* @@ -4836,12 +4837,12 @@ int icb_write_csr (ICB_CCNIM_ANY *ccnim, int icb_monitor_modules () { - int32_t i; + epicsInt32 i; ICB_MODULE_INFO *entry; static float tc; - static int32_t tc_verify; - static int32_t inhibit; - static int32_t overload; + static epicsInt32 tc_verify; + static epicsInt32 inhibit; + static epicsInt32 overload; static ICB_PARAM_LIST amp_plist[] = {{CAM_F_AMPTC, 0, &tc}, {CAM_L_AMPVFTC, 0, &tc_verify}, {0, 0, 0}}; From d4fb12aa691dbacbb2ce30d3d9e4cdc106d86abe Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Fri, 23 Oct 2015 16:30:55 -0500 Subject: [PATCH 15/17] Switched icb_strings.c from stdint to epicstypes.h --- mcaApp/CanberraSrc/icb_strings.c | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_strings.c b/mcaApp/CanberraSrc/icb_strings.c index 42774ddf..72796022 100644 --- a/mcaApp/CanberraSrc/icb_strings.c +++ b/mcaApp/CanberraSrc/icb_strings.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include "epicsTypes.h" #define OK 0 @@ -17,17 +17,17 @@ * * "status" is the status of the operation. Any errors have been signaled. * -* "str" (int8_t *) the destination zero terminated string. +* "str" (epicsInt8 *) the destination zero terminated string. * * "dsc" (struct dsc$descriptor *) is the source descriptor * -* "str" (int32_t) is the max length of the string. +* "str" (epicsInt32) is the max length of the string. * *******************************************************************************/ -int icb_dsc2str (int8_t *str, - int8_t *dsc, - int32_t max_len) +int icb_dsc2str (epicsInt8 *str, + epicsInt8 *dsc, + epicsInt32 max_len) { /* @@ -55,12 +55,12 @@ int icb_dsc2str (int8_t *str, * * "dsc" (struct dsc$descriptor *) is the destination descriptor * -* "str" (int8_t *) the source zero terminated string. +* "str" (epicsInt8 *) the source zero terminated string. * *******************************************************************************/ -int icb_str2dsc (int8_t *dsc, - int8_t *str) +int icb_str2dsc (epicsInt8 *dsc, + epicsInt8 *str) { /* @@ -94,19 +94,19 @@ int icb_str2dsc (int8_t *dsc, * * "status" is the status of the operation. != 0 if strings are the same * -* "s1" (int8_t *) string 1 +* "s1" (epicsInt8 *) string 1 * -* "s2" (int8_t *) string 2 +* "s2" (epicsInt8 *) string 2 * * "len" (int) Length of strings to compare * *******************************************************************************/ -int StrNCmp (int8_t *s1, - int8_t *s2, +int StrNCmp (epicsInt8 *s1, + epicsInt8 *s2, int len) { - int32_t i; + epicsInt32 i; if (strlen(s1) < len) len = strlen(s1); if (strlen(s2) < len) len = strlen(s2); @@ -128,19 +128,19 @@ int StrNCmp (int8_t *s1, * * "status" is the status of the operation. * -* "dst" (int8_t *) destination string +* "dst" (epicsInt8 *) destination string * -* "src" (int8_t *) source string +* "src" (epicsInt8 *) source string * * "len" (int) Maximum length * *******************************************************************************/ -int StrUpCase (int8_t *dst, - int8_t *src, +int StrUpCase (epicsInt8 *dst, + epicsInt8 *src, int len) { - int32_t i; + epicsInt32 i; if (strlen(src) < len) len = strlen(src); strncpy(dst, src, len); @@ -163,9 +163,9 @@ int StrUpCase (int8_t *dst, * * "status" is the status of the operation. * -* "dst" (int8_t *) destination string +* "dst" (epicsInt8 *) destination string * -* "src" (int8_t *) source string +* "src" (epicsInt8 *) source string * * "len" (int) Maximum length * @@ -173,12 +173,12 @@ int StrUpCase (int8_t *dst, * *******************************************************************************/ -int StrTrim (int8_t *dst, - int8_t *src, +int StrTrim (epicsInt8 *dst, + epicsInt8 *src, int len, int *trim_len) { - int32_t i; + epicsInt32 i; if (strlen(src) < len) len = strlen(src); *trim_len = 0; From ff001a658d982b7c1db08f2af945b8111899af2c Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Fri, 23 Oct 2015 16:33:12 -0500 Subject: [PATCH 16/17] Switched icb_sys_defs.h from stdint to epicstypes.h --- mcaApp/CanberraSrc/icb_sys_defs.h | 160 +++++++++++++++--------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/mcaApp/CanberraSrc/icb_sys_defs.h b/mcaApp/CanberraSrc/icb_sys_defs.h index 4bdcec44..7ba2fcc8 100644 --- a/mcaApp/CanberraSrc/icb_sys_defs.h +++ b/mcaApp/CanberraSrc/icb_sys_defs.h @@ -27,7 +27,7 @@ extern "C" { #endif -#include +#include "epicsTypes.h" #define ICB_K_MAX_MODULES 96 /* The number of entries in ICB_MODULE_INFO */ @@ -71,8 +71,8 @@ extern "C" { */ typedef struct { - int32_t pcode; /* CAM parameter code */ - int32_t cached_flag; /* Boolian */ + epicsInt32 pcode; /* CAM parameter code */ + epicsInt32 cached_flag; /* Boolian */ } ICB_CACHED_PARAM; @@ -87,9 +87,9 @@ extern "C" { typedef struct { - int32_t icb_index; /* Module ICB database index */ + epicsInt32 icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - int8_t extra_header[24]; /* Space for more header info */ + epicsInt8 extra_header[24]; /* Space for more header info */ } ICB_CCNIM_ANY; @@ -141,30 +141,30 @@ extern "C" { typedef struct { - int32_t icb_index; /* Module ICB database index */ + epicsInt32 icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - int8_t extra_header[24]; /* Space for more header info */ + epicsInt8 extra_header[24]; /* Space for more header info */ /*----------------------*/ /* ADC CAM values */ /*----------------------*/ - int32_t range; /* ADC range */ - int32_t offset; /* ADC offset */ - int8_t acqmode[12]; /* ADC acquisition mode (8 char)*/ - int32_t cnvgain; /* ADC conversion gain */ - int32_t abs_cnvlim; /* Absolute conv. gain limit */ + epicsInt32 range; /* ADC range */ + epicsInt32 offset; /* ADC offset */ + epicsInt8 acqmode[12]; /* ADC acquisition mode (8 char)*/ + epicsInt32 cnvgain; /* ADC conversion gain */ + epicsInt32 abs_cnvlim; /* Absolute conv. gain limit */ float lld; /* Lower level descriminator */ float uld; /* Upper level descriminator */ float zero; /* ADC zero */ - int8_t extra_values[32]; /* Space for more values */ + epicsInt8 extra_values[32]; /* Space for more values */ /*--------------------------------*/ /* ADC CAM flags (CAM_L_ADCFLAGS) */ /*--------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_ADC_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -173,11 +173,11 @@ extern "C" { /*----------------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_ADC_VFLAGS bit; /* Individual flag bit struct */ } vflags; - int32_t extra_flags[1]; /* Space for extra values */ + epicsInt32 extra_flags[1]; /* Space for extra values */ } ICB_CCNIM_ADC; @@ -233,33 +233,33 @@ extern "C" { typedef struct { - int32_t icb_index; /* Module ICB database index */ + epicsInt32 icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - int8_t extra_header[24]; /* Space for more header info */ + epicsInt8 extra_header[24]; /* Space for more header info */ /*----------------------*/ /* AMP CAM values */ /*----------------------*/ - int8_t pramptype[12]; /* Preamp type (RC,TRP) (8 char) */ + epicsInt8 pramptype[12]; /* Preamp type (RC,TRP) (8 char) */ float gain; /* Virtual gain (hwg1 * hwg2 * hwg3) */ float hwgain1; /* Course gain */ float hwgain2; /* Fine gain */ float hwgain3; /* Super fine gain */ - int8_t shapemode[12]; /* Shaping mode (8 char) */ - int32_t pz; /* Pole zero */ - int8_t blrtype[12]; /* Base-line restore (SYM,ASYM) (8 char) */ - int8_t dtctype[12]; /* Dead-time control (Normal,LFC) (8 char) */ + epicsInt8 shapemode[12]; /* Shaping mode (8 char) */ + epicsInt32 pz; /* Pole zero */ + epicsInt8 blrtype[12]; /* Base-line restore (SYM,ASYM) (8 char) */ + epicsInt8 dtctype[12]; /* Dead-time control (Normal,LFC) (8 char) */ float tc; /* AMP time constant (seconds) */ - int32_t hwgain2_timer; /* Callback Timer id for fine gain */ - int8_t extra_values[32]; /* Space for more values */ + epicsInt32 hwgain2_timer; /* Callback Timer id for fine gain */ + epicsInt8 extra_values[32]; /* Space for more values */ /*--------------------------------*/ /* AMP CAM flags (CAM_L_AMPFLAGS) */ /*--------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_AMP_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -268,11 +268,11 @@ extern "C" { /*----------------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_AMP_VFLAGS bit; /* Individual flag bit struct */ } vflags; - int32_t extra_flags[1]; /* Space for more values */ + epicsInt32 extra_flags[1]; /* Space for more values */ } ICB_CCNIM_AMP; @@ -322,9 +322,9 @@ extern "C" { typedef struct { - int32_t icb_index; /* Module ICB database index */ + epicsInt32 icb_index; /* Module ICB database index */ ICB_CACHED_PARAM param_list[ICB_K_MAX_CACHED_PARAMS]; - int8_t extra_header[24]; /* Space for more header info */ + epicsInt8 extra_header[24]; /* Space for more header info */ /*----------------------*/ /* HVPS CAM values */ @@ -337,14 +337,14 @@ extern "C" { void *ramp_ast_id; /* Id of ramp function AST */ /* Non-zero indicates that a */ /* ramp is in progress */ - int8_t extra_values[24]; /* Space for more values */ + epicsInt8 extra_values[24]; /* Space for more values */ /*----------------------------------*/ /* HVPS CAM flags (CAM_L_HVPSFLAGS) */ /*----------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_HVPS_FLAGS bit; /* Individual flag bit struct */ } flags; @@ -353,11 +353,11 @@ extern "C" { /*------------------------------------------*/ union { - int32_t lword; /* Standard flags field */ + epicsInt32 lword; /* Standard flags field */ ICB_HVPS_VFLAGS bit;/* Individual flag bit struct */ } vflags; - int32_t extra_flags[1]; /* Space for more values */ + epicsInt32 extra_flags[1]; /* Space for more values */ } ICB_CCNIM_HVPS; @@ -368,8 +368,8 @@ extern "C" { typedef struct _ICB_PARAM_LIST { - int32_t pcode; - int32_t reserved; + epicsInt32 pcode; + epicsInt32 reserved; void *value; } ICB_PARAM_LIST; @@ -480,54 +480,54 @@ int icb_crmpsc(); int icb_get_module_state(int index); /* Functions in icb_handler_subs.c */ -int32_t icb_hvps_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_adc_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_amp_hdlr (int32_t index, ICB_PARAM_LIST *params, int32_t flags); -int icb_validate_module (int32_t index, ICB_PARAM_LIST *params, - int32_t *present, int32_t *reset, int32_t flags); -int icb_init_ccnim_cache (int32_t index, int32_t flags); +epicsInt32 icb_hvps_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_adc_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_amp_hdlr (epicsInt32 index, ICB_PARAM_LIST *params, epicsInt32 flags); +int icb_validate_module (epicsInt32 index, ICB_PARAM_LIST *params, + epicsInt32 *present, epicsInt32 *reset, epicsInt32 flags); +int icb_init_ccnim_cache (epicsInt32 index, epicsInt32 flags); ICB_PARAM_LIST *icb_build_cached_plist (ICB_CCNIM_ANY *ccany); int icb_set_cached_flags (ICB_CCNIM_ANY *ccany, ICB_PARAM_LIST *params); -int32_t icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, int32_t flags, - uint8_t *reg_list); -int32_t icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps); -int32_t icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, int32_t flags); -int32_t icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, float *voltage, int32_t flags); -int32_t icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, int32_t state, int32_t flags); -int32_t icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, int32_t flags, - uint8_t *reg_list); -int32_t icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags); -int32_t icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, int32_t flags, - uint8_t *reg_list); -int32_t icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, int32_t flags); -int32_t icb_amp_write_gain2 (ICB_CCNIM_AMP *amp); -int32_t icb_amp_complete_position (ICB_CCNIM_AMP *amp); -int32_t icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp); -int32_t icb_amp_home_motor (ICB_CCNIM_AMP *amp); -int32_t icb_amp_test_home (ICB_CCNIM_AMP *amp); -uint32_t icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp); -int32_t icb_amp_get_nvram_motor_pos (int32_t index, int32_t *nvpos, int32_t flags); -int32_t icb_amp_put_nvram_motor_pos (int32_t index, int32_t nvpos, int32_t flags); -int32_t icb_amp_put_motor_pos (int32_t index, int32_t pos, int32_t flags); -int32_t icb_amp_start_pz (ICB_CCNIM_AMP *amp); -int32_t icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp); -int32_t icb_amp_write_pz (ICB_CCNIM_AMP *amp); -int32_t icb_adc_encode_chns (uint32_t chns); -int32_t icb_write_csr (ICB_CCNIM_ANY *ccnim, int32_t perm_bits, int32_t temp_bits, - int32_t mask); -int32_t icb_monitor_modules (); +epicsInt32 icb_hvps_write (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_hvps_read (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_hvps_verify (ICB_CCNIM_HVPS *hvps, ICB_PARAM_LIST *params, epicsInt32 flags, + epicsUInt8 *reg_list); +epicsInt32 icb_hvps_ramp_voltage (ICB_CCNIM_HVPS *hvps); +epicsInt32 icb_hvps_send_voltage (ICB_CCNIM_HVPS *hvps, float voltage, epicsInt32 flags); +epicsInt32 icb_hvps_convert_voltage (ICB_CCNIM_HVPS *hvps, float *voltage, epicsInt32 flags); +epicsInt32 icb_hvps_set_state (ICB_CCNIM_HVPS *hvps, epicsInt32 state, epicsInt32 flags); +epicsInt32 icb_adc_write (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_adc_read (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_adc_verify (ICB_CCNIM_ADC *adc, ICB_PARAM_LIST *params, epicsInt32 flags, + epicsUInt8 *reg_list); +epicsInt32 icb_amp_write (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_amp_read (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, epicsInt32 flags); +epicsInt32 icb_amp_verify (ICB_CCNIM_AMP *amp, ICB_PARAM_LIST *params, epicsInt32 flags, + epicsUInt8 *reg_list); +epicsInt32 icb_amp_vgain_to_hwgain (ICB_CCNIM_AMP *amp, epicsInt32 flags); +epicsInt32 icb_amp_write_gain2 (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_complete_position (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_test_gain2_complete (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_home_motor (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_test_home (ICB_CCNIM_AMP *amp); +epicsUInt32 icb_amp_compute_motor_pos (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_get_nvram_motor_pos (epicsInt32 index, epicsInt32 *nvpos, epicsInt32 flags); +epicsInt32 icb_amp_put_nvram_motor_pos (epicsInt32 index, epicsInt32 nvpos, epicsInt32 flags); +epicsInt32 icb_amp_put_motor_pos (epicsInt32 index, epicsInt32 pos, epicsInt32 flags); +epicsInt32 icb_amp_start_pz (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_test_pz_complete (ICB_CCNIM_AMP *amp); +epicsInt32 icb_amp_write_pz (ICB_CCNIM_AMP *amp); +epicsInt32 icb_adc_encode_chns (epicsUInt32 chns); +epicsInt32 icb_write_csr (ICB_CCNIM_ANY *ccnim, epicsInt32 perm_bits, epicsInt32 temp_bits, + epicsInt32 mask); +epicsInt32 icb_monitor_modules (); /* The following routines are in icb_strings.c */ -int icb_dsc2str (int8_t *str, int8_t *dsc, int32_t max_len); -int icb_str2dsc (int8_t *dsc, int8_t *str); -int StrNCmp (int8_t *s1, int8_t *s2, int len); -int StrUpCase (int8_t *dst, int8_t *src, int len); -int StrTrim (int8_t *dst, int8_t *src, int len, int *trim_len); +int icb_dsc2str (epicsInt8 *str, epicsInt8 *dsc, epicsInt32 max_len); +int icb_str2dsc (epicsInt8 *dsc, epicsInt8 *str); +int StrNCmp (epicsInt8 *s1, epicsInt8 *s2, int len); +int StrUpCase (epicsInt8 *dst, epicsInt8 *src, int len); +int StrTrim (epicsInt8 *dst, epicsInt8 *src, int len, int *trim_len); #ifdef __cplusplus } From 9a89eea993bd415c9d8716b495f5230c361acf52 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Fri, 23 Oct 2015 16:35:56 -0500 Subject: [PATCH 17/17] missed one --- mcaApp/CanberraSrc/icb_handler_subs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcaApp/CanberraSrc/icb_handler_subs.c b/mcaApp/CanberraSrc/icb_handler_subs.c index 2c8580a7..f856ebc0 100644 --- a/mcaApp/CanberraSrc/icb_handler_subs.c +++ b/mcaApp/CanberraSrc/icb_handler_subs.c @@ -4381,7 +4381,7 @@ epicsInt32 flags; epicsInt32 s; epicsInt32 i; epicsUInt8 reg_val; - int8_t nibble; + epicsInt8 nibble; epicsUInt32 temp; struct icb_module_info_struct *entry;