putting Endstops back into main.cpp
[clinton/Smoothieware.git] / src / main.cpp
CommitLineData
df27a6a3 1/*
4cff3ded
AW
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.
df27a6a3 5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
4cff3ded
AW
6*/
7
4cff3ded
AW
8#include "libs/Kernel.h"
9#include "modules/tools/laser/Laser.h"
be8332cd 10#include "modules/tools/extruder/Extruder.h"
3c132bd0 11#include "modules/tools/temperaturecontrol/TemperatureControlPool.h"
201bcb94 12#include "modules/tools/endstops/Endstops.h"
cc1d3b1f 13#include "modules/tools/switch/SwitchPool.h"
3fceb8eb 14#include "modules/robot/Conveyor.h"
a6dea425 15#include "modules/utils/button/ButtonPool.h"
4eb9c745 16#include "modules/utils/simpleshell/SimpleShell.h"
cf44cb59 17#include "modules/utils/configurator/Configurator.h"
0e8b102e 18#include "modules/utils/currentcontrol/CurrentControl.h"
1cf49da1 19#include "modules/utils/player/Player.h"
81b547a1 20#include "modules/utils/pausebutton/PauseButton.h"
2487f50b 21// #include "libs/ChaNFSSD/SDFileSystem.h"
4cff3ded 22#include "libs/Config.h"
4eb9c745
AW
23#include "libs/nuts_bolts.h"
24#include "libs/utils.h"
4cff3ded 25
40c831b8
MM
26// Debug
27#include "libs/SerialMessage.h"
a39e1557 28
7c3c5e0f
MM
29#include "libs/USBDevice/USB.h"
30#include "libs/USBDevice/USBMSD/USBMSD.h"
31#include "libs/USBDevice/USBMSD/SDCard.h"
32#include "libs/USBDevice/USBSerial/USBSerial.h"
9f0f2c8f 33#include "libs/USBDevice/DFU.h"
7c3c5e0f 34
246fd409
MM
35#include "libs/SDFAT.h"
36
073b1698
MM
37#include "libs/Watchdog.h"
38
764b2de4
L
39#define second_usb_serial_enable_checksum CHECKSUM("second_usb_serial_enable")
40
073b1698
MM
41// Watchdog wd(5000000, WDT_MRI);
42
7c3c5e0f
MM
43// #include "libs/USBCDCMSC/USBCDCMSC.h"
44// SDFileSystem sd(p5, p6, p7, p8, "sd"); // LPC17xx specific : comment if you are not using a SD card ( for example with a mBed ).
45SDCard sd(P0_9, P0_8, P0_7, P0_6);
7b49793d 46//LocalFileSystem local("local"); // LPC17xx specific : comment if you are not running a mBed
7c3c5e0f
MM
47// USBCDCMSC cdcmsc(&sd); // LPC17xx specific : Composite serial + msc USB device
48
49USB u;
50
51USBSerial usbserial(&u);
52USBMSD msc(&u, &sd);
9f0f2c8f 53DFU dfu(&u);
7c3c5e0f 54
246fd409 55SDFAT mounter("sd", &sd);
a39e1557 56
7c3c5e0f 57char buf[512];
a39e1557 58
ca3a28b4
MM
59GPIO leds[5] = {
60 GPIO(P1_18),
61 GPIO(P1_19),
62 GPIO(P1_20),
63 GPIO(P1_21),
64 GPIO(P4_28)
65};
a39e1557 66
4cff3ded 67int main() {
2a1089e1
AW
68
69 // Default pins to low status
70 for (int i = 0; i < 5; i++){
ca3a28b4
MM
71 leds[i].output();
72 leds[i] = (i & 1) ^ 1;
73 }
74
7c3c5e0f 75 sd.disk_initialize();
a39e1557 76
4464301d 77 Kernel* kernel = new Kernel();
a39e1557 78
8a179ddb 79 kernel->streams->printf("Smoothie ( grbl port ) version 0.7.2 \r\n");
4cff3ded 80
2a1089e1
AW
81 // Create and add main modules
82 kernel->add_module( new Laser() );
be8332cd 83 kernel->add_module( new Extruder() );
4eb9c745 84 kernel->add_module( new SimpleShell() );
d3a6143b 85 kernel->add_module( new Configurator() );
0e8b102e 86 kernel->add_module( new CurrentControl() );
3c132bd0 87 kernel->add_module( new TemperatureControlPool() );
cc1d3b1f 88 kernel->add_module( new SwitchPool() );
a6dea425 89 kernel->add_module( new ButtonPool() );
df27a6a3 90 kernel->add_module( new PauseButton() );
76dccfbb 91 kernel->add_module( new Endstops() );
1cf49da1 92 kernel->add_module( new Player() );
81b547a1 93
2a1089e1 94 // Create and initialize USB stuff
7c3c5e0f 95 u.init();
7c3c5e0f
MM
96 kernel->add_module( &msc );
97 kernel->add_module( &usbserial );
764b2de4
L
98 if( kernel->config->value( second_usb_serial_enable_checksum )->by_default(false)->as_bool() ){
99 kernel->add_module( new USBSerial(&u) );
100 }
9737eccb 101 kernel->add_module( &dfu );
7c3c5e0f
MM
102 kernel->add_module( &u );
103
2a1089e1 104 // Main loop
4cff3ded
AW
105 while(1){
106 kernel->call_event(ON_MAIN_LOOP);
f9005ebe 107 kernel->call_event(ON_IDLE);
4cff3ded 108 }
4cff3ded 109}