#include "libs/Kernel.h"
#include "libs/Module.h"
#include "libs/Config.h"
-#include "mbed.h"
#include "libs/nuts_bolts.h"
+#include "libs/SlowTicker.h"
+#include "libs/Adc.h"
+#include "libs/Digipot.h"
+#include "libs/Pauser.h"
+#include "libs/StreamOutputPool.h"
#include "modules/communication/SerialConsole.h"
#include "modules/communication/GcodeDispatch.h"
#include "modules/robot/Planner.h"
#include "modules/robot/Robot.h"
#include "modules/robot/Stepper.h"
+#include "modules/robot/Player.h"
+
// List of callback functions, ordered as their corresponding events
const ModuleCallback kernel_callback_functions[NUMBER_OF_DEFINED_EVENTS] = {
&Module::on_block_end,
&Module::on_config_reload,
&Module::on_play,
- &Module::on_pause
+ &Module::on_pause,
+ &Module::on_idle
};
-#define baud_rate_setting_ckeckusm 10922
+#define baud_rate_setting_checksum 10922
+#define uart0_checksum 16877
// The kernel is the central point in Smoothie : it stores modules, and handles event calls
Kernel::Kernel(){
-
+
// Config first, because we need the baud_rate setting before we start serial
this->config = new Config();
// Serial second, because the other modules might want to say something
- this->serial = new SerialConsole(USBTX, USBRX, this->config->get(baud_rate_setting_ckeckusm));
+ this->streams = new StreamOutputPool();
- this->add_module( this->config );
- this->add_module( this->serial );
+ //this->serial = new SerialConsole(USBTX, USBRX, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number());
- // Core modules
- this->gcode_dispatch = new GcodeDispatch();
- this->robot = new Robot();
- this->stepper = new Stepper();
- this->planner = new Planner();
+ this->add_module( this->config );
+ //this->add_module( this->serial );
+
+ // HAL stuff
+ this->slow_ticker = new SlowTicker();
+ this->step_ticker = new StepTicker();
+ this->adc = new Adc();
+ this->digipot = new Digipot();
- this->add_module( this->gcode_dispatch );
- this->add_module( this->robot );
- this->add_module( this->stepper );
- this->add_module( this->planner );
+ // LPC17xx-specific
+ NVIC_SetPriority(TIMER0_IRQn, 1);
+ NVIC_SetPriority(TIMER2_IRQn, 2);
+ // Core modules
+ this->add_module( this->gcode_dispatch = new GcodeDispatch() );
+ this->add_module( this->robot = new Robot() );
+ this->add_module( this->stepper = new Stepper() );
+ this->add_module( this->planner = new Planner() );
+ this->add_module( this->player = new Player() );
+ this->add_module( this->pauser = new Pauser() );
}
void Kernel::add_module(Module* module){
module->kernel = this;
module->on_module_loaded();
+ module->register_for_event(ON_CONFIG_RELOAD);
}
void Kernel::register_for_event(unsigned int id_event, Module* module){