📄 emeter-toolkit.h
字号:
//--------------------------------------------------------------------------
//
// Software for MSP430 based e-meters.
//
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//
// File: emeter-toolkit.h
//
// Steve Underwood <steve-underwood@ti.com>
// Texas Instruments Hong Kong Ltd.
//
// Date Comments
// =====================
// 2002-09-16 Initial version
//
//--------------------------------------------------------------------------
#if !defined(_emeter_toolkit_h_)
#define _emeter_toolkit_h_
#include <stdint.h>
#include "device.h"
#include "comms_uart.h"
//#include "parameter.h"
extern const char banner[];
extern const unsigned int sbanner;
extern const char TempBanner[];
/*
#if defined(__MSP430__)
#if defined(__MSP430_435__) || defined(__MSP430_447__) || defined(__MSP430_448__) || defined(__MSP430_449__)
#define SUPPORT_INTERNAL_LCD 1
#define SUPPORT_LCD_MODULE 0
#else
#define SUPPORT_INTERNAL_LCD 0
#define SUPPORT_LCD_MODULE 1
#endif
#else
#define SUPPORT_INTERNAL_LCD 0
#define SUPPORT_LCD_MODULE 0
#endif
*/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#define BUTTON_PERSISTENCE_CHECK 60
#define DEBOUNCE_JUST_RELEASED 0
#define DEBOUNCE_JUST_HIT 1
#define DEBOUNCE_RELEASED 2
#define DEBOUNCE_HIT 3
typedef struct rtc_s
{
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t sumcheck;
} rtc_t;
/* Return values for bump_rtc. These indicate the most significant element
of the rtc which was changed. The rtc is not updated if it's sumcheck is
incorrect, so nothing is updated for an inconsistent rtc setting. */
#define RTC_INCONSISTENT 0
#define RTC_CHANGED_SECOND 1
#define RTC_CHANGED_MINUTE 2
#define RTC_CHANGED_HOUR 3
#define RTC_CHANGED_DAY 4
#define RTC_CHANGED_MONTH 5
#define RTC_CHANGED_YEAR 6
//extern int16_t Q1_15_mul(int16_t operand1, int16_t operand2);
//extern int16_t Q1_15_mulr(int16_t operand1, int16_t operand2);
//extern int16_t Q1_15_mulq(int16_t operand1, int16_t operand2);
//extern void tpd_gen(void);
//extern int32_t imul16(int16_t operand1, int16_t operand2);
//extern int32_t isqrt32(int32_t x);
//#if defined(__GNUC__)
//extern int64_t isqrt64(int64_t x);
//#endif
//extern int16_t isqrt32i(int32_t x);
//extern int16_t dc_filter(int32_t *p, int16_t x);
extern void bin2bcd16(uint8_t bcd[3], uint16_t bin);
extern void bin2bcd32(uint8_t bcd[5], uint32_t bin);
//extern const uint8_t lcd_digit_table[16];
//extern void LCDinit(void);
//extern void LCDsleep(void);
//extern void LCDawaken(void);
//extern void LCDchars(const uint8_t *s, int pos, int len);
//extern void LCDchar(uint8_t ch, int pos);
//extern void LCDmodify_char(uint8_t ch, int pos, int on);
extern void LCDdec16(int16_t value, int pos, int digits, int after);
extern void LCDdec32(int32_t value, int pos, int digits, int after);
extern void LCDdecu16(uint16_t value, int pos, int digits, int after);
extern void LCDdecu32(uint32_t value, int pos, int digits, int after);
extern void LCDtext(unsigned char text[], int pos, int digits);
//extern int debounce(uint8_t *deb, uint8_t state);
//extern int16_t calc_phase_shift(int32_t undelayed, int32_t delayed);
//extern int16_t calc_power_factor(int32_t undelayed, int32_t delayed);
//extern int16_t rand16(void);
//extern int16_t dds(int *phase_acc, int phase_rate);
//extern int16_t dds_offset(int phase_acc, int phase_offset);
//extern const int cos_table[];
//extern int bump_rtc(void);
//extern void set_rtc_sumcheck(void);
//extern int check_rtc_sumcheck(void);
extern int weekday(void);
//extern rtc_t rtc;
extern void flash_write_int8(int8_t *ptr, int8_t value);
extern void flash_write_int16( int16_t *ptr, int16_t value);
extern void flash_write_int32( int32_t *ptr, int32_t value);
extern void flash_memcpy( char *ptr, char *from, int len);
extern void flash_clr( int *ptr);
extern void flash_secure(void);
extern void flash_replace16(int16_t *ptr, int16_t word);
extern void flash_replace32(int32_t *ptr, int32_t word);
extern void host_hex16(uint16_t value);
extern void host_hex32(uint32_t value);
extern void host_dec16(int16_t value);
extern void host_dec32(int32_t value);
extern void host_decu16(uint16_t value);
extern void host_decu32(uint32_t value);
//extern int hex2ASCII(int hex);
#define hex2ASCII(hex) Hex2ASCII(hex)
//extern void host_char(char ch);
#define host_char(ch) SendChar(ch)
//extern void host_str(const char *s);
#define host_str(ps) SendString(ps)
//extern int iicEEPROM_read(uint16_t addr, void *dat, int len);
//extern int iicEEPROM_write(uint16_t addr, void *dat, int len);
/* AQ430 and IAR cannot handle int64_t data type. GNU can, but it
wastes some memory when we are accumulating things only a little
longer than 32 bits. Use some simple functions to achieve some
basic handling of a 48 bit int data type. This is stored as a
3 element int16_t array. */
/* If an accumulated value in one of our 48 bit ints is composed of
many 32 bit values, then dividing by the number of values returns
us to a 32 bit value. 48/16 => 32 division is, therefore, ideal for
scalar dot product handling. */
int32_t div48(register int16_t x[3], register int16_t y);
/* Multiply an int32_t by an int16_t, and return the top 32 bits of the
48 bit result. */
//int32_t mul48(int32_t x, int16_t y);
//void shift48(register int16_t x[3], register int how_far);
//void accum48(register int16_t x[3], register int32_t y);
/*
#if !defined(__MSP430__)
// When int64_t is available, this can be a useful thing to have.
static __inline__ int64_t int48_to_64(register int16_t x[3])
{
int64_t y;
y = x[2];
y <<= 16;
y |= (uint16_t) x[1];
y <<= 16;
y |= (uint16_t) x[0];
return y;
}
#endif
static __inline__ void transfer48(register int16_t y[3], register int16_t x[3])
{
y[2] = x[2];
y[1] = x[1];
y[0] = x[0];
x[0] =
x[1] =
x[2] = 0;
}
static __inline__ void assign48(register int16_t y[3], register int16_t x[3])
{
y[2] = x[2];
y[1] = x[1];
y[0] = x[0];
}
static void __inline__ restart_watchdog(void)
{
#if defined(__MSP430__)
WDTCTL = (WDTCTL & 0xFF) | WDTPW | WDTCNTCL;
#endif
}
*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -