
/**************************************************************************
Name            - init_rotor_ctl_io()
Parameters      - None
Responsibility  - Set Data Direction Registers (DDR) for PORTS used as
                  outputs for rotor direction control.


Notes           -

Returns         - Nothing
Author          - wje
Last change     - 4-12-2006
 **************************************************************************/


#include <inttypes.h>
#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>

#include <avr/sleep.h>

void    init_rotor_ctl_io(void){

    /* set-up the PORTB data direction register
       to make these pins outputs .
       Pins not declared as outputs below will be inputs with pull-ups.
    */

    // PINS 0, 1,2, 3 & 4 are outputs - leave others alone.

    // set the DDR
    DDRB =  _BV(DDB0) |
            _BV(DDB1) |
            _BV(DDB2) |
            _BV(DDB3) |
            _BV(DDB4)
            ;
    // write 1 to the rotor motor pins (turn motors off)
    PORTB |=  _BV(PIN0) ;
    PORTB |=  _BV(PIN1) ;
    PORTB |=  _BV(PIN2) ;
    PORTB |=  _BV(PIN3) ;
    PORTB |=  _BV(PIN4) ;
    

    //activate the pull-ups on PORTD PINS 6 & 7
    PORTD |= _BV(PIN6);
    PORTD |= _BV(PIN7);

    // set the DDR for PORT A
    DDRA = 0;
    // Enable the pull-up resistors on PORT A
    PORTA |= _BV(PIN0);
    PORTA |= _BV(PIN1);
    PORTA |= _BV(PIN2);
    PORTA |= _BV(PIN3);
    PORTA |= _BV(PIN4);
    PORTA |= _BV(PIN5);
}
