mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Various refactorings
This commit is contained in:
+21
-10
@@ -34,11 +34,6 @@ void crc16(__xdata uint8_t *v) __naked;
|
||||
void flash_default_config(void);
|
||||
void early_boot_handle_button(void);
|
||||
|
||||
extern __xdata char logbuf[LOGBUF_SIZE];
|
||||
extern __xdata uint16_t logptr_w;
|
||||
extern __xdata uint8_t full_line_available;
|
||||
extern __xdata uint8_t syslog_enabled;
|
||||
|
||||
// See setup_serial_timer1() for valid baudrate settings!
|
||||
#define SERIAL_BAUD_RATE 115200
|
||||
|
||||
@@ -179,7 +174,7 @@ void isr_serial(void) __interrupt(4)
|
||||
}
|
||||
|
||||
|
||||
void write_char(char c)
|
||||
void write_char_no_syslog(char c)
|
||||
{
|
||||
do {
|
||||
} while (tx_buf_empty == 0);
|
||||
@@ -191,12 +186,17 @@ void write_char(char c)
|
||||
}
|
||||
tx_buf_empty = 0;
|
||||
SBUF = c;
|
||||
}
|
||||
|
||||
if (syslog_enabled) {
|
||||
logbuf[logptr_w++] = c;
|
||||
logptr_w &= (LOGBUF_SIZE - 1);
|
||||
void write_char(char c)
|
||||
{
|
||||
write_char_no_syslog(c);
|
||||
|
||||
if (syslog_state.enabled) {
|
||||
logbuf[syslog_state.writeptr++] = c;
|
||||
syslog_state.writeptr &= (LOGBUF_SIZE - 1);
|
||||
if (c == '\n')
|
||||
full_line_available = 1;
|
||||
syslog_state.line_available = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,12 @@ void print_string(__code char *p)
|
||||
write_char(*p++);
|
||||
}
|
||||
|
||||
void print_string_no_syslog(__code char *p)
|
||||
{
|
||||
while (*p)
|
||||
write_char_no_syslog(*p++);
|
||||
}
|
||||
|
||||
void print_string_x(__xdata char *p)
|
||||
{
|
||||
while (*p)
|
||||
@@ -319,6 +325,11 @@ void print_byte(uint8_t a)
|
||||
write_char(low);
|
||||
}
|
||||
|
||||
void print_cmd_prompt(void)
|
||||
{
|
||||
print_string_no_syslog("\n> ");
|
||||
}
|
||||
|
||||
/*
|
||||
* External IRQ 0 Service Routine: Called on link change?
|
||||
* Note that all registers are being put on the STACK because of calling a subroutine
|
||||
|
||||
Reference in New Issue
Block a user