solver_zc.h 2.62 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
/* Copyright 2002-2006 The MathWorks, Inc. */
/**
 *
 * Types and define related to zero crossing signals and events
 *
 * $Revision: 1.1.6.1 $
 */

#ifndef _solver_zc_hpp_
#define _solver_zc_hpp_

/* slZcSignalType ==============================================================
 *
 */
typedef enum {

    SL_ZCS_TYPE_CONT   = 0,
    SL_ZCS_TYPE_DISC   = 1,
    SL_ZCS_TYPE_HYBRID = 2

} slZcSignalType;


/* slZcEventType ===============================================================
 *
 *  zcEvents are bit packed as follows:
 *
 *   .-----.-----.-----.-----.-----.-----.-----.-----.
 *   |     |     | z2n | p2z | p2n | z2p | n2z | n2p |
 *   '-----'-----'-----'-----'-----'-----'-----'-----'
 *               |<----------- eventTypes ---------->|
 *            
 */
typedef uint8_T slZcEventType;
#define SL_ZCS_EVENT_NUL  0x00
#define SL_ZCS_EVENT_N2P  0x01
#define SL_ZCS_EVENT_N2Z  0x02
#define SL_ZCS_EVENT_Z2P  0x04
#define SL_ZCS_EVENT_P2N  0x08
#define SL_ZCS_EVENT_P2Z  0x10
#define SL_ZCS_EVENT_Z2N  0x20

#define SL_ZCS_EVENT_ALL_UP  ( SL_ZCS_EVENT_N2P | \
                               SL_ZCS_EVENT_N2Z | \
                               SL_ZCS_EVENT_Z2P )

#define SL_ZCS_EVENT_ALL_DN  ( SL_ZCS_EVENT_P2N | \
                               SL_ZCS_EVENT_P2Z | \
                               SL_ZCS_EVENT_Z2N )

#define SL_ZCS_EVENT_ALL     ( SL_ZCS_EVENT_ALL_UP | SL_ZCS_EVENT_ALL_DN )


/* slZcSignalAttribType ========================================================
 *
 *  ZcSignal attributes are bit packed as follows:
 *
 *   .-----.-----.-----.-----.-----.-----.-----.-----.
 *   |     |     | z2n | p2z | p2n | z2p | n2z | n2p |
 *   '-----'-----'-----'-----'-----'-----'-----'-----'
 *      ^     ^  |<---- which events to look for --->|
 *      |     |
 *      |     `--- isDiscrete 
 *      |
 *      `--------- needsEventNotification
 */
typedef uint8_T slZcSignalAttribType;

#define slZcSignalGetEventDirections(a) \
        ((a) & 0x3F)

#define slZcSignalSetEventDirections(a, d) \
        a = ((a & 0xC0) | d)

#define slZcSignalGetIsDiscrete(a) \
        (((a) & 0x40) != 0x00)

#define slZcSignalSetIsDiscrete(a, v) \
        a = (v) ? (a | 0x40) : (a & 0xBF)

#define slZcSignalGetNeedsEventNotification(a) \
        (((a) & 0x80) != 0x00)

#define slZcSignalSetNeedsEventNotification(a, v) \
        a = (v) ? (a | 0x80) : (a & 0x7F)


/* slZcSignalSignType ==========================================================
 *
 */
typedef uint8_T slZcSignalSignType;
#define SL_ZCS_SIGN_ZERO      0x00
#define SL_ZCS_SIGN_POS       0x01
#define SL_ZCS_SIGN_NEG       0x02
#define SL_ZCS_SIGN_UNKNOWN   0x03

#endif /* _solver_zc_hpp_ */

/* eof */