All pastes #56733 Raw Edit

wegstar

public c v1 · immutable
#56733 ·published 2006-05-18 00:39 UTC
rendered paste body
#include <avr/io.h>#include <avr/signal.h>#include "usart.h"#include "i2c.h"#include <stdlib.h> // for itoa#define DEVICE 0x90#define CPU 1000000UL#define FREQ 400000ULint main(){char datah[1];int data, i;char buffer [8];usartInit(BAUDRATE(9600,1));    DDRC  = 0xff;                              // use all pins on port B for output     PORTC = 0xff;                              // (active low LED's )i2cInit(CPU, FREQ);/*for (i=0; i < 10; i++){	itoa(i, buffer,10);	usartsend((char*)buffer);	}*/i2cStart(DEVICE|I2C_W);i2cSend(0xac);i2cSend(0x00);	for(i=0; i < 255; i++);i2cSend(0xee);i2cSend(0xaa);datah[0]=i2cRecieve(1);datah[1]=i2cRecieve(0);i2cStop(); data=*datah; if((datah[0] & 0x80)!=0){ // see if it is done converting yet     debug("done converting...");    //char* x = (char*)atoi(data);  itoa(data, buffer, 10);  usartsend((char*) buffer);}elseusartsend("END \n\r");//while(1){//usartsend("Hello World \n\r");//}return 0;}