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

📄 pulse_src.c

📁 TDK 6521 SOC 芯片 DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:
    #if EQUATION == _1ELEMENT_2WIRE 
    return ((i0sqsum > i1sqsum) 
            ? PulseSrcE (i0sqsum, w0sum) : PulseSrcE (i1sqsum, w1sum));
    #else
    return (
    PulseSrcE (i0sqsum, w0sum)
    #if PHASE_B_PRESENT
    + PulseSrcE (i1sqsum, w1sum)
    #endif
    #if PHASE_C_PRESENT
    + PulseSrcE (i2sqsum, w2sum)
    #endif
    );
    #endif
#else
    return (ZERO);
#endif
}

int32_t W0_Esrc (void)
{
#if EXPORT && WATT_ELEMENT
    return (PulseSrcE (i0sqsum, w0sum));
#else
    return (ZERO);
#endif
}

int32_t W1_Esrc (void)
{
#if EXPORT && WATT_ELEMENT && PHASE_B_PRESENT
    return (PulseSrcE (i1sqsum, w1sum));
#else
    return (ZERO);
#endif
}

int32_t W2_Esrc (void)
{
#if EXPORT && WATT_ELEMENT && PHASE_C_PRESENT
    return (PulseSrcE (i2sqsum, w2sum));
#else
    return (ZERO);
#endif
}

//---------------------------------------------------------------------------//
int32_t VARSum_Esrc(void)
{
#if EXPORT && VAR_SUMS
    #if EQUATION == _1ELEMENT_2WIRE 
    return ((i0sqsum > i1sqsum) 
            ? PulseSrcE (i0sqsum, var0sum) : PulseSrcE (i1sqsum, var1sum));
    #else
    return (
    PulseSrcE (i0sqsum, var0sum)
    #if PHASE_B_PRESENT
    + PulseSrcE (i1sqsum, var1sum)
    #endif
    #if PHASE_C_PRESENT
    + PulseSrcE (i2sqsum, var2sum) 
    #endif
    );
    #endif
#else
    return (ZERO);
#endif
}

int32_t VAR0_Esrc   (void)
{
#if EXPORT && VAR_ELEMENT
    return (PulseSrcE (i0sqsum, var0sum));
#else
    return (ZERO);
#endif
}

int32_t VAR1_Esrc   (void)
{
#if EXPORT && VAR_ELEMENT && PHASE_B_PRESENT
    return (PulseSrcE (i1sqsum, var1sum));
#else
    return (ZERO);
#endif
}

int32_t VAR2_Esrc   (void)
{
#if EXPORT && VAR_ELEMENT && PHASE_C_PRESENT
    return (PulseSrcE (i2sqsum, var2sum));
#else
    return (ZERO);
#endif
}

//---------------------------------------------------------------------------//
int32_t VASum_Esrc (void)
{
#if EXPORT && VA_SUMS
    #if EQUATION == _1ELEMENT_2WIRE 
    return ((i0sqsum > i1sqsum) 
            ? PulseSrcE (i0sqsum, va0sum) : PulseSrcE (i1sqsum, va1sum));
    #else
    return (
    PulseSrcE (i0sqsum, va0sum)
    #if PHASE_B_PRESENT
    + PulseSrcE (i1sqsum, va1sum)
    #endif
    #if PHASE_C_PRESENT
    + PulseSrcE (i2sqsum, va2sum)
    #endif
    );
    #endif
#else
    return (ZERO);
#endif
}

int32_t VA0_Esrc (void)
{
#if EXPORT && VA_ELEMENT
    return (PulseSrcE (i0sqsum, va0sum));
#else
    return (ZERO);
#endif
}

int32_t VA1_Esrc (void)
{
#if EXPORT && VA_ELEMENT && PHASE_B_PRESENT
    return (PulseSrcE (i1sqsum, va1sum));
#else
    return (ZERO);
#endif
}

int32_t VA2_Esrc (void)
{
#if EXPORT && VA_ELEMENT && PHASE_C_PRESENT
    return (PulseSrcE (i2sqsum, va2sum));
#else
    return (ZERO);
#endif
}

//===========================================================================//
int32_t Insq_src (void)
{
    #if (ISQ_SUMS) && ( \
        EQUATION == _2ELEMENT_4WIRE_DELTA \ 
     || EQUATION == _2ELEMENT_4WIRE_WYE \
     || EQUATION == _3ELEMENT_4WIRE_WYE \
     )
    return (insqsum);
    #elif EQUATION == _1ELEMENT_2WIRE 
    return ((i0sqsum > i1sqsum) ? i0sqsum : i1sqsum);
    #elif ISQ_SUMS
    return (i0sqsum
        #if PHASE_B_PRESENT
        + i1sqsum
        #endif
        );
    #else
    return (ZERO);
    #endif
}

int32_t I0sq_src (void)
{
#if ISQ_SUMS
    return (i0sqsum);
#else
    return (ZERO);
#endif
}

int32_t I1sq_src (void)
{
#if ISQ_SUMS && PHASE_B_PRESENT
    return (i1sqsum);
#else
    return (ZERO);
#endif
}

int32_t I2sq_src (void)
{
#if ISQ_SUMS && PHASE_C_PRESENT
    return (i2sqsum);
#else
    return (ZERO);
#endif
}

//---------------------------------------------------------------------------//
int32_t V0sq_src (void)
{
#if VSQ_SUMS
    return (v0sqsum);
#else
    return (ZERO);
#endif
}

int32_t V1sq_src (void)
{
#if (VSQ_SUMS) &&                                                          \
    (EQUATION == _2ELEMENT_3WIRE_DELTA ||                                     \
    EQUATION == _2ELEMENT_4WIRE_WYE   || EQUATION == _3ELEMENT_4WIRE_WYE)
    return (v1sqsum);
#else
    return (ZERO);
#endif
}

int32_t V2sq_src (void)
{
#if (VSQ_SUMS) &&                                                           \
    (EQUATION == _2ELEMENT_4WIRE_DELTA || EQUATION == _3ELEMENT_4WIRE_WYE)
    return (v2sqsum);
#else
    return (ZERO);
#endif
}

#if EXPORT
#pragma save
#pragma NOAREGS
int32_t PulseSrcE (int32i_t isqsum, int32_t sum) small reentrant
{
    if (sum < ZERO)
        return (PulseSrcG (isqsum, sum));
    else
        return (ZERO);
}
#pragma restore
#endif

#if IMPORT
#pragma save
#pragma NOAREGS
int32_t PulseSrcI (int32i_t isqsum, int32_t sum) small reentrant
{
    if (sum > ZERO)
        return (PulseSrcG (isqsum, sum));
    else
        return (ZERO);
}
#pragma restore
#endif

#pragma save
#pragma NOAREGS
int32_t PulseSrcG (int32i_t isqsum, int32_t sum) small reentrant
{
#if ABS_VALUE
    if (ZERO != isqsum)
        return (labsx(sum));
    else
        return (ZERO);
#else
    // NET_METER, any others
    if (ZERO != isqsum)
        return (sum);
    else
        return (ZERO);
#endif
}
#pragma restore

/***************************************************************************
 * History:
 * $Log: pulse_src.c,v $
 * Revision 1.27  2006/09/09 01:14:44  gmikef
 * *** empty log message ***
 *
 * Revision 1.26  2006/09/06 21:40:55  tvander
 * Made the reentrant routines use no absolute registers.
 *
 * Revision 1.25  2006/09/06 02:26:29  tvander
 * Fixed "recursion error" in linker.
 *
 * Revision 1.24  2006/08/30 02:09:47  gmikef
 * *** empty log message ***
 *
 * Revision 1.23  2006/08/19 01:37:21  tvander
 * Fixed equation 1's pulse outputs.
 *
 * Revision 1.22  2006/06/06 05:15:20  tvander
 * clean build
 *
 * Revision 1.21  2006/05/25 03:31:45  tvander
 * Renamed variables so nonvolatile variables can be switched to other definitions
 * of watt-hours (e.g. from absolute value to volt-amps or imports)
 * (meter.c, meter.h, pulse_src.c)
 * FIxed power factors so they zero correctly.
 * Fixed RMS to work with different accumulation interval.
 *
 * Revision 1.20  2006/05/18 23:18:53  tvander
 * 16K and 32K
 * First cut at new requirements.
 * 32K 6521 is grossly tested.
 * All others have a clean compile with C51 8.02
 *
 * Revision 1.19  2006/04/12 00:27:49  tvander
 * Debugged compilation with equations 3 and 4, on 6513
 *
 * Revision 1.18  2006/03/08 00:08:03  tvander
 * Multiplexed interrupts are in io65xx.c
 * Added stubbed interrupt to io65xx.c
 * Clean build
 *
 * Revision 1.17  2006/03/06 03:40:43  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.16  2006/02/08 22:39:56  gmikef
 * *** empty log message ***
 *
 * Revision 1.15  2006/02/08 03:43:27  tvander
 * Made "import" the default power measurement mode, rather than net-metering
 *
 * Revision 1.13  2005/10/15 02:19:24  tvander
 * Improved compilation flags so imports and exports are not required.
 *
 * Revision 1.12  2005/10/08 04:41:26  tvander
 * Fixed priority inversion.
 * Rewrote watchdog to work in brownout, but of course it doesn't work.
 * Watchdog can now be defeated by clearing watchdog option to 0.
 * Reorganized watt hour modules (at last!).
 * Disabled reading of STATUS in 6521_cli because the CE's status is always SAG.
 * Tested with 6521_CLI; measurements seem to work.
 * Fixed other builds.
 *
 * Revision 1.11  2005/09/22 23:45:20  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.10  2005/09/11 00:34:05  tvander
 * Clean compiles
 *
 * Revision 1.9  2005/08/30 18:20:04  gmikef
 * *** empty log message ***
 *
 * Revision 1.8  2005/07/19 22:31:19  tvander
 * Creep condition was reading only i0sqsum for many watt hour pulse sources.
 *
 * Revision 1.7  2005/07/14 20:15:53  tvander
 * ce code concentrated in ce.c
 * ce interface concentrated in ce652x.c, .h
 * Fixed 0-length read or write using flag protocol.
 * display.c is out of the build
 * kwh_initialize now reads the LRC.
 *
 * Revision 1.6  2005/06/17 22:54:45  tvander
 * Separated imports and exports.
 * Some imports and exports were not being updated.
 *
 * Revision 1.5  2005/06/03 00:33:34  tvander
 * Added imports to 6511.
 * Added register definition spreadsheet to .doc
 *
 * Revision 1.4  2005/05/13 00:34:45  tvander
 * 6511/32k works
 * Integrated and debugged self-calibration.
 * The build has one unused segment, and no other errors or warnings.
 * default LCD and pulse displays appear OK.
 * EEPROM, software timers and hardware timers are all integrated.
 *
 * Revision 1.3  2005/04/30 02:15:12  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/04/27 21:38:10  gmikef
 * *** empty log message ***
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/
#endif /* pulse_src.c */

⌨️ 快捷键说明

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