Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const char *menu_str[] = {"\r\n",
};
#define MENU_LEN (sizeof(menu_str)/sizeof(*menu_str))

// number of UART_MSG_TERMINATOR in UARTQUEUE
static uint8_t _msgCount;
static uint8_t _fpgaEnable;

Expand Down Expand Up @@ -719,11 +720,23 @@ void CONSOLE_USART_ISR(void) {
return;
}

// call only from ISR
void console_pend_msg(void) {
_msgCount++;
return;
}

static bool console_dequeue_msg(void) {
bool ret = false;
INTERRUPTS_DISABLE();
if(_msgCount) {
_msgCount--;
ret = true; // caller must console_shift_msg()
}
INTERRUPTS_ENABLE();
return ret;
}

/*
* int console_service(void);
* Service the console system.
Expand All @@ -732,9 +745,8 @@ void console_pend_msg(void) {
int console_service(void) {
uint8_t msg[CONSOLE_MAX_MESSAGE_LENGTH];
int len;
if (_msgCount) {
if (console_dequeue_msg()) {
len = console_shift_msg(msg);
_msgCount--;
if (len) {
return console_handle_msg((char *)msg, len);
}
Expand Down Expand Up @@ -767,8 +779,11 @@ static int console_shift_all(uint8_t *pData) {
* Returns the number of bytes shifted out.
*/
static int console_shift_msg(uint8_t *pData) {
//UARTQUEUE_ShiftOut(pData, CONSOLE_MAX_MESSAGE_LENGTH);
return UARTQUEUE_ShiftUntil(pData, UART_MSG_TERMINATOR, CONSOLE_MAX_MESSAGE_LENGTH);
int ret;
INTERRUPTS_DISABLE();
ret = UARTQUEUE_ShiftUntil(pData, UART_MSG_TERMINATOR, CONSOLE_MAX_MESSAGE_LENGTH);
INTERRUPTS_ENABLE();
return ret;
}

static int xatoi(char c) {
Expand Down