?? cli.c
字號:
/***************************************************************************
* This code and information is provided "as is" without warranty of any *
* kind, either expressed or implied, including but not limited to the *
* implied warranties of merchantability and/or fitness for a particular *
* purpose. *
* *
* Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved. *
***************************************************************************/
//*************************************************************************
// DESCRIPTION: 71M652x POWER METER - Command Line Interface Routines.
//
// AUTHOR: MTF
//
// HISTORY: see below
//***************************************************************************
// File: CLI.C
//
#include "options.h"
#if CLI
#include <ctype.h>
#include "ce_dat.h"
#include "stm.h"
#include "main.h"
#include "batmodes.h"
#include "defaults.h"
#include "help.h"
#include "io.h"
#include "cli.h"
/*** Public variables declared within this module ***/
volatile uint8i_t cli_index;
uint8i_t cli_result;
/*** Private functions declared within this module ***/
static void cmd_H (uint8_t c); // '?' Usage help
static void cmd_i (void); // 'In' Information.
static void cmd_z (void); // 'Z' Reset.
static void send_version (void);
/*** Private variables declared within this module ***/
static int8r_t v1code_0[] = { ">" };
#if HELP
static int8r_t v1code_1[] = { "INVALID COMMAND. TYPE \'??\' FOR HELP\r\n>" };
#else
static int8r_t v1code_1[] = { "INVALID COMMAND.\r\n>" };
#endif
static int8r_t v1code_2[] = { "PARITY ERROR.\r\n>" };
static int8r_t vlcode_3[] = { "NOTE: SESSION MAY HANG! MATCH SERIAL RATE WITH NEW SETTINGS.\r\n"};
static int8r_t v1code_4[] = { "NO HELP AVAILABLE.\r\n"};
static int8r_t v1code_5[] = { "B>" };
static int8r_t * code v1_result[] = {
v1code_0, // CMD PROMPT
v1code_1, // ERROR.
v1code_2, // PARITY ERROR.
vlcode_3, // SERIAL RATE CHANGE WARNING
v1code_4, // No help available.
v1code_5 // BROWNOUT CMD PROMPT
};
// Exit control.
bool done (uint8d_t *c)
{
uint8_t data d;
*c = get_char_d (&d);
if (*c == '\0')
cli_index = d; // Unget last character.
return (*c == '\0' || *c == ';');
}
void cli (void) // Command Line Interpreter.
{
uint8_t data d;
set_result(OK_ID);
while (cli_result == OK_ID && (!done (&d)) )
{ // Command processing.
switch (toupper (d))
{
#if LOAD
case '@': // '@' Upload/Download record.
cmd_download ();
break;
#endif
#if TRACE10 // in brownout, only 1 rate is ok
case ' ': // Update Serial port bit rate.
cmd_rate ();
break;
#endif
#if 0 // in the serial driver, parity and bits are static
case '7':
cmd_width_parity (7); // '7' Serial port width, parity, stop bit controls.
break;
case '8':
cmd_width_parity (8); // '8' Serial port width, parity, stop bit controls.
break;
#endif
#if TRACE10
case '!': // '!' CE Code Access.
cmd_ce_code_access ();
break;
#endif
case ']': // ']' CE Data Access.
cmd_ce_data_access ();
break;
case ')': // ')' MPU Data Access.
cmd_mpu_data_access ();
break;
#if BROWNOUT_BATMODE
case 'B':
cmd_batmode (); // 'B' Battery modes.
break;
#endif
case 'C':
cmd_ce (); // 'C' (C)ompute Engine controls.
break;
#if 0
case 'D':
cmd_lcd (); // 'D' LC(D)isplay controls.
break;
#endif
case 'E':
switch(toupper( get_char_d (&d) ))
{
#if CLI_EEPROM
case 'E':
cmd_eeprom (); // (EE)prom controls.
break;
#endif
#if ERROR_RECORDING
case 'R':
cmd_err_record (); // error recording tests
break;
#endif
#if 0
case 'I':
cmd_ext_ints (); // 'EI' (E)xternal (I)terrupt controls.
break;
default:
cli_index = d; // Unget last character.
cmd_events (); // 'E' (E)vent controls.
break;
#else
default:
break;
#endif
}
break;
#if FLASH
case 'F':
cmd_flash (); // 'F' (F)lash controls.
break;
#endif
case 'I':
send_version ();
break;
#if LOAD
case 'L': // 'L' (L)oad controls.
cmd_load ();
break;
#endif
case 'M': // 'M' (M)eter controls.
cmd_meter ();
break;
case 'P':
if ('S' == toupper (get_char_d (&d)))
cmd_power_save (); // 'PS' Power Save.
#if PROFILE
else
{
cli_index = d; // Unget last character.
cmd_profile (); // 'P' Meter Profile.
}
#endif
break;
case 'R':
#if REAL_TIME_DATE
if ('T' == toupper (get_char_d (&d)))
cmd_rtc (); // 'RT' (R)eal (T)ime Clock controls.
else
{
cli_index = d; // Unget last character.
cmd_sfr (); // 'R' Special Function (R)egisters.
}
#endif
break;
case 'S': // 'S' Serial controls.
cmd_serial ();
break;
#if ENHANCED_TRIM
case 'T':
cmd_trim ();
break;
case 'W':
send_a_result (OK_ID); // Defaults to 'OK'.
stm_wait ( milliseconds(300) ); // let the typing echo
EA = 0;
while (TRUE) // watchdog reset
;
break;
case 'Z':
send_a_result (OK_ID); // Defaults to 'OK'.
stm_wait ( milliseconds(300) ); // let the typing echo
switch (get_num ())
{
default:
case 0:
main_soft_reset ();
break;
case 1:
EA = 0;
while (TRUE) // watchdog reset
;
break;
#if HARD_RESET_USABLE
case 2:
USER1 += 1; // assumes DIO_8 wired to reset
break;
#endif
}
case '?':
#if HELP
if ('\0' == toupper (d = get_char ()))
send_help (Usage);
else
cmd_H (d);
#else
set_result(NO_HELP_AVAIL_ID);
#endif
break;
case '~':
default:
set_result(ERROR_ID);
break;
}
}
cli_index = CLI_BASE;
send_result ();
} // end cli
// Send passed result code to UART.
void send_a_result (uint8_t c)
{
#if BROWNOUT_BATMODE
if (c == OK_ID && batmode_is_brownout ())
c = OK_BROWNOUT_ID; // display B>
#endif
start_tx_rslt (v1_result[ c - 1 ]);
}
// Looks up result code, primes pump for result codes.
void send_result (void)
{
send_a_result(cli_result);
if (cli_result != OK_ID)
send_a_result (OK_ID); // reprompt after an error
}
// Sends the copyright data
void send_copyright (void)
{
start_tx_rslt (copyright1);
#if ENHANCED_TRIM
if (0 != Read_Trim (_TRIMBGB))
start_tx_rslt("H");
#endif
start_tx_rslt("A");
send_byte (VERSION);
start_tx_rslt (copyright2);
send_crlf ();
}
// Sends all the version data
void send_version (void)
{
send_crlf ();
start_tx_rslt (r_demo_version); send_crlf ();
start_tx_rslt ((uint8r_t *) &CeData[0] ); send_crlf ();
send_copyright ();
}
#if HELP
void send_help (int8r_t * code *s)
{
while (*s != NULL)
{
send_crlf ();
start_tx_rslt (*s++);
}
send_crlf ();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -