Skip to content

Commit

Permalink
Added support for spindle plugin, [issue #26](#26).
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Apr 16, 2022
1 parent a9a332f commit 759f94c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include(pico_sdk_import.cmake)
include(grbl/CMakeLists.txt)
include(fatfs/CMakeLists.txt)
include(trinamic/CMakeLists.txt)
include(spindle/CMakeLists.txt)
# include(hpgl/CMakeLists.txt)

project(grblHAL)
Expand Down Expand Up @@ -43,6 +44,7 @@ target_link_libraries(grblHAL PRIVATE
# hpgl
fatfs
trinamic
spindle
tinyusb_device_unmarked
pico_stdlib
hardware_uart
Expand Down
10 changes: 1 addition & 9 deletions driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ bool driver_init (void)
systick_hw->csr = M0PLUS_SYST_CSR_TICKINT_BITS|M0PLUS_SYST_CSR_ENABLE_BITS;

hal.info = "RP2040";
hal.driver_version = "220325";
hal.driver_version = "220416";
hal.driver_options = "SDK_" PICO_SDK_VERSION_STRING;
#ifdef BOARD_NAME
hal.board = BOARD_NAME;
Expand Down Expand Up @@ -1993,14 +1993,6 @@ bool driver_init (void)
ioexpand_init();
#endif

#if MODBUS_ENABLE
modbus_init(serial2Init(115200));
#endif

#if SPINDLE_HUANYANG > 0
huanyang_init();
#endif

#include "grbl/plugins_init.h"

// debounceAlarmPool = alarm_pool_create(DEBOUNCE_ALARM_HW_TIMER, DEBOUNCE_ALARM_MAX_TIMER);
Expand Down
2 changes: 2 additions & 0 deletions my_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#endif
//#define SAFETY_DOOR_ENABLE 1 // Enable safety door input.
//#define BLUETOOTH_ENABLE 1 // Set to 1 for HC-05 module.
//#define VFD_ENABLE 1 // Set to 1 or 2 for Huanyang VFD spindle. More here https://github.com/grblHAL/Plugins_spindle
//#define MODBUS_ENABLE 1 // Set to 1 for auto direction, 2 for direction signal on auxillary output pin.
//#define SDCARD_ENABLE 1 // Run gcode programs from SD card.
//#define MPG_ENABLE 1 // Enable MPG interface. Requires serial port and one handshake pin unless
// KEYPAD_ENABLE is set to 2 when mode switching is done by the CMD_MPG_MODE_TOGGLE (0x8B)
Expand Down
6 changes: 6 additions & 0 deletions serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static io_stream_properties_t serial[] = {
.flags.claimed = Off,
.flags.connected = On,
.flags.can_set_baud = On,
.flags.modbus_ready = On,
.claim = serialInit
},
#ifdef SERIAL2_MOD
Expand All @@ -82,6 +83,7 @@ static io_stream_properties_t serial[] = {
.flags.claimed = Off,
.flags.connected = On,
.flags.can_set_baud = On,
.flags.modbus_ready = On,
.claim = serial2Init
}
#endif
Expand Down Expand Up @@ -116,6 +118,7 @@ static int16_t serialGetC (void)

static void serialTxFlush (void)
{
hw_clear_bits(&UART->imsc, UART_UARTIMSC_TXIM_BITS);
txbuf.tail = txbuf.head;
}

Expand Down Expand Up @@ -238,12 +241,15 @@ const io_stream_t *serialInit (uint32_t baud_rate)
.state.connected = On,
.read = serialGetC,
.write = serialWriteS,
.write_n = serialWrite,
.write_char = serialPutC,
.enqueue_rt_command = serialEnqueueRtCommand,
.get_rx_buffer_free = serialRxFree,
.get_rx_buffer_count = serialRxCount,
.get_tx_buffer_count = serialTxCount,
.reset_read_buffer = serialRxFlush,
.cancel_read_buffer = serialRxCancel,
.reset_write_buffer = serialTxFlush,
.suspend_read = serialSuspendInput,
.disable_rx = serialDisable,
.set_baud_rate = serialSetBaudRate,
Expand Down

0 comments on commit 759f94c

Please sign in to comment.