Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | jlesech | 1 | /**************************************************************************//** |
2 | * \file input_to_output.c |
||
3 | ******************************************************************************/ |
||
4 | |||
5 | /****************************************************************************** |
||
6 | * Header file inclusions. |
||
7 | ******************************************************************************/ |
||
8 | |||
9 | #include <digital_io/digital_io.h> |
||
10 | |||
11 | #include <avr/io.h> |
||
12 | #include <util/delay.h> |
||
13 | |||
14 | /****************************************************************************** |
||
15 | * Public function definitions. |
||
16 | ******************************************************************************/ |
||
17 | |||
18 | /**************************************************************************//** |
||
19 | * \fn int main(void) |
||
20 | * |
||
21 | * \brief Main function. |
||
22 | ******************************************************************************/ |
||
23 | int |
||
24 | main |
||
25 | ( |
||
26 | void |
||
27 | ){ |
||
28 | // Configure PB4 as input. |
||
29 | digital_io__pin_position_t input = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_4; |
||
30 | digital_io__configure_pin(input, DIGITAL_IO__DIRECTION__INPUT); |
||
31 | |||
32 | // Configure PB5 as output. |
||
33 | digital_io__pin_position_t output = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5; |
||
34 | digital_io__configure_pin(output, DIGITAL_IO__DIRECTION__OUTPUT); |
||
35 | |||
36 | while (1) |
||
37 | { |
||
38 | // Get input level on PB4. |
||
39 | digital_io__level_t level = digital_io__get_pin_level(input); |
||
40 | |||
41 | // Set output level on PB5. |
||
42 | digital_io__set_pin_level(output, level); |
||
43 | |||
44 | _delay_ms(250); |
||
45 | } |
||
46 | |||
47 | return 0; |
||
48 | } |