void tg_application_reset(void) { cli(); // disable global interrupts st_reset(); // reset stepper subsystem mp_init(); // motion planning subsystem cm_init(); // canonical machine gc_init(); // gcode-parser PMIC_SetVectorLocationToApplication(); // as opposed to boot ROM PMIC_EnableHighLevel(); // all levels are used, so don't bother to abstract them PMIC_EnableMediumLevel(); PMIC_EnableLowLevel(); sei(); // enable global interrupts tg_ready(); // (LAST) announce app is online }
int main(void) { // There are a lot of dependencies in the order of these inits. // Don't change the ordering unless you understand this. // Inits can assume that all memory has been zeroed by either // a hardware reset or a watchdog timer reset. cli(); // system and drivers sys_init(); // system hardware setup - must be first rtc_init(); // real time counter xio_init(); // xmega io subsystem sig_init(); // signal flags st_init(); // stepper subsystem - must precede gpio_init() gpio_init(); // switches and parallel IO pwm_init(); // pulse width modulation drivers - must follow gpio_init() // application structures tg_init(STD_INPUT); // tinyg controller (controller.c) - must be first app init; reqs xio_init() cfg_init(); // config records from eeprom - must be next app init mp_init(); // motion planning subsystem cm_init(); // canonical machine - must follow cfg_init() sp_init(); // spindle PWM and variables // now bring up the interupts and get started PMIC_SetVectorLocationToApplication(); // as opposed to boot ROM PMIC_EnableHighLevel(); // all levels are used, so don't bother to abstract them PMIC_EnableMediumLevel(); PMIC_EnableLowLevel(); sei(); // enable global interrupts rpt_print_system_ready_message();// (LAST) announce system is ready _unit_tests(); // run any unit tests that are enabled tg_canned_startup(); // run any pre-loaded commands while (true) { // if (tg.network == NET_MASTER) { // tg_repeater(); // } else if (tg.network == NET_SLAVE) { // tg_receiver(); // } else { tg_controller(); // NET_STANDALONE // } } }
void tg_system_reset(void) { cli(); // These inits are order dependent: _tg_debug_init(); // (0) inits for the debug system sys_init(); // (1) system hardware setup xio_init(); // (2) xmega io subsystem tg_init(STD_INPUT); // (3) tinyg controller (arg is std devices) sig_init(); // (4) signal flags rtc_init(); // (5) real time counter st_init(); // (6) stepper subsystem (must run before gp_init()) gpio_init(); // (7) switches and parallel IO PMIC_EnableMediumLevel();// enable TX interrupts for init reporting sei(); // enable global interrupts cfg_init(); // (8) get config record from eeprom (reqs xio) tg_announce(); // print version string }