sys/timers.h

#include <sys/timers.h>

This header includes defines for the CE’s 3 hardware timers. It is discouraged from directly modifying the timers themseleves, and instead use the standard C clock() fuction. These functions provide direct maniplution of the hardware timers. Keep in mind that using them may cause the clock() and related functions to not work correctly. This header also includes functions such as sleep() and delay() which are based around clock()’s functionality and are always safe to use.

There are two possible timing (“clock”) sources: a 32768 Hz crystal with similar accuracy to the clock found in any smartphone or wristwatch, and the CPU’s main 48 MHz clock with likely much inferior accuracy.

API Documentation

CE hardware timers define file.

Authors

Matt “MateoConLechuga” Waltz

Jacob “jacobly” Young

Typedefs

typedef unsigned int useconds_t

An unsigned integer type capable of holding integers in the range [0,1000000].

See also

usleep

Functions

void delay(uint16_t msec)

Suspends execution of the calling thread for (at least) msec milliseconds.

See also

sleep

See also

usleep

Parameters

msec[in] number of milliseconds

void msleep(uint16_t msec)

Suspends execution of the calling thread for (at least) msec milliseconds.

See also

sleep

See also

usleep

Parameters

msec[in] number of milliseconds

unsigned int sleep(unsigned int seconds)

Sleeps until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored.

See also

delay

See also

usleep

Note

Currently, signals do not exist, so this will never be interrupted.

Parameters

seconds[in] number of seconds

Returns

zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler

void ticksleep(unsigned long ticks)

Suspends execution of the calling thread for (at least) ticks clock ticks.

See also

CLOCKS_PER_SEC

See also

delay

See also

usleep

Parameters

ticks[in] number of clock ticks

int usleep(useconds_t usec)

Suspends execution of the calling thread for (at least) usec microseconds.

The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.

See also

delay

See also

sleep

See also

useconds_t

Note

Currently, no errors are possible.

Parameters

usec[in] number of microseconds

Returns

0 on success, or -1 on error, with errno set to indicate the error

void boot_WaitShort(void)

Waits for ~10 ms.

In most cases it is better to use the delay() function.