gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
serial.c File Reference
#include "grbl.h"

Go to the source code of this file.

Macros

#define RX_RING_BUFFER   (RX_BUFFER_SIZE+1)
 
#define TX_RING_BUFFER   (TX_BUFFER_SIZE+1)
 

Functions

uint8_t serial_get_rx_buffer_available ()
 Returns the number of bytes available in the RX serial buffer. More...
 
uint8_t serial_get_rx_buffer_count ()
 Returns the number of bytes used in the RX serial buffer. More...
 
uint8_t serial_get_tx_buffer_count ()
 Returns the number of bytes used in the TX serial buffer. More...
 
void serial_init ()
 
void serial_write (uint8_t data)
 Writes one byte to the TX serial buffer. Called by main program. More...
 
 ISR (SERIAL_UDRE)
 Data Register Empty Interrupt handler. More...
 
uint8_t serial_read ()
 Fetches the first byte in the serial read buffer. Called by main program. More...
 
 ISR (SERIAL_RX)
 
void serial_reset_read_buffer ()
 Reset and empty data in read buffer. Used by e-stop and reset. More...
 

Variables

uint8_t serial_rx_buffer [RX_RING_BUFFER]
 
uint8_t serial_rx_buffer_head = 0
 
volatile uint8_t serial_rx_buffer_tail = 0
 
uint8_t serial_tx_buffer [TX_RING_BUFFER]
 
uint8_t serial_tx_buffer_head = 0
 
volatile uint8_t serial_tx_buffer_tail = 0
 

Macro Definition Documentation

#define RX_RING_BUFFER   (RX_BUFFER_SIZE+1)

Definition at line 24 of file serial.c.

#define TX_RING_BUFFER   (TX_BUFFER_SIZE+1)

Definition at line 25 of file serial.c.

Function Documentation

ISR ( SERIAL_UDRE  )

Data Register Empty Interrupt handler.

< Temporary serial_tx_buffer_tail (to optimize for volatile)

Definition at line 104 of file serial.c.

ISR ( SERIAL_RX  )

< Call motion control reset routine.

< Set as true

< Set as true

< Set as true

< Real-time control characters are extended ACSII only.

< Set as true

< Block all other states from invoking motion cancel.

< Write character to buffer

Definition at line 139 of file serial.c.

uint8_t serial_get_rx_buffer_available ( )

Returns the number of bytes available in the RX serial buffer.

< Copy to limit multiple calls to volatile

Definition at line 36 of file serial.c.

uint8_t serial_get_rx_buffer_count ( )

Returns the number of bytes used in the RX serial buffer.

NOTE: Deprecated. Not used unless classic status reports are enabled in config.h.

< Copy to limit multiple calls to volatile

Definition at line 46 of file serial.c.

uint8_t serial_get_tx_buffer_count ( )

Returns the number of bytes used in the TX serial buffer.

NOTE: Not used except for debugging and ensuring no TX bottlenecks.

< Copy to limit multiple calls to volatile

Definition at line 56 of file serial.c.

void serial_init ( )

< baud doubler on for high baud rates, i.e. 115200

Definition at line 64 of file serial.c.

uint8_t serial_read ( )

Fetches the first byte in the serial read buffer. Called by main program.

< Temporary serial_rx_buffer_tail (to optimize for volatile)

Definition at line 122 of file serial.c.

void serial_reset_read_buffer ( )

Reset and empty data in read buffer. Used by e-stop and reset.

Definition at line 195 of file serial.c.

void serial_write ( uint8_t  data)

Writes one byte to the TX serial buffer. Called by main program.

Todo:
Restructure st_prep_buffer() calls to be executed here during a long print.

Definition at line 84 of file serial.c.

Variable Documentation

uint8_t serial_rx_buffer[RX_RING_BUFFER]

Definition at line 27 of file serial.c.

uint8_t serial_rx_buffer_head = 0

Definition at line 28 of file serial.c.

volatile uint8_t serial_rx_buffer_tail = 0

Definition at line 29 of file serial.c.

uint8_t serial_tx_buffer[TX_RING_BUFFER]

Definition at line 31 of file serial.c.

uint8_t serial_tx_buffer_head = 0

Definition at line 32 of file serial.c.

volatile uint8_t serial_tx_buffer_tail = 0

Definition at line 33 of file serial.c.