System and time

Functions

int os_init(void)
Returns:0 on success, -1 on errors

Low-level system setup. Should be always called first at start of application main entry point. Generally will at least set all ports as inputs.

void os_quit(void)

Will de-initialize system. On many smaller targets this is just an empty define and does nothing.

time_t os_timei(void)
Returns:seconds since some unspecified constant point in the past, usually system boot
os_time_t os_timef(void)
Returns:seconds since some unspecified constant point in the past, usually system boot
void os_sleepi(time_t t)
Parameters:
  • t (time_t) – seconds to sleep

Sleep given amount of seconds. On most targets this is stupid while-loop that simply blocks.

void os_sleepf(os_time_t t)
Parameters:
  • t (os_time_t) – seconds to sleep, floating point, with fractions of second included

Sleep given amount of seconds. On most targets this is stupid while-loop that simply blocks.

Macros

os_delay_us(delay)
Parameters:
  • delay – microseconds to sleep

This usually calls target specific macro, like _delay_us() in AVR and __delay_us() in PIC.

os_delay_ms(delay)
Parameters:
  • delay – milliseconds to sleep

This usually calls target specific macro, like _delay_ms() in AVR and __delay_ms() in PIC.

Types

os_time_t

Floating point time representation type:

  • default: long double
  • AVR: double
  • PIC, 8-bit: double