/* * monitor.c * * Created: Mar 2021 * Author: Arjan te Marvelde * * Command shell on stdin/stdout. * Collects characters and parses commandstring. */ #include #include #include "pico/stdlib.h" #include "lcd.h" #include "si5351.h" #include "dsp.h" #include "monitor.h" /* Monitor definitions */ #define ENDSTDIN 255 #define CR 13 #define LF 10 #define CMD_LEN 32 char mon_cmd[CMD_LEN+1]; uint8_t si5351_reg[200]; bool ptt = false; extern volatile uint32_t fifo_overrun, fifo_rx, fifo_tx, fifo_xx, fifo_incnt; extern uint32_t adc_count; /* Commandstring parser */ char delim[] = " "; #define NCMD 5 char shell[NCMD][3] = {"si", "lt", "fo", "pt", "ad"}; void mon_parse(char* s) { char *p; int base, nreg, i; p = s; //strtok(s, delim); // Get command part of string for (i=0; i0) // something to parse? mon_parse(mon_cmd); // process command i=0; // reset index printf("Pico> "); // prompt break; case LF: putchar((char)c); // Echo character break; // Further ignore, assume CR as terminator default: if ((c<32)||(c>=128)) break; // Only allow alfanumeric putchar((char)c); // Echo character mon_cmd[i] = (char)c; // store in command string if (i