📄 emeter-structs.h
字号:
failure has been detected. This function does not return until power has been restored. The
machine sits in LPM3 within the function, waiting for actions within an interrupt routine to wake
it up.
\brief Switch the meter to minimum power operation (usual on supply failure). */
extern void switch_to_powerfail_mode(void);
/*! \brief Display a meter startup message on the LCD. */
extern void display_startup_message(void);
/*! \brief Display a power fail message on the LCD. */
extern void display_power_fail_message(void);
/*! \brief Display a mesage indicating the power supply had reached the low tide mark. */
extern void display_power_4v2_message(void);
/*! \brief Display a mesage indicating the power supply had reached the high tide mark. */
extern void display_power_normal_message(void);
/*! \brief Display a status mesage, showing the current progress of the calibration process. */
extern int display_calibration_status(void);
#if SELF_TEST_SUPPORT
/*! \brief Record a self-detected unrecoverable error in the meter. */
extern int record_meter_failure(int type);
/*! \brief Record a self-detected recoverable error in the meter. */
extern int record_meter_warning(int type);
#endif
#if !defined(SINGLE_PHASE)
/*! This functions calculates the frequency of the power for a single phase, from the information
in the specified phase and phase_nv structures.
\brief Calculate the mains frequency for a single phase.
\param phase
\param phase_nv
\return The frequency in 1/100Hz increments. */
extern int16_t frequency(struct phase_parms_s *phase);
/*! This functions calculates the RMS voltage for a single phase, from the information in the
specified phase and phase_nv structures.
\brief Calculate the RMS voltage of a single phase.
\param phase
\param phase_nv
\return The RMS voltage in 10mV increments. */
extern int32_t voltage(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv);
/*! This functions calculates the RMS current for a single phase, from the information in the
specified phase and phase_nv structures.
\brief Calculate the RMS current flowing in a single phase.
\param phase
\param phase_nv
\return The RMS current in 1mA increments. */
extern int32_t current(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv, int ph);
/*! This functions calculates the power factor of a single phase, from the information in the
specified phase and phase_nv structures.
\brief Calculate the power factor of a single phase.
\param phase
\param phase_nv
\return The power factor, as Q1.15 fraction. */
extern int16_t power_factor(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv);
/*! This functions calculates the power for a single phase, from the information in the
specified phase and phase_nv structures.
\brief Calculate the active power for a single phase.
\param phase
\param phase_nv
\return The active power in 10mW increments. */
extern int32_t power(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv);
/*! This functions calculates the reactive power for a single phase, from the information in the
specified phase and phase_nv structures.
\brief Calculate the reactive power for a single phase.
\param phase
\param phase_nv
\return The reactive power in 10mW increments. */
extern int32_t reactive_power(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv);
/*! This function calculates the VA power (i.e. the simple product of RMS voltage and RMS current) for a
single phase, from the information in the specified phase and phase_nv structures.
\brief Calculate the VA power for a single phase.
\param phase
\param phase_nv
\return The VA power in 10mW increments. */
extern int32_t VA_power(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv);
#else
/*! This functions calculates the frequency of the power, from the information in the phase
and phase_nv structures.
\brief Calculate the mains frequency.
\return The frequency in 1/100Hz increments. */
extern int16_t frequency(void);
/*! \brief Calculate the RMS voltage of the specified phase, based on the information within that
phase structure.
\brief Calculate the phase RMS voltage.
\return The RMS voltage in 10mV increments. */
extern int32_t voltage(void);
/*! \brief Calculate the RMS current flowing in the specified phase, based on the information within that
phase structure.
\brief Calculate the phase RMS current.
\return The RMS current in 1mA increments. */
extern int32_t current(void);
/*! \brief Calculate the power factor in the specified phase, based on the information within that
phase structure.
\brief Calculate the power factor of a phase.
\return The power factor, as Q1.15 fraction. */
extern int16_t power_factor(void);
/*! \brief Calculate the active power in the specified phase, based on the information within that
phase structure.
\brief Calculate the active power.
\return The active power in 10mW increments. */
extern int32_t power(void);
/*! \brief Calculate the reactive power in the specified phase, based on the information within that
phase structure.
\brief Calculate the phase reactive power.
\return The reactive power in 10mW increments. */
extern int32_t reactive_power(void);
/*! This function calculates the VA power (i.e. the simple product of RMS voltage and RMS current),
from the information in the phase and phase_nv structures.
\brief Calculate the VA power.
\return The VA power in 10mW increments. */
extern int32_t VA_power(void);
#endif
#if defined(PER_SECOND_ACTIVITY_SUPPORT)
extern void per_second_activity(void);
#endif
#if defined(PER_MINUTE_ACTIVITY_SUPPORT)
extern void per_minute_activity(void);
#endif
#if defined(PER_HOUR_ACTIVITY_SUPPORT)
extern void per_hour_activity(void);
#endif
#if defined(PER_DAY_ACTIVITY_SUPPORT)
extern void per_day_activity(void);
#endif
#if defined(PER_MONTH_ACTIVITY_SUPPORT)
extern void per_month_activity(void);
#endif
#if defined(PER_YEAR_ACTIVITY_SUPPORT)
extern void per_year_activity(void);
#endif
#if defined(CUSTOM_LCD_SUPPORT)
extern void update_custom_display(void);
#endif
#if defined(CUSTOM_KEYPAD_SUPPORT)
extern void custom_keypad_handler(void);
#endif
#if defined(CUSTOM_MAINLOOP_SUPPORT)
extern void custom_mainloop_handler(void);
#endif
#if defined(BASIC_KEYPAD_SUPPORT)
extern void keypad_handler(void);
#endif
/* Definitions for custom feature handling, which should only be used if the relevant
feature is enabled. */
#if !defined(custom_rtc)
extern void custom_rtc(void);
#endif
#if !defined(custom_rtc_set)
extern void custom_rtc_set(uint8_t *buf);
#endif
#if !defined(custom_rtc_retrieve)
extern void custom_rtc_retrieve(uint8_t *buf);
#endif
#if !defined(custom_adc_interrupt)
extern custom_adc_interrupt(void);
#endif
#if !defined(custom_energy_pulse_start)
extern void custom_energy_pulse_start(void);
#endif
#if !defined(custom_energy_pulse_end)
extern void custom_energy_pulse_end(void);
#endif
#if defined(CUSTOM_KEYPAD_SUPPORT) && !defined(custom_keypad_handler)
extern void custom_keypad_handler(void);
#endif
#if !defined(custom_mainloop_handler)
extern void custom_mainloop_handler(void);
#endif
#if !defined(custom_2second_handler)
extern void custom_2second_handler(void);
#endif
#if !defined(custom_initialisation)
extern void custom_initialisation(void);
#endif
#if defined(CUSTOM_SERIAL_MESSAGE_SUPPORT) && !defined(custom_serial_message_handler)
extern void custom_serial_message_handler(void);
#endif
#if !defined(custom_power_fail_handler)
extern void custom_power_fail_handler(void);
#endif
#if !defined(custom_power_restore_handler)
extern void custom_power_restore_handler(void);
#endif
#if defined(CUSTOM_LCD_SUPPORT) && !defined(custom_lcd_wakeup_handler)
extern void custom_lcd_wakeup_handler(void);
#endif
#if EXTERNAL_EEPROM_SUPPORT
extern void log_energy_to_external_eeprom(void);
extern void external_eeprom_init(void);
#endif
#if MULTI_RATE_SUPPORT
/*! The current daily tariff schedule number */
extern uint8_t current_tariff;
/*! ??? */
extern uint8_t tariff_flags;
#define TARIFF_NEW_MINUTE 0x01
#define TARIFF_NEW_DAY 0x02
/*! Initialise multi-tariff operation */
void tariff_initialise(void);
/*! Perform the regular multi-tariff management operations, such as time-slot checking,
and day checking. */
void tariff_management(void);
void multirate_energy_pulse(void);
int multirate_put(uint8_t *msg);
int multirate_get(uint8_t *msg, uint8_t *txmsg);
int multirate_clear_usage(uint8_t *msg);
int multirate_get_usage(uint8_t *msg, uint8_t *txmsg);
void multirate_align_with_rtc(void);
#endif
#if defined(__MSP430__) && (defined(IEC1107_SUPPORT) || defined(SERIAL_CALIBRATION_SUPPORT))
extern uint8_t char_timeout_1107;
#endif
#if IO_EXPANDER_SUPPORT
/* what == -1 to clear bits
what == 0 to set the whole word
what == +1 to set bits
which == the bit pattern to change */
void set_io_expander(int what, int which);
#endif
#if defined(__MSP430__) && defined(USE_WATCHDOG)
#define kick_watchdog() WDTCTL = WDT_ARST_1000;
#else
#define kick_watchdog() /**/
#endif
#if defined(__MSP430__)
#define inhibit_rtc_updates() (IE2 &= ~BTIE)
#else
#define inhibit_rtc_updates() /**/
#endif
#if defined(__MSP430__)
#define enable_rtc_updates() (IE2 |= BTIE)
#else
#define enable_rtc_updates() /**/
#endif
#endif
/* Do some configuration consistency checking */
#if defined(PWM_DITHERING_SUPPORT)
#if !defined(__MSP430_HAS_TB7__)
#error PWM dithering requires a Timer B module
#endif
#if !defined(__MSP430_HAS_ADC10__) && !defined(__MSP430_HAS_ADC12__)
#error PWM dithering requires an ADC10 or ADC12 module
#endif
#endif
#if defined(POWER_DOWN_SUPPORT) || defined(POWER_UP_BY_SUPPLY_SENSING)
#if !defined(__MSP430_HAS_COMPA__)
#error Power up/down sensing requires a comparator A module
#endif
#endif
#if defined(VA_POWER_SUPPORT)
#if !defined(IRMS_SUPPORT) || !defined(VRMS_SUPPORT)
#error VA power support requires RMS voltage and current support
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -