Witam, podczas kompilacji programu w atmelu, wyskakuje jeden błąd
Co z tym faktem zrobić?
Error 1 sys/time.h: No such file or directory
Co z tym faktem zrobić?
Error 1 sys/time.h: No such file or directory
Program:
#include <inttypes.h>
#include <sys/time.h>
#include <sys/io.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#ifdef AVR
#include <sys/time.h>
#include <sys/io.h>
#include <unistd.h>
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <sys/time.h>
#include <time.h>
#else // AVR
#include <sys/time.h>
#include <sys/io.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/io.h>
#include <unistd.h>
#include <iostream>
#include <iomanip>
#include <sys/time.h>
#include <time.h>
#endif // AVR
#include <sys/time.h>
#include <sys/io.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
using namespace std;
uint64_t czas = 0;
uint64_t timestamp()
{
#ifdef AVR
uint64_t pomiar;
cli();
pomiar = czas;
sei();
return pomiar;
#else // AVR
timeval tm;
gettimeofday( &tm, 0 );
uint64_t sekundy;
sekundy=tm.tv_sec;
uint64_t usekundy;
usekundy=tm.tv_usec;
return sekundy*1000000+usekundy;
#endif // AVR
}
#ifdef AVR
SIGNAL( SIG_OVERFLOW0 )
{
++czas;
}
#endif // AVR
void led_configure()
{
#ifdef AVR
DDRD |= 1 << PD0;
DDRD |= 1 << PD1;
#endif // AVR
}
void buttons_configure()
{
#ifdef AVR
PORTD |= 1 << PD2;
PORTD |= 1 << PD3;
#endif // AVR
}
void d1( bool b )//funkcja zapala/gasi I diode
{
#ifdef AVR
if ( b )
PORTD |= 1 << PD0;
else
PORTD &= ~( 1 << PD0 );
#else // AVR
if ( b )
outb( inb( 0x378 ) | 1, 0x378 );
else
outb( inb( 0x378 ) & ~1, 0x378 );
#endif // AVR
}
void d2( bool b )//funkcja zapala/gasi druga diode
{
#ifdef AVR
if ( b )
PORTD |= 1 << PD1;
else
PORTD &= ~( 1 << PD1 );
#else
if ( b )
outb( inb( 0x378 ) | 2, 0x378 );
else
outb( inb( 0x378 ) & ~2, 0x378 );
#endif
}
void d_( bool b )//funkcja zapala/gasi obie diody jednoczesnie
{
#ifdef AVR
if ( b )
{
PORTD |= 1 << PD0;
PORTD |= 1 << PD1;
}
else
{
PORTD &= ~( 1 << PD0 );
PORTD &= ~( 1 << PD1 );
}
#else
if ( b )
outb( 3, 0x378);
else
outb( 0, 0x378);
#endif
}
bool button1_down()
{
#ifdef AVR
return ( PIND & 1 << PD2 ) == 0;
#else // AVR
return ( inb( 0x379 ) & 1 << 6 ) == 0;
#endif // AVR
}
bool button2_down()
{
#ifdef AVR
return ( PIND & 1 << PD3 ) == 0;
#else
return ( inb( 0x379 ) & 1 << 7 ) != 0;
#endif
}
void czekaj ( uint8_t k ) //wstrzymanie procesora
{
#ifdef AVR
for( ; k ; --k )
{
_delay_loop_2( 25000 );
}
#else // AVR
for( ; k ; --k )
{
usleep ( 100000 );
}
#endif // AVR
}
void pulse( uint16_t n )
{
#ifdef AVR
d1 ( true );
for ( ; n; --n )
{
d2 ( true );
czekaj( 2 );
d2 ( false );
czekaj( 6 );
}
czekaj( 10 );
d_ ( false );
czekaj( 10 );
#endif
}
void wynik ( uint64_t n , bool z )
{
#ifdef AVR
uint16_t n1 = (n%1000000 - n%100000);
uint16_t n2 = (n%100000 - n%10000);
uint16_t n3 = n%10000;
if ( n > 999000 ) //wyĹwietlenie wyniku na diodach
{
d_( true );
czekaj ( 7 );
d_( false );
}
else
{
pulse( n1/100000 );
pulse( n2/10000 );
pulse( n3/1000 );
}
#else // AVR
if ( z )
cout<<"Czas refleksu = "<<n/1000000<<"."<<(n%1000000-n%1000)/1000<<" sekund."<<endl;
else
cout<<"sredni czas refleksu = "<<n/1000000<<"."<<(n%1000000-n%1000)/1000<<" sekund."<<endl;
#endif // AVR
}
int main()
{
#ifdef AVR
led_configure();
buttons_configure();
TCCR0 = 1 << CS01 | 1 << CS00;
TIMSK |= 1 << TOIE0;
sei();
#else
//wartosci p zaleza od komputera
uint8_t p1=56;//przycisk 1
uint8_t p2=248;//przycisk 2
#endif
//Blysk na poczatek
d_( true );
czekaj ( 10 );
for ( int p=3; p; --p )
{
d1( true );
d2( false );
czekaj ( 2 );
d1( false );
d2( true );
czekaj ( 2 );
}
d_( false );
czekaj( 10 );
uint64_t t;
uint64_t suma_t=0;
for( uint8_t m=0; m<10; ++m )
{
uint8_t u=timestamp()%7;//losowa przerwa
czekaj ( u+1 ); //losowa przerwa
uint8_t s=timestamp()%2;//losowanie diody
t=timestamp();// sczytanie czasu
//zapalenie odpowiedniej diody
if (s==0)
{
d1( true );
while (true)
{
if( button1_down() )
break;
}
}
if (s==1)
{
d2( true );
while (true)
{
if( button2_down() )
break;
}
}
d_( false);
t=timestamp()-t;
#ifdef AVR
t=t*15625;
#endif //AVR
czekaj ( u+6 );
suma_t=suma_t+t;
wynik ( t , true );
}
wynik ( suma_t/10 , false );
}