📄 c_serial.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: 71M651x POWER METER - Serial Commands (Extended).
//
// AUTHOR: MTF/RGV
//
// HISTORY: See end of file
//
//**************************************************************************
//
// File: C_SERIAL.C
//
//**************************************************************************
#include "options.h"
#if CLI
#include "oscope.h"
#include "ce_ce.h"
#include "cli.h"
#include "io.h"
#include "ser0cli.h"
#include "ser1cli.h"
#include "sercli.h"
#include "serial.h"
#if SERIAL0
#include "ser0.h"
#endif
#if SERIAL1
#include "ser1.h"
#endif
#include <ctype.h>
/*** Private functions declared within this module ***/
// None.
/*** Private variables used within this module ***/
static void echo_on (void);
static void echo_off (void);
//--------------------------------------//
void echo_on (void)
{
echo = TRUE;
}
void echo_off (void)
{
echo = FALSE;
}
void cmd_serial (void)
{
uint8_t data c;
while (!done (&c))
{
switch (toupper (c))
{
case 'C':
#if SERIAL0_CLI && SERIAL1_CLI
if (SERIAL_0 == port)
{
bit_rate_1 = bit_rate_0;
xon_xoff_1 = xon_xoff_0;
#if 0
parity_none_1 = parity_none_0;
parity_odd_1 = parity_odd_0;
stop_bit2_1 = stop_bit2_0;
seven_bit_1 = seven_bit_0;
#endif
cli1_init (bit_rate_1, xon_xoff_1);
}
if (SERIAL_1 == port)
{
bit_rate_0 = bit_rate_1;
xon_xoff_0 = xon_xoff_1;
#if 0
parity_none_0 = parity_none_1;
parity_odd_0 = parity_odd_1;
stop_bit2_0 = stop_bit2_1;
seven_bit_0 = seven_bit_1;
#endif
cli0_init (bit_rate_0, xon_xoff_0);
}
#endif
break;
case 'E':
if (get_num ())
echo_on ();
else
echo_off ();
break;
case 'K':
#if SERIAL0_CLI
if (SERIAL_0 == port)
{
xon_xoff_0 = get_num ();
send_a_result (RATE_CHANGE_ID);
send_a_result (OK_ID);
cli0_init (bit_rate_0, xon_xoff_0);
}
#endif
#if SERIAL1_CLI
if (SERIAL_1 == port)
{
xon_xoff_1 = get_num ();
send_a_result (RATE_CHANGE_ID);
send_a_result (OK_ID);
cli1_init (bit_rate_1, xon_xoff_1);
}
#endif
break;
case 'O':
{
uint8_t other_port;
uint8_t cmd_serial_o_buffer;
ser_initialize (BAUD);
cmd_serial_o_buffer = get_num ();
other_port = 1;
if (port == 1)
other_port = 0;
while (!ser_xmit_rdy())
;
OSCOPE_INIT;
OSCOPE_ONE;
OSCOPE_ZERO;
ser_xmit (cmd_serial_o_buffer);
while (!ser_xmit_rdy())
;
OSCOPE_ONE;
}
break;
case 'P':
port = get_num ();
break;
default:
break;
}
}
}
#if 0
void cmd_width_parity (uint8_t bit_cnt) // '8' Serial port width, parity, stop bit controls.
{
uint8_t idata c;
done (&c);
#if SERIAL0_CLI
if (SERIAL_0 == port)
{
switch (toupper (c))
{
case 'O':
parity_odd_0 = TRUE;
parity_none_0 = FALSE;
break;
case 'N':
parity_none_0 = TRUE;
TB8 = TRUE;
break;
case 'E':
parity_odd_0 = FALSE;
parity_none_0 = FALSE;
break;
default: // No change.
start_tx_rslt ("\r\nNo change in serial port setting.\r\n");
send_a_result (OK_ID);
return;
}
done(&c);
stop_bit2_0 = '2' == c; // Assume one stop bit unless two specified.
if(bit_cnt == 7)
seven_bit_0 = TRUE;
else
seven_bit_0 = FALSE;
send_a_result (RATE_CHANGE_ID);
send_a_result (OK_ID);
cli0_init (bit_rate_0, !parity_none_0, parity_odd_0, stop_bit2_0, xon_xoff_0, seven_bit_0);
}
#endif
#if SERIAL1_CLI
if (SERIAL_1 == port)
{
switch (toupper (c))
{
case 'O':
parity_odd_1 = TRUE;
parity_none_1 = FALSE;
break;
case 'N':
parity_none_1 = TRUE;
S1CON |= TB8_;
break;
case 'E':
parity_odd_1 = FALSE;
parity_none_1 = FALSE;
break;
default: // No change.
start_tx_rslt ("\r\nNo change in serial port setting.\r\n");
send_a_result (OK_ID);
return;
}
done(&c);
stop_bit2_1 = '2' == c; // Assume one stop bit unless two specified.
if(bit_cnt == 7)
seven_bit_1 = TRUE;
else
seven_bit_1 = FALSE;
send_a_result (RATE_CHANGE_ID);
send_a_result (OK_ID);
cli1_init (bit_rate_1, !parity_none_1, parity_odd_1, stop_bit2_1, xon_xoff_1, seven_bit_1);
}
#endif
}
#endif
#if TRACE10
void cmd_rate (void)
{
uint8_t data c;
enum SERIAL_SPD bit_rate;
done (&c);
switch (c)
{
case '1':
done (&c);
switch (c)
{
case '2': // 1200 bps.
bit_rate = _RATE_1200;
break;
case '9': // 19200 bps.
bit_rate = _RATE_19200;
break;
}
break;
case '2': // 2400 bps.
bit_rate = _RATE_2400;
break;
case '3':
done (&c);
switch (c)
{
case '0': // 300 bps.
bit_rate = _RATE_300;
break;
case '8': // 38400 bps.
bit_rate = _RATE_38400;
break;
}
break;
case '4': // 4800 bps.
bit_rate = _RATE_4800;
break;
case '6': // 600 bps.
bit_rate = _RATE_600;
break;
case '9': // 9600 bps.
bit_rate = _RATE_9600;
break;
}
send_a_result (RATE_CHANGE_ID);
send_a_result (OK_ID);
#if SERIAL0_CLI
if (SERIAL_0 == port)
if (!cli0_init (bit_rate, xon_xoff_0))
start_tx_rslt ("\r\nNeed to first increase MPU speed\r\n");
#endif
#if SERIAL1_CLI
if (SERIAL_1 == port)
if (!cli1_init (bit_rate, xon_xoff_1))
start_tx_rslt ("\r\nNeed to first increase MPU speed\r\n");
else
bit_rate_1 = bit_rate;
#endif
cli_index = CLI_BASE; // Start 'cli_index' at base of CLI buffer.
}
#endif
/***************************************************************************
* History:
* $Log: c_serial.c,v $
* Revision 1.12 2006/10/13 00:46:18 tvander
* Removed compile options for 6530, 6515; renamed 6511 and 6513 to trace11 and trace13; Binary verified unchanged from previous version.
*
* Revision 1.11 2006/09/10 00:25:18 Michael T. Fischer
* First version to support DGM0915 LCD.
*
* Revision 1.10 2006/09/09 01:08:03 gmikef
* *** empty log message ***
*
* Revision 1.9 2006/03/07 23:57:06 tvander
* Revised help system for accuracy.
* Revised help system for compile flags.
* Clean build
*
* Revision 1.8 2006/03/06 03:27:37 Michael T. Fischer
* More 6530 prep.
*
* Revision 1.7 2006/03/03 11:24:11 Michael T. Fischer
* Prep for 6530 LCD, etc.
*
* Revision 1.5 2005/12/07 01:35:10 tvander
* Add test of serial 1; command SO
*
* Revision 1.4 2005/10/18 02:17:07 tvander
* Access CLI in brownout by pressing reset.
* Debugged serial 1 usage from CLI.
* Implemented scrolling display as M17
*
* Revision 1.3 2005/09/22 23:44:54 tvander
* Clean build all models and unit tests, updated copyright to be fore Teridian
*
* Revision 1.2 2005/09/12 07:47:27 tvander
* Power measurement is stable, with no creep.
* VARh measurement is stable, with no creep.
* Pulse sources work.
* Full access to MPU variables.
* Rolled date.
* Clock software works.
*
* Revision 1.1 2005/08/31 06:30:39 gmikef
* *** empty log message ***
*
* Revision 1.3 2005/08/03 18:34:48 tvander
* Changed copyright to "Teridian Semiconductor Co."
* Put in alt-mux change in MPU parameters in api_struct.h
* Revised validity date of cal.c
*
* Revision 1.2 2005/02/17 18:32:21 tvander
* Added automatic check-in logging to all source code.
*
* 2004 OCTOBER 21; 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 + -