Rev 3379 | Rev 3380 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "main.h" |
1 | #include "main.h" |
2 | #use i2c(Slave,Fast,sda=PIN_B1,scl=PIN_B4,force_hw,address=0xA2) // Motor 2 |
2 | #use i2c(Slave,Fast,sda=PIN_C4,scl=PIN_C3,force_hw,address=0xA2) // Motor 2 |
3 | |
3 | |
4 | #define H1 PIN_A1 |
4 | #define H1 PIN_A1 |
5 | #define L1 PIN_A2 |
5 | #define L1 PIN_A2 |
6 | #define H2 PIN_A3 |
6 | #define H2 PIN_A3 |
7 | #define L2 PIN_A4 |
7 | #define L2 PIN_A4 |
Line 13... | Line 13... | ||
13 | { |
13 | { |
14 | BYTE incoming, state; |
14 | BYTE incoming, state; |
15 | |
15 | |
16 | output_a(0); // vypnuti vsech budicu |
16 | output_a(0); // vypnuti vsech budicu |
17 | |
17 | |
18 | state = i2c_isr_state(); |
18 | state = i2c_isr_state(); |
19 | |
19 | |
20 | if(state < 0x80) //Master is sending data |
20 | if(state < 0x80) //Master is sending data |
21 | { |
21 | { |
22 | command = i2c_read(); |
22 | command = i2c_read(); |
23 | } |
23 | } |
24 | |
24 | |
25 | if(state == 0x80) //Master is requesting data |
25 | if(state == 0x80) //Master is requesting data |
26 | { |
26 | { |
27 | i2c_write(command); |
27 | i2c_write(command); |
28 | } |
28 | } |
29 | } |
29 | } |
30 | |
30 | |
31 | |
31 | |
32 | void main() |
32 | void main() |
33 | { |
33 | { |