Merge branch 'contiki' into osd

This commit is contained in:
Harald Pichler 2015-02-18 10:04:47 +01:00
commit d31ecbf486
116 changed files with 5024 additions and 1427 deletions

View file

@ -159,7 +159,7 @@ clock_set_seconds(unsigned long sec)
seconds = sec;
}
/*---------------------------------------------------------------------------*/
/**
/*
* Wait for a number of clock ticks.
*/
void
@ -175,7 +175,7 @@ clock_wait(clock_time_t t)
}
}
/*---------------------------------------------------------------------------*/
/**
/*
* Delay the CPU for up to 65535*(4000000/F_CPU) microseconds.
* Copied from _delay_loop_2 in AVR library delay_basic.h, 4 clocks per loop.
* For accurate short delays, inline _delay_loop_2 in the caller, use a constant
@ -193,44 +193,44 @@ my_delay_loop_2(uint16_t __count)
);
}
void
clock_delay_usec(uint16_t howlong)
clock_delay_usec(uint16_t dt)
{
#if 0
/* Accurate delay at any frequency, but introduces a 64 bit intermediate
* and has a 279 clock overhead.
*/
if(howlong<=(uint16_t)(279000000UL/F_CPU)) return;
howlong-=(uint16_t) (279000000UL/F_CPU);
my_delay_loop_2(((uint64_t)(howlong) * (uint64_t) F_CPU) / 4000000ULL);
if(dt<=(uint16_t)(279000000UL/F_CPU)) return;
dt-=(uint16_t) (279000000UL/F_CPU);
my_delay_loop_2(((uint64_t)(dt) * (uint64_t) F_CPU) / 4000000ULL);
/* Remaining numbers tweaked for the breakpoint CPU frequencies */
/* Add other frequencies as necessary */
#elif F_CPU>=16000000UL
if(howlong<1) return;
my_delay_loop_2((howlong*(uint16_t)(F_CPU/3250000)));
if(dt<1) return;
my_delay_loop_2((dt*(uint16_t)(F_CPU/3250000)));
#elif F_CPU >= 12000000UL
if(howlong<2) return;
howlong-=(uint16_t) (3*12000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/3250000)));
if(dt<2) return;
dt-=(uint16_t) (3*12000000/F_CPU);
my_delay_loop_2((dt*(uint16_t)(F_CPU/3250000)));
#elif F_CPU >= 8000000UL
if(howlong<4) return;
howlong-=(uint16_t) (3*8000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/2000000))/2);
if(dt<4) return;
dt-=(uint16_t) (3*8000000/F_CPU);
my_delay_loop_2((dt*(uint16_t)(F_CPU/2000000))/2);
#elif F_CPU >= 4000000UL
if(howlong<5) return;
howlong-=(uint16_t) (4*4000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/2000000))/2);
if(dt<5) return;
dt-=(uint16_t) (4*4000000/F_CPU);
my_delay_loop_2((dt*(uint16_t)(F_CPU/2000000))/2);
#elif F_CPU >= 2000000UL
if(howlong<11) return;
howlong-=(uint16_t) (10*2000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/1000000))/4);
if(dt<11) return;
dt-=(uint16_t) (10*2000000/F_CPU);
my_delay_loop_2((dt*(uint16_t)(F_CPU/1000000))/4);
#elif F_CPU >= 1000000UL
if(howlong<=17) return;
howlong-=(uint16_t) (17*1000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/1000000))/4);
if(dt<=17) return;
dt-=(uint16_t) (17*1000000/F_CPU);
my_delay_loop_2((dt*(uint16_t)(F_CPU/1000000))/4);
#else
howlong >> 5;
if (howlong < 1) return;
my_delay_loop_2(howlong);
dt >> 5;
if (dt < 1) return;
my_delay_loop_2(dt);
#endif
}
#if 0
@ -250,7 +250,7 @@ clock_delay(unsigned int howlong)
/*---------------------------------------------------------------------------*/
/**
* Delay up to 65535 milliseconds.
* \param dt How many milliseconds to delay.
* \param howlong How many milliseconds to delay.
*
* Neither interrupts nor the watchdog timer is disabled over the delay.
* Platforms are not required to implement this call.
@ -279,7 +279,7 @@ clock_delay_msec(uint16_t howlong)
/*---------------------------------------------------------------------------*/
/**
* Adjust the system current clock time.
* \param dt How many ticks to add
* \param howmany How many ticks to add
*
* Typically used to add ticks after an MCU sleep
* clock_seconds will increment if necessary to reflect the tick addition.