Sunteți pe pagina 1din 2

void SendString(char *StringPtr){

while(*StringPtr!=0x00){
USART_Transmit(*StringPtr);
StringPtr++;
}
//SendString("test\n");
}
void initTimer(){
TCCR0A=(1<<WGM01)|(0<<WGM00);
OCR0A=250;
TIMSK0|=(1<<OCIE0A);
TCCR0B=(1<<CS02);//|(0<<CS01)|(0<<CS00);
}
void SendString(char *StringPtr){
while(*StringPtr!=0x00){
USART_Transmit(*StringPtr);
StringPtr++;
}
//SendString("test\n");
}
void initIntr(){
EICRA=(1<<ISC01)|(1<ISC00);
EIMSK=(0<<INT1)|(1<<INT0);
EIFR=(0<<INTF0);
SREG=(1<<SREG_I);
}

unsigned int citesteADC(unsigned char adc_input){


ADMUX=adc_input | ((0<<REFS1)|(0<<REFS0)|(0<<ADLAR));
delayMicroseconds(10);
ADCSRA|=(1<<ADSC);
while((ADCSRA & (1<<ADIF))==0){}

USART_Transmit(*StringPtr);
StringPtr++;
}
//SendString("test\n");
}
void initIntr(){
EICRA=(1<<ISC01)|(1<ISC00);

ADCSRA|=(1<<ADIF);

return ADCW;
}

void initializareADC(){
DIDR0=(0<<ADC5D)|(0<<ADC4D)|(0<<ADC3D)|(0<<ADC2D)|(0<<ADC1D)|(0<<ADC0D);
ADMUX=((0<<REFS1)|(0<<REFS0)|(0<<ADLAR));
ADCSRA=(1<<ADEN)|(0<<ADSC)|(1<<ADATE)|(0<<ADIF)|(0<<ADIE)|(1<<ADPS2)|(0<<ADPS1)|
(0<<ADPS0);
//float stepADC=0.0048828125;
//unsigned int sesnorvalue=citesteADC(0);
//float tensiune=stepADC*sensorValue;
//float fTemp=(stepADC*sensorValue-0.5)*100;
}
void USART_Init(unsigned int ubrr){
//define BAUD 9600
//define MYUBRR F_CPU/16/BAUD-1
//USART_Init(MYUBRR);
UBRR0H=(unsigned char)(ubrr>>8);
UBRR0L=(unsigned char)ubrr;

UCSR0B=(1<<RXEN0)|(1<<TXEN0);
UCSR0C=(1<<USBS0)|(3<<UCSZ00);
}
void USART_Transmit(unsigned char data){
while(!(UCSR0A&(1<<UDRE0)));
UDR0=data;
}