示例#1
0
int main() {

    // Default pins to low status
    for (int i = 0; i < 5; i++){
        leds[i].output();
        leds[i] = (i & 1) ^ 1;
    }

    //bool sdok= (sd.disk_initialize() == 0);
    sd.disk_initialize();

    Kernel* kernel = new Kernel();

    kernel->streams->printf("Smoothie ( grbl port ) version 0.8.0-rc1 with new accel @%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());

    // Create and add main modules
    kernel->add_module( new Laser() );
    kernel->add_module( new Extruder() );
    kernel->add_module( new SimpleShell() );
    kernel->add_module( new Configurator() );
    kernel->add_module( new CurrentControl() );
    kernel->add_module( new TemperatureControlPool() );
    kernel->add_module( new SwitchPool() );
    kernel->add_module( new PauseButton() );
    kernel->add_module( new PlayLed() );
    kernel->add_module( new Endstops() );
    kernel->add_module( new Player() );
    kernel->add_module( new Panel() );
    kernel->add_module( new Touchprobe() );

    // Create and initialize USB stuff
    u.init();
    //if(sdok) { // only do this if there is an sd disk
    //    msc= new USBMSD(&u, &sd);
    //    kernel->add_module( msc );
    //}

    kernel->add_module( &msc );

    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( &dfu );
    kernel->add_module( &u );

    // clear up the config cache to save some memory
    kernel->config->config_cache_clear();

    // Main loop
    while(1){
        kernel->call_event(ON_MAIN_LOOP);
        kernel->call_event(ON_IDLE);
    }
}
示例#2
0
文件: main.cpp 项目: triffid/usbcpp
int main(void) {
    dbgled(0);

    iprintf("start\n");

    uc.attach(&u);
// 	msc.attach(&u);
    ecm.setMAC(mac);
    ecm.attach(&u);

    iprintf("u.dump\n");

    u.dumpDescriptors();

    iprintf("u.init\n");

    u.init();

    sysclock.setTimeout(5 S);

    // because leds[0] is connected to USB_UP_LED signal and usb hardware takes it over
    leds[0].setup();

// 	dbgled(15);

// 	int l = 0;

    while (1) {
// 		u.USBHW::HwISR();
        if (sysclock.poll()) {
// 			iprintf("-------------------\n");
// 			iprintf("USBClkCtrl:   0x%8lX\n", LPC_USB->USBClkCtrl);
// 			iprintf("USBClkSt:     0x%8lX\n", LPC_USB->USBClkSt);
// 			iprintf("USBIntSt:     0x%8lX\n", LPC_SC->USBIntSt);
// 			iprintf("USBDevIntSt:  0x%8lX\n", LPC_USB->USBDevIntSt);
// 			iprintf("USBDevIntEn:  0x%8lX\n", LPC_USB->USBDevIntEn);
// 			iprintf("USBDevIntPri: 0x%8lX\n", LPC_USB->USBDevIntPri);
            iprintf("Fr: %d\n", u.USBCTRL::lastFrame());
        }
        w.feed();
// 		l++;
// 		if ((l & ((1UL << 19) - 1UL)) == 0)
// 			dbgled(l >> 19);
    }
}
示例#3
0
int main() {

    // Default pins to low status
    for (int i = 0; i < 5; i++){
        leds[i].output();
        leds[i] = (i & 1) ^ 1;
    }

    sd.disk_initialize();

    Kernel* kernel = new Kernel();

    kernel->streams->printf("Smoothie ( grbl port ) version 0.7.2 @%dMHz\r\n", SystemCoreClock / 1000000);

    // Create and add main modules
    kernel->add_module( new Laser() );
    kernel->add_module( new Extruder() );
    kernel->add_module( new SimpleShell() );
    kernel->add_module( new Configurator() );
    kernel->add_module( new CurrentControl() );
    kernel->add_module( new TemperatureControlPool() );
    kernel->add_module( new SwitchPool() );
    kernel->add_module( new ButtonPool() );
    kernel->add_module( new PauseButton() );
    kernel->add_module( new PlayLed() );
    kernel->add_module( new Endstops() );
    kernel->add_module( new Player() );

    // Create and initialize USB stuff
    u.init();
    kernel->add_module( &msc );
    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( &dfu );
    kernel->add_module( &u );

    // Main loop
    while(1){
        kernel->call_event(ON_MAIN_LOOP);
        kernel->call_event(ON_IDLE);
    }
}
示例#4
0
int main() {

    // Default pins to low status
    for (int i = 0; i < 5; i++){
        leds[i].output();
        leds[i]= 0;
    }

    Kernel* kernel = new Kernel();

    kernel->streams->printf("Smoothie ( grbl port ) version 0.7.2 with new accel @%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();

    // attempt to be able to disable msd in config
    // if(!kernel->config->value( disable_msd_checksum )->by_default(false)->as_bool()){
    //     msc= new USBMSD(&u, &sd);
    // }else{
    //     msc= NULL;
    //     kernel->streams->printf("MSD is disabled\r\n");
    // }

    bool sdok= (sd.disk_initialize() == 0);

    // Create and add main modules
    kernel->add_module( new Laser() );
    kernel->add_module( new ExtruderMaker() );
    kernel->add_module( new SimpleShell() );
    kernel->add_module( new Configurator() );
    kernel->add_module( new CurrentControl() );
    kernel->add_module( new TemperatureControlPool() );
    kernel->add_module( new SwitchPool() );
    kernel->add_module( new PauseButton() );
    kernel->add_module( new PlayLed() );
    kernel->add_module( new Endstops() );
    kernel->add_module( new Player() );
    kernel->add_module( new Panel() );
    kernel->add_module( new Touchprobe() );

    // Create and initialize USB stuff
    u.init();
    //if(sdok) { // only do this if there is an sd disk
    //    msc= new USBMSD(&u, &sd);
    //    kernel->add_module( msc );
    //}

    // if(msc != NULL){
    //     kernel->add_module( msc );
    // }

    kernel->add_module( &msc );
    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( &dfu );
    kernel->add_module( &u );

    // clear up the config cache to save some memory
    kernel->config->config_cache_clear();

    if(kernel->use_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)
    }

    if(sdok) {
        // load config override file if present
        // NOTE only Mxxx commands that set values should be put in this file. The file is generated by M500
        FILE *fp= fopen(kernel->config_override_filename(), "r");
        if(fp != NULL) {
            char buf[132];
            kernel->streams->printf("Loading config override file: %s...\n", kernel->config_override_filename());
            while(fgets(buf, sizeof buf, fp) != NULL) {
                kernel->streams->printf("  %s", buf);
                if(buf[0] == ';') continue; // skip the comments
                struct SerialMessage message= {&(StreamOutput::NullStream), buf};
                kernel->call_event(ON_CONSOLE_LINE_RECEIVED, &message);
            }
            kernel->streams->printf("config override file executed\n");
            fclose(fp);
        }
    }

    uint16_t cnt= 0;
    // Main loop
    while(1){
        if(kernel->use_leds) {
            // flash led 2 to show we are alive
            leds[1]= (cnt++ & 0x1000) ? 1 : 0;
        }
        kernel->call_event(ON_MAIN_LOOP);
        kernel->call_event(ON_IDLE);
    }
}