Example #1
0
void init(void) {
	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up default feedrate
	current_position.F = startpoint.F = next_target.target.F = SEARCH_FEEDRATE_Z;

	// start up analog read interrupt loop, if anything uses analog as determined by ANALOG_MASK in your config.h
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	sei();

	// reset watchdog
	wd_reset();

	// say hi to host
	serial_writestr_P(PSTR("Start\nok\n"));

}
Example #2
0
/// Startup code, run when we come out of reset
void init(void) {

	halInit();
  	chSysInit();

#if defined(PORT_LED1) && defined(PIN_LED1)
	palSetPadMode(PORT_LED1, PIN_LED1, PAL_MODE_OUTPUT_PUSHPULL);
#endif
#if defined(PORT_LED2) && defined(PIN_LED2)
	palSetPadMode(PORT_LED2, PIN_LED2, PAL_MODE_OUTPUT_PUSHPULL);
#endif

	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up G-code parsing
	gcode_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up dda
	dda_init();

	// start up analog read interrupt loop,
	// if any of the temp sensors in your config.h use analog interface
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	enable_irq();

	// reset watchdog
	wd_reset();

	// say hi to host
	serial_writestr_P(PSTR("start\nok\n"));

}
Example #3
0
/// Startup code, run when we come out of reset
void init(void) {
	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up G-code parsing
	gcode_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up dda
	dda_init();

	// start up analog read interrupt loop,
	// if any of the temp sensors in your config.h use analog interface
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	sei();

	// reset watchdog
	wd_reset();

  // prepare the power supply
  power_init();

	// say hi to host
	serial_writestr_P(PSTR("start\nok\n"));

}
Example #4
0
int unicorn_init(void)
{
    channel_tag fan = NULL;
    int ret = 0;
    board_info_t board_info; 

	printf("unicorn_init...\n");
    ret = eeprom_read_board_info(EEPROM_DEV, &board_info);
    if (ret < 0) {
        printf("Read eeprom board info failed\n");
        return -1;
    }

    if (!strncasecmp("bbp1s", board_info.name, 5)) {
            bbp_board_type = BOARD_BBP1S;
    } else if(!strncasecmp("bbp1", board_info.name, 4)){
            bbp_board_type = BOARD_BBP1;
    }

	printf("board name:%s, version:%s, get board type:%d \n", board_info.name, board_info.version, bbp_board_type);
    
    /* 
     * Create fifo 
     * fifo_plan2st, fifo_st2plan
     * fifo_plan2gc, fifo_gc2plan
     */
    Fifo_Attrs fAttrs = Fifo_Attrs_DEFAULT;
    hFifo_plan2st = Fifo_create(&fAttrs);
    hFifo_st2plan = Fifo_create(&fAttrs);
    if ((hFifo_st2plan == NULL) ||
        (hFifo_plan2st == NULL)) {
        printf("Create Fifo failed\n");
        return -1;
    }
    
    Pause_Attrs pAttrs = Pause_Attrs_DEFAULT;
    hPause_printing = Pause_create(&pAttrs);
    if (hPause_printing == NULL) { 
        printf("Create pause err\n");
        return -1;
    } else {
        Pause_on(hPause_printing);
    }

    /* set up unicorn system */
    ret = unicorn_setup();
    if (ret < 0) {
        return ret;
    }

    /* init sub systems of unicorn */
    ret = parameter_init(EEPROM_DEV);
    if (ret < 0) {
        printf("parameter_init failed\n");
        return ret;
    }

    ret = analog_init();
    if (ret < 0) {
        printf("analog_init failed\n");
        return ret;
    }

    ret = temp_init();
    if (ret < 0) {
        printf("temp_init failed\n");
        return ret;
    }

    ret = pwm_init();
    if (ret < 0) {
        printf("pwm_init failed\n");
        return ret;
    }

    ret = fan_init();
    if (ret < 0) {
        printf("fan_init failed\n");
        return ret;
    }

    ret = heater_init();
    if (ret < 0) {
        printf("heater_init failed\n");
        return ret;
    }

#ifdef SERVO
    if (bbp_board_type == BOARD_BBP1S) {
		ret = servo_init();
		if (ret < 0) {
			printf("servo_init failed\n");
			return ret;
		}
	}
#endif

    ret = lmsw_init();
    if (ret < 0) {
        printf("lmsw_init failed\n");
        return ret;
    }

    ret = plan_init();
    if (ret < 0) {
        printf("plan_init failed\n");
        return ret;
    }

    ret = stepper_init();
    if (ret < 0) {
        printf("stepper_init failed\n");
        return ret;
    }
    
    ret = gcode_init();
    if (ret < 0) {
        printf("gcode_init failed\n");
        return ret;
    }

    fan = fan_lookup_by_name("fan_3");
    if (fan) {
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
        fan_enable(fan);
    }

    fan = fan_lookup_by_name("fan_4");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }

    fan = fan_lookup_by_name("fan_5");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }

    fan = fan_lookup_by_name("fan_6");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }
  
	printf("unicorn_init ok!!!\n");
    return ret;
}