lib_ocx.c

00001 
00002 #include "edtinc.h"
00003 
00004 #include "edt_ocx.h"
00005 
00006 /***************************************
00007 * Some utility functions
00008 * These probably ought to go in a general
00009 * library file
00010 **************************************/
00011 
00012 
00013 int
00014 edt_reg_set_bitmask(EdtDev *edt_p, u_int reg, u_int mask, int state)
00015 
00016 {
00017 
00018     return  (state)? edt_reg_or(edt_p, reg, mask) : edt_reg_and(edt_p, reg, ~mask);
00019 }
00020 
00021 
00022 int
00023 edt_wait_register_bits_low(EdtDev *edt_p, u_int reg, u_int mask, int timeout)
00024 
00025 {
00026     int t = 0;
00027     int s;
00028 
00029     while ((t < timeout || !timeout) && (edt_reg_read(edt_p,reg) & mask))
00030     {
00031 
00032         s = timeout - t;
00033         if (s > 10)
00034             s = 10;
00035 
00036         edt_msleep(s);
00037         t += s;
00038     }
00039 
00040     return (t >= timeout && (timeout != 0));
00041 }
00042 
00043 int
00044 edt_wait_register_bits_low_timer(EdtDev *edt_p, u_int reg, u_int mask, int timeout)
00045 
00046 {
00047     int t = 0;
00048     int s;
00049 
00050     while ((t < timeout || !timeout) && (edt_reg_read(edt_p,reg) & mask))
00051     {
00052 
00053         s = timeout - t;
00054         if (s > 10)
00055             s = 10;
00056 
00057         edt_msleep(s);
00058         t += s;
00059     }
00060 
00061     return t;
00062 }
00063 
00064 int
00065 edt_wait_register_bits_high(EdtDev *edt_p, u_int reg, u_int mask, int timeout)
00066 
00067 {
00068     int t = 0;
00069     int s;
00070 
00071     while ((t < timeout || !timeout) && 
00072         !((edt_reg_read(edt_p,reg) & mask)==mask))
00073     {
00074 
00075         s = timeout - t;
00076         if (s > 10)
00077             s = 10;
00078 
00079         edt_msleep(s);
00080         t += s;
00081     }
00082 
00083     /* fixed bug where t == timeout does not return error -mcm 11/25/08 */
00084     return (t >= timeout && (timeout != 0));
00085 
00086 }
00087 
00088 int
00089 edt_wait_register_bits_high_timer(EdtDev *edt_p, u_int reg, u_int mask, int timeout)
00090 
00091 {
00092     int t = 0;
00093     int s;
00094 
00095     while ((t < timeout || !timeout) && 
00096         !((edt_reg_read(edt_p,reg) & mask)==mask))
00097     {
00098 
00099         s = timeout - t;
00100         if (s > 10)
00101             s = 10;
00102 
00103         edt_msleep(s);
00104         t += s;
00105     }
00106 
00107     /* fixed bug where t == timeout does not return error -mcm 11/25/08 */
00108     return t;
00109 
00110 }
00111 
00112 void
00113 edt_ocx_clear_state_flag(EdtOCConfig *cfg, const u_int flag)
00114 
00115 {
00116     cfg->state &= ~flag;
00117 }
00118 
00119 void
00120 edt_ocx_set_state_flag(EdtOCConfig *cfg, const u_int flag)
00121 
00122 {
00123     cfg->state |= ~flag;
00124 }
00125 
00126 
00127 
00142 void
00143 edt_ocx_cfg_init(EdtOCConfig *cfg,
00144                  u_int flags,
00145                  int timeout,
00146                  EdtLineRate rate)
00147 
00148 {
00149     memset(cfg, 0, sizeof(*cfg));
00150 
00151     cfg->flags = flags;
00152     cfg->line_rate = rate;
00153     cfg->frame_timeout = timeout;
00154     cfg->timeout = timeout;
00155     cfg->signal_timeout = timeout;
00156     cfg->receive_dcm_timeout = timeout;
00157     cfg->transceiver_timeout = timeout;
00158 
00159 
00160 }

Generated on 19 Jun 2015 by  doxygen 1.4.7