void adc_toggle_leds(void){
  if (g_adc_togglecount<ADC_TOGGLE_MAX){
    if ((tick&0x01FF)==0){
        setInLed(g_adc_togglecount&0x1);
        g_adc_togglecount++;
    }
  }
}
Exemple #2
0
int main(void)
{
    laser_off(); 
	bootloaderSwitcher();

  init_serial_number();
	USB_Start();
  
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

	setupJP5();
	setupJP6();
	setupLeds();
  init_watchdog();
  setup_interlock();

	//debug: flas the light on boot, to watch for watchdog resets
	setCoilLed(1);

	initialize_led_override();
	if (LED_OVERRIDES_EN){
		play_long_spin(); //Spin the led's while we load the rest of this stuff
	}

  initialize_pwm();
  initialize_dripper();

	setCornerLed(0);
	setInLed(0);
	setCoilLed(0);
	setUSBLed(0);

  SysTick_Config(SystemCoreClock / 2000); //48MHz/2000 gives us 2000 ticks per second (2KHz)

  int last_drip_count = g_dripcount;

  while(1) {
    serialio_feed();
    updateADC();
    if (move_count!=0){
      g_twig_coils=0;
      g_key_coil_gate=0;
    }
    if (g_dripcount != last_drip_count) {
      last_drip_count = g_dripcount;
      send_updated_drip_count();
    }
    if ((tick % 500) == 0) {
      send_printer_status();
    } 
  }
}