#include "libs/Kernel.h"
#include "modules/tools/laser/Laser.h"
+#include "modules/tools/spindle/Spindle.h"
#include "modules/tools/extruder/ExtruderMaker.h"
#include "modules/tools/temperaturecontrol/TemperatureControlPool.h"
#include "modules/tools/endstops/Endstops.h"
#include "modules/tools/scaracal/SCARAcal.h"
#include "modules/tools/switch/SwitchPool.h"
#include "modules/tools/temperatureswitch/TemperatureSwitch.h"
+#include "modules/tools/drillingcycles/Drillingcycles.h"
+#include "FilamentDetector.h"
#include "modules/robot/Conveyor.h"
#include "modules/utils/simpleshell/SimpleShell.h"
#include "Config.h"
#include "checksumm.h"
#include "ConfigValue.h"
+#include "StepTicker.h"
// #include "libs/ChaNFSSD/SDFileSystem.h"
#include "libs/nuts_bolts.h"
#define second_usb_serial_enable_checksum CHECKSUM("second_usb_serial_enable")
#define disable_msd_checksum CHECKSUM("msd_disable")
-#define disable_leds_checksum CHECKSUM("leds_disable")
+#define dfu_enable_checksum CHECKSUM("dfu_enable")
+#define watchdog_timeout_checksum CHECKSUM("watchdog_timeout")
-// Watchdog wd(5000000, WDT_MRI);
// USB Stuff
SDCard sd __attribute__ ((section ("AHBSRAM0"))) (P0_9, P0_8, P0_7, P0_6); // this selects SPI1 as the sdcard as it is on Smoothieboard
//SDCard sd(P0_18, P0_17, P0_15, P0_16); // this selects SPI0 as the sdcard
+//SDCard sd(P0_18, P0_17, P0_15, P2_8); // this selects SPI0 as the sdcard witrh a different sd select
USB u __attribute__ ((section ("AHBSRAM0")));
USBSerial usbserial __attribute__ ((section ("AHBSRAM0"))) (&u);
#else
USBMSD *msc= NULL;
#endif
-DFU dfu __attribute__ ((section ("AHBSRAM0"))) (&u);
SDFAT mounter __attribute__ ((section ("AHBSRAM0"))) ("sd", &sd);
GPIO(P4_28)
};
+// debug pins, only used if defined in src/makefile
+#ifdef STEPTICKER_DEBUG_PIN
+GPIO stepticker_debug_pin(STEPTICKER_DEBUG_PIN);
+#endif
+
void init() {
// Default pins to low status
leds[i]= 0;
}
+#ifdef STEPTICKER_DEBUG_PIN
+ stepticker_debug_pin.output();
+ stepticker_debug_pin= 0;
+#endif
+
Kernel* kernel = new Kernel();
kernel->streams->printf("Smoothie Running @%ldMHz\r\n", SystemCoreClock / 1000000);
Version version;
kernel->streams->printf(" Build version %s, Build date %s\r\n", version.get_build(), version.get_build_date());
- //some boards don't have leds.. TOO BAD!
- kernel->use_leds= !kernel->config->value( disable_leds_checksum )->by_default(false)->as_bool();
+ bool sdok= (sd.disk_initialize() == 0);
+ if(!sdok) kernel->streams->printf("SDCard is disabled\r\n");
#ifdef DISABLEMSD
// attempt to be able to disable msd in config
- if(!kernel->config->value( disable_msd_checksum )->by_default(false)->as_bool()){
+ if(sdok && !kernel->config->value( disable_msd_checksum )->by_default(false)->as_bool()){
// HACK to zero the memory USBMSD uses as it and its objects seem to not initialize properly in the ctor
size_t n= sizeof(USBMSD);
void *v = AHB0.alloc(n);
}
#endif
- bool sdok= (sd.disk_initialize() == 0);
// Create and add main modules
kernel->add_module( new SimpleShell() );
#ifndef NO_TOOLS_LASER
kernel->add_module( new Laser() );
#endif
+ #ifndef NO_TOOLS_SPINDLE
+ kernel->add_module( new Spindle() );
+ #endif
#ifndef NO_UTILS_PANEL
kernel->add_module( new Panel() );
#endif
kernel->add_module( new Network() );
#endif
#ifndef NO_TOOLS_TEMPERATURESWITCH
- // Must be loaded after TemperatureControlPool
+ // Must be loaded after TemperatureControl
kernel->add_module( new TemperatureSwitch() );
#endif
+ #ifndef NO_TOOLS_DRILLINGCYCLES
+ kernel->add_module( new Drillingcycles() );
+ #endif
+ #ifndef NO_TOOLS_FILAMENTDETECTOR
+ kernel->add_module( new FilamentDetector() );
+ #endif
// Create and initialize USB stuff
u.init();
kernel->add_module( &usbserial );
if( kernel->config->value( second_usb_serial_enable_checksum )->by_default(false)->as_bool() ){
- kernel->add_module( new USBSerial(&u) );
+ kernel->add_module( new(AHB0) USBSerial(&u) );
+ }
+
+ if( kernel->config->value( dfu_enable_checksum )->by_default(false)->as_bool() ){
+ kernel->add_module( new(AHB0) DFU(&u));
+ kernel->streams->printf("WARNING Watchdog is disabled when DFU is enabled\n");
+
+ }else{
+ // 5 second watchdog timeout (or config as seconds)
+ float t= kernel->config->value( watchdog_timeout_checksum )->by_default(5.0F)->as_number();
+ if(t > 0) {
+ kernel->add_module( new Watchdog(t*1000000, WDT_RESET));
+ kernel->streams->printf("Watchdog enabled for %f seconds\n", t);
+ }else{
+ kernel->streams->printf("WARNING Watchdog is disabled\n");
+ }
}
- kernel->add_module( &dfu );
+
kernel->add_module( &u );
// clear up the config cache to save some memory
kernel->config->config_cache_clear();
- if(kernel->use_leds) {
+ if(kernel->is_using_leds()) {
// set some leds to indicate status... led0 init doe, led1 mainloop running, led2 idle loop running, led3 sdcard ok
leds[0]= 1; // indicate we are done with init
leds[3]= sdok?1:0; // 4th led inidicates sdcard is available (TODO maye should indicate config was found)
fclose(fp);
}
}
+
+ THEKERNEL->step_ticker->start();
}
int main()
uint16_t cnt= 0;
// Main loop
while(1){
- if(THEKERNEL->use_leds) {
+ if(THEKERNEL->is_using_leds()) {
// flash led 2 to show we are alive
leds[1]= (cnt++ & 0x1000) ? 1 : 0;
}