/* Clear all character and graphic attributes */ void clear_all_attributes(void) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x30); /* 0 */ UART_putc(0x6D); /* m */ }
/* Moves the cursor down 1-6 lines in the same column, stops at the bottom */ void cursor_down(unsigned char lines) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x30+lines); /* number of lines */ UART_putc(0x42); /* B */ }
/* Blinking */ void blinking_on(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x35); /* 5 */ UART_putc(0x6D); /* m */ }
/* Reverse Video */ void reverse_video_on(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x37); /* 7 */ UART_putc(0x6D); /* m */ }
unsigned int UART_puts(char *pTxBuffer, int numBytesToWrite) { unsigned int count = 0; unsigned int flag = 0; if(numBytesToWrite < 0) flag = 1; while('\0' != *pTxBuffer) { /* Checks if data is a newline character. */ if('\n' == *pTxBuffer) { /* Ensuring applicability to serial console.*/ UART_putc('\r'); UART_putc('\n'); } else UART_putc((unsigned char)*pTxBuffer); pTxBuffer++; count++; if((0 == flag) && (count == (unsigned int)numBytesToWrite)) break; } /* Returns the number of bytes written onto the transmitter FIFO. */ return count; }
/* Moves the cursor left 1-9 columns, stops at the left margin */ void cursor_left(unsigned char cols) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x30+cols); /* number of lines */ UART_putc(0x44); /* D */ }
/* Request cursor position */ void request_cursor(void) /* unknown, probably doesnt work */ { row_report = 0; col_report = 0; UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x36); /* 6 */ UART_putc(0x6E); /* n */ UART_getc(); /* ESC */ UART_getc(); /* [ */ row_report += (UART_getc() - 0x30) * 10; /* Row, 10's digit */ row_report += UART_getc() - 0x30; /* Row, 1's digit */ UART_getc(); /* ; */ col_report += (UART_getc() - 0x30) * 100; /* Column, 100's digit */ col_report += (UART_getc() - 0x30) * 10; /* Column, 10's digit */ col_report += UART_getc() - 0x30; /* Column, 1's digit */ if( UART_getc() == 'R' ) { cursor_responded = 1; /* Put up cursor valid flag */ } else { cursor_responded = 0; } }
/* Init UART driver */ unsigned int dinit_uart() { UART_stdioInit(); UART_putc('\n'); UART_putc('\n'); return EXIT_SUCCESS; }
void blinking_off(void) /* works, tested by Barnett */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x32); /* 2 */ UART_putc(0x35); /* 5 */ UART_putc(0x6D); /* m */ }
void reverse_video_off(void) /* works, tested by Barnett */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x32); /* 2 */ UART_putc(0x37); /* 7 */ UART_putc(0x6D); /* m */ }
void auto_linefeed_off(void) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x32); /* 2 */ UART_putc(0x30); /* 0 */ UART_putc(0x6C); /* l */ }
inline void debugProcess() { if (isDebugEnabled && commandeCourante != FREINAGE) { UART_putc(vitL); UART_putc(vitR); } #ifdef NB_GET_TIME if (!cpt_boucle && commandeCourante != FREINAGE) SEND_TIME; cpt_boucle ++; cpt_boucle %= NB_GET_TIME; #endif // #ifdef NB_GET_TIME }
/* Moves the cursor to an arbitrary position */ void cursor_position(unsigned char row, unsigned char col) /* DOES NOT work */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x30+(row/10)); /* Row, 10's digit */ UART_putc(0x30+(row%10)); /* Row, 1's digit */ UART_putc(0x3B); /* ; */ UART_putc(0x30+(col/100)); /* Column, 100's digit */ UART_putc(0x30+((col/10)%10)); /* Column, 10's digit */ UART_putc(0x30+(col%10)); /* Column, 1's digit */ UART_putc(0x52); /* R */ }
/* Brightness, 4 levels */ void brightness(unsigned char level) /* works, tested by Barnett */ { UART_putc(0x1B); /* ESC */ UART_putc(0x23); /* # */ if( level == 1 ) /* Dimmest */ { UART_putc(0x61); /* a */ } else if( level == 2 ) { UART_putc(0x62); /* b */ } else if( level == 3 ) { UART_putc(0x63); /* c */ } else if( level == 4 ) /* Brightest */ { UART_putc(0x64); /* d */ } else /* Default to Brightness */ { UART_putc(0x64); /* d */ } }
int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) { while (len) { UART_putc(*buf); buf++; len--; } return len; }
void forth_print_all() { if( datastack.size < 1 ) { UART_print( "stack is empty\r\n" ); } else { char value[16]; for( int i = 0; i < datastack.size; i++ ) { Dasha_itoa( (int)datastack.data[i], value ); UART_print( value ); UART_putc( ' ' ); } UART_print( "\r\n" ); } }
void main() { TRISA = 0; PORTA = 0; TRISB = 0; PORTB = 0; TRISD = 0; PORTD = 0; ANSELH = 0; init_uart(); // init UART module while (1) // infinite loop which handles ncoming data as they arrive { if (cUART_data_flg==1)// if new data available, send it back through USART tx line (echo it) { UART_putc(cUART_char); cUART_data_flg=0; // clear new data flag so one charactor will echoed once } } }
//--------------------------------------------------------------------------// // Function: main // //--------------------------------------------------------------------------// void main(void) { int c; //inicjalizacje Init_Interrupts(); LED_Init(); UART_initialize(115200); //jakiœ tam komunikat powitalny UART_putc('H'); UART_putc('e'); UART_putc('l'); UART_putc('l'); UART_putc('o'); for (;;) { //odbieramy znak i odbijamy go na terminal c = UART_getc(); UART_putc(c); //w zale¿noœci od tego co przysz³o, prze³¹czamy stan jednej z diod switch (c) { case '1': *pPORTFIO_TOGGLE = 0x0040; break; case '2': *pPORTFIO_TOGGLE = 0x0080; break; case '3': *pPORTFIO_TOGGLE = 0x0100; break; case '4': *pPORTFIO_TOGGLE = 0x0200; break; case '5': *pPORTFIO_TOGGLE = 0x0400; break; case '6': *pPORTFIO_TOGGLE = 0x0800; break; } } }
void UART_stdioRead(unsigned char *rxBuff, unsigned char rxByte) { unsigned int inputCount = 0u; while((rxByte != '\r') && (rxByte != ' ')) { UART_putc(rxByte); /* Account for the backspace to allow user to edit the input */ if(('\b' == rxByte) && (inputCount > 0)) { rxBuff--; inputCount--; } else { *rxBuff++ = rxByte; inputCount++; } rxByte = UART_getc(); } /* Add the delimiting character at the end of the buffer */ *rxBuff = rxByte; }
void _ttywrch(int ch) { UART_putc(ch); }
/* Restores the previously saved cursor position */ void restore_cursor(void) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x38); /* 8 */ }
/* Saves the present value of the cursor location, character attribute, and character set selection, moves to home if none were saved */ void save_cursor(void) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x37); /* 7 */ }
/* Character Sizes */ void single_single(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x23); /* # */ UART_putc(0x35); /* 5 */ }
void rcvd_data_test_exit(void) /* unknown */ { UART_putc(0x1B); /* ESC */ UART_putc(0x45); /* E */ }
/* Cancel */ void cancel(void) /* unknown */ { UART_putc(0x18); /* CAN */ }
/* All bytes recieved will be displayed in HEX rather than ASCII. */ void rcvd_data_test(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x44); /* D */ }
/* Self-test mode */ void self_test(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x42); /* B */ }
/* Moves cursor to home position */ void cursor_home(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x5B); /* [ */ UART_putc(0x48); /* H */ }
void double_double(void) /* works */ { UART_putc(0x1B); /* ESC */ UART_putc(0x23); /* # */ UART_putc(0x33); /* 3 */ }
/* Example: ESC/4;+123,+010,g Display: +123 +10 */ void dpmm(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e, unsigned char f, unsigned char g, unsigned char h) /* works, tested by Barnett */ { UART_putc(0x1B); /* ESC */ UART_putc(0x2F); /* / */ UART_putc(0x34); /* 4 */ UART_putc(0x30+a); UART_putc(0x30+b); UART_putc(0x30+c); UART_putc(0x30+d); UART_putc(0x2C); /* , */ UART_putc(0x30+e); UART_putc(0x30+f); UART_putc(0x30+g); UART_putc(0x30+h); UART_putc(0x2C); /* , */ UART_putc(0x67); /* g */ }