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

📄 function.h

📁 a/d公司8位微控制器aduc812(10路10位adc)应用笔记
💻 H
📖 第 1 页 / 共 2 页
字号:

//
// The Trigger State-Machine States
// --------------------------------
#define POWER_ON_INIT               0
#define QUIESCENT                   1
#define QUIESCENT_VALID_DATA_SEN       11 // sensor state
#define QUIESCENT_VALID_DATA_ACT       12 // actuator state
#define QUIESCENT_INVALID_DATA_ACT     13 // actuator state
#define QUIESCENT_CONVERT_SAMPLE       14 
#define TRIGGERED                   2
#define TRIG_ACQUIRE_SAMPLE            21 // sensor state
#define TRIG_DATA_TXFRD                22 // actuator state
#define ABORT_ACTION                3
#define ACK_TRIGGER                 4
#define REMOVE_ACK                  5
#define DATA_TRANSPORT              6

//
// Standard Status Register: Bit Positions
// ---------------------------------------
#define STD_OPEN                        0xF000
#define STD_RESERVED                    0x0E00
#define STD_OPERATIONAL                 0x0100
#define STD_NOT_IMPLEMENTED             0x00E0
#define STD_AUXILIARY_STATUS_AVAILABLE  0x0010
#define STD_INVALID_COMMAND             0x0008
#define STD_RESET_COMPLETE              0x0004
#define STD_TRIGGER_ACK                 0x0002
#define STD_SERVICE_REQUEST             0x0001
//
// channel_zero implements bits: 0,1,2,3,4,8
//
#define STD_CH_ZERO                     0x011F
#define STD_IMPLEMENTED                 0x011F
//
// all channels *except* channel_zero implement bits: 0,1,2,4,8
//
#define STD_CH_NONZERO                  0x0117

//
// Auxiliary Status Register: Bit Positions
// ----------------------------------------
#define AUX_OPEN                           0xFC00
#define AUX_RESERVED                       0x03E0
#define AUX_CHANNEL_OUT_OF_RANGE           0x0010
#define AUX_CHANNEL_CONSUMABLES_EXHAUSTED  0x0008
#define AUX_FAILED_SELF_TEST               0x0004
#define AUX_FAILED_CALIBRATION             0x0002
#define AUX_CHANNEL_BUSY                   0x0001
//
// channel_zero implements bits: 0,1,2,3,4
//
#define AUX_CH_ZERO                     0x001F
#define AUX_IMPLEMENTED                 0x001F
//
// all channels *except* channel_zero implement bits: 0,1,2,3,4
//
#define AUX_CH_NONZERO                  0x001F

//
// Boolean values used as flags within 'status' and 'interrupt' functions,
// as in 'standard' and 'auxiliary' status and interrupt-mask registers.
// 
#define STANDARD     1  
#define AUXILIARY    0


//
// Definitions for the 'Control Commands'
// --------------------------------------
#define CTRL_NOP        0
#define CTRL_RESET      1
#define CTRL_SELFTEST   2
#define CTRL_CALIBRATE  3
#define CTRL_ZERO       4


/**************************
   Function Addressing:
   --------------------

   The mapping of functional or channel addresses to physical addresses
   will be left up to the implementation of the STIM.

   A full address will be 2 bytes long, and consists of the Functional
   address and the Channel address (least significant byte).

   The Functional address is subordinate to the Channel address.

   Channel Address:
   Each transducer in a STIM must be assigned a channel number.
   A STIM may have up to 255 channels.

   The number of implemented channels can be determined from reading
   the Meta-TEDS.

   Every channel number between one and the highest implemented channel
   number must address an implemented channel.

   Channel address 0 has a special meaning and is called CHANNEL_ZERO.

   When CHANNEL_ZERO is used, the function refers to all channels 
   collectively.

   Functional Address:
   The msb of the functional address is used to specify direction of comms:
   i.e. read from (set) or write to (reset) the STIM.

   A function has a 'global' interpretation if CHANNEL_ZERO is addressed,
   and a 'channel-specific' interpretation for channels 1-255.
   
   There are 4 categories of functional addresses:
   - addresses whose functions are defined completely
   - addresses whose functions are only partly defined or not at all
   - addresses that are reserved for future versions
   - addresses that are open for industry use

   Functional addresses 32 thru' 127 (write) and 160 thru' 255 (read) deal with
   data-sheet type information: i.e. read-only and non-volatile.

   [ Data structures in these ranges will have 4-byte length fields at the 
   start and a 2-byte checksum at the end (specified in section 5 - TEDS) ]

   Functional addresses 32, 33 and 48-63 may be used by a STIM manufacturer to 
   create TEDS via the TII. The manufacturer must use some method to prevent
   unauthorised updating of these TEDS.

   General: (sec 4.8)
   The STIM will respond to any attempt to read or write to any unimplemented
   or reserved functional address by setting the STIM 'invalid command' bit
   in the standard status register (see 'status' section).

 *************************/
//
// Definitions for Function Addressing:
// ------------------------------------
// Functions: Which direction is the transport? Read or Write?
//           (NOTE: Function addresses are located in the MSB)
//
#define WRITE_FN    0x00    // write to the STIM
#define READ_FN     0x80    // read from the STIM

// 
// Functions: Operational Addresses (p.22 of IEEE 1451.2 standard)
//
#define TRANSDUCER_DATA             0x00  // Decimal: 0
#define CONTROL_COMMAND             0x01
#define STANDARD_STATUS             0x02
#define TRIGGERED_CHANNEL_ADDRESS   0x03
#define AUXILIARY_STATUS            0x04
#define STANDARD_INTERRUPT_MASK     0x05
#define AUXILIARY_INTERRUPT_MASK    0x06
#define STIM_VERSION                0x07  

//
// Functions: TEDS Addresses (p.22)
//
#define META_TEDS                   0x20  // Decimal: 32
#define META_ID_TEDS                0x21  // Decimal: 33
#define CHANNEL_TEDS                0x20  // Decimal: 32
#define CHANNEL_ID_TEDS             0x21  // Decimal: 33

// NOTE: The Meta-TEDS are addressed when the Channel Address is CHANNEL_ZERO.
//       The Channel-TEDS are addressed otherwise.

//
// Functions: Calibration TEDS Addresses (p.22)
//
#define CALIBRATION_TEDS            0x40  // Decimal: 64
#define CALIBRATION_ID_TEDS         0x41  // Decimal: 65

//
// Functions: General writable storage Addresses (p.22)
//
#define USERS_APP_SPECIFIC_TEDS     0x60  // Decimal: 96


//
// Define the register types for use within the 'status' functions.
// ---------------------------------------------------------------
//
typedef unsigned int STD_STATUS_REGISTER;
typedef unsigned int AUX_STATUS_REGISTER;
typedef unsigned int STATUS_REGISTER;

//
// Define the 'interrupt' mask-register types:
// ------------------------------------------
typedef unsigned int STD_INTERRUPT_MASK;
typedef unsigned int AUX_INTERRUPT_MASK;
typedef unsigned int INTERRUPT_MASK;


/************************
   Data Transport:
   --------------

   The data transport conveys addressing to the STIM and conveys data
   associated with the address between STIM and NCAP.

   Data transport involving multiple byte numeric representations will:
   - send the MSByte first
   - add padded 0s above the msb (for reps non-divisible by 8-bits)
   - add padded 0s below the lsb (for fracts non-divisible by 8-bits)

   The physical interface will transport each data byte in bit-serial form,
   msb first.

   Means will be provided for:
   - NCAP to indicate when data transport is active
   - NCAP to delimit data frames
   - STIM to acknowledge readiness for data transport

   The data transport function will be inactivated before a trigger is 
   asserted.
   A Data-transport frame begins with the NCAP sending an Address to the STIM.
   The address specifies the direction (r/w), channel and function involved.

   The lengths of the data structures to be transported can be determined by:
   1. Status, interrupt mask, control data and triggered channel address
      are specified in the standard.
   2. Transducer data lengths are specified in the Channel TEDS.
   3. All other structures are preceeded by a 4-byte integer 'length' value.
    _                                    _
   |    Defined Data Structure Lengths    |
   | Status:                    2 Bytes   |
   | Interrupt Mask:            2 Bytes   |
   | Control Data:              1 Byte    |
   | Triggered Channel Address: 1 Byte    |
    -                                    -

   All STIMs and NCAPs must support a common data rate: 6000 bps. (6.4)
   Data rates are controlled by the NCAP.
   Both the STIM and NCAP must provide a means of regulating the flow of data
   bytes within a frame (pacing).
   
   Writing data to a sensor, buffered sensor, data sequence sensor or buffered
   data sequence sensor will have no effect.
   Reading from one of the above without triggering will return the same 
   data as when last read.
   Reading from any sensor after an aborted trigger cycle may have 
   unpredictable results.
   Reading from an actuator returns the latest data written to it.

   The CHANNEL_ZERO functions 'write global transducer data' and 'read global
   transducer data' result in writing to or reading from the data structures
   of all implemented channels concatenated together, in order, beginning at 
   channel 1. (see section 4.5.4).

   The CHANNEL_ZERO status and control functions are not concatenated channel
   status and control commands. Instead global status and control functions
   are defined.

   Some data sheet information is writable and non-volatile (i.e. Calib TEDS,
   End Users' Application Specific TEDS).

   Data reads and writes are intended to access entire data structures:
   Partial reads of fn addresses 160-255 are allowed (and non-corruptive).
   Partial reads of fn addresses 128-159 are not allowed.
   Partial writes of any fn address is not allowed.

   Writing more bytes than are specified for the data structure accessed may
   leave data corrupted for the addressed channel, but not for any other 
   channel.

 ************************/

// 'Data Transport' Function Prototypes:
// ------------------------------------

boolean DAT_TransportActive(void);
U16C    DAT_CalcChecksum(unsigned char *pBuf);

boolean DAT_ReadMetaTEDS(void);
boolean DAT_ReadChannelTEDS(U8E ChanNum);
boolean DAT_ReadMetaIdTEDS(void);
boolean DAT_ReadChannelIdTEDS(U8E ChanNum);
boolean DAT_ReadCalibrationTEDS(void);
boolean DAT_ReadCalibrationIdTEDS(void);
boolean DAT_ReadEndUserAppTEDS(void);
boolean DAT_ReadXdcrData(unsigned char ucChNum);
boolean DAT_ReadStatus(U8E eReg, unsigned char ucChNum);
boolean DAT_ReadTrigChAddr(void);
boolean DAT_ReadIntMask(U8E eReg, unsigned char ucChNum);
boolean DAT_ReadSTIMVersion(void);

boolean DAT_WriteXdcrData(unsigned char ucChNum);
boolean DAT_WriteCtrlCmmd(unsigned char ucChNum);
boolean DAT_WriteTrigChAddr(void);
boolean DAT_WriteIntMask(U8E eMask, unsigned char ucChan);
boolean DAT_WriteCalibTEDS(void);
boolean DAT_WriteCalibIdTEDS(void);
boolean DAT_WriteEndUserAppTEDS(void);


/************************
   Triggering:
   ----------

   The triggering function provides a means for:
   - an NCAP to send to a STIM a command for an action to take place (the 
      trigger signal).
   - the STIM to signal the time when the action occurred (trigger acknowledge).

   Triggering can be applied to 
   - a single channel (selected by the 'triggered channel address').
   - all channels at once (global triggering).

   The general STIM states related to triggering are:
      - Power on Initialization
      - Quiescent
      - Abort Action
      - Acknowledge Trigger
      - Remove Acknowledge
      - Data Transport

   The Trigger Signal:
   - is driven by the NCAP
   - is a command to the STIM for an action to occur
   - is negated (by NCAP?) when data transport is active
   The Trigger Acknowledge Signal:
   - is driven by the STIM
   - marks the time an event occurs (channel triggering)
   - reference from which individual event times can be calculated (global)
   - confirms action(s) occurred

⌨️ 快捷键说明

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