// The kernel is the central point in Smoothie : it stores modules, and handles event calls Kernel::Kernel(){ instance= this; // setup the Singleton instance of the 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->streams = new StreamOutputPool(); // Configure UART depending on MRI config // If MRI is using UART0, we want to use UART1, otherwise, we want to use UART0. This makes it easy to use only one UART for both debug and actual commands. NVIC_SetPriorityGrouping(0); if( !isDebugMonitorUsingUart0() ){ this->serial = new SerialConsole(USBTX, USBRX, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number()); }else{ this->serial = new SerialConsole(p13, p14, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number()); } this->add_module( this->config ); this->add_module( this->serial ); // HAL stuff add_module( this->slow_ticker = new SlowTicker()); this->step_ticker = new StepTicker(); this->adc = new Adc(); // TODO : These should go into platform-specific files // LPC17xx-specific NVIC_SetPriorityGrouping(0); NVIC_SetPriority(TIMER0_IRQn, 2); NVIC_SetPriority(TIMER1_IRQn, 1); NVIC_SetPriority(TIMER2_IRQn, 3); // Set other priorities lower than the timers NVIC_SetPriority(ADC_IRQn, 4); NVIC_SetPriority(USB_IRQn, 4); // If MRI is enabled if( MRI_ENABLE ){ if( NVIC_GetPriority(UART0_IRQn) > 0 ){ NVIC_SetPriority(UART0_IRQn, 4); } if( NVIC_GetPriority(UART1_IRQn) > 0 ){ NVIC_SetPriority(UART1_IRQn, 4); } if( NVIC_GetPriority(UART2_IRQn) > 0 ){ NVIC_SetPriority(UART2_IRQn, 4); } if( NVIC_GetPriority(UART3_IRQn) > 0 ){ NVIC_SetPriority(UART3_IRQn, 4); } }else{ NVIC_SetPriority(UART0_IRQn, 4); NVIC_SetPriority(UART1_IRQn, 4); NVIC_SetPriority(UART2_IRQn, 4); NVIC_SetPriority(UART3_IRQn, 4); } // Configure the step ticker int base_stepping_frequency = this->config->value(base_stepping_frequency_checksum )->by_default(100000)->as_number(); double microseconds_per_step_pulse = this->config->value(microseconds_per_step_pulse_checksum )->by_default(5 )->as_number(); // Configure the step ticker ( TODO : shouldnt this go into stepticker's code ? ) this->step_ticker->set_reset_delay( microseconds_per_step_pulse / 1000000L ); this->step_ticker->set_frequency( base_stepping_frequency ); // 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->conveyor = new Conveyor() ); this->add_module( this->pauser = new Pauser() ); this->add_module( this->public_data = new PublicData() ); }
// 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->streams = new StreamOutputPool(); // Configure UART depending on MRI config NVIC_SetPriorityGrouping(0); if( !isDebugMonitorUsingUart0() ) { this->serial = new SerialConsole(USBTX, USBRX, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number()); } else { this->serial = new SerialConsole(p13, p14, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number()); } this->add_module( this->config ); this->add_module( this->serial ); // HAL stuff add_module( this->slow_ticker = new SlowTicker()); this->step_ticker = new StepTicker(); this->adc = new Adc(); // LPC17xx-specific NVIC_SetPriorityGrouping(0); NVIC_SetPriority(TIMER0_IRQn, 2); NVIC_SetPriority(TIMER1_IRQn, 1); NVIC_SetPriority(TIMER2_IRQn, 3); // Set other priorities lower than the timers NVIC_SetPriority(ADC_IRQn, 4); NVIC_SetPriority(USB_IRQn, 4); // If MRI is enabled if( MRI_ENABLE ) { if( NVIC_GetPriority(UART0_IRQn) > 0 ) { NVIC_SetPriority(UART0_IRQn, 4); } if( NVIC_GetPriority(UART1_IRQn) > 0 ) { NVIC_SetPriority(UART1_IRQn, 4); } if( NVIC_GetPriority(UART2_IRQn) > 0 ) { NVIC_SetPriority(UART2_IRQn, 4); } if( NVIC_GetPriority(UART3_IRQn) > 0 ) { NVIC_SetPriority(UART3_IRQn, 4); } } else { NVIC_SetPriority(UART0_IRQn, 4); NVIC_SetPriority(UART1_IRQn, 4); NVIC_SetPriority(UART2_IRQn, 4); NVIC_SetPriority(UART3_IRQn, 4); } // Configure the step ticker int base_stepping_frequency = this->config->value(base_stepping_frequency_checksum )->by_default(100000)->as_number(); double microseconds_per_step_pulse = this->config->value(microseconds_per_step_pulse_checksum )->by_default(5 )->as_number(); this->step_ticker->set_reset_delay( microseconds_per_step_pulse / 1000000L ); this->step_ticker->set_frequency( base_stepping_frequency ); // 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->conveyor = new Conveyor() ); this->add_module( this->pauser = new Pauser() ); }