📄 cmd_misc.c
字号:
c = get_num();
if ( cli_result == OK_ID )
{
rx.len = min (BUFFER_SIZE, c);
rx.status = memcpy_xpr (rx.buffer, rx.addr, rx.len);
while (_PENDING == *rx.status)
main_background ();
if (_OK == *rx.status)
{
start_tx_rslt ("Read from EEPROM at addr:");
send_long_hex (rx.addr);
for (c = 0; c < rx.len; c++)
{
if ((c & 0x0f) == 0)
send_crlf ();
send_hex (*rx.buffer++);
send_char (' ');
}
}
else
{
start_tx_rslt ("Could not read from EEPROM at addr:");
send_long_hex (rx.addr);
}
}
}
else
start_tx_rslt ("EEPROM interface not active");
send_crlf ();
break;
case 'S':
pBuffer = Buffer;
while (!done (&c) && (BUFFER_SIZE > (pBuffer - Buffer)))
*pBuffer++ = c;
break;
case 'T':
if (active)
{
tx.buffer = Buffer;
tx.addr = get_long ();
if ( cli_result == OK_ID )
{
tx.len = pBuffer - Buffer;
tx.status = memcpy_prx (tx.addr, tx.buffer, tx.len);
while (_PENDING == *tx.status)
main_background ();
if (_OK == *tx.status)
{
start_tx_rslt ("Written to EEPROM at addr:");
send_long_hex (tx.addr);
send_char (' ');
for (c = 0; c < tx.len; c++)
{
send_hex (*tx.buffer++);
send_char (' ');
}
}
else
{
start_tx_rslt ("Could not write to EEPROM at addr:");
send_long_hex (tx.addr);
}
}
}
else
start_tx_rslt ("EEPROM interface not active");
send_crlf ();
break;
case 'W':
pBuffer = Buffer;
do
*pBuffer++ = get_num ();
while ('.' == get_char_d (&c)
&& ((pBuffer - Buffer) < BUFFER_SIZE));
cli_index = c; // Unget character.
break;
default:
break;
}
}
}
}
#endif
#if ERROR_RECORDING
void send_er (uint8_t ier)
{
send_hex (ier);
send_char (':');
start_tx_rslt(" errno:");
send_byte (Aer[ier].errno);
start_tx_rslt(" cnt:");
send_byte (Aer[ier].cnt);
start_tx_rslt(" mon:");
send_byte (Aer[ier].month);
start_tx_rslt(" day:");
send_byte (Aer[ier].date);
start_tx_rslt(" hr:");
send_byte (Aer[ier].hour);
send_crlf();
}
void cmd_err_record (void)
{
uint8_t data c;
while (!done (&c))
{
switch (toupper (c))
{
case 'C': // clear
Error_Clear();
break;
default:
case 'D': // display
for (c = 0; c < cer; ++c)
send_er (c);
break;
case 'S': // set
Status |= 1L << (get_num ());
Error_Record();
break;
}
}
}
#endif
#if ENHANCED_TRIM
void cmd_trim (void)
{
send_byte (Read_Trim (get_num ()));
send_crlf ();
}
#endif
void cmd_power_save (void)
{
EA = 0; // disable interrupts
CE0 &= ~CE_EN; // disable the compute engine
#if TRACE10
CE0 &= ~TMUX; // put ground out the test mux (no switching = less power)
#else
TMUX = _DGND;
#endif
CE0 = (CE0 & ~CHOP_EN) | 0x10; // chop enable is unchanging
#if TRACE10
// slowest MPU speed, disable clock output, RTM, and ADC's vref
CONFIG0 = (CONFIG0 & ~(MPU_DIV | RTM_EN)) | (CKOUT_DIS | VREF_DIS | _38400Hz);
// disable emulator clock output and ADC
CONFIG1 |= ECK_DIS | ADC_DIS;
#elif M6520
// slowest MPU speed, disable clock output, RTM, and ADC's vref
CONFIG0 = (CONFIG0 & ~(MPU_DIV | RTM_EN)) | (VREF_DIS | _38400Hz);
// disable emulator clock output and ADC
CONFIG1 |= ECK_DIS;
#endif
while (TRUE)
RESET_WD(); // Reset watchdog, OK due to slow MPU.
}
/***************************************************************************
* History:
* $Log: cmd_misc.c,v $
* Revision 1.24 2006/10/13 00:46:19 tvander
* Removed compile options for 6530, 6515; renamed 6511 and 6513 to trace11 and trace13; Binary verified unchanged from previous version.
*
* Revision 1.23 2006/09/29 08:51:56 tvander
* EEPROM operations are locked out when the CE is running.
*
* Revision 1.22 2006/09/09 01:08:14 gmikef
* *** empty log message ***
*
* Revision 1.21 2006/08/30 02:09:06 gmikef
* *** empty log message ***
*
* Revision 1.20 2006/06/15 19:56:03 tvander
* Fixed misc. serial errors.
*
* Revision 1.19 2006/06/14 02:53:17 tvander
* Improved the compile flags
*
* Revision 1.18 2006/06/06 03:53:51 tvander
* Added calibration count to access.c
* Added to help files, at least, they compile for a 6513.
* io.c support the calibration loader.
* ser0cli.c and ser1cli.c were allocating too many timers. Fixed.
*
* Revision 1.17 2006/06/05 23:50:52 tvander
* Added error recording commands
* trime now present only if enhanced trim present
*
* Revision 1.16 2006/05/18 23:18:42 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.15 2006/03/07 23:57:07 tvander
* Revised help system for accuracy.
* Revised help system for compile flags.
* Clean build
*
* Revision 1.14 2006/03/06 03:28:13 Michael T. Fischer
* More 6530 prep.
*
* Revision 1.13 2006/03/03 11:24:38 Michael T. Fischer
* Prep for 6530 LCD, etc.
*
* Revision 1.12 2006/02/08 03:43:17 tvander
* Made "import" the default power measurement mode, rather than net-metering
*
* Revision 1.11 2006/01/10 03:54:16 gmikef
* Added PDATA support for CE Outputs.
*
* Revision 1.9 2005/11/10 22:51:31 tvander
* 6520 has battery mode commands.
* Brownout always has decimal point 7.
* LCD Mode always has decimal points 7 and 6.
* Sag detection is disabled.
*
* Revision 1.8 2005/11/05 01:55:38 tvander
* Added EEPROM erase command
*
* Revision 1.7 2005/10/20 18:39:39 tvander
* Ported 2-wire EEPROM code from 6511/6513, including interrupting version, polling version for DIO, and polling version using the 2-wire logic.
*
* Revision 1.6 2005/10/08 04:41:17 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.5 2005/09/02 20:38:34 gmikef
* Modified to fit CeCode of 1.5Kbytes and support new "ce_merge".
*
* Revision 1.4 2005/09/02 01:48:44 gmikef
* Fixed CLI RTR command.
*
* Revision 1.3 2005/08/31 05:51:57 gmikef
* First version w/ LAPIE interface.
*
* Revision 1.2 2005/08/30 01:56:33 gmikef
* *** empty log message ***
*
* Revision 1.1 2005/08/28 02:22:40 gmikef
* *** empty log message ***
*
* Revision 1.3 2005/08/20 01:32:44 gmikef
* *** empty log message ***
*
* Revision 1.2 2005/08/19 01:04:37 gmikef
* *** empty log message ***
*
* Revision 1.1 2005/08/18 02:56:06 gmikef
* *** empty log message ***
*
*
* 2005 AUGUST 17; First Version.
* 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -