1 | #include <avr/io.h>
|
2 | #include <avr/i2cmaster.h>
|
3 | #include <util/delay.h>
|
4 |
|
5 | #define F_CPU 8000000UL
|
6 | #define Display 0x70 // device address Display
|
7 |
|
8 | int main(void)
|
9 | {
|
10 | unsigned char ret;
|
11 |
|
12 | DDRB |= (1<<DDB0);
|
13 | PORTB |= (1<<PB0);
|
14 | PORTB ^= (1<<PB0);
|
15 |
|
16 | _delay_ms(2);
|
17 | i2c_init(); // initialize I2C library
|
18 |
|
19 |
|
20 |
|
21 | while(1)
|
22 | {
|
23 | if(!(i2c_start(Display+I2C_WRITE))) // set device address and write mode
|
24 | {
|
25 | i2c_write(0b11001100); // mode-set
|
26 | i2c_write(0b01001111); // load-data-pointer
|
27 | i2c_write(0b11100111); // device-select
|
28 | i2c_write(0b11111011); // bank-select
|
29 | i2c_write(0b11110000); // blink-select
|
30 |
|
31 | i2c_rep_start(Display+I2C_READ); // set device adresse and read mode
|
32 | ret = i2c_readNak(); // read one byte from Display
|
33 |
|
34 | i2c_stop();
|
35 |
|
36 | PORTB ^= (1<<PB0);
|
37 | _delay_ms(1000);
|
38 | }
|
39 |
|
40 | // write 0x75 to EEPROM address 5 (Byte Write)
|
41 | // ret = i2c_start(Display+I2C_WRITE);
|
42 | // i2c_start_wait(Display+I2C_WRITE); // set device address and write mode
|
43 | // i2c_write(0b11001101); // mode-set
|
44 | // i2c_write(0b01001111); // load-data-pointer
|
45 | // i2c_write(0b11100111); // device-select
|
46 | // i2c_write(0b11111011); // bank-select
|
47 | // i2c_write(0b11110000); // blink-select
|
48 | // i2c_rep_start(Display+I2C_READ); // set device adresse and read mode
|
49 | // ret = i2c_readNak(); // read one byte from Display
|
50 | // i2c_stop(); // set STOP
|
51 |
|
52 |
|
53 |
|
54 | }
|
55 | }
|