Exemple #1
0
void led_wave_on(LED_BLOCK block)
{
    switch(block)
    {
        case LED_PIN_ESC:
            timer3PWMCOn();
            break;
        case LED_PIN_Fx:
            timer3PWMAOn();
            break;
        case LED_PIN_PAD:
            timer0PWMOn();
#ifdef KBDMOD_M5            
            if(!isLED3000)
                timer1PWMAOn();
#endif
            break;
        case LED_PIN_BASE:
            timer3PWMBOn();
            break;
        case LED_PIN_WASD:
            timer1PWMCOn();
            break;
        case LED_PIN_ARROW18:
            timer1PWMBOn();
#ifdef KBDMOD_M5            
            if(isLED3000)
                timer1PWMAOn();
#endif
            break;
        case LED_PIN_VESEL:
            timer1PWMAOn();
            break;
            
        case LED_PIN_ALL:
            timer3PWMCOn();
            timer3PWMAOn();
            timer3PWMBOn();
            timer1PWMCOn();
            timer1PWMBOn();
            timer1PWMAOn();
            timer0PWMOn();
            break;
        default:
            break;
    }
}
Exemple #2
0
void init_motors()
{
		//off
	cbi(PORTD, 4); //motor off
	cbi(PORTD, 5); //motor off
	cbi(PORTD, 7); //motor off
	cbi(PORTB, 3); //motor off

	sbi(DDRD, 4); //motor outs
	sbi(DDRD, 5); //motor outs
	sbi(DDRD, 7); //motor outs
	sbi(DDRB, 3); //motor outs


	timerInit();
	cbi(TIMSK, TOIE0); // disable timer 0 overflow interrupt
	cbi(TIMSK, TOIE1); // disable timer 1 overflow interrupt
	cbi(TIMSK, TOIE2); // disable timer 2 overflow interrupt

	timer0SetPrescaler(TIMER_CLK_DIV1);
	timer1SetPrescaler(TIMER_CLK_DIV1);
	timer2SetPrescaler(TIMER_CLK_DIV1);

	// setup PWM timer 0
	OCR0 = 0;	// duty cycle 0%
	// enable timer0 as PWM phase correct, todo: use fast pwm
	sbi(TCCR0,WGM00);
	cbi(TCCR0,WGM01);
	// turn on channel (OC0) PWM output
	// set OC0 as non-inverted PWM
	cbi(TCCR0,COM00);
	sbi(TCCR0,COM01);


	// setup timer 1A/B
	timer1PWMInit(8);	// pwm 8 bit

	timer1PWMASet(0);	// duty cycle 0%
	timer1PWMBSet(0);	// duty cycle 0%
	timer1PWMAOn();
	timer1PWMBOn();

	//setup PWM timer 2
	OCR2 = 0;	// duty cycle 0%
	// enable timer2 as PWM phase correct, todo: use fast pwm
	sbi(TCCR2,WGM20);
	cbi(TCCR2,WGM21);
	// turn on channel (OC0) PWM output
	// set OC0 as non-inverted PWM
	cbi(TCCR2,COM20);
	sbi(TCCR2,COM21);


	// enable timer interrupt
	sbi(TIMSK, TOIE0); //enable timer 0 overflow interrupt
}
Exemple #3
0
void init(void)
{
   // Initialize Timer
   timerInit();
   // Initialize LCD
   lcdInit();
   ourLcdControlWrite(1<<LCD_ON_CTRL | 1<<LCD_ON_DISPLAY);
   // Initialize UART
	uartInit();
	uartSetBaudRate(CMU_BAUD);
	uartSetRxHandler(packetRcv);
   rprintfInit(uartSendByte);
   // Initialize PWM
   outb(DDRD, 0xFF);	// set all port D pins to output
   timer1PWMInit(8);
	timer1PWMAOn();
   timer1PWMBOn();
   // Initialize  Servos
   servoInit();
   // Initialize CMU
   lcdWriteStr("CMUcam2 init", 0, 0);
   cmuInit();
}
Exemple #4
0
void init(void)
{
	//Make outputs low
	cbi(PWM_PORT, PWM_BIT);
	cbi(SD_PORT, PWM_BIT);
	
	//Make outputs outputs
	sbi(PWM_DDR, PWM_BIT);

	//Pull-up swithces
	sbi(ESTOP_PORT, ESTOP_BIT);
	sbi(BRAKE_PORT, BRAKE_BIT);
	
	//RGB Outputs
	sbi(RGB_DDR, RED);
	sbi(RGB_DDR, GREEN);
	sbi(RGB_DDR, BLUE);
	
	//RGB Off
	sbi(RGB_PORT, RED);
	sbi(RGB_PORT, GREEN);
	sbi(RGB_PORT, BLUE);
	
	//Initialise the ADC 
	a2dInit();
	
	//Initialise timer 1
	timer1Init();
	timer1SetPrescaler(TIMER_CLK_DIV1);
	timer1PWMInitICR(TOP_COUNT); //Enable PWM with top count
	timer1PWMAOn(); //Turn PWM on
	
	rgb(green);

	sei(); //Enable interupts
}