2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
8 #include "libs/Module.h"
9 #include "libs/Kernel.h"
14 #include "checksumm.h"
15 #include "ConfigValue.h"
16 #include "ModbusSpindleControl.h"
18 #define spindle_checksum CHECKSUM("spindle")
19 #define spindle_rx_pin_checksum CHECKSUM("rx_pin")
20 #define spindle_tx_pin_checksum CHECKSUM("tx_pin")
21 #define spindle_dir_pin_checksum CHECKSUM("dir_pin")
23 void ModbusSpindleControl::on_module_loaded()
31 // preparing PinName objects from the config string
33 Pin
*smoothie_pin
= new Pin();
34 smoothie_pin
->from_string(THEKERNEL
->config
->value(spindle_checksum
, spindle_rx_pin_checksum
)->by_default("nc")->as_string());
35 smoothie_pin
->as_input();
36 rx_pin
= port_pin((PortName
)smoothie_pin
->port_number
, smoothie_pin
->pin
);
38 smoothie_pin
->from_string(THEKERNEL
->config
->value(spindle_checksum
, spindle_tx_pin_checksum
)->by_default("nc")->as_string());
39 smoothie_pin
->as_input();
40 tx_pin
= port_pin((PortName
)smoothie_pin
->port_number
, smoothie_pin
->pin
);
42 smoothie_pin
->from_string(THEKERNEL
->config
->value(spindle_checksum
, spindle_dir_pin_checksum
)->by_default("nc")->as_string());
43 smoothie_pin
->as_input();
44 dir_pin
= port_pin((PortName
)smoothie_pin
->port_number
, smoothie_pin
->pin
);
49 // setup the Modbus interface
50 modbus
= new Modbus(tx_pin
, rx_pin
, dir_pin
);