mbgtools-lx  4.2.8
myutil.h File Reference
#include <words.h>
#include <use_pack.h>

Go to the source code of this file.

Data Structures

union  UL
 

Macros

#define _CSFAR
 
#define _ext   extern
 
#define _frac(_x)   ( ( (_x) == 0.0 ) ? 0.0 : ( (_x) - (double) ( (long) (_x) ) ) )
 
#define _eos(_s)   ( &(_s)[strlen( _s )] )
 
#define MIN(_x, _y)   ( ( (_x) < (_y) ) ? (_x) : (_y) )
 
#define MAX(_x, _y)   ( ( (_x) > (_y) ) ? (_x) : (_y) )
 
#define SWAP(_x, _y)   { temp = (_x); (_x) = (_y); (_y) = temp; }
 
#define SQR(_x)   ( (_x) * (_x) )
 
#define DP   (double *)
 
#define bcd_from_bin(_x)   ( ( ( (_x) / 10 ) << 4 ) | ( (_x) % 10 ) )
 
#define bin_from_bcd(_x)   ( ( ( (_x) >> 4 ) * 10 ) + ( (_x) & 0x0F ) )
 
#define _CSUM_DEFINED
 
#define _csum(_p)   checksum( (void _CSFAR *)(_p), sizeof( *(_p) ) )
 
#define _set_csum(_p)   (_p)->csum = _csum( (_p) )
 
#define _valid_csum(_p)   ( (_p)->csum == _csum( (_p) ) )
 
#define _inrange(_val, _min, _max)   ( ( (_val) >= (_min) ) && ( (_val) <= (_max) ) )
 
#define _mask(_n)   ( ( 1UL << (_n) ) - 1 )
 
#define _idx_bit(_i)   ( 1UL << (_i) )
 
#define _is_supported(_i, _msk)   ( ( (_msk) & _idx_bit( _i ) ) != 0 )
 
#define _sgn(_x)   ( ( ( _x ) < 0 ) ? -1 : 1 )
 
#define _m(_Y1, _X1, _Y2, _X2)   ( ( _Y2 -_Y1 ) / ( _X2 -_X1 ) )
 
#define _b(_Y1, _X1, _Y2, _X2)   ( ( ( _Y1 * _X2 ) - ( _Y2 * _X1 ) ) / ( _X2 -_X1 ) )
 
#define _strncpy_0(_dst, _src)
 
#define _memfill(_p, _v)   memset( _p, _v, sizeof( *(_p) ) )
 
#define _memclr(_p)   _memfill( _p, 0 )
 
#define _dos_idle()   geninterrupt( 0x28 )
 

Typedefs

typedef uint16_t CSUM
 

Functions

void spaces_to_zeros (char *s)
 Replace whitespace ' ' characters by 0 characters. More...
 
CSUM checksum (const void *vp, int n)
 Create a simple checksum. More...
 

Macro Definition Documentation

◆ _b

#define _b (   _Y1,
  _X1,
  _Y2,
  _X2 
)    ( ( ( _Y1 * _X2 ) - ( _Y2 * _X1 ) ) / ( _X2 -_X1 ) )

Definition at line 172 of file myutil.h.

◆ _CSFAR

#define _CSFAR

Definition at line 72 of file myutil.h.

◆ _csum

#define _csum (   _p)    checksum( (void _CSFAR *)(_p), sizeof( *(_p) ) )

Definition at line 142 of file myutil.h.

◆ _CSUM_DEFINED

#define _CSUM_DEFINED

Definition at line 137 of file myutil.h.

◆ _dos_idle

#define _dos_idle ( )    geninterrupt( 0x28 )

Definition at line 203 of file myutil.h.

◆ _eos

#define _eos (   _s)    ( &(_s)[strlen( _s )] )

Definition at line 98 of file myutil.h.

◆ _ext

#define _ext   extern

Definition at line 79 of file myutil.h.

◆ _frac

#define _frac (   _x)    ( ( (_x) == 0.0 ) ? 0.0 : ( (_x) - (double) ( (long) (_x) ) ) )

Definition at line 94 of file myutil.h.

◆ _idx_bit

#define _idx_bit (   _i)    ( 1UL << (_i) )

Definition at line 159 of file myutil.h.

Referenced by print_cfg_rx(), print_cfg_tx(), and set_new_tfom_flag().

◆ _inrange

#define _inrange (   _val,
  _min,
  _max 
)    ( ( (_val) >= (_min) ) && ( (_val) <= (_max) ) )

Definition at line 151 of file myutil.h.

Referenced by check_valid_port_info().

◆ _is_supported

#define _is_supported (   _i,
  _msk 
)    ( ( (_msk) & _idx_bit( _i ) ) != 0 )

◆ _m

#define _m (   _Y1,
  _X1,
  _Y2,
  _X2 
)    ( ( _Y2 -_Y1 ) / ( _X2 -_X1 ) )

Definition at line 171 of file myutil.h.

◆ _mask

#define _mask (   _n)    ( ( 1UL << (_n) ) - 1 )

Definition at line 155 of file myutil.h.

Referenced by check_valid_port_info().

◆ _memclr

#define _memclr (   _p)    _memfill( _p, 0 )

Definition at line 197 of file myutil.h.

◆ _memfill

#define _memfill (   _p,
  _v 
)    memset( _p, _v, sizeof( *(_p) ) )

Definition at line 194 of file myutil.h.

◆ _set_csum

#define _set_csum (   _p)    (_p)->csum = _csum( (_p) )

Definition at line 145 of file myutil.h.

◆ _sgn

#define _sgn (   _x)    ( ( ( _x ) < 0 ) ? -1 : 1 )

Definition at line 167 of file myutil.h.

◆ _strncpy_0

#define _strncpy_0 (   _dst,
  _src 
)
Value:
{ \
int n = sizeof( _dst ) - 1; \
\
strncpy( _dst, _src, n ); \
(_dst)[n] = 0; \
}

Definition at line 180 of file myutil.h.

◆ _valid_csum

#define _valid_csum (   _p)    ( (_p)->csum == _csum( (_p) ) )

Definition at line 148 of file myutil.h.

◆ bcd_from_bin

#define bcd_from_bin (   _x)    ( ( ( (_x) / 10 ) << 4 ) | ( (_x) % 10 ) )

Definition at line 113 of file myutil.h.

◆ bin_from_bcd

#define bin_from_bcd (   _x)    ( ( ( (_x) >> 4 ) * 10 ) + ( (_x) & 0x0F ) )

Definition at line 114 of file myutil.h.

◆ DP

#define DP   (double *)

Definition at line 111 of file myutil.h.

◆ MAX

#define MAX (   _x,
  _y 
)    ( ( (_x) > (_y) ) ? (_x) : (_y) )

Definition at line 105 of file myutil.h.

◆ MIN

#define MIN (   _x,
  _y 
)    ( ( (_x) < (_y) ) ? (_x) : (_y) )

Definition at line 101 of file myutil.h.

◆ SQR

#define SQR (   _x)    ( (_x) * (_x) )

Definition at line 109 of file myutil.h.

◆ SWAP

#define SWAP (   _x,
  _y 
)    { temp = (_x); (_x) = (_y); (_y) = temp; }

Definition at line 108 of file myutil.h.

Typedef Documentation

◆ CSUM

typedef uint16_t CSUM

Definition at line 136 of file myutil.h.

Function Documentation

◆ checksum()

CSUM checksum ( const void *  vp,
int  n 
)

Create a simple checksum.

Parameters
[in]vpPointer to a data block
[in]nSize of the datablock to calulate the checksum from.
Returns
The computed checksum.

◆ spaces_to_zeros()

void spaces_to_zeros ( char *  s)

Replace whitespace ' ' characters by 0 characters.

Parameters
[in,out]sThe string to be modified.