Subversion Repositories idreammicro-avr

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \file input_to_output.c
 ******************************************************************************/


/******************************************************************************
 * Header file inclusions.
 ******************************************************************************/


#include <digital_io/digital_io.h>

#include <avr/io.h>
#include <util/delay.h>

/******************************************************************************
 * Public function definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \fn int main(void)
 *
 * \brief Main function.
 ******************************************************************************/

int
main
(
    void
){
    // Configure PB4 as input.
    digital_io__pin_position_t input = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_4;
    digital_io__configure_pin(input, DIGITAL_IO__DIRECTION__INPUT);
   
    // Configure PB5 as output.
    digital_io__pin_position_t output = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
    digital_io__configure_pin(output, DIGITAL_IO__DIRECTION__OUTPUT);

    while (1)
    {
        // Get input level on PB4.
        digital_io__level_t level = digital_io__get_pin_level(input);

        // Set output level on PB5.
        digital_io__set_pin_level(output, level);

        _delay_ms(250);
    }

    return 0;
}