Revision 383
IT WORKS! i cleared portb. oops.....
branches/autonomous_recharging/code/projects/autonomous_recharging/archs/Robot Debug/main.c | ||
---|---|---|
2 | 2 |
#include <i2c.h> |
3 | 3 |
|
4 | 4 |
void recv(char i2c_byte){ |
5 |
usb_puts("ab"); |
|
6 | 5 |
usb_putc(i2c_byte); |
7 |
}
|
|
6 |
} |
|
8 | 7 |
|
9 | 8 |
int main(){ |
10 | 9 |
|
11 | 10 |
dragonfly_init(ALL_ON); |
12 |
i2c_init(1, NULL, recv, NULL); |
|
11 |
sei(); |
|
12 |
i2c_init(0x01, NULL, recv, NULL); |
|
13 | 13 |
|
14 | 14 |
usb_puts("init'd everything.\r\n"); |
15 | 15 |
|
16 |
while(1); |
|
16 |
while(1) { |
|
17 |
delay_ms(2000); |
|
18 |
} |
|
17 | 19 |
} |
branches/autonomous_recharging/code/projects/autonomous_recharging/archs/I2c test/main.c | ||
---|---|---|
126 | 126 |
int main(void) |
127 | 127 |
{ |
128 | 128 |
setup(); |
129 |
|
|
129 |
//sei(); |
|
130 | 130 |
i2c_init(); |
131 |
setup(); |
|
131 |
//setup();
|
|
132 | 132 |
|
133 | 133 |
OCR1B=0; |
134 | 134 |
|
135 |
sei(); |
|
135 |
|
|
136 | 136 |
|
137 |
delay_ms(3000); |
|
138 |
cli(); |
|
139 |
while(1){ |
|
140 |
PORTB|=_BV(LED2); |
|
141 |
PORTB|=_BV(LED1); |
|
142 |
delay_ms(500); |
|
137 | 143 |
|
138 |
PORTB|=_BV(LED2); |
|
139 |
PORTB|=_BV(LED1); |
|
140 |
delay_ms(500); |
|
141 |
PORTB&=~_BV(LED2); |
|
142 |
PORTB&=~_BV(LED1); |
|
143 |
|
|
144 |
i2c_putpacket(0x01,"a ", 2); |
|
144 |
i2c_putpacket(0x01,"hello.", 6); |
|
145 | 145 |
|
146 |
delay_ms(500); |
|
147 |
PORTB|=_BV(LED2); |
|
148 |
PORTB|=_BV(LED1); |
|
149 |
|
|
150 |
while(1); |
|
146 |
delay_ms(500); |
|
147 |
/*PORTB&=~_BV(LED2); |
|
148 |
PORTB&=~_BV(LED1);*/ |
|
149 |
} |
|
151 | 150 |
|
152 | 151 |
return 1; |
153 | 152 |
} |
branches/autonomous_recharging/code/projects/autonomous_recharging/archs/I2c test/i2c.c | ||
---|---|---|
39 | 39 |
packet[i+1] = data[i]; |
40 | 40 |
} |
41 | 41 |
|
42 |
PORTB&=~_BV(PB4); |
|
43 |
|
|
42 | 44 |
//Send packet. Will open line, transmit, and close line. |
43 | 45 |
USI_TWI_Start_Transceiver_With_Data(packet, (data_size + 1)); |
46 |
|
|
47 |
PORTB&=~_BV(PB5); |
|
44 | 48 |
|
45 | 49 |
} |
46 | 50 |
|
Also available in: Unified diff