Project

General

Profile

Revision 403

I2C works! and by works i mean it sends some stuff and then crashes Tera Term

View differences:

ConstantCharging.c
23 23
#define SW0 PA6
24 24
#define HOMING_PIN PA7
25 25

  
26
#define DEBUG 0
26
#define DEBUG 1
27 27
#define USE_I2C 1
28 28

  
29 29

  
......
248 248
void send_done(void)
249 249
{
250 250

  
251
#if use_I2C
251
#if USE_I2C
252 252
	char tempData;
253 253
	//Finished, leave
254 254
	tempData = 'F';
......
267 267
#endif
268 268
	PORTA = 0x00;
269 269
	DDRB = (_BV(ROBOT_TX)|_BV(PWM)|_BV(LED1)|_BV(LED2)); //confiure output pins
270
	PORTB = 0x00;
270
	PORTB &= ~(_BV(LED1) | _BV(LED2)); //clear LEDs without messing everything else up!
271 271
	
272 272
	ADCSRA = (_BV(ADEN)|_BV(ADPS2)|_BV(ADPS1)); //start ADC with a division factor of 64
273 273
	
......
346 346
}
347 347

  
348 348

  
349
uint8_t read_homing()
349
uint8_t read_homing(void)
350 350
{
351 351
    uint8_t ret = PINA & _BV(HOMING_PIN);
352 352
    if(ret)
......
443 443
				if(status==0)
444 444
				{
445 445
					status=1;
446
#if use_I2C
446
#if USE_I2C
447 447
					data[1]='a';
448 448
					i2c_putpacket(0x01, data, 2);
449 449
					data[1]=I2C_MSG_BATTERY_CHARGING;
......
462 462
				if(status==1)
463 463
				{
464 464
					status=0;
465
#if use_I2C
465
#if USE_I2C
466 466
					data[1]=I2C_MSG_CONTACT_ERROR;
467 467
					i2c_putpacket(0x01, data, 2);
468 468
#endif
......
539 539

  
540 540
		temp=6666;
541 541
	}
542
#if use_I2C
542
#if USE_I2C
543 543
	data[1]=I2C_MSG_BATTERY_FULL;
544 544
	i2c_putpacket(0x01, data, 2);
545 545
#endif
......
552 552
  
553 553
	setup();
554 554

  
555
#if use_I2C
555
#if USE_I2C
556
	delay_ms(500);
556 557
	i2c_init();
557 558
	i2c_putpacket(0x01,"I2C init'd on ARCHS\r\n", 21);
559
	delay_ms(500);
558 560
#endif
559 561
	
560 562
	

Also available in: Unified diff