Sergey Pastor / grbl1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial.h Source File

serial.h

00001 /*
00002   serial.c - Low level functions for sending and recieving bytes via the serial port
00003   Part of Grbl
00004 
00005   Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
00006   Copyright (c) 2009-2011 Simen Svale Skogsrud
00007 
00008   Grbl is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012 
00013   Grbl is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017 
00018   You should have received a copy of the GNU General Public License
00019   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #ifndef serial_h
00023 #define serial_h
00024 
00025 #ifdef AVRTARGET
00026 #ifndef RX_BUFFER_SIZE
00027   #define RX_BUFFER_SIZE 128
00028 #endif
00029 #ifndef TX_BUFFER_SIZE
00030   #ifdef USE_LINE_NUMBERS
00031     #define TX_BUFFER_SIZE 112
00032   #else
00033     #define TX_BUFFER_SIZE 104
00034   #endif
00035 #endif
00036 #else
00037 #define RX_BUFFER_SIZE 254
00038 #ifndef WIN32
00039 #define TX_BUFFER_SIZE 128  // Do not try 256 it will not work for STM32.
00040 #else
00041 #define TX_BUFFER_SIZE 254
00042 #endif
00043 #endif
00044 
00045 #define SERIAL_NO_DATA 0xff
00046 
00047 #ifdef WIN32
00048 void winserial_init(char *pPort);
00049 #endif
00050 
00051 void serial_init();
00052 
00053 // Writes one byte to the TX serial buffer. Called by main program.
00054 void serial_write(uint8_t data);
00055 
00056 // Fetches the first byte in the serial read buffer. Called by main program.
00057 uint8_t serial_read();
00058 
00059 // Reset and empty data in read buffer. Used by e-stop and reset.
00060 void serial_reset_read_buffer();
00061 
00062 // Returns the number of bytes available in the RX serial buffer.
00063 uint8_t serial_get_rx_buffer_available();
00064 
00065 // Returns the number of bytes used in the RX serial buffer.
00066 // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h.
00067 uint8_t serial_get_rx_buffer_count();
00068 
00069 // Returns the number of bytes used in the TX serial buffer.
00070 // NOTE: Not used except for debugging and ensuring no TX bottlenecks.
00071 uint8_t serial_get_tx_buffer_count();
00072 
00073 #endif