Luigi Santivetti | 69972f9 | 2019-11-12 22:55:40 +0000 | [diff] [blame^] | 1 | /* |
| 2 | serial.c - Low level functions for sending and recieving bytes via the serial port |
| 3 | Part of Grbl |
| 4 | |
| 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC |
| 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud |
| 7 | |
| 8 | Grbl is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | Grbl is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with Grbl. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef serial_h |
| 23 | #define serial_h |
| 24 | |
| 25 | |
| 26 | #ifndef RX_BUFFER_SIZE |
| 27 | #define RX_BUFFER_SIZE 128 |
| 28 | #endif |
| 29 | #ifndef TX_BUFFER_SIZE |
| 30 | #ifdef USE_LINE_NUMBERS |
| 31 | #define TX_BUFFER_SIZE 112 |
| 32 | #else |
| 33 | #define TX_BUFFER_SIZE 104 |
| 34 | #endif |
| 35 | #endif |
| 36 | |
| 37 | #define SERIAL_NO_DATA 0xff |
| 38 | |
| 39 | |
| 40 | void serial_init(); |
| 41 | |
| 42 | // Writes one byte to the TX serial buffer. Called by main program. |
| 43 | void serial_write(uint8_t data); |
| 44 | |
| 45 | // Fetches the first byte in the serial read buffer. Called by main program. |
| 46 | uint8_t serial_read(); |
| 47 | |
| 48 | // Reset and empty data in read buffer. Used by e-stop and reset. |
| 49 | void serial_reset_read_buffer(); |
| 50 | |
| 51 | // Returns the number of bytes available in the RX serial buffer. |
| 52 | uint8_t serial_get_rx_buffer_available(); |
| 53 | |
| 54 | // Returns the number of bytes used in the RX serial buffer. |
| 55 | // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. |
| 56 | uint8_t serial_get_rx_buffer_count(); |
| 57 | |
| 58 | // Returns the number of bytes used in the TX serial buffer. |
| 59 | // NOTE: Not used except for debugging and ensuring no TX bottlenecks. |
| 60 | uint8_t serial_get_tx_buffer_count(); |
| 61 | |
| 62 | #endif |