Pic terminal routines. More...
Go to the source code of this file.
Functions | |
void | term_entry_callback (uns8 *term_buffer) |
void | term_init () |
void | term_process () |
Allows the use of a serial terminal for interaction with the PIC
Put the following into your config.h
// - - - - - - - - - - - - - - - - - - - - // pic_term defines // - - - - - - - - - - - - - - - - - - - - #define TERM_BUFFER_SIZE 10 // Reset (go to bootloader) if magic character received #define TERM_ALLOW_BOOSTBLOADER // Echo typing so user can see what they're doing #define TERM_ECHO_INPUT // - - - - - - - - - - - - - - - - - - - - // Create term_entry_callback in your own code // void term_entry_callback(uns8 *term_buffer);
void term_entry_callback | ( | uns8 * | term_buffer | ) |
void term_init | ( | ) |
00082 { 00083 00084 term_buffer[0] = '\0'; 00085 buffer_len = 0; 00086 00087 }
void term_process | ( | ) |
00043 { 00044 00045 uns8 len, // length of string 00046 rec; // received character 00047 00048 if (serial_rx_avail()) { 00049 00050 rec = serial_getc(); // get the character from the fifo 00051 00052 #ifdef TERM_ALLOW_BOOSTBLOADER 00053 if (rec == MAGIC_BOOSTBLOADER_REQUEST) { 00054 boostbloader(); 00055 } 00056 #endif 00057 00058 00059 if (rec == '\r') { // did we press return? 00060 00061 if (buffer_len > 0) { 00062 term_entry_callback(term_buffer); 00063 } 00064 term_buffer[0] = '\0'; // clear the buffer 00065 buffer_len = 0; 00066 #ifdef TERM_ECHO_INPUT 00067 serial_putc('\n'); // print new line 00068 serial_putc('>'); // print the prompt 00069 #endif 00070 } else { 00071 if (buffer_len < TERM_BUFFER_SIZE + 2) { // space for null and new character 00072 #ifdef TERM_ECHO_INPUT 00073 serial_putc(rec); // print it out so we can see what we typed 00074 #endif 00075 term_buffer[buffer_len++] = rec; 00076 term_buffer[buffer_len] = '\0'; 00077 } 00078 } 00079 } 00080 }