Skip to content

Commit

Permalink
Updated drivers to use networking protocol code for telnet and websoc…
Browse files Browse the repository at this point in the history
…ket from plugin

Moved stream buffer structs from drivers to core grbl for better standardisation amongst drivers.

Simplified configuration of ESP32 compilation - see CMakeLists.txt in driver for details.
  • Loading branch information
terjeio committed Nov 18, 2019
1 parent 04398b8 commit a3ac7fc
Show file tree
Hide file tree
Showing 49 changed files with 1,003 additions and 2,334 deletions.
32 changes: 31 additions & 1 deletion GRBL/stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
stream.h - some ASCII control character definitions
stream.h - some ASCII control character definitions and optional structures for stream buffers
Part of Grbl
Copyright (c) 2019 Terje Io
Expand Down Expand Up @@ -35,4 +36,33 @@
#define ASCII_DEL 0x7F
#define ASCII_EOL "\r\n"

#ifndef RX_BUFFER_SIZE
#define RX_BUFFER_SIZE 1024 // must be a power of 2
#endif

#ifndef TX_BUFFER_SIZE
#define TX_BUFFER_SIZE 512 // must be a power of 2
#endif

#define BUFCOUNT(head, tail, size) ((head >= tail) ? (head - tail) : (size - tail + head))

// These structures are not referenced in the core code, may be used by drivers

typedef struct {
volatile uint_fast16_t head;
volatile uint_fast16_t tail;
bool overflow;
#ifdef SERIAL_RTS_HANDSHAKE
bool rts_state;
#endif
bool backup;
char data[RX_BUFFER_SIZE];
} stream_rx_buffer_t;

typedef struct {
volatile uint16_t head;
volatile uint16_t tail;
char data[TX_BUFFER_SIZE];
} stream_tx_buffer_t;

#endif
56 changes: 39 additions & 17 deletions drivers/ESP32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# The following four lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
# CMake for GrblHAL driver for ESP32
# 2019-11-18

cmake_minimum_required(VERSION 3.5)

# The following plugins are supported:
# I2C keypad
# SD Card
# Trinamic TMC2130 stepper drivers via I2C <> SPI bridge
# Networking
# ---
# Move the commented lines below to MAIN_SRCS list
# if enabled in driver.h:
# keypad/keypad.c
# trinamic/trinamic2130.c
# trinamic/TMC2130_I2C_map.c
# tmc2130/trinamic.c
# sdcard/sdcard.c
# web/backend.c
# sdcard/sdcard.c
# dns_server.c
# wifi.c

set(MAIN_SRCS main.c driver.c nvs.c esp32-hal-uart.c bluetooth.c TCPStream.c
# Change the corresponding OPTION setting below
# to ON if plugin is enabled in driver.h:

OPTION(Networking "Wifi + protocols" OFF)
OPTION(Keypad "I2C Keypad" OFF)
OPTION(SDcard "SD Card Streaming" OFF)
OPTION(Trinamic "Trinamic driver support over I2C" OFF)

set(SDCARD_SOURCE sdcard/sdcard.c)
set(KEYPAD_SOURCE keypad/keypad.c)
set(TRINAMIC_SOURCE trinamic/trinamic2130.c trinamic/TMC2130_I2C_map.c tmc2130/trinamic.c)
set(NETWORKING_SOURCE wifi.c dns_server.c web/backend.c networking/TCPStream.c networking/WsStream.c networking/base64.c networking/sha1.c )

set(MAIN_SRCS main.c driver.c nvs.c esp32-hal-uart.c bluetooth.c
i2c.c
ioexpand.c
eeprom.c
Expand All @@ -42,6 +45,27 @@ set(MAIN_SRCS main.c driver.c nvs.c esp32-hal-uart.c bluetooth.c TCPStream.c
GRBL/system.c
)

if(Networking)
list (APPEND MAIN_SRCS ${NETWORKING_SOURCE})
endif()

if(SDcard)
list (APPEND MAIN_SRCS ${SDCARD_SOURCE})
endif()

if(Keypad)
list (APPEND MAIN_SRCS ${KEYPAD_SOURCE})
endif()

if(Trinamic)
list (APPEND MAIN_SRCS ${TRINAMIC_SOURCE})
endif()

unset(Networking CACHE)
unset(Keypad CACHE)
unset(SDcard CACHE)
unset(Trinamic CACHE)

set(INCLUDE_DIRS ".")

#file(GLOB GRBL_SOURCE "GRBL/*.c")
Expand All @@ -61,5 +85,3 @@ include_directories(BEFORE ".")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#add_subdirectory (GRBL)

#register_component()
Loading

0 comments on commit a3ac7fc

Please sign in to comment.