⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dac.h

📁 * DEFINITION * This is the header file for a library module used to calculate the median * of a
💻 H
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *  Copyright (c) 2007 by Qu chun lei watt@vip.163.com
 *
 *  Filename:  Dac.h
 *  Module:    0101C
 *  Language:  ANSI C
 *  $Revision: 25 $
 *
 *  DEFINITION
 *  Standard definitions for all modules.  Includes type aliases.
 *
 *  CONSTRAINTS
 *  Depends on the existance of LIMITS.H, a standard file always included with
 *     ANSI C compilers
 *
 *  Type BOOLEAN should be used only for variables that store "trueness".
 *  Storage for enumerated data items that happen to have two possible values
 *  should be defined as UINT8 rather than BOOLEAN.
 *
 *  BOOLEAN variables and the constants TRUE and FALSE defined in this module
 *  must be used carefully.  ANSI C interprets any non-zero value as true, so
 *  code should not assume that two "true" values must be equal to each other
 *  unless they are both results of logical expressions.  For example:
 *
 *    Ok:  if(flag)                       Bad:  if(flag == TRUE)
 *    Ok:  if(!flag)                      Bad:  if(flag != TRUE)
 *    Ok:  if(flag == FALSE)              Bad:  if(flag1 == flag2)
 *    Ok:  if(flag != FALSE)              Bad:  if(flag1 != flag2)
 *    Ok:  if(!flag1 == !flag2)           Bad:  if(flag == (count > MAX))
 *    Ok:  if(!flag1 != !flag2)
 *    Ok:  if(!flag != (count > MAX))     The above give unexpected results if
 *    Ok:  if(flag1 && flag2)             a flag holds a value greater than 1.
 *
 *  Binary conversion macros allow constants to be written in this format:
 *
 *    Binary8(00101101)                   Equivalent to 0x2D or 45
 *    Binary16(01001111, 10001000)        Equivalent to 0x4F88 or 20360
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef DAC_H
#define DAC_H

#include <limits.h>

/*-------------*
 |  Constants
 *-------------*/

#define FALSE  0              /* Refer to usage notes in the title block */
#define TRUE   1

#define OFF    0
#define ON     1

#ifndef NULL
#define NULL   ((void *)0)
#endif

/*----------------------------*
 |  Binary conversion macros
 *----------------------------*/

#define Bin1(lsb)                      ((lsb & 0x00000001)? 0x0001 : 0)
#define Bin2(lsb)          Bin1(lsb) | ((lsb & 0x00000010)? 0x0002 : 0)
#define Bin3(lsb)          Bin2(lsb) | ((lsb & 0x00000100)? 0x0004 : 0)
#define Bin4(lsb)          Bin3(lsb) | ((lsb & 0x00001000)? 0x0008 : 0)
#define Bin5(lsb)          Bin4(lsb) | ((lsb & 0x00010000)? 0x0010 : 0)
#define Bin6(lsb)          Bin5(lsb) | ((lsb & 0x00100000)? 0x0020 : 0)
#define Bin7(lsb)          Bin6(lsb) | ((lsb & 0x01000000)? 0x0040 : 0)
#define Bin8(lsb)          Bin7(lsb) | ((lsb & 0x10000000)? 0x0080 : 0)
#define Bin9(msb, lsb)     Bin8(lsb) | ((msb & 0x00000001)? 0x0100 : 0)
#define Bin10(msb, lsb)    Bin9(msb,  lsb) | ((msb & 0x00000010)? 0x0200 : 0)
#define Bin11(msb, lsb)    Bin10(msb, lsb) | ((msb & 0x00000100)? 0x0400 : 0)
#define Bin12(msb, lsb)    Bin11(msb, lsb) | ((msb & 0x00001000)? 0x0800 : 0)
#define Bin13(msb, lsb)    Bin12(msb, lsb) | ((msb & 0x00010000)? 0x1000 : 0)
#define Bin14(msb, lsb)    Bin13(msb, lsb) | ((msb & 0x00100000)? 0x2000 : 0)
#define Bin15(msb, lsb)    Bin14(msb, lsb) | ((msb & 0x01000000)? 0x4000 : 0)
#define Bin16(msb, lsb)    Bin15(msb, lsb) | ((msb & 0x10000000)? 0x8000 : 0)

#define Binary8(lsb)          (Bin8(0x##lsb))
#define Binary16(msb, lsb)    (Bin16(0x##msb, 0x##lsb))

/*---------*
 |  Types
 *---------*/

#define INT8      signed char
#define UINT8     unsigned char

#if INT_MAX == 2147483647
#define INT16     signed short
#define UINT16    unsigned short
#define INT32     signed int
#define UINT32    unsigned int
#else
#define INT16     signed int
#define INT32     signed long int
#define UINT16    unsigned int
#define UINT32    unsigned long int
#endif

#define BOOLEAN   unsigned char

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -